-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver_handler_tun_test.go
More file actions
51 lines (47 loc) · 1 KB
/
server_handler_tun_test.go
File metadata and controls
51 lines (47 loc) · 1 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
package socksgo_test
import (
"context"
"net"
"testing"
"github.com/asciimoth/socksgo"
"github.com/asciimoth/socksgo/protocol"
)
func TestTunHandlerAddrBlocked(t *testing.T) {
server := socksgo.Server{
LaddrFilter: func(*protocol.Addr) bool {
return false
},
RaddrFilter: func(*protocol.Addr) bool {
return false
},
}
conn := &net.TCPConn{}
err := socksgo.DefaultGostUDPTUNHandler.Handler(
context.Background(),
&server,
conn,
"5",
protocol.AuthInfo{},
protocol.CmdGostUDPTun,
protocol.AddrFromFQDN("example.com", 8080, ""),
)
if err.Error() != "address example.com:8080 is disallowed by server raddr filter" {
t.Fatal(err)
}
}
func TestTunHandlerReplyFail(t *testing.T) {
server := socksgo.Server{}
conn := &net.TCPConn{}
err := socksgo.DefaultGostUDPTUNHandler.Handler(
context.Background(),
&server,
conn,
"5",
protocol.AuthInfo{},
protocol.CmdGostUDPTun,
protocol.AddrFromIP(net.IPv4(8, 8, 8, 8), 53, "udp"),
)
if err == nil {
t.Fatal("error expected")
}
}