Support --host argument to weave launch

Allow the weave router bind to a specific host IP address instead of
INADDR_ANY.
This commit is contained in:
Adam Harrison authored and Matthias Radestock committed 2016-02-02 20:48:49 +00:00
1 parent 4117ef0c50
commit 1e01a31939
3 files changed
+9 -7

No files matched your search

+4 -3
View File
@@ -62,6 +62,7 @@ const (
)
type SleeveOverlay struct {
host string
localPort int
// These fields are set in StartConsumingPackets, and not
@@ -76,12 +77,12 @@ type SleeveOverlay struct {
forwarders map[mesh.PeerName]*sleeveForwarder
}
func NewSleeveOverlay(localPort int) NetworkOverlay {
return &SleeveOverlay{localPort: localPort}
func NewSleeveOverlay(host string, localPort int) NetworkOverlay {
return &SleeveOverlay{host: host, localPort: localPort}
}
func (sleeve *SleeveOverlay) StartConsumingPackets(localPeer *mesh.Peer, peers *mesh.Peers, consumer OverlayConsumer) error {
localAddr, err := net.ResolveUDPAddr("udp4", fmt.Sprint(":", sleeve.localPort))
localAddr, err := net.ResolveUDPAddr("udp4", fmt.Sprint(sleeve.host, ":", sleeve.localPort))
if err != nil {
return err
}