mirror of
https://github.com/fosrl/olm.git
synced 2026-02-27 15:26:45 +00:00
Middle device working but not closing
This commit is contained in:
14
olm/olm.go
14
olm/olm.go
@@ -952,22 +952,20 @@ func StartTunnel(config TunnelConfig) {
|
|||||||
logger.Info("Tunnel process context cancelled, cleaning up")
|
logger.Info("Tunnel process context cancelled, cleaning up")
|
||||||
}
|
}
|
||||||
|
|
||||||
func AddDevice(fd uint32) {
|
func AddDevice(fd uint32) error {
|
||||||
if middleDev == nil {
|
if middleDev == nil {
|
||||||
logger.Error("MiddleDevice is nil, cannot add device")
|
return fmt.Errorf("middle device is not initialized")
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if tunnelConfig.MTU == 0 {
|
if tunnelConfig.MTU == 0 {
|
||||||
logger.Error("No MTU configured, cannot create device")
|
// error
|
||||||
return
|
return fmt.Errorf("tunnel MTU is not set")
|
||||||
}
|
}
|
||||||
|
|
||||||
tdev, err := olmDevice.CreateTUNFromFD(fd, tunnelConfig.MTU)
|
tdev, err := olmDevice.CreateTUNFromFD(fd, tunnelConfig.MTU)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("Failed to create TUN device: %v", err)
|
return fmt.Errorf("failed to create TUN device from fd: %v", err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if config.FileDescriptorTun == 0 {
|
// if config.FileDescriptorTun == 0 {
|
||||||
@@ -977,6 +975,8 @@ func AddDevice(fd uint32) {
|
|||||||
|
|
||||||
// Here we replace the existing TUN device in the middle device with the new one
|
// Here we replace the existing TUN device in the middle device with the new one
|
||||||
middleDev.AddDevice(tdev)
|
middleDev.AddDevice(tdev)
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func Close() {
|
func Close() {
|
||||||
|
|||||||
Reference in New Issue
Block a user