tun: remove TUN prefix from types to reduce stutter elsewhere
Signed-off-by: Matt Layher <mdlayher@gmail.com>
This commit is contained in:
committed by
Jason A. Donenfeld
parent
3371f8dac6
commit
1f48971a80
@@ -86,7 +86,7 @@ type Device struct {
|
||||
}
|
||||
|
||||
tun struct {
|
||||
device tun.TUNDevice
|
||||
device tun.Device
|
||||
mtu int32
|
||||
}
|
||||
}
|
||||
@@ -252,7 +252,7 @@ func (device *Device) SetPrivateKey(sk NoisePrivateKey) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewDevice(tunDevice tun.TUNDevice, logger *Logger) *Device {
|
||||
func NewDevice(tunDevice tun.Device, logger *Logger) *Device {
|
||||
device := new(Device)
|
||||
|
||||
device.isUp.Set(false)
|
||||
@@ -324,7 +324,6 @@ func (device *Device) LookupPeer(pk NoisePublicKey) *Peer {
|
||||
func (device *Device) RemovePeer(key NoisePublicKey) {
|
||||
device.peers.Lock()
|
||||
defer device.peers.Unlock()
|
||||
|
||||
// stop peer and remove from routing
|
||||
|
||||
peer, ok := device.peers.keyMap[key]
|
||||
|
||||
@@ -23,7 +23,7 @@ func (device *Device) RoutineTUNEventReader() {
|
||||
device.state.starting.Done()
|
||||
|
||||
for event := range device.tun.device.Events() {
|
||||
if event&tun.TUNEventMTUUpdate != 0 {
|
||||
if event&tun.EventMTUUpdate != 0 {
|
||||
mtu, err := device.tun.device.MTU()
|
||||
old := atomic.LoadInt32(&device.tun.mtu)
|
||||
if err != nil {
|
||||
@@ -38,13 +38,13 @@ func (device *Device) RoutineTUNEventReader() {
|
||||
}
|
||||
}
|
||||
|
||||
if event&tun.TUNEventUp != 0 && !setUp {
|
||||
if event&tun.EventUp != 0 && !setUp {
|
||||
logInfo.Println("Interface set up")
|
||||
setUp = true
|
||||
device.Up()
|
||||
}
|
||||
|
||||
if event&tun.TUNEventDown != 0 && setUp {
|
||||
if event&tun.EventDown != 0 && setUp {
|
||||
logInfo.Println("Interface set down")
|
||||
setUp = false
|
||||
device.Down()
|
||||
|
||||
@@ -13,27 +13,27 @@ import (
|
||||
)
|
||||
|
||||
// newDummyTUN creates a dummy TUN device with the specified name.
|
||||
func newDummyTUN(name string) tun.TUNDevice {
|
||||
func newDummyTUN(name string) tun.Device {
|
||||
return &dummyTUN{
|
||||
name: name,
|
||||
packets: make(chan []byte, 100),
|
||||
events: make(chan tun.TUNEvent, 10),
|
||||
events: make(chan tun.Event, 10),
|
||||
}
|
||||
}
|
||||
|
||||
// A dummyTUN is a tun.TUNDevice which is used in unit tests.
|
||||
// A dummyTUN is a tun.Device which is used in unit tests.
|
||||
type dummyTUN struct {
|
||||
name string
|
||||
mtu int
|
||||
packets chan []byte
|
||||
events chan tun.TUNEvent
|
||||
events chan tun.Event
|
||||
}
|
||||
|
||||
func (d *dummyTUN) Events() chan tun.TUNEvent { return d.events }
|
||||
func (*dummyTUN) File() *os.File { return nil }
|
||||
func (*dummyTUN) Flush() error { return nil }
|
||||
func (d *dummyTUN) MTU() (int, error) { return d.mtu, nil }
|
||||
func (d *dummyTUN) Name() (string, error) { return d.name, nil }
|
||||
func (d *dummyTUN) Events() chan tun.Event { return d.events }
|
||||
func (*dummyTUN) File() *os.File { return nil }
|
||||
func (*dummyTUN) Flush() error { return nil }
|
||||
func (d *dummyTUN) MTU() (int, error) { return d.mtu, nil }
|
||||
func (d *dummyTUN) Name() (string, error) { return d.name, nil }
|
||||
|
||||
func (d *dummyTUN) Close() error {
|
||||
close(d.events)
|
||||
|
||||
Reference in New Issue
Block a user