def handleCmd_ADDPEER(self, out, args, prefix): if len(args) == 1: try: ad = Ad().setTextIPPort(args[0]) except ValueError: pass else: if not ad.port: out("Port number must be nonzero.") elif ad.auth('sx', self.main): self.main.state.refreshPeer(ad, 0) out("Added to peer cache: %s" % ad.getTextIPPort()) # Jump-start stuff if it's not already going self.main.startConnecting() else: out("The address '%s' is not permitted on this network." % ad.getTextIPPort()) return self.syntaxHelp(out, 'ADDPEER', prefix)
def handleCmd_INVITE(self, out, args, prefix): if len(args) == 0: osm = self.main.osm if osm: ad = Ad().setRawIPPort(osm.me.ipp) extra_msg = "" else: # If I don't know my own IP, at least fill in a dummy one. ad = Ad().setAddrTuple(("0.0.0.0", self.main.state.udp_port)) extra_msg = " (replace 0.0.0.0 with your real IP address)" out("Tell your friend to enter the following into their client " "to join the network%s:" % extra_msg) out("") out(" !addpeer %s" % ad.getTextIPPort()) out("") return self.syntaxHelp(out, 'INVITE', prefix)
def pushSearchRequest(self, ipp, search_string): ad = Ad().setRawIPPort(ipp) self.sendLine("$Search %s %s" % (ad.getTextIPPort(), search_string))