[Pkg-privacy-commits] [obfsproxy] 171/353: Fix a bug in the SOCKS logic.
Ximin Luo
infinity0 at moszumanska.debian.org
Sat Aug 22 13:01:56 UTC 2015
This is an automated email from the git hooks/post-receive script.
infinity0 pushed a commit to branch master
in repository obfsproxy.
commit b1ae5afc64d9035af1d4a1b5619b7819239e6f25
Author: George Kadianakis <desnacked at riseup.net>
Date: Fri Jul 12 16:01:40 2013 +0300
Fix a bug in the SOCKS logic.
An assertion would trigger when the destination of a SOCKS connection
sent us data before obfsproxy (for example, an SSH server sends data
before the client does).
---
obfsproxy/network/socks.py | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/obfsproxy/network/socks.py b/obfsproxy/network/socks.py
index 2ecd098..344bf16 100644
--- a/obfsproxy/network/socks.py
+++ b/obfsproxy/network/socks.py
@@ -41,6 +41,7 @@ class MySOCKSv4Outgoing(socks.SOCKSv4Outgoing, network.GenericProtocol):
'socksProtocol' is a 'SOCKSv4Protocol' object.
"""
self.name = "socks_down_%s" % hex(id(self))
+ self.socksProtocol = socksProtocol
network.GenericProtocol.__init__(self, socksProtocol.circuit)
return super(MySOCKSv4Outgoing, self).__init__(socksProtocol)
@@ -49,7 +50,9 @@ class MySOCKSv4Outgoing(socks.SOCKSv4Outgoing, network.GenericProtocol):
log.debug("%s: Received %d bytes:\n%s" \
% (self.name, len(data), str(data)))
- assert(self.circuit.circuitIsReady()) # XXX Is this always true?
+ # If the circuit was not set up, set it up now.
+ if not self.circuit.circuitIsReady():
+ self.socksProtocol.set_up_circuit()
self.buffer.write(data)
self.circuit.dataReceived(self.buffer, self)
@@ -104,19 +107,25 @@ class SOCKSv4Protocol(socks.SOCKSv4, network.GenericProtocol):
% (self.name, len(data), str(data)))
self.buffer.write(data)
- assert(self.otherConn)
-
"""
If we came here with an incomplete circuit, it means that we
finished the SOCKS handshake and connected downstream. Set up
our circuit and start proxying traffic.
"""
if not self.circuit.circuitIsReady():
- self.circuit.setDownstreamConnection(self.otherConn)
- self.circuit.setUpstreamConnection(self)
+ self.set_up_circuit()
self.circuit.dataReceived(self.buffer, self)
+ def set_up_circuit(self):
+ """
+ Set the upstream/downstream SOCKS connections on the circuit.
+ """
+
+ assert(self.otherConn)
+ self.circuit.setDownstreamConnection(self.otherConn)
+ self.circuit.setUpstreamConnection(self)
+
def authorize(self, code, server, port, user):
"""
(Overriden)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/obfsproxy.git
More information about the Pkg-privacy-commits
mailing list