Skip to content

Commit

Permalink
replace old value of interface with the new one
Browse files Browse the repository at this point in the history
  • Loading branch information
nazarewk committed Mar 2, 2023
1 parent 1c5162e commit a6080bd
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions client/internal/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,10 @@ func ReadConfig(input ConfigInput) (*Config, error) {
config.WgPort = iface.DefaultWgPort
refresh = true
}
if config.WgIface == "" && input.WgIface == "" {

oldIface := config.WgIface

if oldIface == "" && input.WgIface == "" {
log.Infof("using default Wireguard Interface Name: %#v ", iface.WgInterfaceDefault)
config.WgIface = iface.WgInterfaceDefault
refresh = true
Expand All @@ -249,7 +252,18 @@ func ReadConfig(input ConfigInput) (*Config, error) {
}

if !slices.Contains(config.IFaceBlackList, config.WgIface) {
newBlacklist := append([]string{config.WgIface}, config.IFaceBlackList...)
var newBlacklist []string
replaced := false
for _, ifc := range config.IFaceBlackList {
if ifc == oldIface {
ifc = config.WgIface
replaced = true
}
newBlacklist = append(newBlacklist, ifc)
}
if !replaced {
newBlacklist = append(newBlacklist, config.WgIface)
}
log.Infof("prepending Wireguard Interface Name to interface blacklist %#v, updated to %v (old value %v)", config.WgIface, newBlacklist, config.IFaceBlackList)
config.IFaceBlackList = newBlacklist
refresh = true
Expand Down

0 comments on commit a6080bd

Please sign in to comment.