def insert_session_data(self, fd, sender, recipient, type, data=None): args = dict(session_id = self.session_id, _time = "from_unixtime(%s)" % fd.current_packet.ts_sec, sender = sender, offset = fd.tell(), recipient = recipient, type = type) CacheManager.urn_insert_to_table(fd.urn, "msn_session", args)
def insert_session_data(self, fd, sender, recipient, type, data=None): args = dict(session_id=self.session_id, _time="from_unixtime(%s)" % fd.current_packet.ts_sec, sender=sender, offset=fd.tell(), recipient=recipient, type=type) CacheManager.urn_insert_to_table(fd.urn, "msn_session", args)
def MSG(self, items, fd, scanners): """ Sends message to members of the current session There are two types of messages that may be sent: 1) A message from the client to the message server. This does not contain the nick of the client, but does contain a transaction ID. This message is sent to all users in the current session. 2) A message from the Switchboard server to the client contains the nick of the sender. These two commands are totally different. 1. MSG 1532 U 92 MIME-Version: 1.0 Content-Type: text/x-msmsgscontrol TypingUser: [email protected] Format is: MSG <Transaction ID> <Type of ACK required> <length of message in bytes> Transaction ID is used to correlate server responses to client requests. 2. MSG [email protected] I%20am%20so%20great 102 MIME-Version: 1.0 Content-Type: text/x-msmsgscontrol TypingUser: [email protected] Format is: MSG <Nick> <URL encoded displayname> <length of message in bytes> """ length = int(items[-1]) start = fd.tell() end = start + length if "@" in items[1]: ## Its type 2 (see above) sender_name = "(%s)" % HTML.url_unquote(items[2]) else: ## Its type 1 sender_name = '' sender = fd.client_id ct = '' while 1: line = fd.readline().strip() if not line: break header, value = line.split(":",1) header = header.lower() if header == 'typinguser': fd.client_id = fd.reverse.dest_id = value.strip() elif header == 'content-type': ct = value ## Update the start to be start start of this line start = fd.tell() fd.seek(end - start, 1) ## We only care about text messages here if end > start and 'text/plain' in ct: ## Lets find out the timestamp of this point CacheManager.urn_insert_to_table(fd.urn, "msn_session", dict(session_id = self.session_id, _time = "from_unixtime(%s)" % fd.current_packet.ts_sec, offset = start, length = end - start, sender = fd.client_id, recipient = fd.dest_id, type = 'MESSAGE', ))
def MSG(self, items, fd, scanners): """ Sends message to members of the current session There are two types of messages that may be sent: 1) A message from the client to the message server. This does not contain the nick of the client, but does contain a transaction ID. This message is sent to all users in the current session. 2) A message from the Switchboard server to the client contains the nick of the sender. These two commands are totally different. 1. MSG 1532 U 92 MIME-Version: 1.0 Content-Type: text/x-msmsgscontrol TypingUser: [email protected] Format is: MSG <Transaction ID> <Type of ACK required> <length of message in bytes> Transaction ID is used to correlate server responses to client requests. 2. MSG [email protected] I%20am%20so%20great 102 MIME-Version: 1.0 Content-Type: text/x-msmsgscontrol TypingUser: [email protected] Format is: MSG <Nick> <URL encoded displayname> <length of message in bytes> """ length = int(items[-1]) start = fd.tell() end = start + length if "@" in items[1]: ## Its type 2 (see above) sender_name = "(%s)" % HTML.url_unquote(items[2]) else: ## Its type 1 sender_name = '' sender = fd.client_id ct = '' while 1: line = fd.readline().strip() if not line: break header, value = line.split(":", 1) header = header.lower() if header == 'typinguser': fd.client_id = fd.reverse.dest_id = value.strip() elif header == 'content-type': ct = value ## Update the start to be start start of this line start = fd.tell() fd.seek(end - start, 1) ## We only care about text messages here if end > start and 'text/plain' in ct: ## Lets find out the timestamp of this point CacheManager.urn_insert_to_table( fd.urn, "msn_session", dict( session_id=self.session_id, _time="from_unixtime(%s)" % fd.current_packet.ts_sec, offset=start, length=end - start, sender=fd.client_id, recipient=fd.dest_id, type='MESSAGE', ))