diff options
Diffstat (limited to 'tun/tun.go')
-rw-r--r-- | tun/tun.go | 17 |
1 files changed, 16 insertions, 1 deletions
@@ -5,7 +5,10 @@ package tun -import "os" +import ( + "fmt" + "os" +) type TUNEvent int @@ -24,3 +27,15 @@ type TUNDevice interface { Events() chan TUNEvent // returns a constant channel of events related to the device Close() error // stops the device and closes the event channel } + +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()) + } +}
\ No newline at end of file |