diff options
author | Soren L. Hansen <sorenisanerd@gmail.com> | 2021-10-06 10:40:01 +0000 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2023-02-07 20:38:19 -0300 |
commit | 0ae4b3177cd6867f261ad661bd7bff3a0984ff2b (patch) | |
tree | d393a8838866422c40ce8be053eb4a0167f2697b /tun | |
parent | 077ce8ecab38fbd2d9f10e8bc486ba165271a7ff (diff) |
tun/netstack: make http examples communicate with each other
This seems like a much better demonstration as it removes the need for
external components.
Signed-off-by: Søren L. Hansen <sorenisanerd@gmail.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'tun')
-rw-r--r-- | tun/netstack/examples/http_client.go | 10 | ||||
-rw-r--r-- | tun/netstack/examples/http_server.go | 8 |
2 files changed, 9 insertions, 9 deletions
diff --git a/tun/netstack/examples/http_client.go b/tun/netstack/examples/http_client.go index ef5efe5..0c70893 100644 --- a/tun/netstack/examples/http_client.go +++ b/tun/netstack/examples/http_client.go @@ -21,17 +21,17 @@ import ( func main() { tun, tnet, err := netstack.CreateNetTUN( - []netip.Addr{netip.MustParseAddr("192.168.4.29")}, + []netip.Addr{netip.MustParseAddr("192.168.4.28")}, []netip.Addr{netip.MustParseAddr("8.8.8.8")}, 1420) if err != nil { log.Panic(err) } dev := device.NewDevice(tun, conn.NewDefaultBind(), device.NewLogger(device.LogLevelVerbose, "")) - dev.IpcSet(`private_key=a8dac1d8a70a751f0f699fb14ba1cff7b79cf4fbd8f09f44c6e6a90d0369604f -public_key=25123c5dcd3328ff645e4f2a3fce0d754400d3887a0cb7c56f0267e20fbf3c5b -endpoint=163.172.161.0:12912 + err = dev.IpcSet(`private_key=087ec6e14bbed210e7215cdc73468dfa23f080a1bfb8665b2fd809bd99d28379 +public_key=c4c8e984c5322c8184c72265b92b250fdb63688705f504ba003c88f03393cf28 allowed_ip=0.0.0.0/0 +endpoint=127.0.0.1:58120 `) err = dev.Up() if err != nil { @@ -43,7 +43,7 @@ allowed_ip=0.0.0.0/0 DialContext: tnet.DialContext, }, } - resp, err := client.Get("https://www.zx2c4.com/ip") + resp, err := client.Get("http://192.168.4.29/") if err != nil { log.Panic(err) } diff --git a/tun/netstack/examples/http_server.go b/tun/netstack/examples/http_server.go index 2ffdb35..75e4180 100644 --- a/tun/netstack/examples/http_server.go +++ b/tun/netstack/examples/http_server.go @@ -30,10 +30,10 @@ func main() { log.Panic(err) } dev := device.NewDevice(tun, conn.NewDefaultBind(), device.NewLogger(device.LogLevelVerbose, "")) - dev.IpcSet(`private_key=a8dac1d8a70a751f0f699fb14ba1cff7b79cf4fbd8f09f44c6e6a90d0369604f -public_key=25123c5dcd3328ff645e4f2a3fce0d754400d3887a0cb7c56f0267e20fbf3c5b -endpoint=163.172.161.0:12912 -allowed_ip=0.0.0.0/0 + dev.IpcSet(`private_key=003ed5d73b55806c30de3f8a7bdab38af13539220533055e635690b8b87ad641 +listen_port=58120 +public_key=f928d4f6c1b86c12f2562c10b07c555c5c57fd00f59e90c8d8d88767271cbf7c +allowed_ip=192.168.4.28/32 persistent_keepalive_interval=25 `) dev.Up() |