1010sub_lock = set ()
1111
1212def substitute_ip (client , dst_black_list ):
13- if client .dst_ip not in sub_map :
14- gevent .spawn (fill_sub_map , client .host , client .dst_ip )
15- return False
16- if client .dst_ip in sub_map and sub_map [client .dst_ip ] is None :
17- return False
18- candidate_ips = []
19- for ip in sub_map .get (client .dst_ip ):
20- if (ip , client .dst_port ) not in dst_black_list :
21- candidate_ips .append (ip )
22- if candidate_ips :
23- substituted_ip = random .choice (candidate_ips )
24- client .dst_ip = substituted_ip
25- return True
26- else :
27- sub_map [client .dst_ip ] = None
28- return False
13+ '''not available anymore'''
14+ return False
15+ # if client.dst_ip not in sub_map:
16+ # gevent.spawn(fill_sub_map, client.host, client.dst_ip)
17+ # return False
18+ # if client.dst_ip in sub_map and sub_map[client.dst_ip] is None:
19+ # return False
20+ # candidate_ips = []
21+ # for ip in sub_map.get(client.dst_ip):
22+ # if (ip, client.dst_port) not in dst_black_list:
23+ # candidate_ips.append(ip)
24+ # if candidate_ips:
25+ # substituted_ip = random.choice(candidate_ips)
26+ # client.dst_ip = substituted_ip
27+ # return True
28+ # else:
29+ # sub_map[client.dst_ip] = None
30+ # return False
2931
3032
3133def fill_sub_map (host , dst_ip ):
@@ -55,4 +57,4 @@ def add_sub_map_ips(from_ip, to_ips):
5557 sub_map [from_ip ] = total_ips
5658 total_ips .extend (to_ips )
5759 if from_ip in total_ips :
58- total_ips .remove (from_ip )
60+ total_ips .remove (from_ip )
0 commit comments