wg-portal/internal/wireguard/config.go

18 lines
863 B
Go
Raw Normal View History

2020-11-05 13:37:51 -05:00
package wireguard
2021-03-22 08:00:02 -04:00
import "github.com/h44z/wg-portal/internal/common"
2020-11-05 13:37:51 -05:00
type Config struct {
DeviceNames []string `yaml:"devices" envconfig:"WG_DEVICES"` // managed devices
2021-03-22 08:00:02 -04:00
DefaultDeviceName string `yaml:"devices" envconfig:"WG_DEFAULT_DEVICE"` // this device is used for auto-created peers, use GetDefaultDeviceName() to access this field
ConfigDirectoryPath string `yaml:"configDirectory" envconfig:"WG_CONFIG_PATH"` // optional, if set, updates will be written to this path, filename: <devicename>.conf
ManageIPAddresses bool `yaml:"manageIPAddresses" envconfig:"MANAGE_IPS"` // handle ip-address setup of interface
2020-11-05 13:37:51 -05:00
}
2021-03-22 08:00:02 -04:00
func (c Config) GetDefaultDeviceName() string {
if c.DefaultDeviceName == "" || !common.ListContains(c.DeviceNames, c.DefaultDeviceName) {
return c.DeviceNames[0]
}
return c.DefaultDeviceName
}