summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorjwijenbergh <jeroenwijenbergh@protonmail.com>2024-03-06 19:56:49 +0100
committerjwijenbergh <jeroenwijenbergh@protonmail.com>2024-03-06 19:57:18 +0100
commit2388cfa0b517e1ef3e05e278ffcd6d6db981381b (patch)
tree7c2ec316cbc64c701b707cee4d5ec45fa6dfe3d4 /client
parenta2f9a000e635876126ab41a7969973a8f03a109a (diff)
Client + Exports + Wrappers: Add peer IPs argument to fd callback
And rename the callback to be closer to what it does
Diffstat (limited to 'client')
-rw-r--r--client/proxy.go20
1 files changed, 14 insertions, 6 deletions
diff --git a/client/proxy.go b/client/proxy.go
index 4f87a3f..2f05f8a 100644
--- a/client/proxy.go
+++ b/client/proxy.go
@@ -1,7 +1,10 @@
package client
import (
+ "encoding/json"
+
"codeberg.org/eduVPN/proxyguard"
+
"github.com/eduvpn/eduvpn-common/i18nerr"
"github.com/eduvpn/eduvpn-common/internal/log"
"github.com/eduvpn/eduvpn-common/types/cookie"
@@ -21,18 +24,23 @@ func (pl *ProxyLogger) Log(msg string) {
}
// StartProxyguard starts proxyguard for proxied WireGuard connections
-func (c *Client) StartProxyguard(ck *cookie.Cookie, listen string, tcpsp int, peer string, gotFD func(fd int), ready func()) error {
+func (c *Client) StartProxyguard(ck *cookie.Cookie, listen string, tcpsp int, peer string, gotFD func(fd int, pips string), ready func()) error {
var err error
proxyguard.UpdateLogger(&ProxyLogger{})
proxyc := proxyguard.Client{
- Listen: listen,
+ Listen: listen,
TCPSourcePort: tcpsp,
- SetupSocket: func(fd int, _ []string) {
- if gotFD != nil {
- gotFD(fd)
+ SetupSocket: func(fd int, pips []string) {
+ if gotFD == nil {
+ return
+ }
+ b, err := json.Marshal(pips)
+ if err != nil {
+ log.Logger.Errorf("marshalling peer IPs failed: %v", err)
+ return
}
- // TODO: support peerips
+ gotFD(fd, string(b))
},
Ready: ready,
}