diff --git a/proxy/socks/socks_test.go b/proxy/socks/socks_test.go index 5384b74f..cbb50344 100644 --- a/proxy/socks/socks_test.go +++ b/proxy/socks/socks_test.go @@ -235,64 +235,3 @@ func TestSocksTcpConnectWithWrongAuthMethod(t *testing.T) { _, err = socks5Client.Dial("tcp", targetServer) assert.Error(err).IsNotNil() } - -func TestSocksUdpSend(t *testing.T) { - v2testing.Current(t) - port := v2nettesting.PickPort() - - connInput := []byte("The data to be returned to socks server.") - connOutput := bytes.NewBuffer(make([]byte, 0, 1024)) - och := &proxymocks.OutboundConnectionHandler{ - ConnInput: bytes.NewReader(connInput), - ConnOutput: connOutput, - } - - protocol, err := proxytesting.RegisterOutboundConnectionHandlerCreator("mock_och", - func(space app.Space, config interface{}) (v2proxy.OutboundHandler, error) { - return och, nil - }) - assert.Error(err).IsNil() - - config := &point.Config{ - Port: port, - InboundConfig: &point.ConnectionConfig{ - Protocol: "socks", - Settings: []byte(`{"auth": "noauth", "udp": true}`), - }, - OutboundConfig: &point.ConnectionConfig{ - Protocol: protocol, - Settings: nil, - }, - } - - point, err := point.NewPoint(config) - assert.Error(err).IsNil() - - err = point.Start() - assert.Error(err).IsNil() - - conn, err := net.DialUDP("udp", nil, &net.UDPAddr{ - IP: []byte{127, 0, 0, 1}, - Port: int(port), - Zone: "", - }) - - assert.Error(err).IsNil() - - data2Send := []byte("Fake DNS request") - - buffer := make([]byte, 0, 1024) - buffer = append(buffer, 0, 0, 0) - buffer = append(buffer, 1, 8, 8, 4, 4, 0, 53) - buffer = append(buffer, data2Send...) - - conn.Write(buffer) - - response := make([]byte, 1024) - nBytes, err := conn.Read(response) - - assert.Error(err).IsNil() - assert.Bytes(response[10:nBytes]).Equals(connInput) - assert.Bytes(data2Send).Equals(connOutput.Bytes()) - assert.StringLiteral(och.Destination.String()).Equals("udp:8.8.4.4:53") -}