Refactor TUN setup (isolated config)

This commit is contained in:
Neil Alexander 2022-09-03 12:20:57 +01:00
parent b1f61fb0a8
commit a7d06e048a
4 changed files with 57 additions and 40 deletions

20
src/tuntap/options.go Normal file
View file

@ -0,0 +1,20 @@
package tuntap
func (m *TunAdapter) _applyOption(opt SetupOption) {
switch v := opt.(type) {
case InterfaceName:
m.config.name = v
case InterfaceMTU:
m.config.mtu = v
}
}
type SetupOption interface {
isSetupOption()
}
type InterfaceName string
type InterfaceMTU uint64
func (a InterfaceName) isSetupOption() {}
func (a InterfaceMTU) isSetupOption() {}