fix: golint errors (part 2)

This commit is contained in:
braginini
2021-05-19 11:13:25 +02:00
parent 5342f10e7f
commit 790858c31b
9 changed files with 32 additions and 34 deletions
+1 -1
View File
@@ -3,7 +3,7 @@ package connection
import (
"context"
"fmt"
"github.com/pion/ice/v2"
ice "github.com/pion/ice/v2"
log "github.com/sirupsen/logrus"
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
"sync"
+13 -13
View File
@@ -3,7 +3,7 @@ package connection
import (
"fmt"
"github.com/cenkalti/backoff/v4"
"github.com/pion/ice/v2"
ice "github.com/pion/ice/v2"
log "github.com/sirupsen/logrus"
"github.com/wiretrustee/wiretrustee/iface"
"github.com/wiretrustee/wiretrustee/signal"
@@ -38,11 +38,11 @@ type Peer struct {
func NewEngine(signal *signal.Client, stunsTurns []*ice.URL, wgIface string, wgAddr string,
iFaceBlackList map[string]struct{}) *Engine {
return &Engine{
stunsTurns: stunsTurns,
signal: signal,
wgIface: wgIface,
wgIP: wgAddr,
conns: map[string]*Connection{},
stunsTurns: stunsTurns,
signal: signal,
wgIface: wgIface,
wgIP: wgAddr,
conns: map[string]*Connection{},
iFaceBlackList: iFaceBlackList,
}
}
@@ -110,13 +110,13 @@ func (e *Engine) openPeerConnection(wgPort int, myKey wgtypes.Key, peer Peer) (*
remoteKey, _ := wgtypes.ParseKey(peer.WgPubKey)
connConfig := &ConnConfig{
WgListenAddr: fmt.Sprintf("127.0.0.1:%d", wgPort),
WgPeerIP: e.wgIP,
WgIface: e.wgIface,
WgAllowedIPs: peer.WgAllowedIps,
WgKey: myKey,
RemoteWgKey: remoteKey,
StunTurnURLS: e.stunsTurns,
WgListenAddr: fmt.Sprintf("127.0.0.1:%d", wgPort),
WgPeerIP: e.wgIP,
WgIface: e.wgIface,
WgAllowedIPs: peer.WgAllowedIps,
WgKey: myKey,
RemoteWgKey: remoteKey,
StunTurnURLS: e.stunsTurns,
iFaceBlackList: e.iFaceBlackList,
}
+4 -1
View File
@@ -1,7 +1,7 @@
package connection
import (
"github.com/pion/ice/v2"
ice "github.com/pion/ice/v2"
log "github.com/sirupsen/logrus"
"github.com/wiretrustee/wiretrustee/iface"
"net"
@@ -85,6 +85,7 @@ func (p *WgProxy) proxyToRemotePeer(remoteConn *ice.Conn) {
_, err = remoteConn.Write(buf[:n])
if err != nil {
//log.Warnln("failed writing to remote peer: ", err.Error())
continue
}
}
}
@@ -104,11 +105,13 @@ func (p *WgProxy) proxyToLocalWireguard(remoteConn *ice.Conn) {
n, err := remoteConn.Read(buf)
if err != nil {
//log.Errorf("failed reading from remote connection %s", err)
continue
}
_, err = p.wgConn.Write(buf[:n])
if err != nil {
//log.Errorf("failed writing to local Wireguard instance %s", err)
continue
}
}
}