mirror of
https://github.com/netbirdio/netbird.git
synced 2025-01-31 10:31:58 +01:00
Close turn connection
Without it the WG can not exit from the read loop
This commit is contained in:
parent
b5c4802bb9
commit
b68a02acee
@ -143,7 +143,7 @@ func (m *Manager) AllowNetbird() error {
|
||||
}
|
||||
|
||||
if rule := m.detectAllowNetbirdRule(rules); rule != nil {
|
||||
log.Debugf("allow netbird rule already exists: %v", rule)
|
||||
log.Debugf("allow netbird rule already exists: %#v", rule)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -200,6 +200,7 @@ func NewEngineWithProbes(
|
||||
networkSerial: 0,
|
||||
sshServerFunc: nbssh.DefaultSSHServer,
|
||||
statusRecorder: statusRecorder,
|
||||
wgProxyFactory: &wgproxy.Factory{},
|
||||
mgmProbe: mgmProbe,
|
||||
signalProbe: signalProbe,
|
||||
relayProbe: relayProbe,
|
||||
@ -1157,6 +1158,8 @@ func (e *Engine) close() {
|
||||
log.Errorf("failed closing ebpf proxy: %s", err)
|
||||
}
|
||||
|
||||
e.turnRelay.Close()
|
||||
|
||||
// stop/restore DNS first so dbus and friends don't complain because of a missing interface
|
||||
if e.dnsServer != nil {
|
||||
e.dnsServer.Stop()
|
||||
|
@ -87,6 +87,20 @@ func (r *PermanentTurn) RelayConn() net.PacketConn {
|
||||
return r.relayConn
|
||||
}
|
||||
|
||||
func (r *PermanentTurn) Close() {
|
||||
r.turnClient.Close()
|
||||
|
||||
err := r.relayConn.Close()
|
||||
if err != nil {
|
||||
log.Errorf("failed to close relayConn: %s", err.Error())
|
||||
}
|
||||
|
||||
err = r.stunConn.Close()
|
||||
if err != nil {
|
||||
log.Errorf("failed to close stunConn: %s", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func (r *PermanentTurn) discoverPublicIP() (*net.UDPAddr, error) {
|
||||
addr, err := r.turnClient.SendBindingRequest()
|
||||
if err != nil {
|
||||
|
@ -76,7 +76,6 @@ func (s *ICEBind) createIPv4ReceiverFn(ipv4MsgsPool *sync.Pool, pc *ipv4.PacketC
|
||||
msg := &(*msgs)[0]
|
||||
msg.N, msg.Addr, err = netConn.ReadFrom(msg.Buffers[0])
|
||||
if err != nil {
|
||||
log.Debugf("read err from turn server: %v", err)
|
||||
return 0, err
|
||||
}
|
||||
log.Debugf("----msg address is: %s, size: %d", msg.Addr.String(), msg.N)
|
||||
|
@ -54,7 +54,7 @@ func (t *tunUSPDevice) Create() (wgConfigurer, error) {
|
||||
t.device = device.NewDevice(
|
||||
t.wrapper,
|
||||
t.iceBind,
|
||||
device.NewLogger(device.LogLevelVerbose, "[netbird] "),
|
||||
device.NewLogger(device.LogLevelError, "[netbird] "),
|
||||
)
|
||||
|
||||
err = t.assignAddr()
|
||||
|
Loading…
Reference in New Issue
Block a user