From b9ada6c046d776da21900aa28cb9b4f09874cbf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Otto=20Kr=C3=B6pke?= Date: Sat, 7 Oct 2023 23:56:51 +0200 Subject: [PATCH] small nits MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jan-Otto Kröpke --- internal/openvpn/client.go | 6 ++++-- internal/openvpn/connection/client.go | 2 +- tests/docker-compose.yaml | 12 ++++++------ 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/internal/openvpn/client.go b/internal/openvpn/client.go index 1b780a06..ba4c658b 100644 --- a/internal/openvpn/client.go +++ b/internal/openvpn/client.go @@ -31,6 +31,8 @@ func (c *Client) processClient(client connection.Client) error { } func (c *Client) clientConnect(client connection.Client) error { + var err error + logger := c.logger.With( slog.Uint64("cid", client.Cid), slog.Uint64("kid", client.Kid), @@ -51,7 +53,7 @@ func (c *Client) clientConnect(client connection.Client) error { } session := state.New(ClientIdentifier, client.IPAddr, client.CommonName) - if err := session.Encode(c.conf.HTTP.Secret); err != nil { + if err = session.Encode(c.conf.HTTP.Secret); err != nil { return fmt.Errorf("error encoding state: %w", err) } @@ -62,7 +64,7 @@ func (c *Client) clientConnect(client connection.Client) error { logger.Info("start pending auth") - _, err := c.SendCommandf(`client-pending-auth %d %d "WEB_AUTH::%s" %.0f`, client.Cid, client.Kid, startURL, c.conf.OpenVpn.AuthPendingTimeout.Seconds()) + _, err = c.SendCommandf(`client-pending-auth %d %d "WEB_AUTH::%s" %.0f`, client.Cid, client.Kid, startURL, c.conf.OpenVpn.AuthPendingTimeout.Seconds()) if err != nil { logger.Warn(err.Error()) } diff --git a/internal/openvpn/connection/client.go b/internal/openvpn/connection/client.go index 3e416f8f..99064b01 100644 --- a/internal/openvpn/connection/client.go +++ b/internal/openvpn/connection/client.go @@ -30,7 +30,7 @@ func NewClient(message string) (Client, error) { //nolint:cyclop } else if strings.HasPrefix(line, ">CLIENT:ENV,") { envKey, envValue := parseClientEnv(line) if envKey == "" || envValue == "" { - break + continue } switch envKey { diff --git a/tests/docker-compose.yaml b/tests/docker-compose.yaml index 85f1eca6..2c10c6ad 100644 --- a/tests/docker-compose.yaml +++ b/tests/docker-compose.yaml @@ -14,7 +14,7 @@ services: - "0.0.0.0:1194:1194/udp" - "8080:8080/tcp" - "8081:8081/tcp" - - "9000:9000/tcp" + - "9001:9001/tcp" volumes: - ./:/tests/:ro - ./data:/etc/openvpn @@ -71,15 +71,15 @@ services: fast-io user nobody group nogroup - auth-gen-token 240 120 + #auth-gen-token 240 120 management 0.0.0.0 8081 /etc/openvpn/password.txt - #management-hold - #management-client-auth + management-hold + management-client-auth - plugin /plugin/openvpn-auth-oauth2.so /plugin/config.yaml + #plugin /plugin/openvpn-auth-oauth2.so /plugin/config.yaml - reneg-sec 60 + reneg-sec 30 auth-user-pass-optional EOF