2019-03-20 20:45:40 +00:00
|
|
|
// +build !windows
|
|
|
|
|
|
|
|
/* SPDX-License-Identifier: MIT
|
|
|
|
*
|
2020-05-02 08:08:26 +00:00
|
|
|
* Copyright (C) 2017-2020 WireGuard LLC. All Rights Reserved.
|
2019-03-20 20:45:40 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
package tun
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (tun *NativeTun) operateOnFd(fn func(fd uintptr)) {
|
|
|
|
sysconn, err := tun.tunFile.SyscallConn()
|
|
|
|
if err != nil {
|
|
|
|
tun.errors <- fmt.Errorf("unable to find sysconn for tunfile: %s", err.Error())
|
|
|
|
return
|
|
|
|
}
|
|
|
|
err = sysconn.Control(fn)
|
|
|
|
if err != nil {
|
|
|
|
tun.errors <- fmt.Errorf("unable to control sysconn for tunfile: %s", err.Error())
|
|
|
|
}
|
|
|
|
}
|