From bb498cbfa879b8421e598ed5e00caf3463134c54 Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Wed, 21 Dec 2016 10:45:47 +0100 Subject: [PATCH 1/2] Fix shadowsocks client handling proxied connection --- proxy/shadowsocks/client.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/proxy/shadowsocks/client.go b/proxy/shadowsocks/client.go index ca833304..96ce20c7 100644 --- a/proxy/shadowsocks/client.go +++ b/proxy/shadowsocks/client.go @@ -99,9 +99,11 @@ func (v *Client) Dispatch(destination v2net.Destination, payload *buf.Buffer, ra return } - if err := bodyWriter.Write(payload); err != nil { - log.Info("Shadowsocks|Client: Failed to write payload: ", err) - return + if !payload.IsEmpty() { + if err := bodyWriter.Write(payload); err != nil { + log.Info("Shadowsocks|Client: Failed to write payload: ", err) + return + } } var responseMutex sync.Mutex From eddde847df20d0984daac2178d02f71d5d84bbea Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Wed, 21 Dec 2016 10:46:27 +0100 Subject: [PATCH 2/2] comments --- app/dispatcher/impl/default.go | 1 + 1 file changed, 1 insertion(+) diff --git a/app/dispatcher/impl/default.go b/app/dispatcher/impl/default.go index 61dca923..e0b9f843 100644 --- a/app/dispatcher/impl/default.go +++ b/app/dispatcher/impl/default.go @@ -72,6 +72,7 @@ func (v *DefaultDispatcher) DispatchToOutbound(session *proxy.SessionInfo) ray.I return direct } +// FilterPacketAndDispatch waits for a payload from source and starts dispatching. // Private: Visible for testing. func (v *DefaultDispatcher) FilterPacketAndDispatch(destination v2net.Destination, link ray.OutboundRay, dispatcher proxy.OutboundHandler) { payload, err := link.OutboundInput().Read()