Files
wireguard-go/tun/operateonfd.go
T

25 lines
500 B
Go
Raw Normal View History

2019-03-20 21:45:40 +01:00
// +build !windows
/* SPDX-License-Identifier: MIT
*
2020-05-02 02:08:26 -06:00
* Copyright (C) 2017-2020 WireGuard LLC. All Rights Reserved.
2019-03-20 21:45:40 +01: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())
}
}