python - Compare protocol type -


def main():     pkt = sniff(filter = server_ip_filter, lfilter= check_protocol, count = 1)     print pkt[0].summary()      black_list = open ("black_list" ,"r")     list_lines = black_list.readlines()     black_list.close()     black_list_lines = [(i.split(',')) in list_lines]      layer = pkt[0].getlayer(2).name      line in black_list_lines:          if line[0] == pkt[0][ip].src:             if str(line[2]) == str(layer[0]):                 print "block ! " 

i trying create simple firewall, have file called black_list has ip, port, protocol. when try compare protocol type in order know if packet should block, says line[2] , protocol doesn't match.

i check type , both of them <str>.


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -