Supported Protocols in the Fanqiang Repository: A Complete Technical Guide
The bannedbook/fanqiang repository supports network protocols ranging from core Go implementations (HTTP/HTTPS, SOCKS5, STUN, DNS) to bundled proxy binaries (Shadowsocks, V2Ray, Trojan, Brook, Lightsocks, Lantern, and Psiphon).
The Fanqiang codebase provides a comprehensive censorship-circumvention toolkit used by Android and desktop "one-click" tools. This guide examines the protocol implementations across the core Go library (fqnews2/libcore) and the higher-level wrapper scripts that extend support to additional proxy technologies.
Core Protocols Implemented in Go
The core Go library (fqnews2/libcore) contains native implementations for four fundamental network protocols. These provide the foundation for connectivity and NAT traversal.
HTTP and HTTPS with Modern TLS
The repository implements a configurable HTTP client in fqnews2/libcore/http.go that enforces modern TLS standards. The client supports restricted TLS configurations and certificate pinning to prevent downgrade attacks.
Key methods include NewHttpClient(), ModernTLS() for TLS 1.2+ enforcement, and NewRequest() for building requests with SetURL(), SetMethod(), and SetUserAgent().
SOCKS5 Proxy Integration
SOCKS5 support is integrated directly into the HTTP client via the TrySocks5() method. When invoked (e.g., TrySocks5(1080)), the client attempts to tunnel traffic through 127.0.0.1:1080 using socks.ClientHandshake5 from the github.com/sagernet/sing/protocol/socks package.
This implementation allows the HTTP client to automatically fallback to local SOCKS5 servers when direct connections fail.
STUN for NAT Traversal
Full Session Traversal Utilities for NAT (STUN) protocol support resides in fqnews2/libcore/stun/. The implementation includes packet handling (packet.go), client logic (client.go), and discovery mechanisms (discover.go, host.go).
The STUN client enables public IP/port discovery essential for peer-to-peer connections behind NAT devices.
DNS Resolution (UDP and TCP)
Basic DNS query handling operates over UDP and is implemented in fqnews2/libcore/dns_box.go. This module provides DNS request/response structures and UDP socket management, used internally by the STUN client and other utilities for hostname resolution without relying on system DNS.
Extended Protocol Support via Bundled Tools
Beyond the native Go implementations, the repository extends support to additional proxy protocols through pre-compiled binaries and wrapper scripts located in the ChromeGo directories and Android documentation.
Shadowsocks (SS)
The repository ships with a ready-made Android Shadowsocks client documented in android/Shadowsocks.md. The Go layer provides shared cryptographic primitives in fqnews2/libcore/crypto.go for packet encryption and decryption, supporting the Shadowsocks protocol suite.
V2Ray Protocol Suite
Multiple V2Ray-compatible protocols (VMess, VLess, etc.) are bundled in the ChromeGo packages. Rather than re-implementing these in Go, the repository invokes external V2Ray core binaries through wrapper scripts. The Go code serves as a launcher and process manager for these protocols.
Trojan, Brook, and Lightsocks
- Trojan: Supported via the ChromeGo one-click package with launch scripts that invoke the Trojan binary.
- Brook: Implemented through external binary invocation with repository-provided wrapper scripts.
- Lightsocks: Bundled similarly in the ChromeGo package with wrapper scripts managing the pre-compiled Lightsocks binary.
Proprietary Protocols (Lantern, Psiphon)
Protocols such as 蓝灯 (Lantern) and Psiphon are supported out-of-the-box through packaged binaries. These are not re-implemented in Go but are launched via helper scripts in the ChromeGo directory, providing immediate usability without custom protocol coding.
Working with the Core Protocols
The following examples demonstrate practical usage of the native Go implementations for HTTP tunneling, STUN discovery, and DNS resolution.
Creating an HTTP Client with SOCKS5 Fallback
This example creates an HTTP client that enforces modern TLS and tunnels through a local SOCKS5 proxy on port 1080:
client := libcore.NewHttpClient().
ModernTLS(). // enforce TLS 1.2+
TrySocks5(1080) // forward through 127.0.0.1:1080 if available
req := client.NewRequest().
SetURL("https://example.com").
SetMethod("GET").
SetUserAgent("Fanqiang/1.0")
resp, err := req.Execute()
if err == nil {
body, _ := resp.GetContentString()
fmt.Println(body)
}
Discovering Public IP via STUN
To discover your public IP address and port using Google's STUN server:
stunClient := stun.NewClient("stun.l.google.com:19302")
addr, err := stunClient.Discover()
if err == nil {
fmt.Printf("Public IP: %s:%d\n", addr.IP, addr.Port)
}
Executing Raw DNS Queries
For direct DNS resolution over UDP without system resolver dependencies:
dnsReq := libcore.NewDNSRequest()
dnsReq.SetQuestion("example.com.", dns.TypeA)
resp, err := dnsReq.Exchange("8.8.8.8:53")
if err == nil {
fmt.Println(resp.Answers)
}
Key Implementation Files
The following source files contain the protocol implementations referenced throughout this guide:
fqnews2/libcore/http.go: HTTP/HTTPS client with SOCKS5 tunneling support viaTrySocks5()andsocks.ClientHandshake5.fqnews2/libcore/stun/: Complete STUN protocol stack includingclient.go,discover.go,packet.go, andhost.gofor NAT traversal.fqnews2/libcore/dns_box.go: DNS request/response utilities and UDP handling for raw DNS queries.fqnews2/libcore/crypto.go: Shared cryptographic primitives supporting Shadowsocks and other encrypted protocols.ChromeGo*/: Directories containing wrapper scripts for Trojan, Brook, Lightsocks, Lantern, and Psiphon binaries.android/Shadowsocks.md: Documentation and configuration for the Android Shadowsocks client implementation.
Summary
- The core Go library natively implements HTTP/HTTPS (with modern TLS), SOCKS5 proxy tunneling, STUN for NAT traversal, and DNS over UDP.
- Extended protocol support comes via bundled binaries for Shadowsocks, V2Ray (VMess/VLess), Trojan, Brook, Lightsocks, Lantern, and Psiphon.
- Key entry points in
fqnews2/libcore/http.goallow configurable HTTP clients with automatic SOCKS5 fallback. - The STUN implementation in
fqnews2/libcore/stun/provides complete NAT discovery capabilities without external dependencies. - Wrapper scripts in the ChromeGo directories enable "one-click" usage of complex proxy protocols without requiring users to compile or configure binary dependencies manually.
Frequently Asked Questions
Does the Fanqiang repository implement V2Ray protocols in Go?
No, the repository does not implement V2Ray protocols (VMess, VLess) directly in Go code. Instead, it bundles official V2Ray core binaries and provides Go-based wrapper scripts to launch and manage these processes. The native Go implementation focuses on HTTP/HTTPS, SOCKS5, STUN, and DNS protocols.
How does the HTTP client handle SOCKS5 proxy connections?
The HTTP client in fqnews2/libcore/http.go implements SOCKS5 support through the TrySocks5() method, which accepts a port number (e.g., TrySocks5(1080)). This method uses socks.ClientHandshake5 from the Sing protocol library to negotiate a tunnel through 127.0.0.1:1080 before sending HTTP requests, enabling automatic fallback when direct connections fail.
Where is the STUN protocol implemented in the codebase?
The complete STUN protocol implementation resides in the fqnews2/libcore/stun/ directory. This includes client.go for session management, discover.go for public IP discovery, packet.go for message formatting, and host.go for address handling. These files provide standalone NAT traversal capabilities without requiring external STUN libraries.
What encryption protocols does the Shadowsocks implementation support?
The repository's Shadowsocks support utilizes shared cryptographic primitives located in fqnews2/libcore/crypto.go. While the Android client implementation is documented in android/Shadowsocks.md, the actual encryption/decryption logic for Shadowsocks packets is handled through these Go cryptographic utilities, supporting the standard Shadowsocks cipher suites used by the Android client.
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:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →