lib/connections, lib/config: Bandwidth throttling per remote device (fixes #4516) (#4603)

This commit is contained in:
qepasa
2018-03-26 12:01:59 +02:00
committed by Jakob Borg
parent 3c920c61e9
commit 2621c6fd2f
6 changed files with 360 additions and 39 deletions

View File

@@ -797,3 +797,12 @@ func filterURLSchemePrefix(addrs []string, prefix string) []string {
}
return addrs
}
// mapDeviceConfigs returns a map of device ID to device configuration for the given configuration.
func (cfg *Configuration) DeviceMap() map[protocol.DeviceID]DeviceConfiguration {
m := make(map[protocol.DeviceID]DeviceConfiguration, len(cfg.Devices))
for _, dev := range cfg.Devices {
m[dev.DeviceID] = dev
}
return m
}

View File

@@ -20,6 +20,8 @@ type DeviceConfiguration struct {
Paused bool `xml:"paused" json:"paused"`
AllowedNetworks []string `xml:"allowedNetwork,omitempty" json:"allowedNetworks"`
AutoAcceptFolders bool `xml:"autoAcceptFolders" json:"autoAcceptFolders"`
MaxSendKbps int `xml:"maxSendKbps" json:"maxSendKbps"`
MaxRecvKbps int `xml:"maxRecvKbps" json:"maxRecvKbps"`
}
func NewDeviceConfiguration(id protocol.DeviceID, name string) DeviceConfiguration {