###
### This file is part of Trivial IP Encryption (TrIPE).
###
-### TrIPE is free software; you can redistribute it and/or modify
-### it under the terms of the GNU General Public License as published by
-### the Free Software Foundation; either version 2 of the License, or
-### (at your option) any later version.
+### TrIPE is free software: you can redistribute it and/or modify it under
+### the terms of the GNU General Public License as published by the Free
+### Software Foundation; either version 3 of the License, or (at your
+### option) any later version.
###
-### TrIPE is distributed in the hope that it will be useful,
-### but WITHOUT ANY WARRANTY; without even the implied warranty of
-### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-### GNU General Public License for more details.
+### TrIPE is distributed in the hope that it will be useful, but WITHOUT
+### ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+### FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+### for more details.
###
### You should have received a copy of the GNU General Public License
-### along with TrIPE; if not, write to the Free Software Foundation,
-### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+### along with TrIPE. If not, see <https://www.gnu.org/licenses/>.
VERSION = '@VERSION@'
def kill(me, peername):
"""Remove PEER from the peers being watched by the Pinger."""
- del me._peers[peername]
+ try: del me._peers[peername]
+ except KeyError: pass
return me
def rescan(me, startup):
"""
return me._peers.keys()
+ def find(me, name):
+ """Return the PingPeer with the given name."""
+ return me._peers[name]
+
###--------------------------------------------------------------------------
### New connections.
"""
kick NAME: Force a new connection attempt for the NAMEd peer.
"""
- if name not in pinger.adopted():
- raise T.TripeJobError('peer-not-adopted', name)
+ try: pp = pinger.find(name)
+ except KeyError: raise T.TripeJobError('peer-not-adopted', name)
try: peer = Peer(name)
except KeyError: raise T.TripeJobError('unknown-peer', name)
- T.spawn(run_connect, peer, peer.get('connect'))
+ conn = peer.get('connect', None)
+ if conn: T.spawn(run_connect, peer, peer.get('connect'))
+ else: T.spawn(lambda p: S.forcekx(p.name), peer)
def cmd_adopted():
"""