1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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.")
}
|