Skip to content

Commit

Permalink
make device setting fields public
Browse files Browse the repository at this point in the history
  • Loading branch information
pufferffish committed Jul 22, 2024
1 parent 42a097d commit f8a5d70
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions wireguard.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import (

// DeviceSetting contains the parameters for setting up a tun interface
type DeviceSetting struct {
ipcRequest string
dns []netip.Addr
deviceAddr []netip.Addr
mtu int
IpcRequest string
DNS []netip.Addr
DeviceAddr []netip.Addr
MTU int
}

// CreateIPCRequest serialize the config into an IPC request and DeviceSetting
Expand Down Expand Up @@ -54,7 +54,7 @@ func CreateIPCRequest(conf *DeviceConfig) (*DeviceSetting, error) {
}
}

setting := &DeviceSetting{ipcRequest: request.String(), dns: conf.DNS, deviceAddr: conf.Endpoint, mtu: conf.MTU}
setting := &DeviceSetting{IpcRequest: request.String(), DNS: conf.DNS, DeviceAddr: conf.Endpoint, MTU: conf.MTU}
return setting, nil
}

Expand All @@ -65,12 +65,12 @@ func StartWireguard(conf *DeviceConfig, logLevel int) (*VirtualTun, error) {
return nil, err
}

tun, tnet, err := netstack.CreateNetTUN(setting.deviceAddr, setting.dns, setting.mtu)
tun, tnet, err := netstack.CreateNetTUN(setting.DeviceAddr, setting.DNS, setting.MTU)
if err != nil {
return nil, err
}
dev := device.NewDevice(tun, conn.NewDefaultBind(), device.NewLogger(logLevel, ""))
err = dev.IpcSet(setting.ipcRequest)
err = dev.IpcSet(setting.IpcRequest)
if err != nil {
return nil, err
}
Expand All @@ -84,7 +84,7 @@ func StartWireguard(conf *DeviceConfig, logLevel int) (*VirtualTun, error) {
Tnet: tnet,
Dev: dev,
Conf: conf,
SystemDNS: len(setting.dns) == 0,
SystemDNS: len(setting.DNS) == 0,
PingRecord: make(map[string]uint64),
}, nil
}

0 comments on commit f8a5d70

Please sign in to comment.