From f65aa6b11431b0f01991312ffdef42d0149a74ce Mon Sep 17 00:00:00 2001 From: clowwindy Date: Fri, 2 Nov 2012 17:36:57 +0800 Subject: [PATCH] update readme; auto detect config path --- README.md | 21 ++++++++------------- local.py | 4 ++++ server.py | 4 ++++ 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 0a0b2aa..7dc4855 100644 --- a/README.md +++ b/README.md @@ -6,23 +6,18 @@ shadowsocks is a lightweight tunnel proxy which can help you get through firewal usage ----------- -Put `server.py` on your server. Edit `server.py`, change the following values: +Edit `config.json`, change the following values: - PORT server port - KEY a password to identify clients + server your server ip or hostname + server_port server port + local_port local port + password a password used to encrypt transfer -Run `python server.py` on your server. To run it in the background, run `nohup python server.py > log &`. +Put all the files on your server. Run `python server.py` on your server. To run it in the background, run `nohup python server.py > log &`. -Put `local.py` on your client machine. Edit `local.py`, change these values: - - SERVER your server ip or hostname - REMOTE_PORT server port - PORT local port - KEY a password, it must be the same as the password of your server - -Run `python local.py` on your client machine. +Put all the files on your client machine. Run `python local.py` on your client machine. Change proxy settings of your browser into - SOCKS5 127.0.0.1:PORT + SOCKS5 127.0.0.1:local_port diff --git a/local.py b/local.py index cf5104d..b2141b7 100755 --- a/local.py +++ b/local.py @@ -28,6 +28,7 @@ import struct import string import hashlib import sys +import os import json import logging @@ -59,6 +60,7 @@ class Socks5Server(SocketServer.StreamRequestHandler): if sock.send(self.decrypt(remote.recv(4096))) <= 0: break finally: + sock.close() remote.close() def encrypt(self, data): @@ -115,6 +117,8 @@ class Socks5Server(SocketServer.StreamRequestHandler): if __name__ == '__main__': + os.chdir(os.path.dirname(__file__) or '.') + with open('config.json', 'rb') as f: config = json.load(f) SERVER = config['server'] diff --git a/server.py b/server.py index da4c2e7..670c6d8 100755 --- a/server.py +++ b/server.py @@ -28,6 +28,7 @@ import struct import string import hashlib import sys +import os import json import logging @@ -59,6 +60,7 @@ class Socks5Server(SocketServer.StreamRequestHandler): if sock.send(self.encrypt(remote.recv(4096))) <= 0: break finally: + sock.close() remote.close() def encrypt(self, data): @@ -94,6 +96,8 @@ class Socks5Server(SocketServer.StreamRequestHandler): logging.warn('socket error ' + str(e)) if __name__ == '__main__': + os.chdir(os.path.dirname(__file__) or '.') + with open('config.json', 'rb') as f: config = json.load(f) SERVER = config['server']