### Bash: Sudoku Tunnel Command-Line Interface Examples Source: https://context7.com/sudoku-ascii/sudoku/llms.txt This section provides examples of how to use the Sudoku Tunnel command-line interface (`./sudoku`) for various operations. It covers key generation (Ed25519), managing master and split keys, testing configuration files, starting server and client modes with specified configurations, exporting short links, launching clients directly from short links, and initiating an interactive terminal UI setup wizard. The commands assume the `sudoku` executable is in the current directory. ```bash # Generate new Ed25519 key pair ./sudoku -keygen # Output: # Available Private Key: b1ec294d5dba60a800e1ef8c3423d5a176093f0d8c432e01bc24895d6828140aac81776fc0b44c3c08e418eb702b5e0a4c0a2dd458f8284d67f0d8d2d4bfdd0e # Master Private Key: 709aab5f030c9b8c322811d5c6545497c2136ce1e43b574e231562303de8f108 # Master Public Key: 6e5c05c3f7f5d45fcd2f6a5a7f4700f94ff51db376c128c581849feb71ccc58b # Generate additional split keys from master ./sudoku -keygen -more 709aab5f030c9b8c322811d5c6545497c2136ce1e43b574e231562303de8f108 # Output: # Split Private Key: 89acb9663cfd3bd04adf0001cc7000a8eb312903088b33a847d7e5cf102f1d0ad4c1e755e1717114bee50777d9dd3204d7e142dedcb023a6db3d7c602cb9d40e # Test configuration validity ./sudoku -test -c config.json # Output: # Configuration config.json is valid. # Mode: server # Rules: 3 URLs configured # Start server with configuration ./sudoku -c server_config.json # Server listens on configured port with fallback protection # Start client with configuration ./sudoku -c client_config.json # SOCKS5 proxy on localhost:1080 with rule-based routing # Export short link from configuration ./sudoku -export-link -c server_config.json -public-host example.com # Output: # Short link: sudoku://encoded-config-base64 # Start client directly from short link ./sudoku -link "sudoku://encoded-config-base64" # Bypasses config file, starts immediately # Launch interactive setup wizard ./sudoku -tui -public-host example.com # Generates both server and client configs with key pair # Output: # Server config saved to server_config.json # Client config saved to client_config.json # Short link: sudoku://... # [Server starts automatically after setup] # Build from source go build -o sudoku cmd/sudoku-tunnel/main.go ``` -------------------------------- ### Build Sudoku Tunnel Binary with Go Source: https://github.com/sudoku-ascii/sudoku/blob/main/doc/getting-started.en.md This snippet shows how to clone the Sudoku Tunnel repository and build the executable binary using Go. It requires Go 1.22+ to be installed. ```bash git clone https://github.com/saba-futai/sudoku.git cd sudoku go build -o sudoku ./cmd/sudoku-tunnel ``` -------------------------------- ### Start Sudoku Tunnel Client from Link Source: https://github.com/sudoku-ascii/sudoku/blob/main/doc/README.md This command initiates the Sudoku Tunnel client using a short link. These links, often starting with 'sudoku://', contain bootstrap information for quick client configuration, simplifying the setup process, especially in PAC (Proxy Auto-Config) mode. ```bash ./sudoku -link "sudoku://..." ``` -------------------------------- ### Interactive Sudoku Tunnel Setup (TUI) Source: https://github.com/sudoku-ascii/sudoku/blob/main/doc/README.md This command launches an interactive text-based user interface (TUI) for setting up the Sudoku Tunnel. It guides the user through creating server/client configurations and links, and then starts the server. This is ideal for initial setup or for users who prefer a guided experience. ```bash ./sudoku -tui [-public-host your.ip] ``` -------------------------------- ### Run Sudoku Tunnel Server and Client Source: https://github.com/sudoku-ascii/sudoku/blob/main/doc/getting-started.en.md Commands to launch the Sudoku Tunnel server and client applications. The server listens for incoming connections, while the client initiates the connection to the server and starts a proxy service. ```bash # Server ./sudoku -c server.json # Client (starts a mixed HTTP/SOCKS5 proxy on port 1080) ./sudoku -c client.json ``` -------------------------------- ### Start Sudoku Tunnel in TUI Mode Source: https://github.com/sudoku-ascii/sudoku/blob/main/doc/getting-started.en.md Command to launch Sudoku Tunnel in text-based user interface (TUI) mode, which provides an interactive setup experience with prompts for configuration. ```bash ./sudoku -tui ``` -------------------------------- ### Go Main Function: Start UoT Server and Client Source: https://context7.com/sudoku-ascii/sudoku/llms.txt The main function orchestrates the execution of the UoT server and client. It starts the server in a separate goroutine and then, after a short delay to ensure the server is listening, initiates the client connection to demonstrate the tunneling functionality. ```go package main import ( "time" ) func main() { go uotServer() time.Sleep(1 * time.Second) uotClient() } ``` -------------------------------- ### Sudoku Tunnel Client Configuration Source: https://github.com/sudoku-ascii/sudoku/blob/main/doc/getting-started.en.md Example JSON configuration file for the Sudoku Tunnel client. It defines the server address, client-side port, encryption details, and routing rules. The `key` field must be populated with an available private key. ```json { "mode": "client", "local_port": 1080, "server_address": "1.2.3.4:8080", "key": "Available Private Key here", "aead": "chacha20-poly1305", "padding_min": 5, "padding_max": 15, "custom_table": "xpxvvpvv", "ascii": "prefer_entropy", "disable_http_mask": false, "rule_urls": ["global"] } ``` -------------------------------- ### Sudoku Tunnel Server Configuration Source: https://github.com/sudoku-ascii/sudoku/blob/main/doc/getting-started.en.md Example JSON configuration file for the Sudoku Tunnel server. It specifies the operational mode, listening ports, encryption settings, and behavior for suspicious network activities. The `key` field must be populated with the master public key. ```json { "mode": "server", "local_port": 8080, "fallback_address": "127.0.0.1:80", "key": "Master Public Key here", "aead": "chacha20-poly1305", "suspicious_action": "fallback", "padding_min": 5, "padding_max": 15, "custom_table": "xpxvvpvv", "ascii": "prefer_entropy", "enable_pure_downlink": true } ``` -------------------------------- ### Sudoku Tunnel Systemd Service Example Source: https://github.com/sudoku-ascii/sudoku/blob/main/doc/README.md This is an example Systemd service unit file for running the Sudoku Tunnel as a server. It defines the service's description, dependencies, the command to execute, restart policy, and open file limit. This configuration is suitable for deploying the tunnel as a persistent background service on Linux systems. ```ini [Unit] Description=Sudoku Tunnel Server After=network.target [Service] ExecStart=/usr/local/bin/sudoku -c /etc/sudoku/server.json Restart=on-failure LimitNOFILE=65535 [Install] WantedBy=multi-user.target ``` -------------------------------- ### Export Sudoku Tunnel Link Source: https://github.com/sudoku-ascii/sudoku/blob/main/doc/getting-started.en.md Command to export a shareable short link from a Sudoku Tunnel client configuration. This link can be used to start a client directly or shared with others to connect to the server. ```bash ./sudoku -c client.json -export-link -public-host your.server.com ``` -------------------------------- ### Test Sudoku Tunnel Configuration Source: https://github.com/sudoku-ascii/sudoku/blob/main/doc/getting-started.en.md Command to validate the Sudoku Tunnel server configuration file without actually running the server. This is useful for checking syntax and parameter correctness before deployment. ```bash ./sudoku -c server.json -test ``` -------------------------------- ### Test Sudoku Tunnel Configuration Source: https://github.com/sudoku-ascii/sudoku/blob/main/doc/README.md This command tests the validity of a Sudoku Tunnel configuration file without starting the tunnel service. It's useful for verifying that the configuration is correctly formatted and all parameters are set appropriately before deployment. ```bash ./sudoku -c config.json -test ``` -------------------------------- ### Verify Sudoku Tunnel Connection Source: https://github.com/sudoku-ascii/sudoku/blob/main/doc/getting-started.en.md Command to test the Sudoku Tunnel client-server connection by making a request through the SOCKS5 proxy. It should return the public IP address of the server, confirming the tunnel is operational. ```bash curl -x socks5h://127.0.0.1:1080 https://ipinfo.io/ip ``` -------------------------------- ### Generate Sudoku Tunnel Keys Source: https://github.com/sudoku-ascii/sudoku/blob/main/doc/getting-started.en.md Command to generate cryptographic keys for Sudoku Tunnel. This process creates a master public key and available private keys, essential for establishing secure connections between the client and server. Additional private keys can be generated using the master private key. ```bash ./sudoku -keygen ``` -------------------------------- ### Go: Load Configuration and Build Short Links Source: https://context7.com/sudoku-ascii/sudoku/llms.txt This Go code demonstrates loading server and client configurations from JSON files, building shareable `sudoku://` short links from configuration objects, and parsing configurations directly from these short links. It utilizes the `encoding/json` package for JSON manipulation and a custom `config` package for Sudoku-specific operations. Ensure the `github.com/saba-futai/sudoku/internal/config` package is available. ```go package main import ( "encoding/json" "fmt" "log" "os" "github.com/saba-futai/sudoku/internal/config" ) func main() { // Create server configuration file serverConfig := map[string]interface{}{ "mode": "server", "local_port": 8443, "server_address": "", "fallback_address": "127.0.0.1:80", "key": "6e5c05c3f7f5d45fcd2f6a5a7f4700f94ff51db376c128c581849feb71ccc58b", "aead": "chacha20-poly1305", "suspicious_action": "fallback", "ascii": "prefer_entropy", "padding_min": 5, "padding_max": 15, "custom_table": "xpxvvpvv", "enable_pure_downlink": true, "disable_http_mask": false, } serverJSON, _ := json.MarshalIndent(serverConfig, "", " ") if err := os.WriteFile("server_config.json", serverJSON, 0600); err != nil { log.Fatal(err) } // Load configuration cfg, err := config.Load("server_config.json") if err != nil { log.Fatal(err) } fmt.Printf("Loaded config: mode=%s, port=%d, aead=%s\n", cfg.Mode, cfg.LocalPort, cfg.AEAD) // Generate short link for client distribution shortLink, err := config.BuildShortLinkFromConfig(cfg, "example.com") if err != nil { log.Fatal(err) } fmt.Printf("Short link: %s\n", shortLink) // Client can use short link directly clientConfig := map[string]interface{}{ "mode": "client", "local_port": 1080, "server_address": "example.com:8443", "key": "b1ec294d5dba60a800e1ef8c3423d5a176093f0d8c432e01bc24895d6828140aac81776fc0b44c3c08e418eb702b5e0a4c0a2dd458f8284d67f0d8d2d4bfdd0e", "aead": "chacha20-poly1305", "ascii": "prefer_entropy", "padding_min": 5, "padding_max": 15, "custom_table": "xpxvvpvv", "enable_pure_downlink": true, "disable_http_mask": false, "rule_urls": []string{ "https://example.com/china.list", "global", "direct", }, } clientJSON, _ := json.MarshalIndent(clientConfig, "", " ") if err := os.WriteFile("client_config.json", clientJSON, 0600); err != nil { log.Fatal(err) } // Parse short link parsedCfg, err := config.BuildConfigFromShortLink(shortLink) if err != nil { log.Fatal(err) } fmt.Printf("Parsed from link: server=%s, aead=%s\n", parsedCfg.ServerAddress, parsedCfg.AEAD) } ``` -------------------------------- ### Running Sudoku (Bash) Source: https://github.com/sudoku-ascii/sudoku/blob/main/README.md Command to execute the Sudoku program, specifying the path to the configuration file. This initiates the server or client based on the configuration's 'mode' setting. ```bash ./sudoku -c config.json ``` -------------------------------- ### Initialize Sudoku Encoding Tables (Go) Source: https://context7.com/sudoku-ascii/sudoku/llms.txt Initializes Sudoku encoding tables for obfuscation. These tables map bytes to Sudoku puzzle clues, supporting configurable preferences for ASCII output or entropy. Custom byte patterns can be provided for the table layout. The functionality includes demonstrating encoding of bytes and table rotation. ```go package main import ( "fmt" "log" "github.com/saba-futai/sudoku/pkg/obfs/sudoku" ) func main() { // Create table with entropy preference (default layout) entropyTable, err := sudoku.NewTableWithCustom("my-secret-seed", "prefer_entropy", "") if err != nil { log.Fatal(err) } fmt.Printf("Entropy mode - ASCII: %v, Padding pool size: %d\n", entropyTable.IsASCII, len(entropyTable.PaddingPool)) // Create table with ASCII preference asciiTable := sudoku.NewTable("my-secret-seed", "prefer_ascii") fmt.Printf("ASCII mode - ASCII: %v, Padding pool size: %d\n", asciiTable.IsASCII, len(asciiTable.PaddingPool)) // Create table with custom byte layout pattern // Pattern must have exactly 2 'x', 2 'p', 4 'v' (420 permutations) customTable, err := sudoku.NewTableWithCustom("my-secret-seed", "prefer_entropy", "xpxvvpvv") if err != nil { log.Fatal(err) } fmt.Printf("Custom layout - Padding pool size: %d\n", len(customTable.PaddingPool)) // Example: Encode a byte into Sudoku clues testByte := byte(0x42) if len(entropyTable.EncodeTable[testByte]) > 0 { clues := entropyTable.EncodeTable[testByte][0] fmt.Printf("Byte 0x%02x encodes to clues: %v\n", testByte, clues) // Each clue encodes value (0-3) and position (0-15) for i, clue := range clues { fmt.Printf(" Clue %d: byte=0x%02x\n", i, clue) } } // Demonstrate table rotation with multiple layouts patterns := []string{"xpxvvpvv", "vxpvxvvp", "pvxvxvpv"} tables := make([]*sudoku.Table, len(patterns)) for i, pattern := range patterns { t, err := sudoku.NewTableWithCustom("shared-key", "prefer_entropy", pattern) if err != nil { log.Fatal(err) } tables[i] = t fmt.Printf("Table %d (pattern: %s) created\n", i, pattern) } fmt.Println("✓ Multiple tables ready for rotation") } ``` -------------------------------- ### Build Sudoku Tunnel Executable Source: https://github.com/sudoku-ascii/sudoku/blob/main/doc/README.md This command compiles the Sudoku Tunnel project from source code using Go. It produces a single executable file named 'sudoku' in the current directory. This is the standard method for building the application before deployment. ```bash go build -o sudoku ./cmd/sudoku-tunnel ``` -------------------------------- ### Key Generation (Bash) Source: https://github.com/sudoku-ascii/sudoku/blob/main/README.md Command-line interface commands for generating cryptographic key pairs for Sudoku. It supports generating an initial key pair and deriving additional private keys from a master private key. ```bash $ ./sudoku -keygen Available Private Key: b1ec294d5dba60a800e1ef8c3423d5a176093f0d8c432e01bc24895d6828140aac81776fc0b44c3c08e418eb702b5e0a4c0a2dd458f8284d67f0d8d2d4bfdd0e Master Private Key: 709aab5f030c9b8c322811d5c6545497c2136ce1e43b574e231562303de8f108 Master Public Key: 6e5c05c3f7f5d45fcd2f6a5a7f4700f94ff51db376c128c581849feb71ccc58b ``` ```bash $ ./sudoku -keygen -more 709aab5f030c9b8c322811d5c6545497c2136ce1e43b574e231562303de8f108 Split Private Key: 89acb9663cfd3bd04adf0001cc7000a8eb312903088b33a847d7e5cf102f1d0ad4c1e755e1717114bee50777d9dd3204d7e142dedcb023a6db3d7c602cb9d40e ``` -------------------------------- ### Server Configuration (JSON) Source: https://github.com/sudoku-ascii/sudoku/blob/main/README.md Defines the settings for the Sudoku server, including network ports, encryption details, and custom table configurations for data masking. It supports fallback mechanisms and ASCII preferencing. ```json { "mode": "server", "local_port": 1080, "server_address": "", "fallback_address": "127.0.0.1:80", "key": "See the running steps below", "aead": "chacha20-poly1305", "suspicious_action": "fallback", "ascii": "prefer_entropy", "padding_min": 2, "padding_max": 7, "custom_table": "xpxvvpvv", "custom_tables": [ "xpxvvpvv", "vxpvxvvp" ], "enable_pure_downlink": true, "disable_http_mask": false } ``` -------------------------------- ### Establish Sudoku Client Connection in Go Source: https://context7.com/sudoku-ascii/sudoku/llms.txt Establishes an encrypted tunnel to a Sudoku server and initiates a connection to a target address. This function requires a ProtocolConfig struct containing server details, encryption keys, and Sudoku table configuration. It returns a connection object for application data transmission or an error if the connection fails. ```go package main import ( "context" "log" "time" "github.com/saba-futai/sudoku/apis" "github.com/saba-futai/sudoku/pkg/obfs/sudoku" ) func main() { // Create protocol configuration cfg := &apis.ProtocolConfig{ ServerAddress: "203.0.113.1:8443", TargetAddress: "google.com:443", Key: "b1ec294d5dba60a800e1ef8c3423d5a176093f0d8c432e01bc24895d6828140aac81776fc0b44c3c08e418eb702b5e0a4c0a2dd458f8284d67f0d8d2d4bfdd0e", AEADMethod: "chacha20-poly1305", PaddingMin: 10, PaddingMax: 30, EnablePureDownlink: true, DisableHTTPMask: false, } // Create Sudoku encoding table table, err := sudoku.NewTableWithCustom(cfg.Key, "prefer_entropy", "xpxvvpvv") if err != nil { log.Fatal(err) } cfg.Table = table // Establish connection with timeout ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() conn, err := apis.Dial(ctx, cfg) if err != nil { log.Fatalf("Connection failed: %v", err) } defer conn.Close() // Use connection for application data if _, err := conn.Write([]byte("GET / HTTP/1.1\r\nHost: google.com\r\n\r\n")); err != nil { log.Fatal(err) } buf := make([]byte, 4096) n, err := conn.Read(buf) if err != nil { log.Fatal(err) } log.Printf("Received %d bytes: %s", n, buf[:n]) } ``` -------------------------------- ### Go UoT Server: Handle UDP/TCP Connections Source: https://context7.com/sudoku-ascii/sudoku/llms.txt The UoT server listens for incoming TCP connections on a specified port. Upon receiving a connection, it performs a handshake and then attempts to detect if the connection is a UoT tunnel or a regular TCP connection. If it's UoT, it handles UDP relay; otherwise, it proceeds to proxy regular TCP traffic. ```go package main import ( "fmt" "log" "net" "time" "github.com/saba-futai/sudoku/apis" "github.com/saba-futai/sudoku/pkg/obfs/sudoku" "github.com/saba-futai/sudoku/protocol" ) // Server side: Handle UoT connections func uotServer() { cfg := &apis.ProtocolConfig{ Key: "server-public-key-32bytes", AEADMethod: "chacha20-poly1305", PaddingMin: 5, PaddingMax: 15, EnablePureDownlink: true, HandshakeTimeoutSeconds: 5, } table := sudoku.NewTable(cfg.Key, "prefer_entropy") cfg.Table = table listener, err := net.Listen("tcp", ":8443") if err != nil { log.Fatal(err) } defer listener.Close() fmt.Println("UoT server listening on :8443") for { rawConn, err := listener.Accept() if err != nil { continue } go func(conn net.Conn) { defer conn.Close() // Perform handshake tunnelConn, fail, err := apis.ServerHandshakeFlexible(conn, cfg) if err != nil { log.Printf("Handshake failed: %v", err) return } // Detect if this is UoT or regular TCP isUoT, upgradedConn, err := apis.DetectUoT(tunnelConn) if err != nil { tunnelConn.Close() log.Printf("UoT detection failed: %v", err) return } if isUoT { // Handle as UDP relay if err := apis.HandleUoT(upgradedConn); err != nil { log.Printf("UoT handling error: %v", err) } } else { // Handle as regular TCP proxy targetAddr, _, _, err := protocol.ReadAddress(upgradedConn) if err != nil { upgradedConn.Close() fail(fmt.Errorf("read address: %w", err)) return } log.Printf("TCP connection to %s", targetAddr) // ... relay TCP traffic } }(rawConn) } } ``` -------------------------------- ### Generate Ed25519 Key Pairs and Split Keys (Go) Source: https://context7.com/sudoku-ascii/sudoku/llms.txt Generates Ed25519 master cryptographic key pairs and demonstrates splitting the private key. It verifies that split keys can recover the original public key and that multiple split keys produce the same public key. This functionality is crucial for secure key distribution. ```go package main import ( "encoding/hex" "fmt" "log" "github.com/saba-futai/sudoku/pkg/crypto" "filippo.io/edwards25519" ) func main() { // Generate master key pair masterPair, err := crypto.GenerateMasterKey() if err != nil { log.Fatal(err) } masterPrivateHex := crypto.EncodeScalar(masterPair.Private) masterPublicHex := crypto.EncodePoint(masterPair.Public) fmt.Printf("Master Private Key: %s\n", masterPrivateHex) fmt.Printf("Master Public Key: %s\n", masterPublicHex) // Split private key (x = r + k mod L) splitKey, err := crypto.SplitPrivateKey(masterPair.Private) if err != nil { log.Fatal(err) } fmt.Printf("Split Private Key: %s\n", splitKey) // Verify split key recovers same public key recoveredPublic, err := crypto.RecoverPublicKey(splitKey) if err != nil { log.Fatal(err) } recoveredPublicHex := crypto.EncodePoint(recoveredPublic) fmt.Printf("Recovered Public: %s\n", recoveredPublicHex) if recoveredPublicHex == masterPublicHex { fmt.Println("✓ Key recovery successful") } // Generate additional split keys from master masterBytes, _ := hex.DecodeString(masterPrivateHex) masterScalar, _ := edwards25519.NewScalar().SetCanonicalBytes(masterBytes) anotherSplitKey, err := crypto.SplitPrivateKey(masterScalar) if err != nil { log.Fatal(err) } fmt.Printf("Another Split Key: %s\n", anotherSplitKey) // Verify all split keys produce same public key anotherPublic, _ := crypto.RecoverPublicKey(anotherSplitKey) if crypto.EncodePoint(anotherPublic) == masterPublicHex { fmt.Println("✓ Multiple split keys verified") } } ``` -------------------------------- ### Process Server Handshake and Establish Tunnel Connection in Go Source: https://context7.com/sudoku-ascii/sudoku/llms.txt This Go function, `handleConnection`, processes the server-side handshake for incoming network connections. It validates the handshake using provided protocol configurations, establishes a secure tunnel connection, and relays traffic bidirectionally between the client and the target address. Error handling includes a fallback mechanism for specific handshake errors. ```go package main import ( "log" "net" "github.com/saba-futai/sudoku/apis" "github.com/saba-futai/sudoku/pkg/obfs/sudoku" ) func handleConnection(rawConn net.Conn, cfg *apis.ProtocolConfig) { defer rawConn.Close() // Perform server handshake tunnelConn, targetAddr, err := apis.ServerHandshake(rawConn, cfg) if err != nil { // Check if handshake error for fallback if hsErr, ok := err.(*apis.HandshakeError); ok { // Forward to fallback address fallbackConn, dialErr := net.Dial("tcp", "127.0.0.1:80") if dialErr != nil { log.Printf("Fallback dial failed: %v", dialErr) return } defer fallbackConn.Close() // Replay captured data to fallback if len(hsErr.HTTPHeaderData) > 0 { fallbackConn.Write(hsErr.HTTPHeaderData) } if len(hsErr.ReadData) > 0 { fallbackConn.Write(hsErr.ReadData) } // Bidirectional copy go func() { buf := make([]byte, 32768) for { n, _ := hsErr.RawConn.Read(buf) if n > 0 { fallbackConn.Write(buf[:n]) } } }() buf := make([]byte, 32768) for { n, _ := fallbackConn.Read(buf) if n > 0 { hsErr.RawConn.Write(buf[:n]) } } return } log.Printf("Handshake failed: %v", err) return } defer tunnelConn.Close() log.Printf("Client wants to connect to: %s", targetAddr) // Connect to target targetConn, err := net.Dial("tcp", targetAddr) if err != nil { log.Printf("Target dial failed: %v", err) return } defer targetConn.Close() // Relay traffic bidirectionally done := make(chan struct{}, 2) go func() { buf := make([]byte, 32768) for { n, err := tunnelConn.Read(buf) if n > 0 { targetConn.Write(buf[:n]) } if err != nil { break } } done <- struct{}{} }() go func() { buf := make([]byte, 32768) for { n, err := targetConn.Read(buf) if n > 0 { tunnelConn.Write(buf[:n]) } if err != nil { break } } done <- struct{}{} }() <-done } func main() { cfg := &apis.ProtocolConfig{ Key": "6e5c05c3f7f5d45fcd2f6a5a7f4700f94ff51db376c128c581849feb71ccc58b", AEADMethod": "chacha20-poly1305", PaddingMin": 10, PaddingMax": 30, EnablePureDownlink": true, HandshakeTimeoutSeconds": 5, DisableHTTPMask": false, } table, err := sudoku.NewTableWithCustom(cfg.Key, "prefer_entropy", "xpxvvpvv") if err != nil { log.Fatal(err) } cfg.Table = table listener, err := net.Listen("tcp", ":8443") if err != nil { log.Fatal(err) } defer listener.Close() log.Println("Server listening on :8443") for { conn, err := listener.Accept() if err != nil { log.Printf("Accept failed: %v", err) continue } go handleConnection(conn, cfg) } } ``` -------------------------------- ### Go UoT Client: Send UDP over TCP Tunnel Source: https://context7.com/sudoku-ascii/sudoku/llms.txt The UoT client establishes a secure TCP tunnel using `apis.DialUDPOverTCP` and then sends UDP datagrams to a specified destination, such as a DNS server. It utilizes encryption and padding configured via `apis.ProtocolConfig`. The function sends a sample DNS query and then waits to receive a response. ```go package main import ( "context" "fmt" "log" "net" "time" "github.com/saba-futai/sudoku/apis" "github.com/saba-futai/sudoku/pkg/obfs/sudoku" ) // Client side: Send UDP datagrams through TCP tunnel func uotClient() { cfg := &apis.ProtocolConfig{ ServerAddress: "203.0.113.1:8443", Key: "client-private-key-64bytes", AEADMethod: "chacha20-poly1305", PaddingMin: 5, PaddingMax: 15, EnablePureDownlink: true, } table := sudoku.NewTable(cfg.Key, "prefer_entropy") cfg.Table = table ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() // Establish UoT tunnel tunnelConn, err := apis.DialUDPOverTCP(ctx, cfg) if err != nil { log.Fatal(err) } defer tunnelConn.Close() // Send UDP datagram to DNS server (8.8.8.8:53) dnsQuery := []byte{ 0x12, 0x34, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x03, 0x63, 0x6f, 0x6d, 0x00, 0x00, 0x01, 0x00, 0x01, } if err := apis.WriteUoTDatagram(tunnelConn, "8.8.8.8:53", dnsQuery); err != nil { log.Fatal(err) } fmt.Printf("Sent UDP datagram to 8.8.8.8:53 (%d bytes)\n", len(dnsQuery)) // Receive response targetAddr, responseData, err := apis.ReadUoTDatagram(tunnelConn) if err != nil { log.Fatal(err) } fmt.Printf("Received UDP response from %s (%d bytes)\n", targetAddr, len(responseData)) } ``` -------------------------------- ### Export Sudoku Tunnel Short Link Source: https://github.com/sudoku-ascii/sudoku/blob/main/doc/README.md This command exports a Sudoku Tunnel configuration into a short link format. This is useful for easily sharing configurations or for bootstrapping clients without manually creating config files. The public host can be specified if needed. ```bash ./sudoku -c config.json -export-link [-public-host your.ip] ``` -------------------------------- ### Standard Client Configuration (JSON) Source: https://github.com/sudoku-ascii/sudoku/blob/main/doc/README.md This is a standard JSON configuration for a Sudoku Tunnel client. It defines the client mode, local proxy port, server address, the client's private key (which derives the public key), AEAD settings, padding, Sudoku table preference, and routing rules. ```json { "mode": "client", "local_port": 1080, "server_address": "1.2.3.4:8080", "key": "AVAILABLE_PRIVATE_KEY", "aead": "chacha20-poly1305", "padding_min": 5, "padding_max": 15, "custom_table": "xpxvvpvv", "ascii": "prefer_entropy", "rule_urls": ["global"] } ``` -------------------------------- ### Minimal Server Configuration (JSON) Source: https://github.com/sudoku-ascii/sudoku/blob/main/doc/README.md This is a standard JSON configuration for a Sudoku Tunnel server. It specifies the operating mode, listening ports, fallback address, the master public key, AEAD encryption method, suspicious action handling, padding settings, Sudoku table preference, and downlink mode. ```json { "mode": "server", "local_port": 8080, "fallback_address": "127.0.0.1:80", "key": "MASTER_PUBLIC_KEY", "aead": "chacha20-poly1305", "suspicious_action": "fallback", "padding_min": 5, "padding_max": 15, "custom_table": "xpxvvpvv", "ascii": "prefer_entropy", "enable_pure_downlink": true } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.