Clean up code inside the configuration loaders

This commit is contained in:
NI
2020-02-08 11:17:56 +08:00
parent 921b887550
commit 9b2513c89d
3 changed files with 26 additions and 31 deletions

View File

@@ -144,6 +144,20 @@ func (f fileCfgCommon) build() (fileCfgCommon, network.Dial, error) {
dialer = sDial
}
if f.OnlyAllowPresetRemotes {
accessList := make(network.AllowedHosts, len(f.Presets))
for _, k := range f.Presets {
if len(k.Host) <= 0 {
continue
}
accessList[k.Host] = struct{}{}
}
dialer = network.AccessControlDial(accessList, dialer)
}
return fileCfgCommon{
HostName: f.HostName,
SharedKey: f.SharedKey,