mirror of
https://github.com/gravitl/netmaker.git
synced 2024-09-22 00:06:04 +08:00
Merge pull request #1973 from gravitl/bugfix_staticchecks
Fix static checks
This commit is contained in:
commit
a5aa510b20
|
@ -67,23 +67,17 @@ type ManagerAction struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func StartProxyManager(manageChan chan *ManagerAction) {
|
func StartProxyManager(manageChan chan *ManagerAction) {
|
||||||
for {
|
for mI := range manageChan {
|
||||||
|
log.Printf("-------> PROXY-MANAGER: %+v\n", mI)
|
||||||
select {
|
switch mI.Action {
|
||||||
case mI := <-manageChan:
|
case AddInterface:
|
||||||
log.Printf("-------> PROXY-MANAGER: %+v\n", mI)
|
mI.SetIngressGateway()
|
||||||
switch mI.Action {
|
err := mI.AddInterfaceToProxy()
|
||||||
case AddInterface:
|
if err != nil {
|
||||||
|
log.Printf("failed to add interface: [%s] to proxy: %v\n ", mI.Payload.InterfaceName, err)
|
||||||
mI.SetIngressGateway()
|
|
||||||
err := mI.AddInterfaceToProxy()
|
|
||||||
if err != nil {
|
|
||||||
log.Printf("failed to add interface: [%s] to proxy: %v\n ", mI.Payload.InterfaceName, err)
|
|
||||||
}
|
|
||||||
case DeleteInterface:
|
|
||||||
mI.DeleteInterface()
|
|
||||||
}
|
}
|
||||||
|
case DeleteInterface:
|
||||||
|
mI.DeleteInterface()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,11 +3,12 @@ package packet
|
||||||
import (
|
import (
|
||||||
"golang.org/x/crypto/blake2s"
|
"golang.org/x/crypto/blake2s"
|
||||||
"golang.org/x/crypto/chacha20poly1305"
|
"golang.org/x/crypto/chacha20poly1305"
|
||||||
"golang.org/x/crypto/poly1305"
|
|
||||||
"golang.zx2c4.com/wireguard/tai64n"
|
"golang.zx2c4.com/wireguard/tai64n"
|
||||||
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
|
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const poly1305TagSize = 16
|
||||||
|
|
||||||
var (
|
var (
|
||||||
InitialChainKey [blake2s.Size]byte
|
InitialChainKey [blake2s.Size]byte
|
||||||
InitialHash [blake2s.Size]byte
|
InitialHash [blake2s.Size]byte
|
||||||
|
@ -23,8 +24,8 @@ type MessageInitiation struct {
|
||||||
Type MessageType
|
Type MessageType
|
||||||
Sender uint32
|
Sender uint32
|
||||||
Ephemeral NoisePublicKey
|
Ephemeral NoisePublicKey
|
||||||
Static [NoisePublicKeySize + poly1305.TagSize]byte
|
Static [NoisePublicKeySize + poly1305TagSize]byte
|
||||||
Timestamp [tai64n.TimestampSize + poly1305.TagSize]byte
|
Timestamp [tai64n.TimestampSize + poly1305TagSize]byte
|
||||||
MAC1 [blake2s.Size128]byte
|
MAC1 [blake2s.Size128]byte
|
||||||
MAC2 [blake2s.Size128]byte
|
MAC2 [blake2s.Size128]byte
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,6 +108,7 @@ type (
|
||||||
func sharedSecret(sk *NoisePrivateKey, pk NoisePublicKey) (ss [NoisePublicKeySize]byte) {
|
func sharedSecret(sk *NoisePrivateKey, pk NoisePublicKey) (ss [NoisePublicKeySize]byte) {
|
||||||
apk := (*[NoisePublicKeySize]byte)(&pk)
|
apk := (*[NoisePublicKeySize]byte)(&pk)
|
||||||
ask := (*[NoisePrivateKeySize]byte)(sk)
|
ask := (*[NoisePrivateKeySize]byte)(sk)
|
||||||
|
//lint:ignore SA1019 no need of back and forth conversion between arrays and slices required by curve25519.X25519 function
|
||||||
curve25519.ScalarMult(&ss, ask, apk)
|
curve25519.ScalarMult(&ss, ask, apk)
|
||||||
return ss
|
return ss
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ package proxy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
|
@ -97,27 +96,6 @@ func GetInterfaceListenAddr(port int) (*net.UDPAddr, error) {
|
||||||
return udpAddr, nil
|
return udpAddr, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getBoardCastAddress() ([]net.Addr, error) {
|
|
||||||
localnets, err := net.Interfaces()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
var (
|
|
||||||
ief net.Interface
|
|
||||||
addrs []net.Addr
|
|
||||||
)
|
|
||||||
for _, ief = range localnets {
|
|
||||||
if ief.Flags&net.FlagBroadcast != 0 && ief.Flags&net.FlagUp != 0 {
|
|
||||||
addrs, err = ief.Addrs()
|
|
||||||
if err == nil {
|
|
||||||
return addrs, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil, errors.New("couldn't obtain the broadcast addr")
|
|
||||||
}
|
|
||||||
|
|
||||||
// func StartSniffer(ctx context.Context, ifaceName, ingGwAddr, extClientAddr string, port int) {
|
// func StartSniffer(ctx context.Context, ifaceName, ingGwAddr, extClientAddr string, port int) {
|
||||||
// log.Println("Starting Packet Sniffer for iface: ", ifaceName)
|
// log.Println("Starting Packet Sniffer for iface: ", ifaceName)
|
||||||
// var (
|
// var (
|
||||||
|
|
|
@ -174,12 +174,6 @@ func (p *Proxy) ProxyPeer() {
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|
||||||
}
|
}
|
||||||
func test(n int, buffer []byte) {
|
|
||||||
data := buffer[:n]
|
|
||||||
srcKeyHash := data[n-32 : n-16]
|
|
||||||
dstKeyHash := data[n-16:]
|
|
||||||
log.Printf("--------> TEST PACKET [ SRCKEYHASH: %x ], [ DSTKEYHASH: %x ] \n", srcKeyHash, dstKeyHash)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *Proxy) updateEndpoint() error {
|
func (p *Proxy) updateEndpoint() error {
|
||||||
udpAddr, err := net.ResolveUDPAddr("udp", p.LocalConn.LocalAddr().String())
|
udpAddr, err := net.ResolveUDPAddr("udp", p.LocalConn.LocalAddr().String())
|
||||||
|
|
Loading…
Reference in a new issue