X-Git-Url: https://git.distorted.org.uk/~mdw/tripe/blobdiff_plain/89640f3f83c29967e524d754bf130bc452bdefe2..47828bd9813b146e8569355b3083847299dd8729:/mon/tripemon.in diff --git a/mon/tripemon.in b/mon/tripemon.in index 593b2e8b..1c70d1ff 100644 --- a/mon/tripemon.in +++ b/mon/tripemon.in @@ -323,13 +323,17 @@ class Peer (MonitorObject): def _setaddr(me, addr): """Set the peer's address.""" - if addr[0] == 'INET': + if addr[0] in ['INET', 'INET6']: af, ipaddr, port = addr try: name, _ = S.getnameinfo((ipaddr, int(port)), S.NI_NUMERICSERV | S.NI_NAMEREQD) except S.gaierror: - me.addr = '%s %s:%s' % (af, ipaddr, port) + me.addr = '%s %s%s%s:%s' % (af, + af == 'INET6' and '[' or '', + ipaddr, + af == 'INET6' and ']' or '', + port) else: me.addr = '%s %s:%s [%s]' % (af, name, port, ipaddr) else: @@ -1044,6 +1048,8 @@ class AddPeerDialog (MyDialog): * e_name, e_addr, e_port, c_keepalive, l_tunnel: widgets in the dialog """ + AFS = ['ANY', 'INET', 'INET6'] + def __init__(me): """Initialize the dialogue.""" MyDialog.__init__(me, 'Add peer', @@ -1059,8 +1065,13 @@ class AddPeerDialog (MyDialog): me.e_name = table.labelled('Name', ValidatingEntry(r'^[^\s.:]+$', '', 16), width = 3) + me.l_af = table.labelled('Family', combo_box_text(), + newlinep = True, width = 3) + for af in me.AFS: + me.l_af.append_text(af) + me.l_af.set_active(0) me.e_addr = table.labelled('Address', - ValidatingEntry(r'^[a-zA-Z0-9.-]+$', '', 24), + ValidatingEntry(r'^[a-zA-Z0-9.-:]+$', '', 24), newlinep = True) me.e_port = table.labelled('Port', ValidatingEntry(numericvalidate(0, 65535), @@ -1106,7 +1117,9 @@ class AddPeerDialog (MyDialog): """Handle an OK press: create the peer.""" try: t = me.l_tunnel.get_active() + afix = me.l_af.get_active() me._addpeer(me.e_name.get_text(), + me.AFS[afix], me.e_addr.get_text(), me.e_port.get_text(), keepalive = (me.c_keepalive.get_active() and