- 804C596288D04455BA5127CC25937F7AC76CA289F046AD31BD71B66264B9DB73584A8FC1D4535E882D70A0F5FDE10F896DBD3AE51C3FDE4018A3F3E49B55F7F2
+ 622DC40643FD936B33DF0F60BAC3167453DD1684021504C1D7201E07AEA2140B17C4D857CC106DDD6DF9963A8003E84D938696796C5D2001DE2B68DBE5533F23
blatta/lib/client.py
(462 . 16)(462 . 23)
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,