# the names used by Tribler for the BitTorrent messages
msg_types = {"BT_REQUEST_SEND": "new_request", "BT_REQUEST_RECV": "REQUEST(", "BT_CHOKE": "CHOKE from", "BT_UNCHOKE": "UNCHOKE from",
"BT_HAVE": "HAVE(", "BT_PIECE": "PIECE(", "BT_BITFIELD": "BITFIELD from",
- "BT_CANCEL": "sent cancel"}
+ "BT_CANCEL": "sent cancel", "BT_INTERESTED": "INTERESTED from"}
msg_db_code = {"BT_CHOKE" : 0, "BT_UNCHOKE": 1, "BT_INTERESTED": 2, "BT_NOT_INTERESTED": 3,
"BT_HAVE" : 4, "BT_BITFIELD": 5, "BT_REQUEST" : 6, "BT_PIECE": 7, "BT_CANCEL": 8}
if is_unchoke != -1:
return (timestamp, direction, peer_ip, None, msg_db_code["BT_UNCHOKE"], None, None, None, 0)
+"""
+ Parse a line that contains interested messages.
+ line format: date timestamp connecter: Got INTERESTED from ip
+"""
+
+def tribler_parse_interested_msg(line):
+
+ if line.find(msg_types["BT_INTERESTED"]) == -1:
+ return None
+
+ line_parts = re.split(" *", line)
+ timestamp = tribler_parse_timestamp(line_parts[0], line_parts[1])
+
+ if timestamp == None:
+ print "Error: invalid date & time format for Connecter."
+ return None
+
+ nr_parts = len(line_parts)
+ if nr_parts < 7 :
+ print "Error: invalid line format for Connecter.", line
+ return None
+
+ peer_ip = line_parts[nr_parts-1];
+ direction = log_msg_dir["RECEIVE"];
+ return (timestamp, direction, peer_ip, None, msg_db_code["BT_INTERESTED"], None, None, None, 0)
+
+
"""
sample line: 14-11-2009 23:11:13 connecter: Got HAVE( 14 ) from 141.85.37.41
BitTorrent message format: have <id> <index>
return None
nr_parts = len(line_parts)
- if nr_parts < 8 :
+ if nr_parts < 9 :
print "Error: invalid line format for Connecter.", line
return None
return None
nr_parts = len(line_parts)
- if nr_parts < 8 :
+ if nr_parts < 9 :
print "Error: invalid line format for Connecter.", line
return None