diff --git a/client/internal/peer/conn.go b/client/internal/peer/conn.go index 5f250bdf0..f725f61d0 100644 --- a/client/internal/peer/conn.go +++ b/client/internal/peer/conn.go @@ -149,7 +149,7 @@ func (conn *Conn) reCreateAgent() error { MulticastDNSMode: ice.MulticastDNSModeDisabled, NetworkTypes: []ice.NetworkType{ice.NetworkTypeUDP4, ice.NetworkTypeUDP6}, Urls: conn.config.StunTurn, - CandidateTypes: []ice.CandidateType{ice.CandidateTypeHost, ice.CandidateTypeServerReflexive}, + CandidateTypes: []ice.CandidateType{ice.CandidateTypeHost, ice.CandidateTypeServerReflexive, ice.CandidateTypeRelay}, FailedTimeout: &failedTimeout, InterfaceFilter: stdnet.InterfaceFilter(conn.config.InterfaceBlackList), UDPMux: conn.config.UDPMux, @@ -395,7 +395,7 @@ func (conn *Conn) startProxy(remoteConn net.Conn, remoteWgPort int) error { } func (conn *Conn) getProxyWithMessageExchange(pair *ice.CandidatePair, remoteWgPort int) proxy.Proxy { - return proxy.NewWireguardProxy(conn.config.ProxyConfig) + return proxy.NewWireGuardProxy(conn.config.ProxyConfig) useProxy := shouldUseProxy(pair) localDirectMode := !useProxy remoteDirectMode := localDirectMode @@ -412,7 +412,7 @@ func (conn *Conn) getProxyWithMessageExchange(pair *ice.CandidatePair, remoteWgP } log.Debugf("falling back to local proxy mode with peer %s", conn.config.Key) - return proxy.NewWireguardProxy(conn.config.ProxyConfig) + return proxy.NewWireGuardProxy(conn.config.ProxyConfig) } func (conn *Conn) sendLocalDirectMode(localMode bool) { diff --git a/client/internal/proxy/noproxy.go b/client/internal/proxy/noproxy.go index 361ab68bb..1ad5c79de 100644 --- a/client/internal/proxy/noproxy.go +++ b/client/internal/proxy/noproxy.go @@ -5,12 +5,12 @@ import ( "net" ) -// NoProxy is used when there is no need for a proxy between ICE and Wireguard. +// NoProxy is used when there is no need for a proxy between ICE and WireGuard. // This is possible in either of these cases: // - peers are in the same local network // - one of the peers has a public static IP (host) -// NoProxy will just update remote peer with a remote host and fixed Wireguard port (r.g. 51820). -// In order NoProxy to work, Wireguard port has to be fixed for the time being. +// NoProxy will just update remote peer with a remote host and fixed WireGuard port (r.g. 51820). +// In order NoProxy to work, WireGuard port has to be fixed for the time being. type NoProxy struct { config Config // RemoteWgListenPort is a WireGuard port of a remote peer. @@ -31,7 +31,7 @@ func (p *NoProxy) Close() error { return nil } -// Start just updates Wireguard peer with the remote IP and default Wireguard port +// Start just updates WireGuard peer with the remote IP and default WireGuard port func (p *NoProxy) Start(remoteConn net.Conn) error { log.Debugf("using NoProxy while connecting to peer %s", p.config.RemoteKey) diff --git a/client/internal/proxy/wireguard.go b/client/internal/proxy/wireguard.go index a8609cb18..67b1c4498 100644 --- a/client/internal/proxy/wireguard.go +++ b/client/internal/proxy/wireguard.go @@ -6,8 +6,8 @@ import ( "net" ) -// WireguardProxy proxies -type WireguardProxy struct { +// WireGuardProxy proxies +type WireGuardProxy struct { ctx context.Context cancel context.CancelFunc @@ -17,13 +17,13 @@ type WireguardProxy struct { localConn net.Conn } -func NewWireguardProxy(config Config) *WireguardProxy { - p := &WireguardProxy{config: config} +func NewWireGuardProxy(config Config) *WireGuardProxy { + p := &WireGuardProxy{config: config} p.ctx, p.cancel = context.WithCancel(context.Background()) return p } -func (p *WireguardProxy) updateEndpoint() error { +func (p *WireGuardProxy) updateEndpoint() error { udpAddr, err := net.ResolveUDPAddr(p.localConn.LocalAddr().Network(), p.localConn.LocalAddr().String()) if err != nil { return err @@ -38,7 +38,7 @@ func (p *WireguardProxy) updateEndpoint() error { return nil } -func (p *WireguardProxy) Start(remoteConn net.Conn) error { +func (p *WireGuardProxy) Start(remoteConn net.Conn) error { p.remoteConn = remoteConn var err error @@ -60,7 +60,7 @@ func (p *WireguardProxy) Start(remoteConn net.Conn) error { return nil } -func (p *WireguardProxy) Close() error { +func (p *WireGuardProxy) Close() error { p.cancel() if c := p.localConn; c != nil { err := p.localConn.Close() @@ -77,7 +77,7 @@ func (p *WireguardProxy) Close() error { // proxyToRemote proxies everything from Wireguard to the RemoteKey peer // blocks -func (p *WireguardProxy) proxyToRemote() { +func (p *WireGuardProxy) proxyToRemote() { buf := make([]byte, 1500) for { @@ -101,7 +101,7 @@ func (p *WireguardProxy) proxyToRemote() { // proxyToLocal proxies everything from the RemoteKey peer to local Wireguard // blocks -func (p *WireguardProxy) proxyToLocal() { +func (p *WireGuardProxy) proxyToLocal() { buf := make([]byte, 1500) for { @@ -123,6 +123,6 @@ func (p *WireguardProxy) proxyToLocal() { } } -func (p *WireguardProxy) Type() Type { +func (p *WireGuardProxy) Type() Type { return TypeWireguard } diff --git a/iface/tun_linux.go b/iface/tun_linux.go index 9f8db54b5..abe3e5543 100644 --- a/iface/tun_linux.go +++ b/iface/tun_linux.go @@ -11,10 +11,10 @@ import ( ) func (c *tunDevice) Create() error { - /*if WireguardModuleIsLoaded() { + if WireguardModuleIsLoaded() { log.Info("using kernel WireGuard") return c.createWithKernel() - }*/ + } if !tunModuleIsLoaded() { return fmt.Errorf("couldn't check or load tun module") @@ -30,7 +30,7 @@ func (c *tunDevice) Create() error { } -// createWithKernel Creates a new Wireguard interface using kernel Wireguard module. +// createWithKernel Creates a new WireGuard interface using kernel WireGuard module. // Works for Linux and offers much better network performance func (c *tunDevice) createWithKernel() error {