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
|
package test
import (
"testing"
)
func TestProxyHook(t *testing.T) {
const msg = "Hello, World!"
c, s := newClientServer(t)
defer closeClientServer(c, s)
listen := xListen(t, "tcp", "127.0.0.1:0")
defer listen.Close()
saddr := c.AddListenTunnel("S", "proxy")
caddr := c.AddListenTunnel("C", "proxy,addr=%s dial,addr=%s", listen.Addr(), saddr)
c.Exec("set tunnel.S.proxy.auth user:password")
c.Exec("set tunnel.C.proxy.auth user:password")
out := xDial(t, "tcp", caddr)
defer out.Close()
in := xAccept(t, listen)
defer in.Close()
xWrite(t, out, msg)
buf := make([]byte, len(msg))
xReadFull(t, in, buf)
if r := string(buf); r != msg {
t.Fatalf("wrong reply: send '%s', recv '%s'", msg, r)
}
}
|