fix bug with ord in Py3

This commit is contained in:
mengskysama 2016-01-12 14:20:46 +08:00
parent 811a0e6eb8
commit a8d116d70a
2 changed files with 6 additions and 6 deletions

View file

@ -113,8 +113,8 @@ class TCPRelayHandler(object):
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
@ -338,7 +338,7 @@ class TCPRelayHandler(object):
# 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)
@ -455,8 +455,8 @@ class TCPRelayHandler(object):
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

View file

@ -279,7 +279,7 @@ class UDPRelay(object):
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)