Skip to content

Commit

Permalink
remove useless
Browse files Browse the repository at this point in the history
  • Loading branch information
XndroidDev committed Apr 7, 2019
1 parent e1eba12 commit 436f34c
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions fqrouter/manager/fqsocks/ip_substitution.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,24 @@
sub_lock = set()

def substitute_ip(client, dst_black_list):
if client.dst_ip not in sub_map:
gevent.spawn(fill_sub_map, client.host, client.dst_ip)
return False
if client.dst_ip in sub_map and sub_map[client.dst_ip] is None:
return False
candidate_ips = []
for ip in sub_map.get(client.dst_ip):
if (ip, client.dst_port) not in dst_black_list:
candidate_ips.append(ip)
if candidate_ips:
substituted_ip = random.choice(candidate_ips)
client.dst_ip = substituted_ip
return True
else:
sub_map[client.dst_ip] = None
return False
'''not available anymore'''
return False
# if client.dst_ip not in sub_map:
# gevent.spawn(fill_sub_map, client.host, client.dst_ip)
# return False
# if client.dst_ip in sub_map and sub_map[client.dst_ip] is None:
# return False
# candidate_ips = []
# for ip in sub_map.get(client.dst_ip):
# if (ip, client.dst_port) not in dst_black_list:
# candidate_ips.append(ip)
# if candidate_ips:
# substituted_ip = random.choice(candidate_ips)
# client.dst_ip = substituted_ip
# return True
# else:
# sub_map[client.dst_ip] = None
# return False


def fill_sub_map(host, dst_ip):
Expand Down Expand Up @@ -55,4 +57,4 @@ def add_sub_map_ips(from_ip, to_ips):
sub_map[from_ip] = total_ips
total_ips.extend(to_ips)
if from_ip in total_ips:
total_ips.remove(from_ip)
total_ips.remove(from_ip)

0 comments on commit 436f34c

Please sign in to comment.