summaryrefslogtreecommitdiffhomepage
path: root/tun/tun_linux.go
diff options
context:
space:
mode:
authorMatt Layher <mdlayher@gmail.com>2019-06-10 17:33:40 -0400
committerJason A. Donenfeld <Jason@zx2c4.com>2019-06-14 18:35:57 +0200
commit1f48971a80f48257e478e532f6971d0557026120 (patch)
treecd2a3b83a1b3d5e09d5e8283c61d29537f0cbf3e /tun/tun_linux.go
parent3371f8dac6fe6bbd7522a8316b50f6473012e302 (diff)
tun: remove TUN prefix from types to reduce stutter elsewhere
Signed-off-by: Matt Layher <mdlayher@gmail.com>
Diffstat (limited to 'tun/tun_linux.go')
-rw-r--r--tun/tun_linux.go32
1 files changed, 16 insertions, 16 deletions
diff --git a/tun/tun_linux.go b/tun/tun_linux.go
index 2168f5b..61902e9 100644
--- a/tun/tun_linux.go
+++ b/tun/tun_linux.go
@@ -31,11 +31,11 @@ const (
type NativeTun struct {
tunFile *os.File
- index int32 // if index
- name string // name of interface
- errors chan error // async error handling
- events chan TUNEvent // device related events
- nopi bool // the device was pased IFF_NO_PI
+ index int32 // if index
+ name string // name of interface
+ errors chan error // async error handling
+ events chan Event // device related events
+ nopi bool // the device was pased IFF_NO_PI
netlinkSock int
netlinkCancel *rwcancel.RWCancel
hackListenerClosed sync.Mutex
@@ -64,9 +64,9 @@ func (tun *NativeTun) routineHackListener() {
}
switch err {
case unix.EINVAL:
- tun.events <- TUNEventUp
+ tun.events <- EventUp
case unix.EIO:
- tun.events <- TUNEventDown
+ tun.events <- EventDown
default:
return
}
@@ -148,14 +148,14 @@ func (tun *NativeTun) routineNetlinkListener() {
}
if info.Flags&unix.IFF_RUNNING != 0 {
- tun.events <- TUNEventUp
+ tun.events <- EventUp
}
if info.Flags&unix.IFF_RUNNING == 0 {
- tun.events <- TUNEventDown
+ tun.events <- EventDown
}
- tun.events <- TUNEventMTUUpdate
+ tun.events <- EventMTUUpdate
default:
remain = remain[hdr.Len:]
@@ -342,7 +342,7 @@ func (tun *NativeTun) Read(buff []byte, offset int) (int, error) {
}
}
-func (tun *NativeTun) Events() chan TUNEvent {
+func (tun *NativeTun) Events() chan Event {
return tun.events
}
@@ -364,7 +364,7 @@ func (tun *NativeTun) Close() error {
return err2
}
-func CreateTUN(name string, mtu int) (TUNDevice, error) {
+func CreateTUN(name string, mtu int) (Device, error) {
nfd, err := unix.Open(cloneDevicePath, os.O_RDWR, 0)
if err != nil {
return nil, err
@@ -400,10 +400,10 @@ func CreateTUN(name string, mtu int) (TUNDevice, error) {
return CreateTUNFromFile(fd, mtu)
}
-func CreateTUNFromFile(file *os.File, mtu int) (TUNDevice, error) {
+func CreateTUNFromFile(file *os.File, mtu int) (Device, error) {
tun := &NativeTun{
tunFile: file,
- events: make(chan TUNEvent, 5),
+ events: make(chan Event, 5),
errors: make(chan error, 5),
statusListenersShutdown: make(chan struct{}),
nopi: false,
@@ -445,7 +445,7 @@ func CreateTUNFromFile(file *os.File, mtu int) (TUNDevice, error) {
return tun, nil
}
-func CreateUnmonitoredTUNFromFD(fd int) (TUNDevice, string, error) {
+func CreateUnmonitoredTUNFromFD(fd int) (Device, string, error) {
err := unix.SetNonblock(fd, true)
if err != nil {
return nil, "", err
@@ -453,7 +453,7 @@ func CreateUnmonitoredTUNFromFD(fd int) (TUNDevice, string, error) {
file := os.NewFile(uintptr(fd), "/dev/tun")
tun := &NativeTun{
tunFile: file,
- events: make(chan TUNEvent, 5),
+ events: make(chan Event, 5),
errors: make(chan error, 5),
nopi: true,
}