From 756ba94292b408cc4f23d137b2c4c52009b2b38d Mon Sep 17 00:00:00 2001 From: James O'Doherty Date: Fri, 22 May 2026 09:13:16 -0400 Subject: Scaffold wg-wrap project structure and toolchain --- cmd/wg-test-peer/main.go | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 cmd/wg-test-peer/main.go (limited to 'cmd/wg-test-peer/main.go') diff --git a/cmd/wg-test-peer/main.go b/cmd/wg-test-peer/main.go new file mode 100644 index 0000000..938400d --- /dev/null +++ b/cmd/wg-test-peer/main.go @@ -0,0 +1,39 @@ +package main + +import ( + "flag" + "fmt" + "net/http" +) + +type PeerConfig struct { + InternalIP string + ListenPort int + PrivateKey string +} + +func main() { + internalIP := flag.String("internal-ip", "10.0.0.1", "Internal VPN IP for the peer") + listenPort := flag.Int("port", 51820, "UDP port to listen on") + flag.Parse() + + fmt.Printf("Starting wg-test-peer on UDP port %d...\n", *listenPort) + fmt.Printf("Peer Internal IP: %s\n", *internalIP) + + // The peer will eventually implement a userspace WireGuard device + // and a simple TCP/IP stack (via GVisor or similar) to handle the traffic. + + // For now, we start a dummy HTTP server to demonstrate the intended flow. + // In a real E2E test, this server would be reached via the TUN device. + http.HandleFunc("/verify", func(w http.ResponseWriter, r *http.Request) { + token := r.URL.Query().Get("token") + _, _ = fmt.Fprintf(w, "Verification token received: %s\n", token) + }) + + fmt.Printf("HTTP verification server running on :%s (simulated)\n", *internalIP) + // Note: In final implementation, the HTTP server binds to the internal IP + // provided by the userspace network stack. + + // This is a stub. In a real run, this would block. + fmt.Println("Peer is ready. Generate a matching .conf for the client.") +} -- cgit v1.2.3