Linux: add option to persist TUN device

This commit is contained in:
Jason
2019-11-06 10:45:07 +08:00
parent 3379244ff7
commit 43a90e00d3
4 changed files with 14 additions and 11 deletions

View File

@@ -8,11 +8,12 @@ import (
"github.com/songgao/water"
)
func OpenTunDevice(name, addr, gw, mask string, dnsServers []string) (io.ReadWriteCloser, error) {
func OpenTunDevice(name, addr, gw, mask string, dnsServers []string, persist bool) (io.ReadWriteCloser, error) {
cfg := water.Config{
DeviceType: water.TUN,
}
cfg.Name = name
cfg.Persist = persist
tunDev, err := water.New(cfg)
if err != nil {
return nil, err