cmd,pkg: fix lint warnings
Signed-off-by: Lucas Servén Marín <lserven@gmail.com>
This commit is contained in:
parent
a8568c7399
commit
6ab3c009c7
@ -276,8 +276,6 @@ func cleanUp(iface int, t *route.Table, logger log.Logger) {
|
|||||||
if err := t.CleanUp(); err != nil {
|
if err := t.CleanUp(); err != nil {
|
||||||
level.Error(logger).Log("failed to clean up routes: %v", err)
|
level.Error(logger).Log("failed to clean up routes: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func sync(table *route.Table, peerName string, privateKey wgtypes.Key, iface int, logger log.Logger) error {
|
func sync(table *route.Table, peerName string, privateKey wgtypes.Key, iface int, logger log.Logger) error {
|
||||||
|
@ -61,7 +61,6 @@ type Mesh struct {
|
|||||||
ipTables *iptables.Controller
|
ipTables *iptables.Controller
|
||||||
kiloIface int
|
kiloIface int
|
||||||
kiloIfaceName string
|
kiloIfaceName string
|
||||||
key []byte
|
|
||||||
local bool
|
local bool
|
||||||
port int
|
port int
|
||||||
priv wgtypes.Key
|
priv wgtypes.Key
|
||||||
@ -94,6 +93,9 @@ func New(backend Backend, enc encapsulation.Encapsulator, granularity Granularit
|
|||||||
return nil, fmt.Errorf("failed to create directory to store configuration: %v", err)
|
return nil, fmt.Errorf("failed to create directory to store configuration: %v", err)
|
||||||
}
|
}
|
||||||
privateB, err := ioutil.ReadFile(privateKeyPath)
|
privateB, err := ioutil.ReadFile(privateKeyPath)
|
||||||
|
if err != nil && !os.IsNotExist(err) {
|
||||||
|
return nil, fmt.Errorf("failed to read private key file: %v", err)
|
||||||
|
}
|
||||||
privateB = bytes.Trim(privateB, "\n")
|
privateB = bytes.Trim(privateB, "\n")
|
||||||
private, err := wgtypes.ParseKey(string(privateB))
|
private, err := wgtypes.ParseKey(string(privateB))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -16,7 +16,6 @@ package mesh
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
||||||
"strings"
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -27,10 +26,6 @@ import (
|
|||||||
"github.com/squat/kilo/pkg/wireguard"
|
"github.com/squat/kilo/pkg/wireguard"
|
||||||
)
|
)
|
||||||
|
|
||||||
func allowedIPs(ips ...string) string {
|
|
||||||
return strings.Join(ips, ", ")
|
|
||||||
}
|
|
||||||
|
|
||||||
func mustParseCIDR(s string) (r net.IPNet) {
|
func mustParseCIDR(s string) (r net.IPNet) {
|
||||||
if _, ip, err := net.ParseCIDR(s); err != nil {
|
if _, ip, err := net.ParseCIDR(s); err != nil {
|
||||||
panic("failed to parse CIDR")
|
panic("failed to parse CIDR")
|
||||||
|
@ -183,7 +183,7 @@ func (e *Endpoint) Resolved() bool {
|
|||||||
// UDPAddr() will not try to resolve a DN name, if the Endpoint is not yet resolved.
|
// UDPAddr() will not try to resolve a DN name, if the Endpoint is not yet resolved.
|
||||||
func (e *Endpoint) UDPAddr(resolve bool) (*net.UDPAddr, error) {
|
func (e *Endpoint) UDPAddr(resolve bool) (*net.UDPAddr, error) {
|
||||||
if !e.Ready() {
|
if !e.Ready() {
|
||||||
return nil, errors.New("Enpoint is not ready")
|
return nil, errors.New("endpoint is not ready")
|
||||||
}
|
}
|
||||||
if e.udpAddr != nil {
|
if e.udpAddr != nil {
|
||||||
// Make a copy of the UDPAddr to protect it from modification outside this package.
|
// Make a copy of the UDPAddr to protect it from modification outside this package.
|
||||||
@ -191,7 +191,7 @@ func (e *Endpoint) UDPAddr(resolve bool) (*net.UDPAddr, error) {
|
|||||||
return &h, nil
|
return &h, nil
|
||||||
}
|
}
|
||||||
if !resolve {
|
if !resolve {
|
||||||
return nil, errors.New("Endpoint is not resolved")
|
return nil, errors.New("endpoint is not resolved")
|
||||||
}
|
}
|
||||||
var err error
|
var err error
|
||||||
if e.udpAddr, err = net.ResolveUDPAddr("udp", e.addr); err != nil {
|
if e.udpAddr, err = net.ResolveUDPAddr("udp", e.addr); err != nil {
|
||||||
@ -358,19 +358,13 @@ func (c *Conf) Equal(d *wgtypes.Device) (bool, string) {
|
|||||||
|
|
||||||
func sortPeerConfigs(peers []wgtypes.Peer) {
|
func sortPeerConfigs(peers []wgtypes.Peer) {
|
||||||
sort.Slice(peers, func(i, j int) bool {
|
sort.Slice(peers, func(i, j int) bool {
|
||||||
if peers[i].PublicKey.String() < peers[j].PublicKey.String() {
|
return peers[i].PublicKey.String() < peers[j].PublicKey.String()
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func sortPeers(peers []Peer) {
|
func sortPeers(peers []Peer) {
|
||||||
sort.Slice(peers, func(i, j int) bool {
|
sort.Slice(peers, func(i, j int) bool {
|
||||||
if peers[i].PublicKey.String() < peers[j].PublicKey.String() {
|
return peers[i].PublicKey.String() < peers[j].PublicKey.String()
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user