Verified Commit e2009fa4 authored by Martin Matějek's avatar Martin Matějek
Browse files

wip: refactor protocol handling

parent 1fc4012a
Pipeline #72991 passed with stage
in 1 minute and 21 seconds
......@@ -490,6 +490,18 @@ verb 3
BASE_CERT_PATH = "/etc/ssl/ca/openvpn"
PROTOCOLS_MAP = {
"tcp": "tcp",
"udp": "udp",
"tcp-server": "tcp-client",
"tcp4": "tcp",
"udp4": "udp",
"tcp4-server": "tcp-client",
"tcp6": "tcp",
"udp6": "udp",
"tcp6-server": "tcp-client",
}
def get_config(self, id, hostname, dev, proto, port, compress, cipher, tls_auth_path, ca_path):
ca = self._file_content(ca_path)
cert = self._file_content(os.path.join(self.BASE_CERT_PATH, "%s.crt" % id))
......@@ -513,7 +525,7 @@ verb 3
compress = "compress %s" % compress if compress else ""
# convert proto
proto = proto[:3] + ("-client" if "server" in proto else "")
proto = self.PROTOCOLS_MAP.get(proto, "udp")
return self.CONFIG_TEMPLATE % dict(
dev=dev,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment