From 9b540745d7ce7b5860de2c4ea9946ffb239e2446 Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Thu, 5 Jan 2017 22:01:28 +0100 Subject: [PATCH] (tinc) add some options for https://github.com/opnsense/plugins/issues/61 --- .../OPNsense/Tinc/forms/dialogHost.xml | 6 ++++ .../OPNsense/Tinc/forms/dialogNetwork.xml | 20 ++++++++++++ .../mvc/app/models/OPNsense/Tinc/Tinc.xml | 31 +++++++++++++++---- .../scripts/OPNsense/Tinc/lib/objects.py | 5 ++- .../templates/OPNsense/Tinc/tinc_deploy.xml | 6 +++- 5 files changed, 60 insertions(+), 8 deletions(-) diff --git a/security/tinc/src/opnsense/mvc/app/controllers/OPNsense/Tinc/forms/dialogHost.xml b/security/tinc/src/opnsense/mvc/app/controllers/OPNsense/Tinc/forms/dialogHost.xml index 9e991a432..aedfb2f5a 100644 --- a/security/tinc/src/opnsense/mvc/app/controllers/OPNsense/Tinc/forms/dialogHost.xml +++ b/security/tinc/src/opnsense/mvc/app/controllers/OPNsense/Tinc/forms/dialogHost.xml @@ -23,6 +23,12 @@ text This machines external address to use + + host.extport + + text + This machines external port to use + host.subnet diff --git a/security/tinc/src/opnsense/mvc/app/controllers/OPNsense/Tinc/forms/dialogNetwork.xml b/security/tinc/src/opnsense/mvc/app/controllers/OPNsense/Tinc/forms/dialogNetwork.xml index e43e7ffea..99f48f02f 100644 --- a/security/tinc/src/opnsense/mvc/app/controllers/OPNsense/Tinc/forms/dialogNetwork.xml +++ b/security/tinc/src/opnsense/mvc/app/controllers/OPNsense/Tinc/forms/dialogNetwork.xml @@ -17,6 +17,14 @@ text This machines internal address to use and network mask for the whole network + + network.pingtimeout + + text + The number of seconds to wait for a response to pings or to allow meta connections to block. + If the other end doesn't respond within this time, the connection is terminated, and the others will be notified of this. + + network.cipher @@ -49,6 +57,18 @@ text This machines external address to use + + network.extport + + text + This machines external port to use + + + network.subnet + + text + This machines part of the network + network.subnet diff --git a/security/tinc/src/opnsense/mvc/app/models/OPNsense/Tinc/Tinc.xml b/security/tinc/src/opnsense/mvc/app/models/OPNsense/Tinc/Tinc.xml index 633f34499..466f37b62 100644 --- a/security/tinc/src/opnsense/mvc/app/models/OPNsense/Tinc/Tinc.xml +++ b/security/tinc/src/opnsense/mvc/app/models/OPNsense/Tinc/Tinc.xml @@ -21,11 +21,17 @@ /^([0-9a-zA-Z\_]){1,1024}$/u Please specify a valid hostname. - + Y - N - , + /^([0-9a-zA-Z\.,_\-:]){0,1024}$/u + + Y + 655 + 1 + 65535 + Port number must be between 1...65535 + Y N @@ -36,6 +42,13 @@ Y , + + Y + 5 + 1 + 65535 + Ping timeout must be between 1...65535 + Y @@ -86,10 +99,16 @@ /^([0-9a-zA-Z\_]){1,1024}$/u Please specify a valid hostname. - + Y - N - , + 655 + 1 + 65535 + Port number must be between 1...65535 + + + Y + /^([0-9a-zA-Z\.,_\-:]){0,1024}$/u Y diff --git a/security/tinc/src/opnsense/scripts/OPNsense/Tinc/lib/objects.py b/security/tinc/src/opnsense/scripts/OPNsense/Tinc/lib/objects.py index 299f00911..55c6e34d6 100644 --- a/security/tinc/src/opnsense/scripts/OPNsense/Tinc/lib/objects.py +++ b/security/tinc/src/opnsense/scripts/OPNsense/Tinc/lib/objects.py @@ -31,6 +31,7 @@ class NetwConfObject(object): self._payload['hostname'] = None self._payload['network'] = None self._payload['address'] = None + self._payload['port'] = None def is_valid(self): for key in self._payload: @@ -85,6 +86,8 @@ class Network(NetwConfObject): def config_text(self): result = list() result.append('AddressFamily=any') + result.append('Port=%(port)s' % self._payload) + result.append('PingTimeout=%(pingtimeout)s' % self._payload) for host in self._hosts: if host.connect_to_this_host(): result.append('ConnectTo = %s' % (host.get_hostname(),)) @@ -122,7 +125,7 @@ class Host(NetwConfObject): def config_text(self): result = list() - result.append('Address=%(address)s'%self._payload) + result.append('Address=%(address)s %(port)s'%self._payload) result.append('Subnet=%(subnet)s'%self._payload) result.append('Cipher=%(cipher)s'%self._payload) result.append('Digest=sha256') diff --git a/security/tinc/src/opnsense/service/templates/OPNsense/Tinc/tinc_deploy.xml b/security/tinc/src/opnsense/service/templates/OPNsense/Tinc/tinc_deploy.xml index d2a1a1050..0d7687207 100644 --- a/security/tinc/src/opnsense/service/templates/OPNsense/Tinc/tinc_deploy.xml +++ b/security/tinc/src/opnsense/service/templates/OPNsense/Tinc/tinc_deploy.xml @@ -9,12 +9,15 @@ {{network.intaddress}}
{{network.intaddress}}
+ {{network.extport}} {{network.debuglevel}} + {{network.pingtimeout}} {{network.hostname}} {{network.name}}
{{network.extaddress}}
+ {{network.extport}} {{network.subnet}} {{network.cipher}} @@ -26,6 +29,7 @@ {{host.hostname}} {{network.name}}
{{host.extaddress}}
+ {{network.extport}} {{host.subnet}} {{host.cipher}} @@ -38,4 +42,4 @@ {% endif %} {% endfor %} {% endif %} - \ No newline at end of file +