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 self._ota_enable = True
else: else:
self._ota_enable = False self._ota_enable = False
self._ota_buff_head = '' self._ota_buff_head = b''
self._ota_buff_data = '' self._ota_buff_data = b''
self._ota_len = 0 self._ota_len = 0
self._ota_chunk_idx = 0 self._ota_chunk_idx = 0
self._fastopen_connected = False self._fastopen_connected = False
@ -338,7 +338,7 @@ class TCPRelayHandler(object):
# spec https://shadowsocks.org/en/spec/one-time-auth.html # spec https://shadowsocks.org/en/spec/one-time-auth.html
# ATYP & 0x10 == 1, then OTA is enabled. # ATYP & 0x10 == 1, then OTA is enabled.
if self._ota_enable: 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 key = self._encryptor.cipher_iv + self._encryptor.key
data += onetimeauth_gen(data, key) data += onetimeauth_gen(data, key)
data_to_send = self._encryptor.encrypt(data) data_to_send = self._encryptor.encrypt(data)
@ -455,8 +455,8 @@ class TCPRelayHandler(object):
else: else:
data_cb(self._ota_buff_data) data_cb(self._ota_buff_data)
self._ota_chunk_idx += 1 self._ota_chunk_idx += 1
self._ota_buff_head = '' self._ota_buff_head = b''
self._ota_buff_data = '' self._ota_buff_data = b''
self._ota_len = 0 self._ota_len = 0
return return

View file

@ -279,7 +279,7 @@ class UDPRelay(object):
pass pass
def _ota_chunk_data_gen(self, key, iv, data): 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 key = iv + key
return data + onetimeauth_gen(data, key) return data + onetimeauth_gen(data, key)