Can bannedbook/fanqiang Be Used with Other Tools? Integration Guide and Examples

Yes, bannedbook/fanqiang can be integrated with other tools through its self-contained Go library (fqnews2/libcore), which exposes a configurable HTTP client, TLS utilities, and RSS parsing functions that can be imported into any Go project or wrapped for cross-language use.

While bannedbook/fanqiang is widely recognized as a curated collection of anti-censorship tutorials, the repository also maintains a production-ready Go module separate from its documentation. The fqnews2/libcore package implements a lightweight HTTP client abstraction with support for modern TLS configurations, SOCKS5 proxy routing, and feed parsing. Because the library carries no hidden dependencies, developers can embed bannedbook/fanqiang functionality into custom proxy tools, monitoring services, or CLI utilities with standard Go module imports.

Core Library Architecture

The integration capabilities stem from the libcore package located in fqnews2/libcore/. Unlike the static markdown tutorials, this code is designed for reuse in external applications.

HTTP Client and TLS Configuration

The primary interface is defined in fqnews2/libcore/http.go. The HTTPClient type wraps the standard net/http stack while providing chainable configuration methods:

  • ModernTLS() — Enables TLS 1.2 and above for broad compatibility.
  • RestrictedTLS() — Enforces TLS 1.3-only connections for maximum security.
  • PinnedTLS12() / PinnedSHA256() — Implements certificate pinning to prevent MITM attacks.
  • TrySocks5(port) — Routes all traffic through a local SOCKS5 daemon (e.g., V2Ray or Shadowsocks).
  • KeepAlive() — Enables HTTP/2 support and connection reuse.

These methods return the client instance, allowing fluent configuration before constructing an HTTPRequest via NewRequest().

RSS and Feed Parsing

Located in fqnews2/libcore/export.go, the parsing utilities convert RSS or Atom feeds into JSON. The ParseBodyString() function accepts a raw XML string and returns structured JSON bytes using the github.com/mmcdole/gofeed library. This operates entirely offline, requiring no external services beyond the feed content itself.

Integration Scenarios

Developers can leverage bannedbook/fanqiang in several architectural patterns:

Custom Proxy Tools
Reuse HTTPClient.TrySocks5 to forward requests through existing Shadowsocks or V2Ray SOCKS5 endpoints. Combine with RestrictedTLS() to ensure all proxied traffic uses modern cryptography.

Monitoring and Scraping Services
Use NewHttpClient().ModernTLS().NewRequest() to fetch JSON APIs or news feeds from behind restrictive firewalls. Pipe the response through ParseBodyString to normalize RSS data for storage or analysis pipelines.

Cross-Language Wrappers
Compile the library into a shared object using cgo, then invoke it from Python, Node.js, or Rust via FFI. Alternatively, build static binaries that shell scripts can execute for connectivity testing.

CLI Utilities
Build command-line tools that leverage the STUN client in fqnews2/libcore/stun/* for NAT discovery, or use the HTTP client to verify proxy connectivity and fetch blocked resources.

Implementation Examples

The following snippets demonstrate how to import github.com/bannedbook/fanqiang/fqnews2/libcore and utilize its core features.

Execute a GET Request with Modern TLS

package main

import (
	"fmt"
	"log"

	"github.com/bannedbook/fanqiang/fqnews2/libcore"
)

func main() {
	// Create a reusable client
	c := libcore.NewHttpClient()
	c.ModernTLS()          // TLS 1.2+ (default for most servers)
	c.KeepAlive()          // enable HTTP/2 & keep-alive

	// Build a request
	req := c.NewRequest()
	if err := req.SetURL("https://example.com/api/status"); err != nil {
		log.Fatalf("bad URL: %v", err)
	}
	req.SetMethod("GET")
	req.SetUserAgent("fanqiang-demo/1.0")

	// Execute
	resp, err := req.Execute()
	if err != nil {
		log.Fatalf("request failed: %v", err)
	}
	body, err := resp.GetContentString()
	if err != nil {
		log.Fatalf("read body: %v", err)
	}
	fmt.Println("Response:", body)

	c.Close()
}

Key methods: NewHttpClient and ModernTLS are defined in fqnews2/libcore/http.go.

Parse an RSS Feed into JSON

package main

import (
	"fmt"
	"log"

	"github.com/bannedbook/fanqiang/fqnews2/libcore"
)

func main() {
	// Prepare HTTP client (TLS not required for most RSS endpoints)
	c := libcore.NewHttpClient()
	req := c.NewRequest()
	_ = req.SetURL("https://news.ycombinator.com/rss")
	req.SetMethod("GET")

	resp, err := req.Execute()
	if err != nil {
		log.Fatalf("failed to fetch RSS: %v", err)
	}
	raw, _ := resp.GetContentString()

	// Convert the raw RSS XML to JSON
	jsonBytes, err := libcore.ParseBodyString(raw)
	if err != nil {
		log.Fatalf("parse error: %v", err)
	}
	fmt.Println(string(jsonBytes))

	c.Close()
}

Key methods: ParseBodyString lives in fqnews2/libcore/export.go.

Route Traffic Through a SOCKS5 Proxy

package main

import (
	"log"

	"github.com/bannedbook/fanqiang/fqnews2/libcore"
)

func main() {
	c := libcore.NewHttpClient()
	// Assume a V2Ray SOCKS5 listener on localhost:1080
	c.TrySocks5(1080)

	// Now every request goes through the proxy
	req := c.NewRequest()
	_ = req.SetURL("https://api.ipify.org?format=json")
	req.SetMethod("GET")

	resp, err := req.Execute()
	if err != nil {
		log.Fatalf("proxy request failed: %v", err)
	}
	body, _ := resp.GetContentString()
	log.Println("Public IP:", body)

	c.Close()
}

Key methods: TrySocks5 is implemented in fqnews2/libcore/http.go.

Summary

  • bannedbook/fanqiang provides a reusable Go library at fqnews2/libcore that is decoupled from its tutorial content.
  • The HTTPClient abstraction in http.go supports configurable TLS modes, certificate pinning, and SOCKS5 proxy routing.
  • ParseBodyString in export.go enables server-side RSS-to-JSON conversion without external API dependencies.
  • Zero hidden dependencies allow standard import via go get github.com/bannedbook/fanqiang/fqnews2/libcore.
  • Cross-language integration is achievable through cgo, FFI, or static binary compilation.

Frequently Asked Questions

Can I use bannedbook/fanqiang in a Python or Node.js project?

Yes. While the library is implemented in Go, you can compile it as a shared object using cgo and invoke it via Python's ctypes or Node.js FFI bindings. Alternatively, build a Go binary that exposes CLI commands and call it from your application using subprocess mechanisms.

What is the minimum Go version required to import fqnews2/libcore?

The library relies on standard library features available in Go 1.18 and later. Import it using go get github.com/bannedbook/fanqiang/fqnews2/libcore and ensure your go.mod file specifies a compatible version.

Does the HTTP client support HTTP/2 and TLS 1.3?

Yes. Calling ModernTLS() configures the client for TLS 1.2 and above, while RestrictedTLS() enforces TLS 1.3-only connections. The KeepAlive() method enables HTTP/2 support when the server advertises it via ALPN.

Is the RSS parser dependent on external cloud services?

No. The ParseBodyString function processes XML content locally using the gofeed package. It requires only the RSS or Atom feed content as a string or byte slice, making it suitable for offline or air-gapped environments where external API calls are prohibited.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →