Skip to content

Commit

Permalink
fix bug with ord in Py3
Browse files Browse the repository at this point in the history
  • Loading branch information
mengskysama committed Jan 12, 2016
1 parent 811a0e6 commit a8d116d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions shadowsocks/tcprelay.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ def __init__(self, server, fd_to_handlers, loop, local_sock, config,
self._ota_enable = True
else:
self._ota_enable = False
self._ota_buff_head = ''
self._ota_buff_data = ''
self._ota_buff_head = b''
self._ota_buff_data = b''
self._ota_len = 0
self._ota_chunk_idx = 0
self._fastopen_connected = False
Expand Down Expand Up @@ -338,7 +338,7 @@ def _handle_stage_addr(self, data):
# spec https://shadowsocks.org/en/spec/one-time-auth.html
# ATYP & 0x10 == 1, then OTA is enabled.
if self._ota_enable:
data = chr(ord(data[0]) | ADDRTYPE_AUTH) + data[1:]
data = common.chr(addrtype | ADDRTYPE_AUTH) + data[1:]
key = self._encryptor.cipher_iv + self._encryptor.key
data += onetimeauth_gen(data, key)
data_to_send = self._encryptor.encrypt(data)
Expand Down Expand Up @@ -455,8 +455,8 @@ def _ota_chunk_data(self, data, data_cb):
else:
data_cb(self._ota_buff_data)
self._ota_chunk_idx += 1
self._ota_buff_head = ''
self._ota_buff_data = ''
self._ota_buff_head = b''
self._ota_buff_data = b''
self._ota_len = 0
return

Expand Down
2 changes: 1 addition & 1 deletion shadowsocks/udprelay.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def _handle_client(self, sock):
pass

def _ota_chunk_data_gen(self, key, iv, data):
data = chr(ord(data[0]) | ADDRTYPE_AUTH) + data[1:]
data = common.chr(common.ord(data[0]) | ADDRTYPE_AUTH) + data[1:]
key = iv + key
return data + onetimeauth_gen(data, key)

Expand Down

0 comments on commit a8d116d

Please sign in to comment.