summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjwijenbergh <jeroenwijenbergh@protonmail.com>2024-02-22 16:21:40 +0100
committerJeroen Wijenbergh <46386452+jwijenbergh@users.noreply.github.com>2024-02-23 10:40:50 +0100
commitbec31179c24e6e4151e9657e49b4fb64575a8de0 (patch)
tree6e4099d7d37de109f7aa86e57a5c3ab7b5d6c66d
parenteb0c7e7251a0038963436dcd77e6d92311f0bf8f (diff)
Proxy: Only call ready when client is not connected
-rw-r--r--client/proxy.go11
-rw-r--r--exports/exports.go2
2 files changed, 11 insertions, 2 deletions
diff --git a/client/proxy.go b/client/proxy.go
index 31a17a6..721dcac 100644
--- a/client/proxy.go
+++ b/client/proxy.go
@@ -28,7 +28,16 @@ func (c *Client) StartProxyguard(ck *cookie.Cookie, listen string, tcpsp int, pe
var err error
proxyguard.UpdateLogger(&ProxyLogger{})
proxyguard.GotClientFD = gotFD
- proxyguard.ClientProxyReady = ready
+ proxyguard.ClientProxyReady = func() {
+ // already connected
+ // no need to signal to the client that the proxy is ready
+ if c.InState(StateConnected) {
+ log.Logger.Debugf("proxyguard is ready again when the client was already connected")
+ return
+ }
+ log.Logger.Debugf("forwarding proxyguard ready callback to client")
+ ready()
+ }
u, err := url.Parse(peer)
if err != nil {
diff --git a/exports/exports.go b/exports/exports.go
index b5f9042..61c58d2 100644
--- a/exports/exports.go
+++ b/exports/exports.go
@@ -912,7 +912,7 @@ func StartFailover(c C.uintptr_t, gateway *C.char, mtu C.int, readRxBytes C.Read
// - `peer` is the ip:port of the remote server
// - `proxyFD` is a callback with the file descriptor as only argument. It can be used to set certain
// socket option, e.g. to exclude the proxy connection from going over the VPN
-// - `proxyReady` is a callback when the proxy is ready to be used
+// - `proxyReady` is a callback when the proxy is ready to be used. This is only called when the client is not connected yet. Use this to determine when the actual wireguard connection can be started
//
// If the proxy cannot be started it returns an error
//