diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2024-02-12 19:45:27 +0100 |
|---|---|---|
| committer | Jeroen Wijenbergh <46386452+jwijenbergh@users.noreply.github.com> | 2024-02-19 14:15:07 +0100 |
| commit | 9c848e6cbb3ee5881fd4d894608d8556b2201084 (patch) | |
| tree | 25446e008e860deb2d46dda1ab98d24c15fad7e6 /internal/wireguard | |
| parent | 74e36f0ead717105f26087c2cab08b41ba5a7ce8 (diff) | |
WireGuard: Latest proxyguard server API changes
wireguard+proxy profile and ProxyEndpoint instead of TCPEndpoint as
proxyguard now uses HTTP for the initial packet
Diffstat (limited to 'internal/wireguard')
| -rw-r--r-- | internal/wireguard/wireguard.go | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/internal/wireguard/wireguard.go b/internal/wireguard/wireguard.go index e94a485..a70f21a 100644 --- a/internal/wireguard/wireguard.go +++ b/internal/wireguard/wireguard.go @@ -46,18 +46,18 @@ type Proxy struct { Peer string } -// Config gets a wireguard config with API config `cfg`, wg key `key` and prefer tcp `tcp` -func Config(cfg string, key *wgtypes.Key, tcp bool) (string, *Proxy, error) { +// Config gets a wireguard config with API config `cfg`, wg key `key` and whether to use proxyguard `proxy` +func Config(cfg string, key *wgtypes.Key, proxy bool) (string, *Proxy, error) { // the key is nil if the client does not accept WireGuard if key == nil { return "", nil, errors.New("the server sent us a WireGuard profile but the client does not accept WireGuard") } var tcpp int - var proxy string + var plisten string var err error - if tcp { + if proxy { tcpp, err = availableTCPPort() if err != nil { return "", nil, err @@ -66,18 +66,18 @@ func Config(cfg string, key *wgtypes.Key, tcp bool) (string, *Proxy, error) { if err != nil { return "", nil, err } - proxy = fmt.Sprintf("127.0.0.1:%d", udpp) + plisten = fmt.Sprintf("127.0.0.1:%d", udpp) } - rcfg, peer, err := configReplace(cfg, *key, proxy) + rcfg, peer, err := configReplace(cfg, *key, plisten) if err != nil { return "", nil, err } var retP *Proxy - if tcp { + if proxy { retP = &Proxy{ SourcePort: tcpp, - Listen: proxy, + Listen: plisten, Peer: peer, } } @@ -105,7 +105,7 @@ func configReplace(cfg string, key wgtypes.Key, proxy string) (string, string, e if err != nil { return "", "", err } - peer, err = ps.RemoveKey("TCPEndpoint") + peer, err = ps.RemoveKey("ProxyEndpoint") if err != nil { return "", "", err } |
