diff --git a/PKGBUILD b/PKGBUILD index 426f64c..689596e 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -1,6 +1,6 @@ # Maintainer: mutantmonkey pkgname=tor-control-port-proxy -pkgver=0.1 +pkgver=0.2 pkgrel=1 pkgdesc="Whitelisting Tor control port proxy written in Python" arch=('any') @@ -9,7 +9,7 @@ license=('GPL') depends=('python' 'stem') options=(!emptydirs) source=('tor-control-port-proxy' 'tor-control-port-proxy.service') -sha256sums=('7fbc8295f94d074437ecf0607d2da78624c9cd8b07b4a892b783010a573f0893' +sha256sums=('224c51d07e5393525a05cf11384b775dcb654469a6bdf6c6c5a06375c656c124' 'eda5f0f43c9d2c8956743ba6485bb50fdb307af9941634902385214ecda14ce4') package() { diff --git a/tor-control-port-proxy b/tor-control-port-proxy index c4dbdd9..826275f 100644 --- a/tor-control-port-proxy +++ b/tor-control-port-proxy @@ -1,4 +1,5 @@ #!/usr/bin/python3 + import asyncore import asynchat import shlex @@ -34,12 +35,15 @@ class TorControlProxyHandler(asynchat.async_chat): # we do the authentication later, as it's not needed yet self.authenticated = True self.send_reply(250, 'OK') + elif command[0].lower() == 'quit': + self.send_reply(250, 'closing connection') + self.close() elif self.authenticated: if command[0].lower() == 'getinfo': if command[1] == 'net/listeners/socks': # send a fake response to make TBB happy - self.push( - b'250-net/listeners/socks="192.168.100.1:9050"\r\n') + self.push('250-net/listeners/socks="{}:9050"\r\n'.format( + self.socket.getsockname()[0]).encode('utf-8')) self.send_reply(250, 'OK') elif command[1] == 'status/bootstrap-phase': self.pass_message('GETINFO status/bootstrap-phase') @@ -58,9 +62,6 @@ class TorControlProxyHandler(asynchat.async_chat): self.send_reply( 510, 'Unrecognized command "{}"'.format(command[0])) - elif command[0].lower() == 'quit': - self.send_reply(250, 'closing connection') - self.close() else: self.send_reply(514, 'Authentication required.')