tree checksum vpatch file split hunks
all signers:
antecedents: genesis
press order:
genesis | |
9992-handle-edge-cases-add-feedback |
patch:
(462 . 16)(462 . 23)- C7FCA9B7A5D928F0E6A742D2B6903DD938C8592AD15F6A1423189830F68DC50EC1E37D19A6D6EEB4C5800752213B0F82F19ED3CED68499B9D272719C1D578831
5 def wot_handler():
6 if len(arguments) < 1:
7 # Display the current WOT
8 for peer in self.server.state.get_peers():
9 self.pest_reply("%s %s:%d" % (string.join(peer.handles, ","), peer.address, peer.port))
10 peers = self.server.state.get_peers()
11 if len(peers) > 0:
12 for peer in peers:
13 self.pest_reply("%s %s:%s" % (string.join(peer.handles, ","), peer.address, peer.port))
14 else:
15 self.pest_reply("WOT is empty")
16 elif len(arguments) == 1:
17 # Display all WOT data concerning the peer identified by HANDLE,
18 # including all known keys, starting with the most recently used, for that peer.
19 handle = arguments[0]
20 peer = self.server.state.get_peer_by_handle(handle)
21 self.pest_reply("keys:")
22 for key in peer.keys:
23 self.pest_reply("%s" % key)
24 if peer:
25 self.pest_reply("keys:")
26 for key in peer.keys:
27 self.pest_reply("%s" % key)
28 else:
29 self.pest_reply("unknown peer: %s" % handle)
30
31 else:
32 pass
(488 . 7)(495 . 8)
34 try:
35 self.server.state.remove_peer(arguments[0])
36 self.pest_reply("removed peer %s" % arguments[0])
37 except:
38 except Exception, e:
39 self.server.print_debug(e)
40 self.pest_reply("Error attempting to remove peer")
41 else:
42 self.pest_reply("Usage: UNPEER <HANDLE>")
(504 . 6)(512 . 7)
44 key = arguments[1]
45 try:
46 self.server.state.add_key(handle, key)
47 self.pest_reply("added key: %s" % key)
48 except:
49 self.pest_reply("Error attempting to add key")
50
(513 . 8)(522 . 10)
52 else:
53 try:
54 self.server.state.remove_key(arguments[0])
55 except:
56 self.pest_reply("removed key: %s" % arguments[0])
57 except Exception, e:
58 self.pest_reply("Error attempting to remove key")
59 self.server.print_debug(e)
60
61 def at_handler():
62 if len(arguments) == 0:
(528 . 14)(539 . 18)
64 self.server.state.update_address_table({"handle": handle,
65 "address": address_ip,
66 "port": port})
67 self.pest_reply("updated address table: %s %s" % (handle, address))
68 return
69 elif len(arguments) > 2:
70 self.pest_reply("Usage: AT [<HANDLE>] [<ADDRESS>]")
71 return
72 for address in at:
73 self.pest_reply("%s %s %s" % (address["handle"],
74 address["address"],
75 address["updated_at"]))
76 if len(at) > 0:
77 for address in at:
78 self.pest_reply("%s %s %s" % (address["handle"],
79 address["address"],
80 address["updated_at"]))
81 else:
82 self.pest_reply("no results")
83
84 handler_table = {
85 "AWAY": away_handler,
(15 . 7)(15 . 10)
90 self.infosec = Infosec(server)
91
92 def get_key(self):
93 return self.keys[0]
94 if len(self.keys) > 0:
95 return self.keys[0]
96 else:
97 return None
98
99 def send(self, msg):
100 try:
- 016F72E7FD06B003916FCD423F9AB0155A912B421064D440823AA37D96F532E325120A93308278921F984C6BD5D4E8E887124370059C2D295D2F23FD1F7903E8(1 . 4)(1 . 4)- 4F6467D323B0E8CFE531DDEED0B604438BBC15B6FFB050F0DA9BA0509174C6BB42D633C94F1CD46ACBA1FA7B7D2B74B8C5BDD896080C663B8F9C8BF893A174D6
105 VERSION = "9993"
106 VERSION = "9992"
107
108 import os
109 import select
(142 . 47)(142 . 51)
111 del self.channels[irc_lower(channel.name)]
112
113 def handle_udp_data(self, bytes_address_pair):
114 data = bytes_address_pair[0]
115 address = bytes_address_pair[1]
116 for peer in self.state.get_peers():
117 data = bytes_address_pair[0]
118 address = bytes_address_pair[1]
119 message = self.infosec.unpack(peer, data)
120 if(message != None):
121 self.print_debug("valid message from peer: %s" % peer.handles[0])
122
123 # we only update the address table if the speaker is same as peer
124
125 try:
126 idx = peer.handles.index(message["speaker"])
127 except:
128 idx = None
129
130 if idx != None:
131 self.state.update_address_table({"handle": message["speaker"],
132 "address": address[0],
133 "port": address[1]
134 })
135 # send the message to all clients
136 for c in self.clients:
137 # self.clients[c].udp_socket_readable_notification(message)
138 if (self.clients[c].is_addressed_to_me(message["body"])):
139 self.clients[c].message(message["body"])
140 # send the message to all other peers if it should be propagated
141 if(message["command"] == BROADCAST) and message["bounces"] < MAX_BOUNCES:
142 self.rebroadcast(peer, message)
143 return
144 if peer.get_key() != None:
145 message = self.infosec.unpack(peer, data)
146 if(message != None):
147 self.print_debug("valid message from peer: %s" % peer.handles[0])
148
149 # we only update the address table if the speaker is same as peer
150
151 try:
152 idx = peer.handles.index(message["speaker"])
153 except:
154 idx = None
155
156 if idx != None:
157 self.state.update_address_table({"handle": message["speaker"],
158 "address": address[0],
159 "port": address[1]
160 })
161 # send the message to all clients
162 for c in self.clients:
163 # self.clients[c].udp_socket_readable_notification(message)
164 if (self.clients[c].is_addressed_to_me(message["body"])):
165 self.clients[c].message(message["body"])
166 # send the message to all other peers if it should be propagated
167 if(message["command"] == BROADCAST) and message["bounces"] < MAX_BOUNCES:
168 self.rebroadcast(peer, message)
169 return
170 self.print_debug("Unknown peer: %s %d" % (address[0], address[1]))
171
172 def peer_message(self, message):
173 message["original"] = True
174 if message["command"] == DIRECT:
175 peer = self.state.get_peer_by_handle(message["handle"])
176 if peer:
177 if peer and (peer.get_key() != None):
178 peer.send(message)
179 else:
180 self.print_debug("Discarding message to unknown handle: %s" % message["handle"])
181 self.print_debug("Discarding message to unknown handle or handle with no key: %s" % message["handle"])
182 else:
183 for peer in self.state.get_peers():
184 peer.send(message)
185 if peer.get_key() != None:
186 peer.send(message)
187 else:
188 self.print_debug("Discarding message to handle with no key: %s" % message["handle"])
189
190 def rebroadcast(self, source_peer, message):
191 message["original"] = False
(40 . 14)(40 . 15)
196 results = self.cursor.execute("select handle_id,address,port,updated_at from at\
197 order by updated_at desc").fetchall()
198 else:
199 handle_id = self.cursor.execute("select handle_id from handles where handle=?",
200 (handle,)).fetchone()[0]
201 if None != handle_id:
202 results = self.cursor.execute("select handle_id,address,port,updated_at from at \
203 where handle_id=? order by updated_at desc",
204 (handle_id,)).fetchall()
205 result = self.cursor.execute("select handle_id from handles where handle=?",
206 (handle,)).fetchone()
207 if None != result:
208 handle_id = result[0]
209 else:
210 return []
211 results = self.cursor.execute("select handle_id,address,port,updated_at from at \
212 where handle_id=? order by updated_at desc",
213 (handle_id,)).fetchall()
214 for result in results:
215 handle_id, address, port, updated_at = result
216 h = self.cursor.execute("select handle from handles where handle_id=?",
(130 . 10)(131 . 11)
218 def remove_peer(self, handle):
219 # get peer id
220
221 peer_id = self.cursor.execute("select peer_id from handles where handle=?", (handle,)).fetchone()[0]
222 if peer_id == None:
223 return
224 result = self.cursor.execute("select peer_id from handles where handle=?", (handle,)).fetchone()
225 if result == None:
226 return
227 else:
228 peer_id = result[0]
229 # get all aliases
230
231 handle_ids = self.get_handle_ids_for_peer(peer_id)
(174 . 7)(176 . 7)
233
234 for handle in handles:
235 peer = self.get_peer_by_handle(handle[0])
236 if not self.is_duplicate(peers, peer):
237 if not (self.is_duplicate(peers, peer)):
238 peers.append(peer)
239 return peers
240