- A82E5B4C782B1484C844FD7843441BF0220BD18A796963B836C23DBC00A0F4031677D7699EC86A6A4B892B194871869E3CF55F481A5D978559E235869A7C3417+ 79D6E16967ECED23171091D8CEFD19A20BECA845A68698BE54F75EF48F869C2DFD80D452BA3DC4ABABBE76A5007381D309E627EEC61F2D83AFBC513B543880ABblatta/lib/station.py(1 . 6)(1 . 6)
229 import time
230
231 VERSION = 9979
232 VERSION = 9978
233 STATUS_ONLINE = 0
234 STATUS_AWAY = 1
235
(36 . 6)(36 . 7)
237 self.short_buffer = ShortBuffer(self.state)
238 self.long_buffer = LongBuffer(self.state)
239 self.order_buffer = OrderBuffer(self.state)
240 self.getdata_requests = {}
241 self.server = Server(cmd_line_options, self)
242 self.handlers = {
243 DIRECT: self.handle_direct,
(44 . 6)(45 . 7)
245 IGNORE: self.handle_ignore
246 }
247 self.presence = {}
248 self.last_delivered = 0
249
250 def start(self):
251 self.server.start()
(106 . 7)(108 . 6)
253 def handle_direct(self, message):
254 message.log_incoming(message.peer)
255 self.deliver(message)
256 self.long_buffer.intern(message)
257 self.conditionally_update_at(message, message.metadata["address"])
258
259 def handle_broadcast(self, message):
(119 . 7)(120 . 6)
261 if self.short_buffer.has(message.message_hash):
262 self.short_buffer.drop(message.message_hash)
263 self.deliver(message)
264 self.long_buffer.intern(message)
265 self.state.update_net_chain(message.message_hash)
266 self.rebroadcast(message)
267 else:
(166 . 7)(166 . 6)
269 message.prefix = "%s[%d]" % (message.speaker, len(message_with_stats['closest_peers']))
270
271 self.deliver(message)
272 self.long_buffer.intern(message)
273 self.state.update_net_chain(message.message_hash)
274 message.reporting_peers = message_with_stats['reporting_peers']
275 self.rebroadcast(message)
(226 . 10)(225 . 18)
277 port = packet_info[1]
278 logging.debug(
279 "[%s:%d] -> message received out of order: %s" % (address, port, binascii.hexlify(message['message_hash'])))
280 if not self.order_buffer.has(message['message_hash']):
281 for chain in broken_chains:
282 for chain in broken_chains:
283 if not self.getdata_requests.get(message[chain]):
284 GetData(message, chain, self.state).send()
285 self.getdata_requests[message[chain]] = time.time()
286 self.order_buffer.add(message)
287 self.clean_getdata_requests()
288
289 def clean_getdata_requests(self):
290 for message_hash in self.getdata_requests.keys():
291 if (self.getdata_requests.get(message_hash) <
292 time.time() - self.state.get_knob('getdata_requests_expiration_seconds')):
293 del self.getdata_requests[message_hash]
294
295 def deliver(self, message):
296 # it's possible that these messages are from an order buffer
(238 . 18)(245 . 24)
298 if self.long_buffer.has(message.message_hash):
299 return
300
301
302 # send to the irc client
303 if self.client:
304 # emit a replay warning if this message is a getdata response and older than the last
305 # displayed message
306 if message.get_data_response:
307 if message.timestamp < self.state.get_latest_message_timestamp():
308 if message.timestamp < self.last_delivered:
309 warning = time.strftime(
310 "Replay: %Y-%m-%d %H:%M:%S:",
311 time.localtime(message.timestamp)
312 )
313 self.client.pest_reply(warning)
314 if message.command == BROADCAST:
315 self.client.pest_reply(warning)
316 else:
317 self.client.pest_dm_reply(message.speaker, warning)
318 self.client.message_from_station(message)
319 self.last_delivered = message.timestamp
320 self.long_buffer.intern(message)
321
322 # we only update the address table if the speaker is same as peer
323 def conditionally_update_at(self, message, address):