mirror of
https://github.com/hyprspace/hyprspace.git
synced 2026-09-12 19:51:07 +05:00
27 lines
506 B
Go
27 lines
506 B
Go
package tun
|
|
|
|
import "github.com/songgao/water"
|
|
|
|
// TUN is a struct containing the fields necessary
|
|
// to configure a system TUN device. Access the
|
|
// internal TUN device through TUN.Iface
|
|
type TUN struct {
|
|
Iface *water.Interface
|
|
MTU int
|
|
Src string
|
|
Dst string
|
|
}
|
|
|
|
// Apply configures the specified options for a TUN device.
|
|
func (t *TUN) Apply(opts ...Option) error {
|
|
for _, opt := range opts {
|
|
if opt == nil {
|
|
continue
|
|
}
|
|
if err := opt(t); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
}
|