~fkooman/vpn-user-portal

d24d9696ae57a0ae65d8562f8175d333da33d71c — François Kooman 3 months ago ca2937b
expose `TCPEndpoint` option as a comment in WireGuard config

in case a TCP proxy is available on the VPN server for WireGuard
connections it is advertised in the configuration file as
`#TCPEndpoint`. The endpoint can be used with ProxyGuard
2 files changed, 18 insertions(+), 0 deletions(-)

M src/Cfg/WireGuardConfig.php
M src/WireGuard/ClientConfig.php
M src/Cfg/WireGuardConfig.php => src/Cfg/WireGuardConfig.php +10 -0
@@ 31,4 31,14 @@ class WireGuardConfig
    {
        return $this->requireInt('listenPort', 51820);
    }

    public function tcpProxy(): bool
    {
        return $this->requireBool('tcpProxy', false);
    }

    public function tcpListenPort(): int
    {
        return $this->requireInt('tcpListenPort', $this->listenPort());
    }
}

M src/WireGuard/ClientConfig.php => src/WireGuard/ClientConfig.php +8 -0
@@ 110,6 110,14 @@ class ClientConfig implements ClientConfigInterface
        }
        $output[] = 'Endpoint = ' . $this->profileConfig->hostName($this->nodeNumber) . ':' . (string) $this->wgConfig->listenPort();

        // TCP Proxy
        if ($this->wgConfig->tcpProxy()) {
            // TCPEndpoint is a proprietary eduVPN/Let's Connect! configuration
            // field that instructs the VPN client it is possible to connect
            // over TCP to the server
            $output[] = sprintf('#TCPEndpoint = %s:%d', $this->profileConfig->hostName($this->nodeNumber), $this->wgConfig->tcpListenPort());
        }

        return implode("\n", $output);
    }