Refactor common.GetBridgeNetDev

- Optimize. Use LinkByName instead of iterating over list of available
  links. Linux does not support interfaces with the same names.
- Remove unnecessary indirection in utility functions which return
  common.NetDev.
This commit is contained in:
Martynas Pumputis committed 2016-07-05 15:12:39 +01:00
1 parent e5c23bf9f5
commit 05baa566c6
6 files changed
+40 -19

No files matched your search

+3 -3
View File
@@ -149,14 +149,14 @@ func NewProxy(c Config) (*Proxy, error) {
p.client = client.Client
if !p.WithoutDNS {
netDevs, err := common.GetBridgeNetDev(c.DockerBridge)
netDev, err := common.GetBridgeNetDev(c.DockerBridge)
if err != nil {
return nil, err
}
if len(netDevs) != 1 || len(netDevs[0].CIDRs) != 1 {
if len(netDev.CIDRs) != 1 {
return nil, fmt.Errorf("Could not obtain address of %s", c.DockerBridge)
}
p.dockerBridgeIP = netDevs[0].CIDRs[0].IP.String()
p.dockerBridgeIP = netDev.CIDRs[0].IP.String()
}
p.hostnameMatchRegexp, err = regexp.Compile(c.HostnameMatch)