[Pkg-privacy-commits] [obfsproxy] 91/353: Improve networking code.
Ximin Luo
infinity0 at moszumanska.debian.org
Sat Aug 22 13:01:44 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 1ec013210fad754d836e1234b10c5937b238de2a
Author: George Kadianakis <desnacked at riseup.net>
Date: Thu Nov 29 17:36:39 2012 +0200
Improve networking code.
* Add a connectionLost() method to a Protocol that was missing one.
* Provide the transport circuitDestroyed() method with the reason that
the circuit was destroyed.
Patch by Philipp Winter.
---
obfsproxy/network/network.py | 8 +++++---
obfsproxy/network/socks.py | 13 +++++++++++++
obfsproxy/transports/base.py | 2 +-
3 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/obfsproxy/network/network.py b/obfsproxy/network/network.py
index 0a519d9..812ec2d 100644
--- a/obfsproxy/network/network.py
+++ b/obfsproxy/network/network.py
@@ -149,9 +149,11 @@ class Circuit(Protocol):
log.debug("%s: %s: Closing circuit." % (self.name, str(err)))
self.close()
- def close(self):
+ def close(self, reason=None, side=None):
"""
- Tear down the circuit.
+ Tear down the circuit. The reason for the torn down circuit is given in
+ 'reason' and 'side' tells us where it happened: either upstream or
+ downstream.
"""
if self.closed: return # NOP if already closed
@@ -161,7 +163,7 @@ class Circuit(Protocol):
if self.upstream: self.upstream.close()
self.closed = True
- self.transport.circuitDestroyed(self)
+ self.transport.circuitDestroyed(self, reason, side)
class GenericProtocol(Protocol):
"""
diff --git a/obfsproxy/network/socks.py b/obfsproxy/network/socks.py
index 8f30f89..22c088b 100644
--- a/obfsproxy/network/socks.py
+++ b/obfsproxy/network/socks.py
@@ -59,6 +59,12 @@ class MySOCKSv4Outgoing(socks.SOCKSv4Outgoing, object):
self.transport.loseConnection()
self.closed = True
+ def connectionLost(self, reason):
+ # The circuit is handling this event.
+ log.debug("%s: SOCKS downstream to remote is closing (%s)." % \
+ (self.name, reason.getErrorMessage()))
+ self.circuit.close(reason, 'downstream')
+
# Monkey patches socks.SOCKSv4Outgoing with our own class.
socks.SOCKSv4Outgoing = MySOCKSv4Outgoing
@@ -107,6 +113,13 @@ class SOCKSv4Protocol(socks.SOCKSv4, network.GenericProtocol):
self.circuit.dataReceived(self.buffer, self)
+ def connectionLost(self, reason):
+ # The circuit is handling this event.
+ log.debug("%s: SOCKS upstream to local is closing (%s)." % \
+ (self.name, reason.getErrorMessage()))
+ self.circuit.close(reason, 'upstream')
+
+
class SOCKSv4Factory(Factory):
"""
A SOCKSv4 factory.
diff --git a/obfsproxy/transports/base.py b/obfsproxy/transports/base.py
index 93f3ce6..df3183c 100644
--- a/obfsproxy/transports/base.py
+++ b/obfsproxy/transports/base.py
@@ -41,7 +41,7 @@ class BaseTransport:
"""
pass
- def circuitDestroyed(self, circuit):
+ def circuitDestroyed(self, circuit, reason, side):
"""
Circuit 'circuit' was tore down.
Both connections of the circuit are closed when this callback triggers.
--
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