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 | |
| 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')
| -rw-r--r-- | internal/api/api.go | 6 | ||||
| -rw-r--r-- | internal/wireguard/wireguard.go | 18 |
2 files changed, 12 insertions, 12 deletions
diff --git a/internal/api/api.go b/internal/api/api.go index 2268357..b5c56d8 100644 --- a/internal/api/api.go +++ b/internal/api/api.go @@ -221,8 +221,8 @@ func protocolFromCT(ct string) (protocol.Protocol, error) { switch ct { case "application/x-wireguard-profile": return protocol.WireGuard, nil - case "application/x-wireguard+tcp-profile": - return protocol.WireGuardTCP, nil + case "application/x-wireguard+proxy-profile": + return protocol.WireGuardProxy, nil case "application/x-openvpn-profile": return protocol.OpenVPN, nil } @@ -301,7 +301,7 @@ func (a *API) Connect(ctx context.Context, prof profiles.Profile, protos []proto }, nil } - vpnCfg, proxy, err := wireguard.Config(vpnCfg, wgKey, proto == protocol.WireGuardTCP) + vpnCfg, proxy, err := wireguard.Config(vpnCfg, wgKey, proto == protocol.WireGuardProxy) if err != nil { return nil, err } 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 } |
