- F36BF2D21B07D0A2E017B7C0A1F7C8784DED0A4539F2E6CB9DAC2B834F2909686B0AB3CFA28A64B35DB83C16018B049F99DA69B4EEB61EF238C5FE90555927E3
+ 16E7971B6EAB7483A4060D5CAE5111DEC2F61618A2022620343EF7AA3FCEDEE87CC6499C9F9978215C315FDE958E70FA7810F50967E97DD299CD98842118C12D
blatta/lib/server.py
(1 . 4)(1 . 4)
120 VERSION = "9989"
121 VERSION = "9988"
122
123 import os
124 import select
(9 . 6)(9 . 7)
126 import time
127 import string
128 import binascii
129 import hashlib
130 import datetime
131 from datetime import datetime
132 from lib.client import Client
(24 . 7)(25 . 6)
134 from lib.infosec import Infosec
135 from lib.peer import Peer
136 from lib.message import Message
137 from lib.ringbuffer import Ringbuffer
138 from funcs import *
139 from commands import BROADCAST
140 from commands import DIRECT
(63 . 7)(63 . 6)
142 self.channels = {} # irc_lower(Channel name) --> Channel instance.
143 self.clients = {} # Socket --> Client instance..peers = ""
144 self.nicknames = {} # irc_lower(Nickname) --> Client instance.
145 self.recent = Ringbuffer(100)
146 if self.logdir:
147 create_directory(self.logdir)
148 if self.statedir:
(207 . 11)(206 . 22)
150 message.original = True
151 if message.command == DIRECT:
152 peer = self.state.get_peer_by_handle(message.handle)
153 message_bytes = self.infosec.get_message_bytes(message, peer)
154 message_hash = binascii.hexlify(hashlib.sha256(message_bytes).digest())
155 self.state.add_to_dedup_queue(message_hash)
156
157 self.state.log(message.speaker, message_bytes, peer.peer_id)
158 if peer and (peer.get_key() != None):
159 peer.send(message)
160 else:
161 self.print_debug("Discarding message to unknown handle or handle with no key: %s" % message.handle)
162 else:
163 message.timestamp = int(time.time())
164 message_bytes = self.infosec.get_message_bytes(message)
165 if message.command != IGNORE:
166 self.state.log(message.speaker, message_bytes)
167 message_hash = binascii.hexlify(hashlib.sha256(message_bytes).digest())
168 self.state.add_to_dedup_queue(message_hash)
169 for peer in self.state.get_peers():
170 if peer.get_key() != None:
171 peer.send(message)
(228 . 14)(238 . 13)
173
174
175 def sendrubbish(self):
176 for peer in self.state.get_peers():
177 for socket in self.clients:
178 self.peer_message(Message({
179 "speaker": self.clients[socket].nickname,
180 "command": IGNORE,
181 "bounces": 0,
182 "body": self.infosec.gen_rubbish_body()
183 }, self))
184 for socket in self.clients:
185 self.peer_message(Message({
186 "speaker": self.clients[socket].nickname,
187 "command": IGNORE,
188 "bounces": 0,
189 "body": self.infosec.gen_rubbish_body()
190 }, self))
191
192 def start(self):
193 # Setup UDP first