Documentation
¶
Index ¶
- Constants
- Variables
- func DnsServers(index int) ([]netip.Addr, error)
- type Config
- func (*Config) Descriptor() ([]byte, []int)deprecated
- func (x *Config) GetDns4() []string
- func (x *Config) GetDns6() []string
- func (x *Config) GetIp4() string
- func (x *Config) GetIp6() string
- func (x *Config) GetMtu() uint32
- func (x *Config) GetName() string
- func (x *Config) GetPath() string
- func (x *Config) GetRoutes4() []string
- func (x *Config) GetRoutes6() []string
- func (x *Config) GetStrictRoute() bool
- func (*Config) ProtoMessage()
- func (x *Config) ProtoReflect() protoreflect.Message
- func (x *Config) Reset()
- func (x *Config) String() string
- type DefaultInterfaceChangeNotifier
- type DefaultInterfaceInfo
- func (t *DefaultInterfaceInfo) Close() error
- func (t *DefaultInterfaceInfo) DefaultDns4() []netip.Addr
- func (t *DefaultInterfaceInfo) DefaultDns6() []netip.Addr
- func (t *DefaultInterfaceInfo) DefaultInterface4() uint32
- func (t *DefaultInterfaceInfo) DefaultInterface6() uint32
- func (t *DefaultInterfaceInfo) DefaultInterfaceName4() string
- func (t *DefaultInterfaceInfo) DefaultInterfaceName6() string
- func (t *DefaultInterfaceInfo) HasGlobalIPv6() (bool, error)
- func (t *DefaultInterfaceInfo) Start() error
- func (t *DefaultInterfaceInfo) SupportIPv6() int
- type InterfaceInfo
- type MonitorConfig
- type TunDevice
- type TunDeviceWithInfo
- type TunOption
Constants ¶
View Source
const (
DefaultMtu int = 1500
)
Variables ¶
View Source
var File_tun_config_proto protoreflect.FileDescriptor
Functions ¶
Types ¶
type Config ¶
type Config struct {
// Defaults to "172.23.27.1/24". IP will be the ip address of the interface
// Ending number determines OnLinkPrefixLength
Ip4 string `protobuf:"bytes,1,opt,name=ip4,proto3" json:"ip4,omitempty"`
// Defaults to "fd00::1/64". no zone.
Ip6 string `protobuf:"bytes,2,opt,name=ip6,proto3" json:"ip6,omitempty"`
// defaults to "vtun"
Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"`
// defaults to 8192
Mtu uint32 `protobuf:"varint,4,opt,name=mtu,proto3" json:"mtu,omitempty"`
// path to a dir containing four folders: amd64, x86, arm, arm64.
// Each folder contains the wintun.dll for the corresponding platform.
// Absolute or relative to cwd
Path string `protobuf:"bytes,5,opt,name=path,proto3" json:"path,omitempty"`
// If unset, dns nameserver address of the tun will be set to the next ip of
// [ip4]. Same for dns6.
Dns4 []string `protobuf:"bytes,6,rep,name=dns4,proto3" json:"dns4,omitempty"`
Dns6 []string `protobuf:"bytes,7,rep,name=dns6,proto3" json:"dns6,omitempty"`
// If set, the tun will only accept packets with the specified routes.
StrictRoute bool `protobuf:"varint,8,opt,name=strict_route,json=strictRoute,proto3" json:"strict_route,omitempty"`
// Only used when strict_route is set.
Routes4 []string `protobuf:"bytes,9,rep,name=routes4,proto3" json:"routes4,omitempty"`
Routes6 []string `protobuf:"bytes,10,rep,name=routes6,proto3" json:"routes6,omitempty"`
// contains filtered or unexported fields
}
func (*Config) Descriptor
deprecated
func (*Config) GetRoutes4 ¶
func (*Config) GetRoutes6 ¶
func (*Config) GetStrictRoute ¶
func (*Config) ProtoMessage ¶
func (*Config) ProtoMessage()
func (*Config) ProtoReflect ¶
func (x *Config) ProtoReflect() protoreflect.Message
type DefaultInterfaceChangeNotifier ¶
type DefaultInterfaceChangeNotifier struct {
// contains filtered or unexported fields
}
func (*DefaultInterfaceChangeNotifier) Notify ¶
func (n *DefaultInterfaceChangeNotifier) Notify()
func (*DefaultInterfaceChangeNotifier) Register ¶
func (n *DefaultInterfaceChangeNotifier) Register(observer i.DefaultInterfaceChangeObserver)
func (*DefaultInterfaceChangeNotifier) Unregister ¶
func (n *DefaultInterfaceChangeNotifier) Unregister(observer i.DefaultInterfaceChangeObserver)
type DefaultInterfaceInfo ¶
type DefaultInterfaceInfo struct {
sync.RWMutex
DefaultInterfaceChangeNotifier
// contains filtered or unexported fields
}
implements i.DefaultInterfaceInfo Okay to not start.
func NewInterfaceMonitor ¶
func NewInterfaceMonitor(tunName string) (*DefaultInterfaceInfo, error)
func (*DefaultInterfaceInfo) Close ¶
func (t *DefaultInterfaceInfo) Close() error
func (*DefaultInterfaceInfo) DefaultDns4 ¶
func (t *DefaultInterfaceInfo) DefaultDns4() []netip.Addr
func (*DefaultInterfaceInfo) DefaultDns6 ¶
func (t *DefaultInterfaceInfo) DefaultDns6() []netip.Addr
func (*DefaultInterfaceInfo) DefaultInterface4 ¶
func (t *DefaultInterfaceInfo) DefaultInterface4() uint32
func (*DefaultInterfaceInfo) DefaultInterface6 ¶
func (t *DefaultInterfaceInfo) DefaultInterface6() uint32
func (*DefaultInterfaceInfo) DefaultInterfaceName4 ¶
func (t *DefaultInterfaceInfo) DefaultInterfaceName4() string
func (*DefaultInterfaceInfo) DefaultInterfaceName6 ¶
func (t *DefaultInterfaceInfo) DefaultInterfaceName6() string
func (*DefaultInterfaceInfo) HasGlobalIPv6 ¶
func (t *DefaultInterfaceInfo) HasGlobalIPv6() (bool, error)
func (*DefaultInterfaceInfo) Start ¶
func (t *DefaultInterfaceInfo) Start() error
func (*DefaultInterfaceInfo) SupportIPv6 ¶
func (t *DefaultInterfaceInfo) SupportIPv6() int
type InterfaceInfo ¶
func GetPrimaryPhysicalInterface ¶
func GetPrimaryPhysicalInterface() (info *InterfaceInfo, err error)
type MonitorConfig ¶
type MonitorConfig struct {
// contains filtered or unexported fields
}
func (*MonitorConfig) Descriptor
deprecated
func (*MonitorConfig) Descriptor() ([]byte, []int)
Deprecated: Use MonitorConfig.ProtoReflect.Descriptor instead.
func (*MonitorConfig) ProtoMessage ¶
func (*MonitorConfig) ProtoMessage()
func (*MonitorConfig) ProtoReflect ¶
func (x *MonitorConfig) ProtoReflect() protoreflect.Message
func (*MonitorConfig) Reset ¶
func (x *MonitorConfig) Reset()
func (*MonitorConfig) String ¶
func (x *MonitorConfig) String() string
type TunDevice ¶
type TunDeviceWithInfo ¶
type TunDeviceWithInfo interface {
TunDevice
IP4() netip.Addr
IP6() netip.Addr
DnsServers() []netip.Addr
}
func NewTun0 ¶
func NewTun0(config *TunOption) (TunDeviceWithInfo, error)
func NewTunDeviceWithInfo ¶
type TunOption ¶
type TunOption struct {
Ip4 netip.Prefix
Ip6 netip.Prefix
Name string
Mtu uint32
Dns4 []netip.Addr
Dns6 []netip.Addr
Route4 []netip.Prefix
Route6 []netip.Prefix
// path of "wintun", a dir containing dll for each architecture.
// Absolute or relative to cwd. windows only
Path string
Metric uint32
FD int
// Offset is the offset of the packet in the tun device.
Offset int32
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.