Browse Source

fix Windows

1.4
clowwindy 11 years ago
parent
commit
eb8fccad79
  1. 3
      CHANGES
  2. 2
      README.md
  3. 2
      setup.py
  4. 44
      shadowsocks/utils.py

3
CHANGES

@ -1,3 +1,6 @@
1.4.3 2014-05-13
- Fix Windows
1.4.2 2014-05-10 1.4.2 2014-05-10
- Add salsa20-ctr cipher - Add salsa20-ctr cipher

2
README.md

@ -1,7 +1,7 @@
shadowsocks shadowsocks
=========== ===========
Current version: 1.4.2 [![Build Status][1]][0] Current version: 1.4.3 [![Build Status][1]][0]
shadowsocks is a lightweight tunnel proxy which can help you get through firewalls. shadowsocks is a lightweight tunnel proxy which can help you get through firewalls.

2
setup.py

@ -6,7 +6,7 @@ with open('README.rst') as f:
setup( setup(
name="shadowsocks", name="shadowsocks",
version="1.4.2", version="1.4.3",
license='MIT', license='MIT',
description="a lightweight tunnel proxy", description="a lightweight tunnel proxy",
author='clowwindy', author='clowwindy',

44
shadowsocks/utils.py

@ -22,9 +22,53 @@
# SOFTWARE. # SOFTWARE.
import os import os
import socket
import logging import logging
def inet_ntop(family, ipstr):
if family == socket.AF_INET:
return socket.inet_ntoa(ipstr)
elif family == socket.AF_INET6:
v6addr = ':'.join(('%02X%02X' % (ord(i), ord(j)))
for i, j in zip(ipstr[::2], ipstr[1::2]))
return v6addr
def inet_pton(family, addr):
if family == socket.AF_INET:
return socket.inet_aton(addr)
elif family == socket.AF_INET6:
if '.' in addr: # a v4 addr
v4addr = addr[addr.rindex(':') + 1:]
v4addr = socket.inet_aton(v4addr)
v4addr = map(lambda x: ('%02X' % ord(x)), v4addr)
v4addr.insert(2, ':')
newaddr = addr[:addr.rindex(':') + 1] + ''.join(v4addr)
return inet_pton(family, newaddr)
dbyts = [0] * 8 # 8 groups
grps = addr.split(':')
for i, v in enumerate(grps):
if v:
dbyts[i] = int(v, 16)
else:
for j, w in enumerate(grps[::-1]):
if w:
dbyts[7 - j] = int(w, 16)
else:
break
break
return ''.join((chr(i // 256) + chr(i % 256)) for i in dbyts)
else:
raise RuntimeError("What family?")
if not hasattr(socket, 'inet_pton'):
socket.inet_pton = inet_pton
if not hasattr(socket, 'inet_ntop'):
socket.inet_ntop = inet_ntop
def find_config(): def find_config():
config_path = 'config.json' config_path = 'config.json'
if os.path.exists(config_path): if os.path.exists(config_path):

Loading…
Cancel
Save