if self.queen_connector:
return
if not self.queen_pburl:
- log.msg("no queen_pburl, cannot connect")
+ self.log("no queen_pburl, cannot connect")
return
self.queen_connector = self.tub.connectTo(self.queen_pburl,
self._got_queen)
return service.MultiService.stopService(self)
def _got_queen(self, queen):
- log.msg("connected to queen")
+ self.log("connected to queen")
self.queen = queen
queen.notifyOnDisconnect(self._lost_queen)
queen.callRemote("hello",
nodeid=self.nodeid, node=self, pburl=self.my_pburl)
def _lost_queen(self):
- log.msg("lost connection to queen")
+ self.log("lost connection to queen")
self.queen = None
def remote_get_service(self, name):
for nodeid, pburl in new_peers:
if nodeid == self.nodeid:
continue
- log.msg("adding peer %s" % idlib.b2a(nodeid))
+ self.log("adding peer %s" % idlib.b2a(nodeid))
if nodeid in self.all_peers:
log.msg("weird, I already had an entry for them")
self.all_peers.add(nodeid)
if nodeid not in self.connections:
d = self.tub.getReference(pburl)
def _got_reference(ref):
- log.msg("connected to %s" % idlib.b2a(nodeid))
+ self.log("connected to %s" % idlib.b2a(nodeid))
if nodeid in self.all_peers:
self.connections[nodeid] = ref
d.addCallback(_got_reference)
def remote_lost_peers(self, lost_peers):
for nodeid in lost_peers:
- log.msg("lost peer %s" % idlib.b2a(nodeid))
+ self.log("lost peer %s" % idlib.b2a(nodeid))
if nodeid in self.all_peers:
self.all_peers.remove(nodeid)
else:
- log.msg("weird, I didn't have an entry for them")
+ self.log("weird, I didn't have an entry for them")
if nodeid in self.connections:
del self.connections[nodeid]
f.write(self.tub.getCertData())
f.close()
self.nodeid = idlib.a2b(self.tub.tubID)
+ self.short_nodeid = self.tub.tubID[:4] # ready for printing
portnum = 0
assert self.PORTNUMFILE, "Your node.Node subclass must provide PORTNUMFILE"
self._portnumfile = os.path.join(self.basedir, self.PORTNUMFILE)
from allmydata import manhole
m = manhole.AuthorizedKeysManhole(portnum, keyfile)
m.setServiceParent(self)
- log.msg("AuthorizedKeysManhole listening on %d" % portnum)
+ self.log("AuthorizedKeysManhole listening on %d" % portnum)
+
+ def log(self, msg):
+ log.msg(self.short_nodeid + ": " + msg)
def _setup_tub(self, local_ip):
# we can't get a dynamically-assigned portnum until our Tub is
local_ip = get_local_ip_for()
self._setup_tub(local_ip)
self.tub_ready()
- log.msg("%s running" % self.NODETYPE)
+ self.log("%s running" % self.NODETYPE)
new_peers=[(new_nodeid, new_node_pburl)])
def _lost_node(self, nodeid):
- log.msg("lost contact with %s" % idlib.b2a(nodeid))
+ log.msg("roster: lost contact with %s" % idlib.b2a(nodeid))
del self.phonebook[nodeid]
del self.connections[nodeid]
eventually(self._announce_lost_peer, nodeid)
def tub_ready(self):
r = self.add_service(Roster())
self.urls["roster"] = self.tub.registerReference(r, "roster")
- log.msg(" roster is at %s" % self.urls["roster"])
+ self.log(" roster is at %s" % self.urls["roster"])
f = open(os.path.join(self.basedir, "roster_pburl"), "w")
f.write(self.urls["roster"] + "\n")
f.close()