mirror of
https://github.com/slackhq/nebula.git
synced 2026-05-16 04:47:38 +02:00
WIP
This commit is contained in:
@@ -324,10 +324,12 @@ func (hm *HandshakeManager) handleOutbound(vpnIp netip.Addr, lighthouseTriggered
|
|||||||
hm.messageMetrics.Tx(header.Handshake, header.MessageSubType(hostinfo.HandshakePacket[0][1]), 1)
|
hm.messageMetrics.Tx(header.Handshake, header.MessageSubType(hostinfo.HandshakePacket[0][1]), 1)
|
||||||
err = hm.udpRaw.WriteTo(raw, udp.RandomSendPort.UDPSendPort(hm.multiPort.TxPorts), addr)
|
err = hm.udpRaw.WriteTo(raw, udp.RandomSendPort.UDPSendPort(hm.multiPort.TxPorts), addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
hostinfo.logger(hm.l).WithField("udpAddr", addr).
|
hostinfo.logger(hm.l).Error("Failed to send handshake message",
|
||||||
WithField("initiatorIndex", hostinfo.localIndexId).
|
"error", err,
|
||||||
WithField("handshake", m{"stage": 1, "style": "ix_psk0"}).
|
"udpAddr", addr,
|
||||||
WithError(err).Error("Failed to send handshake message")
|
"initiatorIndex", hostinfo.localIndexId,
|
||||||
|
"handshake", hsFields,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
4
main.go
4
main.go
@@ -241,7 +241,7 @@ func Main(c *config.C, configTest bool, buildVersion string, l *slog.Logger, dev
|
|||||||
if tx && ifce.udpRaw == nil {
|
if tx && ifce.udpRaw == nil {
|
||||||
ifce.udpRaw, err = udp.NewRawConn(l, c.GetString("listen.host", "0.0.0.0"), port, uint16(port))
|
ifce.udpRaw, err = udp.NewRawConn(l, c.GetString("listen.host", "0.0.0.0"), port, uint16(port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.WithError(err).Error("Failed to get raw socket for tun.multiport.tx_enabled")
|
l.Error("Failed to get raw socket for tun.multiport.tx_enabled", "error", err)
|
||||||
ifce.udpRaw = nil
|
ifce.udpRaw = nil
|
||||||
tx = false
|
tx = false
|
||||||
}
|
}
|
||||||
@@ -260,7 +260,7 @@ func Main(c *config.C, configTest bool, buildVersion string, l *slog.Logger, dev
|
|||||||
handshakeManager.udpRaw = ifce.udpRaw
|
handshakeManager.udpRaw = ifce.udpRaw
|
||||||
handshakeManager.multiPort = ifce.multiPort
|
handshakeManager.multiPort = ifce.multiPort
|
||||||
|
|
||||||
l.WithField("multiPort", ifce.multiPort).Info("Multiport configured")
|
l.Info("Multiport configured", "multiPort", ifce.multiPort)
|
||||||
}
|
}
|
||||||
|
|
||||||
loadMultiPortConfig(c)
|
loadMultiPortConfig(c)
|
||||||
|
|||||||
@@ -6,13 +6,13 @@ package udp
|
|||||||
import (
|
import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log/slog"
|
||||||
"net"
|
"net"
|
||||||
"net/netip"
|
"net/netip"
|
||||||
"syscall"
|
"syscall"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"github.com/rcrowley/go-metrics"
|
"github.com/rcrowley/go-metrics"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
"github.com/slackhq/nebula/config"
|
"github.com/slackhq/nebula/config"
|
||||||
"golang.org/x/net/ipv4"
|
"golang.org/x/net/ipv4"
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
@@ -26,10 +26,10 @@ const RawOverhead = 28
|
|||||||
type RawConn struct {
|
type RawConn struct {
|
||||||
sysFd int
|
sysFd int
|
||||||
basePort uint16
|
basePort uint16
|
||||||
l *logrus.Logger
|
l *slog.Logger
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewRawConn(l *logrus.Logger, ip string, port int, basePort uint16) (*RawConn, error) {
|
func NewRawConn(l *slog.Logger, ip string, port int, basePort uint16) (*RawConn, error) {
|
||||||
syscall.ForkLock.RLock()
|
syscall.ForkLock.RLock()
|
||||||
// With IPPROTO_UDP, the linux kernel tries to deliver every UDP packet
|
// With IPPROTO_UDP, the linux kernel tries to deliver every UDP packet
|
||||||
// received in the system to our socket. This constantly overflows our
|
// received in the system to our socket. This constantly overflows our
|
||||||
@@ -130,17 +130,17 @@ func (u *RawConn) ReloadConfig(c *config.C) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := u.SetSendBuffer(b); err != nil {
|
if err := u.SetSendBuffer(b); err != nil {
|
||||||
u.l.WithError(err).Error("Failed to set listen.write_buffer")
|
u.l.Error("Failed to set listen.write_buffer", "error", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
s, err := u.GetSendBuffer()
|
s, err := u.GetSendBuffer()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
u.l.WithError(err).Warn("Failed to get listen.write_buffer")
|
u.l.Warn("Failed to get listen.write_buffer", "error", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
u.l.WithField("size", s).Info("listen.write_buffer was set")
|
u.l.Info("listen.write_buffer was set", "size", s)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *RawConn) SetSendBuffer(n int) error {
|
func (u *RawConn) SetSendBuffer(n int) error {
|
||||||
|
|||||||
Reference in New Issue
Block a user