Skip to content

Commit

Permalink
Merge pull request #1 from Anankke/manyuser
Browse files Browse the repository at this point in the history
update
  • Loading branch information
ximliu authored Oct 20, 2020
2 parents 1bc277f + af66a24 commit ea63f6c
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 24 deletions.
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "pip" # See documentation for possible values
directory: "/" # Location of package manifests
target-branch: "testing"
schedule:
interval: "daily"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ CentOS:
pip install -r requirements.txt

### Python3 TurnKey Install
请参见 https://wiki.sspanel.host/#/onekey-install-for-node
请参见 https://wiki.sspanel.host/#/turnkey-install-for-node

License
-------
Expand Down
1 change: 1 addition & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"obfs_param": "",
"speed_limit_per_con": 0,

"out_bind": "",
"dns_ipv6": false,
"connect_verbose_info": 0,
"connect_hex_data": 0,
Expand Down
45 changes: 29 additions & 16 deletions shadowsocks/obfsplugin/simple_obfs_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,24 @@
from shadowsocks.obfsplugin import plain
from shadowsocks.common import to_bytes, to_str, ord, chr


def create_simple_obfs_http_obfs(method):
return simple_obfs_http(method)


obfs_map = {
'simple_obfs_http': (create_simple_obfs_http_obfs,),
'simple_obfs_http_compatible': (create_simple_obfs_http_obfs,),
'simple_obfs_http': (create_simple_obfs_http_obfs,),
'simple_obfs_http_compatible': (create_simple_obfs_http_obfs,),
}


def match_begin(str1, str2):
if len(str1) >= len(str2):
if str1[:len(str2)] == str2:
return True
return False


class simple_obfs_http(plain.plain):
def __init__(self, method):
self.method = method
Expand All @@ -54,14 +58,16 @@ def __init__(self, method):
self.port = 0
self.recv_buffer = b''

self.curl_version = b"7." + common.to_bytes(str(random.randint(0, 51))) + b"." + common.to_bytes(str(random.randint(0, 2)))
self.nginx_version = b"1." + common.to_bytes(str(random.randint(0, 11))) + b"." + common.to_bytes(str(random.randint(0, 12)))
self.curl_version = b"7." + common.to_bytes(str(random.randint(0, 51))) + b"." + common.to_bytes(
str(random.randint(0, 2)))
self.nginx_version = b"1." + common.to_bytes(str(random.randint(0, 11))) + b"." + common.to_bytes(
str(random.randint(0, 12)))

def encode_head(self, buf):
hexstr = binascii.hexlify(buf)
chs = []
for i in range(0, len(hexstr), 2):
chs.append(b"%" + hexstr[i:i+2])
chs.append(b"%" + hexstr[i:i + 2])
return b''.join(chs)

def client_encode(self, buf):
Expand Down Expand Up @@ -104,16 +110,23 @@ def server_encode(self, buf):
if self.has_sent_header:
return buf

header = b'HTTP/1.1 101 Switching Protocols\r\n'
header += b'Server: nginx/' + self.nginx_version + b'\r\n'
header += b'Date: ' + to_bytes(datetime.datetime.now().strftime('%a, %d %b %Y %H:%M:%S GMT'))
header += b'\r\n'
header += b'Upgrade: websocket\r\n'
header += b'Connection: Upgrade\r\n'
header += b'Sec-WebSocket-Accept: ' + common.to_bytes(common.random_base64_str(64)) + b'\r\n'
header += b'\r\n'
data = b''.join([b'HTTP/1.1 101 Switching Protocols\r\n',
b'Server: nginx/',
self.nginx_version,
b'\r\n',
b'Date: ',
to_bytes(datetime.datetime.now().strftime('%a, %d %b %Y %H:%M:%S GMT')),
b'\r\n',
b'Upgrade: websocket\r\n',
b'Connection: Upgrade\r\n',
b'Sec-WebSocket-Accept: ',
common.to_bytes(common.random_base64_str(64)),
b'\r\n',
b'\r\n',
buf])

self.has_sent_header = True
return header + buf
return data

def get_host_from_http_header(self, buf):
ret_buf = b''
Expand All @@ -127,7 +140,7 @@ def not_match_return(self, buf):
self.has_sent_header = True
self.has_recv_header = True
if self.method == 'simple_obfs_http':
return (b'E'*2048, False, False)
return (b'E' * 2048, False, False)
return (buf, True, False)

def server_decode(self, buf):
Expand All @@ -142,7 +155,7 @@ def server_decode(self, buf):
self.recv_buffer = None
logging.warn('simple_obfs_http: over size')
return self.not_match_return(buf)
else: #not http header, run on original protocol
else: # not http header, run on original protocol
self.recv_buffer = None
logging.debug('simple_obfs_http: not match begin')
return self.not_match_return(buf)
Expand Down
8 changes: 4 additions & 4 deletions shadowsocks/tcprelay.py
Original file line number Diff line number Diff line change
Expand Up @@ -953,10 +953,10 @@ def _socket_bind_addr(self, sock, af):
bind_addr = self._bindv6
else:
bind_addr = self._accept_address[0]
bind_addr = bind_addr.replace("::ffff:", "")

bind_addr = bind_addr.replace("::ffff:", "")
if bind_addr in self._ignore_bind_list:
bind_addr = None
#if bind_addr in self._ignore_bind_list:
# bind_addr = None

if self._is_relay:
bind_addr = None
Expand Down Expand Up @@ -1857,7 +1857,7 @@ def __init__(
except socket.error:
logging.error('warning: fast open is not available')
self._config['fast_open'] = False
server_socket.listen(config.get('max_connect', 1024))
server_socket.listen()
self._server_socket = server_socket
self._server_socket_fd = server_socket.fileno()
self._stat_counter = stat_counter
Expand Down
6 changes: 3 additions & 3 deletions shadowsocks/udprelay.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,9 +440,9 @@ def _socket_bind_addr(self, sock, af, is_relay):
elif self._bindv6 and af == socket.AF_INET6:
bind_addr = self._bindv6

bind_addr = bind_addr.replace("::ffff:", "")
if bind_addr in self._ignore_bind_list:
bind_addr = None
# bind_addr = bind_addr.replace("::ffff:", "")
# if bind_addr in self._ignore_bind_list:
# bind_addr = None

if is_relay:
bind_addr = None
Expand Down

0 comments on commit ea63f6c

Please sign in to comment.