update readme; auto detect config path
This commit is contained in:
parent
2f67cabfe0
commit
f65aa6b114
3 changed files with 16 additions and 13 deletions
21
README.md
21
README.md
|
@ -6,23 +6,18 @@ shadowsocks is a lightweight tunnel proxy which can help you get through firewal
|
||||||
usage
|
usage
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
Put `server.py` on your server. Edit `server.py`, change the following values:
|
Edit `config.json`, change the following values:
|
||||||
|
|
||||||
PORT server port
|
server your server ip or hostname
|
||||||
KEY a password to identify clients
|
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:
|
Put all the files on your client machine. Run `python local.py` on your client machine.
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
Change proxy settings of your browser into
|
Change proxy settings of your browser into
|
||||||
|
|
||||||
SOCKS5 127.0.0.1:PORT
|
SOCKS5 127.0.0.1:local_port
|
||||||
|
|
||||||
|
|
4
local.py
4
local.py
|
@ -28,6 +28,7 @@ import struct
|
||||||
import string
|
import string
|
||||||
import hashlib
|
import hashlib
|
||||||
import sys
|
import sys
|
||||||
|
import os
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
@ -59,6 +60,7 @@ class Socks5Server(SocketServer.StreamRequestHandler):
|
||||||
if sock.send(self.decrypt(remote.recv(4096))) <= 0:
|
if sock.send(self.decrypt(remote.recv(4096))) <= 0:
|
||||||
break
|
break
|
||||||
finally:
|
finally:
|
||||||
|
sock.close()
|
||||||
remote.close()
|
remote.close()
|
||||||
|
|
||||||
def encrypt(self, data):
|
def encrypt(self, data):
|
||||||
|
@ -115,6 +117,8 @@ class Socks5Server(SocketServer.StreamRequestHandler):
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
os.chdir(os.path.dirname(__file__) or '.')
|
||||||
|
|
||||||
with open('config.json', 'rb') as f:
|
with open('config.json', 'rb') as f:
|
||||||
config = json.load(f)
|
config = json.load(f)
|
||||||
SERVER = config['server']
|
SERVER = config['server']
|
||||||
|
|
|
@ -28,6 +28,7 @@ import struct
|
||||||
import string
|
import string
|
||||||
import hashlib
|
import hashlib
|
||||||
import sys
|
import sys
|
||||||
|
import os
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
@ -59,6 +60,7 @@ class Socks5Server(SocketServer.StreamRequestHandler):
|
||||||
if sock.send(self.encrypt(remote.recv(4096))) <= 0:
|
if sock.send(self.encrypt(remote.recv(4096))) <= 0:
|
||||||
break
|
break
|
||||||
finally:
|
finally:
|
||||||
|
sock.close()
|
||||||
remote.close()
|
remote.close()
|
||||||
|
|
||||||
def encrypt(self, data):
|
def encrypt(self, data):
|
||||||
|
@ -94,6 +96,8 @@ class Socks5Server(SocketServer.StreamRequestHandler):
|
||||||
logging.warn('socket error ' + str(e))
|
logging.warn('socket error ' + str(e))
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
os.chdir(os.path.dirname(__file__) or '.')
|
||||||
|
|
||||||
with open('config.json', 'rb') as f:
|
with open('config.json', 'rb') as f:
|
||||||
config = json.load(f)
|
config = json.load(f)
|
||||||
SERVER = config['server']
|
SERVER = config['server']
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue