From f7e165c1149c78f0875cfcbc3d851692db2fe988 Mon Sep 17 00:00:00 2001 From: V2Ray Date: Mon, 5 Oct 2015 17:09:44 +0200 Subject: [PATCH] compatibility --- proxy/socks/socks.go | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/proxy/socks/socks.go b/proxy/socks/socks.go index ed6946b5..0a7237b0 100644 --- a/proxy/socks/socks.go +++ b/proxy/socks/socks.go @@ -147,16 +147,14 @@ func (server *SocksServer) handleSocks5(reader *v2net.TimeOutReader, writer io.W response.Error = protocol.ErrorSuccess - response.Port = request.Port - response.AddrType = request.AddrType - switch response.AddrType { - case protocol.AddrTypeIPv4: - copy(response.IPv4[:], request.IPv4[:]) - case protocol.AddrTypeIPv6: - copy(response.IPv6[:], request.IPv6[:]) - case protocol.AddrTypeDomain: - response.Domain = request.Domain - } + // Some SOCKS software requires a value other than dest. Let's fake one: + response.Port = uint16(38294) + response.AddrType = protocol.AddrTypeIPv4 + response.IPv4[0] = 127 + response.IPv4[1] = 0 + response.IPv4[2] = 0 + response.IPv4[3] = 1 + err = protocol.WriteResponse(writer, response) if err != nil { log.Error("Socks failed to write response: %v", err)