-
Notifications
You must be signed in to change notification settings - Fork 30
Add checks to quit if DefaultInterface address can't be resolved #133
Conversation
Signed-off-by: Matt Oswalt <[email protected]>
…nd. Don't judge me. Signed-off-by: Matt Oswalt <[email protected]>
Signed-off-by: Matt Oswalt <[email protected]>
Signed-off-by: Matt Oswalt <[email protected]>
Signed-off-by: Matt Oswalt <[email protected]>
Signed-off-by: Matt Oswalt <[email protected]>
Signed-off-by: Matt Oswalt <[email protected]>
Signed-off-by: Matt Oswalt <[email protected]>
Signed-off-by: Matt Oswalt <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a couple comments about simplifying. LGTM 👍
// (map of assets:hashes, lock for asset map) | ||
ListenForAgent(assetProvider) error | ||
// (map of assets:hashes, base asset URL) | ||
ListenForAgent(assetProvider, string) error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would make this ListenForAgent(_ assetProvider, assetURLPrefix string) error
instead of putting the description in the comments. Although it will be a bit inconsistent with the rest of the interface definition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, and I think we already discussed this in a previous review (so that's on me). I opened #137 to do this in a future PR
hostresources/network.go
Outdated
return "", err | ||
} else { | ||
return defaultaddr, nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can simplify this to return getIPOfint(ifname)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup - fixed in 7dec374
} | ||
for _, addr := range addrs { | ||
if ipnet, ok := addr.(*net.IPNet); ok { | ||
if ipnet.IP.To4() != nil { | ||
return ipnet.IP | ||
return ipnet.IP.To4().String(), nil | ||
} | ||
|
||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like net.InterfaceByName()
would make this easier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Damn - and it looks like this has existed for some time. Can't believe I missed that!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool - implemented this and got rid of some of my wheel reinvention in c21de2d
Signed-off-by: Matt Oswalt <[email protected]>
Signed-off-by: Matt Oswalt <[email protected]>
Signed-off-by: Matt Oswalt <[email protected]>
The DefaultInterface configuration is necessary for both the server and the agent. If this process isn't able to successfully determine a usable IP address on either the server or agent, the respective process should quit, instead of moving forward with a value.
This PR enforces this behavior on both the server and agent.
Summary of changes:
Closes #132