chiark / gitweb /
mon/tripemon.in: Add a `default' tunnel entry to the `Add peer' box.
[tripe] / mon / tripemon.in
index 96cf9cc2d7e07189479402d727db4b4c51632214..f5b8f8d60ff018a358a69fb66fe9a6dc0c43229f 100644 (file)
 ###
 ### 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/>.
 
 ###--------------------------------------------------------------------------
 ### Dependencies.
@@ -312,6 +311,7 @@ class Peer (MonitorObject):
     """Initialize the object with the given name."""
     MonitorObject.__init__(me, name)
     me.pinghook = HookList()
+    me.__dict__.update(conn.algs(name))
     me.update()
 
   def update(me, hunoz = None):
@@ -790,19 +790,19 @@ def numericvalidate(min = None, max = None):
 ###--------------------------------------------------------------------------
 ### Various minor dialog boxen.
 
-GPL = """This program 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.
+GPL = """\
+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.
 
-This program 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 this program; 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/>."""
 
 class AboutBox (G.AboutDialog, TrivialWindowMixin):
   """The program `About' box."""
@@ -1064,48 +1064,71 @@ class AddPeerDialog (MyDialog):
                                ValidatingEntry(numericvalidate(0, 65535),
                                                '4070',
                                                5))
-    me.c_keepalive = G.CheckButton('Keepalives')
     me.l_tunnel = table.labelled('Tunnel', combo_box_text(),
                                  newlinep = True, width = 3)
-    me.tuns = conn.tunnels()
+    me.tuns = ['(Default)'] + conn.tunnels()
     for t in me.tuns:
       me.l_tunnel.append_text(t)
     me.l_tunnel.set_active(0)
+
+    def tickybox_sensitivity(tickybox, target):
+      tickybox.connect('toggled',
+                       lambda t: target.set_sensitive (t.get_active()))
+
+    me.c_keepalive = G.CheckButton('Keepalives')
     table.pack(me.c_keepalive, newlinep = True, xopt = G.FILL)
-    me.c_keepalive.connect('toggled',
-                           lambda t: me.e_keepalive.set_sensitive\
-                                      (t.get_active()))
     me.e_keepalive = ValidatingEntry(r'^\d+[hms]?$', '', 5)
     me.e_keepalive.set_sensitive(False)
+    tickybox_sensitivity(me.c_keepalive, me.e_keepalive)
     table.pack(me.e_keepalive, width = 3)
+
+    me.c_cork = G.CheckButton('Cork')
+    table.pack(me.c_cork, newlinep = True, width = 4, xopt = G.FILL)
+
+    me.c_mobile = G.CheckButton('Mobile')
+    table.pack(me.c_mobile, newlinep = True, width = 4, xopt = G.FILL)
+
+    me.c_peerkey = G.CheckButton('Peer key tag')
+    table.pack(me.c_peerkey, newlinep = True, xopt = G.FILL)
+    me.e_peerkey = ValidatingEntry(r'^[^.:\s]+$', '', 16)
+    me.e_peerkey.set_sensitive(False)
+    tickybox_sensitivity(me.c_peerkey, me.e_peerkey)
+    table.pack(me.e_peerkey, width = 3)
+
+    me.c_privkey = G.CheckButton('Private key tag')
+    table.pack(me.c_privkey, newlinep = True, xopt = G.FILL)
+    me.e_privkey = ValidatingEntry(r'^[^.:\s]+$', '', 16)
+    me.e_privkey.set_sensitive(False)
+    tickybox_sensitivity(me.c_privkey, me.e_privkey)
+    table.pack(me.e_privkey, width = 3)
+
     me.show_all()
 
   def ok(me):
     """Handle an OK press: create the peer."""
     try:
-      if me.c_keepalive.get_active():
-        ka = me.e_keepalive.get_text()
-      else:
-        ka = None
       t = me.l_tunnel.get_active()
-      if t == 0:
-        tun = None
-      else:
-        tun = me.tuns[t]
-        me._addpeer(me.e_name.get_text(),
-                    me.e_addr.get_text(),
-                    me.e_port.get_text(),
-                    ka,
-                    tun)
+      me._addpeer(me.e_name.get_text(),
+                  me.e_addr.get_text(),
+                  me.e_port.get_text(),
+                  keepalive = (me.c_keepalive.get_active() and
+                               me.e_keepalive.get_text() or None),
+                  tunnel = t and me.tuns[t] or None,
+                  cork = me.c_cork.get_active() or None,
+                  mobile = me.c_mobile.get_active() or None,
+                  key = (me.c_peerkey.get_active() and
+                         me.e_peerkey.get_text() or None),
+                  priv = (me.c_privkey.get_active() and
+                          me.e_privkey.get_text() or None))
     except ValidationError:
       GDK.beep()
       return
 
   @incr
-  def _addpeer(me, name, addr, port, keepalive, tunnel):
+  def _addpeer(me, *args, **kw):
     """Coroutine function: actually do the ADD command."""
     try:
-      conn.add(name, addr, port, keepalive = keepalive, tunnel = tunnel)
+      conn.add(*args, **kw)
       me.destroy()
     except T.TripeError, exc:
       T.defer(moanbox, ' '.join(exc))
@@ -1238,6 +1261,15 @@ statsxlate = \
 ## the entry.
 statslayout = \
   [('Start time', '%(start-time)s'),
+   ('Private key', '%(current-key)s'),
+   ('Diffie-Hellman group',
+    '%(kx-group)s '
+    '(%(kx-group-order-bits)s-bit order, '
+    '%(kx-group-elt-bits)s-bit elements)'),
+   ('Cipher',
+    '%(cipher)s (%(cipher-keysz)s-bit key, %(cipher-blksz)s-bit block)'),
+   ('Mac', '%(mac)s (%(mac-keysz)s-bit key, %(mac-tagsz)s-bit tag)'),
+   ('Hash', '%(hash)s (%(hash-sz)s-bit output)'),
    ('Last key-exchange', '%(last-keyexch-time)s'),
    ('Last packet', '%(last-packet-time)s'),
    ('Packets in/out',
@@ -1325,6 +1357,7 @@ class PeerWindow (TrivialWindow):
       stat = conn.stats(me.peer.name)
       for s, trans in statsxlate:
         stat[s] = trans(stat[s])
+      stat.update(me.peer.__dict__)
       for label, format in statslayout:
         me.e[label].set_text(format % stat)
       GL.timeout_add(1000, lambda: me.cr.switch() and False)