Browse Source

fix some exceptions

dev
breakwa11 10 years ago
parent
commit
928c26e4f2
  1. 4
      shadowsocks/encrypt.py
  2. 3
      shadowsocks/udprelay.py

4
shadowsocks/encrypt.py

@ -21,6 +21,7 @@ import os
import sys import sys
import hashlib import hashlib
import logging import logging
import random
from shadowsocks import common from shadowsocks import common
from shadowsocks.crypto import rc4_md5, openssl, sodium, table from shadowsocks.crypto import rc4_md5, openssl, sodium, table
@ -34,7 +35,10 @@ method_supported.update(table.ciphers)
def random_string(length): def random_string(length):
try:
return os.urandom(length) return os.urandom(length)
except (AttributeError, NotImplementedError):
return ''.join(chr(random.randrange(255)) for _ in range(length))
cached_keys = {} cached_keys = {}

3
shadowsocks/udprelay.py

@ -1036,6 +1036,9 @@ class UDPRelay(object):
self.write_to_server_socket(data_to_send, r_addr) self.write_to_server_socket(data_to_send, r_addr)
elif data[0] > CMD_CONNECT_REMOTE and data[0] <= CMD_DISCONNECT: elif data[0] > CMD_CONNECT_REMOTE and data[0] <= CMD_DISCONNECT:
if data[1] in self._reqid_to_hd: if data[1] in self._reqid_to_hd:
if type(self._reqid_to_hd[data[1]]) is tuple:
pass
else:
self.update_activity(self._reqid_to_hd[data[1]]) self.update_activity(self._reqid_to_hd[data[1]])
self._reqid_to_hd[data[1]].handle_client(r_addr, *data) self._reqid_to_hd[data[1]].handle_client(r_addr, *data)
else: else:

Loading…
Cancel
Save