Initial working source caching
This commit is contained in:
@@ -2,6 +2,8 @@ package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"golang.org/x/net/ipv4"
|
||||
"golang.org/x/net/ipv6"
|
||||
"net"
|
||||
)
|
||||
|
||||
@@ -42,7 +44,6 @@ func unsafeCloseUDPListener(device *Device) error {
|
||||
if netc.bind != nil {
|
||||
err = netc.bind.Close()
|
||||
netc.bind = nil
|
||||
netc.update.Add(1)
|
||||
}
|
||||
return err
|
||||
}
|
||||
@@ -68,6 +69,8 @@ func UpdateUDPListener(device *Device) error {
|
||||
|
||||
if device.tun.isUp.Get() {
|
||||
|
||||
device.log.Debug.Println("UDP bind updating")
|
||||
|
||||
// bind to new port
|
||||
|
||||
var err error
|
||||
@@ -94,8 +97,10 @@ func UpdateUDPListener(device *Device) error {
|
||||
|
||||
// decrease waitgroup to 0
|
||||
|
||||
go device.RoutineReceiveIncomming(ipv4.Version, netc.bind)
|
||||
go device.RoutineReceiveIncomming(ipv6.Version, netc.bind)
|
||||
|
||||
device.log.Debug.Println("UDP bind has been updated")
|
||||
netc.update.Done()
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user