### Configure Relay via CLI Source: https://context7.com/kulikov0/whitelist-bypass/llms.txt Demonstrates building the Go relay binary and executing it with specific flags to toggle between creator and joiner modes. Includes instructions for routing system traffic through the local SOCKS5 proxy. ```bash # Build the relay cd relay go build -o relay . # Start as creator (free internet side) ./relay --mode creator # Start as joiner (censored side) with custom ports ./relay --mode joiner --ws-port 9000 --socks-port 1080 # Configure system proxy to use the tunnel export http_proxy=socks5://127.0.0.1:1080 export https_proxy=socks5://127.0.0.1:1080 curl https://example.com ``` -------------------------------- ### Automate Build Processes for Go and Android Source: https://context7.com/kulikov0/whitelist-bypass/llms.txt Shell scripts to compile the Go relay into an Android AAR library using gomobile and to build the final Android APK using Gradle. ```bash # Build Go mobile library gomobile bind -target=android -androidapi 23 -o mobile.aar ./mobile # Build Android APK ./gradlew assembleDebug ``` -------------------------------- ### Initialize Go Relay Modes Source: https://context7.com/kulikov0/whitelist-bypass/llms.txt Initializes the relay in either 'joiner' mode for censored clients or 'creator' mode for exit nodes. These functions establish the necessary WebSocket and SOCKS5 proxy listeners to facilitate traffic tunneling. ```go package main import ( "log" "whitelist-bypass/relay/mobile" ) type logger struct{} func (l logger) OnLog(msg string) { log.Print(msg) } func main() { // Start joiner mode with WebSocket on port 9000, SOCKS5 on port 1080 err := mobile.StartJoiner(9000, 1080, logger{}) if err != nil { log.Fatal(err) } } ``` ```go package main import ( "log" "whitelist-bypass/relay/mobile" ) type logger struct{} func (l logger) OnLog(msg string) { log.Print(msg) } func main() { // Start creator mode with WebSocket on port 9000 err := mobile.StartCreator(9000, logger{}) if err != nil { log.Fatal(err) } } ``` -------------------------------- ### Configure Android MainActivity and Relay Source: https://context7.com/kulikov0/whitelist-bypass/llms.txt Sets up the Android WebView to load VK calls and initializes the relay service. It includes a JavaScript bridge to notify the application when the tunnel is ready for VPN activation. ```kotlin class MainActivity : AppCompatActivity() { private fun startRelay() { val cb = LogCallback { msg -> appendLog(msg) if (msg.contains("browser connected")) updateVpnStatus(VpnStatus.TUNNEL_ACTIVE) else if (msg.contains("ws read error")) updateVpnStatus(VpnStatus.TUNNEL_LOST) } Thread { Mobile.startJoiner(9000, 1080, cb) }.start() } inner class JsBridge { @JavascriptInterface fun onTunnelReady() { runOnUiThread { requestVpn() } } } } ``` -------------------------------- ### Implement Wire Protocol Frame Encoding Source: https://context7.com/kulikov0/whitelist-bypass/llms.txt Defines the binary frame structure for multiplexing connections. Provides a Go function to encode connection IDs, message types, and payloads into a byte buffer. ```go func encodeFrameInto(buf []byte, connID uint32, msgType byte, payload []byte) int { binary.BigEndian.PutUint32(buf[0:4], connID) buf[4] = msgType copy(buf[5:], payload) return 5 + len(payload) } ``` -------------------------------- ### Perform Bandwidth Testing with JavaScript Hook Source: https://context7.com/kulikov0/whitelist-bypass/llms.txt Measures tunnel throughput by sending data through the DataChannel. It accepts an optional integer parameter to define the amount of data in MB to transmit. ```javascript // Test with 1 MB of data (default) window.__vkHook.runBandwidthTest(); // Test with 5 MB of data window.__vkHook.runBandwidthTest(5); ``` -------------------------------- ### Manage Android VPN Service with tun2socks Source: https://context7.com/kulikov0/whitelist-bypass/llms.txt Configures the VpnService to route device traffic through a SOCKS5 proxy. It establishes a virtual interface and uses tun2socks to forward packets. ```kotlin class TunnelVpnService : VpnService() { private fun start() { val builder = Builder() .setSession("WhitelistBypass") .addAddress("10.0.0.2", 32) .addRoute("0.0.0.0", 0) .addDnsServer("8.8.8.8") .setMtu(MTU) builder.addDisallowedApplication(packageName) vpnFd = builder.establish() Thread { Mobile.startTun2Socks(vpnFd!!.fd.toLong(), MTU.toLong(), SOCKS_PORT.toLong()) }.start() } } ``` -------------------------------- ### Integrate Tun2Socks for Android Source: https://context7.com/kulikov0/whitelist-bypass/llms.txt Utilizes the mobile library to bridge VPN traffic from an Android VpnService file descriptor into the SOCKS5 proxy tunnel. Requires the file descriptor and MTU settings to function correctly. ```go import "whitelist-bypass/relay/mobile" // Start tun2socks with a VPN file descriptor // fd: VPN tunnel file descriptor from Android VpnService // mtu: Maximum transmission unit (typically 1500) // socksPort: Local SOCKS5 proxy port (1080) err := mobile.StartTun2Socks(fd, 1500, 1080) if err != nil { log.Fatal(err) } // Stop tun2socks when done mobile.StopTun2Socks() ``` -------------------------------- ### Intercept RTCPeerConnection with JavaScript Source: https://context7.com/kulikov0/whitelist-bypass/llms.txt Injects a hook into the browser to intercept WebRTC RTCPeerConnection instances. It creates a custom DataChannel alongside existing VK channels to bridge traffic to a local WebSocket. ```javascript // Configuration const WS_URL = 'ws://127.0.0.1:9000/ws'; // The hook intercepts all new RTCPeerConnection instances, // waits for connection, creates a negotiated DataChannel (id:2), // and bridges the DataChannel to a local WebSocket. console.log(window.__vkHook.peers); // Access hook internals ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.