introduce '-nodiscovery' option to disable automatic peer discovery
Closes #847.
This commit is contained in:
1 parent
5f5c0079d3
commit
8f85a07ecc
7 files changed
+40
-19
No files matched your search
@@ -48,6 +48,7 @@ func main() {
|
|||||||
pktdebug bool
|
pktdebug bool
|
||||||
prof string
|
prof string
|
||||||
bufSzMB int
|
bufSzMB int
|
||||||
|
noDiscovery bool
|
||||||
httpAddr string
|
httpAddr string
|
||||||
iprangeCIDR string
|
iprangeCIDR string
|
||||||
peerCount int
|
peerCount int
|
||||||
@@ -66,6 +67,7 @@ func main() {
|
|||||||
flag.BoolVar(&pktdebug, "pktdebug", false, "enable per-packet debug logging")
|
flag.BoolVar(&pktdebug, "pktdebug", false, "enable per-packet debug logging")
|
||||||
flag.StringVar(&prof, "profile", "", "enable profiling and write profiles to given path")
|
flag.StringVar(&prof, "profile", "", "enable profiling and write profiles to given path")
|
||||||
flag.IntVar(&config.ConnLimit, "connlimit", 30, "connection limit (0 for unlimited)")
|
flag.IntVar(&config.ConnLimit, "connlimit", 30, "connection limit (0 for unlimited)")
|
||||||
|
flag.BoolVar(&noDiscovery, "nodiscovery", false, "disable peer discovery")
|
||||||
flag.IntVar(&bufSzMB, "bufsz", 8, "capture buffer size in MB")
|
flag.IntVar(&bufSzMB, "bufsz", 8, "capture buffer size in MB")
|
||||||
flag.StringVar(&httpAddr, "httpaddr", fmt.Sprintf(":%d", weave.HTTPPort), "address to bind HTTP interface to (disabled if blank, absolute path indicates unix domain socket)")
|
flag.StringVar(&httpAddr, "httpaddr", fmt.Sprintf(":%d", weave.HTTPPort), "address to bind HTTP interface to (disabled if blank, absolute path indicates unix domain socket)")
|
||||||
flag.StringVar(&iprangeCIDR, "iprange", "", "IP address range to allocate within, in CIDR notation")
|
flag.StringVar(&iprangeCIDR, "iprange", "", "IP address range to allocate within, in CIDR notation")
|
||||||
@@ -129,6 +131,7 @@ func main() {
|
|||||||
|
|
||||||
config.BufSz = bufSzMB * 1024 * 1024
|
config.BufSz = bufSzMB * 1024 * 1024
|
||||||
config.LogFrame = logFrameFunc(pktdebug)
|
config.LogFrame = logFrameFunc(pktdebug)
|
||||||
|
config.PeerDiscovery = !noDiscovery
|
||||||
|
|
||||||
router := weave.NewRouter(config, name, nickName)
|
router := weave.NewRouter(config, name, nickName)
|
||||||
log.Println("Our name is", router.Ourself)
|
log.Println("Our name is", router.Ourself)
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ type ConnectionMaker struct {
|
|||||||
ourself *LocalPeer
|
ourself *LocalPeer
|
||||||
peers *Peers
|
peers *Peers
|
||||||
port int
|
port int
|
||||||
|
discovery bool
|
||||||
targets map[string]*Target
|
targets map[string]*Target
|
||||||
directPeers peerAddrs
|
directPeers peerAddrs
|
||||||
actionChan chan<- ConnectionMakerAction
|
actionChan chan<- ConnectionMakerAction
|
||||||
@@ -35,11 +36,12 @@ type Target struct {
|
|||||||
|
|
||||||
type ConnectionMakerAction func() bool
|
type ConnectionMakerAction func() bool
|
||||||
|
|
||||||
func NewConnectionMaker(ourself *LocalPeer, peers *Peers, port int) *ConnectionMaker {
|
func NewConnectionMaker(ourself *LocalPeer, peers *Peers, port int, discovery bool) *ConnectionMaker {
|
||||||
return &ConnectionMaker{
|
return &ConnectionMaker{
|
||||||
ourself: ourself,
|
ourself: ourself,
|
||||||
peers: peers,
|
peers: peers,
|
||||||
port: port,
|
port: port,
|
||||||
|
discovery: discovery,
|
||||||
directPeers: peerAddrs{},
|
directPeers: peerAddrs{},
|
||||||
targets: make(map[string]*Target)}
|
targets: make(map[string]*Target)}
|
||||||
}
|
}
|
||||||
@@ -217,7 +219,9 @@ func (cm *ConnectionMaker) checkStateAndAttemptConnections() time.Duration {
|
|||||||
|
|
||||||
// Add targets for peers that someone else is connected to, but we
|
// Add targets for peers that someone else is connected to, but we
|
||||||
// aren't
|
// aren't
|
||||||
cm.addPeerTargets(ourConnectedPeers, addTarget)
|
if cm.discovery {
|
||||||
|
cm.addPeerTargets(ourConnectedPeers, addTarget)
|
||||||
|
}
|
||||||
|
|
||||||
return cm.connectToTargets(validTarget, directTarget)
|
return cm.connectToTargets(validTarget, directTarget)
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-9
@@ -8,16 +8,17 @@ import (
|
|||||||
|
|
||||||
func (router *Router) StatusJSON(version string) ([]byte, error) {
|
func (router *Router) StatusJSON(version string) ([]byte, error) {
|
||||||
return json.Marshal(struct {
|
return json.Marshal(struct {
|
||||||
Version string
|
Version string
|
||||||
Encryption bool
|
Encryption bool
|
||||||
Name string
|
PeerDiscovery bool
|
||||||
NickName string
|
Name string
|
||||||
Interface string
|
NickName string
|
||||||
Macs *MacCache
|
Interface string
|
||||||
Peers *Peers
|
Macs *MacCache
|
||||||
Routes *Routes
|
Peers *Peers
|
||||||
|
Routes *Routes
|
||||||
ConnectionMakerStatus
|
ConnectionMakerStatus
|
||||||
}{version, router.UsingPassword(), router.Ourself.Name.String(), router.Ourself.NickName, fmt.Sprintf("%v", router.Iface), router.Macs, router.Peers, router.Routes, router.ConnectionMaker.Status()})
|
}{version, router.UsingPassword(), router.PeerDiscovery, router.Ourself.Name.String(), router.Ourself.NickName, fmt.Sprintf("%v", router.Iface), router.Macs, router.Peers, router.Routes, router.ConnectionMaker.Status()})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cache *MacCache) MarshalJSON() ([]byte, error) {
|
func (cache *MacCache) MarshalJSON() ([]byte, error) {
|
||||||
|
|||||||
+9
-7
@@ -29,12 +29,13 @@ const (
|
|||||||
type LogFrameFunc func(string, []byte, *layers.Ethernet)
|
type LogFrameFunc func(string, []byte, *layers.Ethernet)
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Port int
|
Port int
|
||||||
Iface *net.Interface
|
Iface *net.Interface
|
||||||
Password []byte
|
Password []byte
|
||||||
ConnLimit int
|
ConnLimit int
|
||||||
BufSz int
|
PeerDiscovery bool
|
||||||
LogFrame LogFrameFunc
|
BufSz int
|
||||||
|
LogFrame LogFrameFunc
|
||||||
}
|
}
|
||||||
|
|
||||||
type Router struct {
|
type Router struct {
|
||||||
@@ -76,7 +77,7 @@ func NewRouter(config Config, name PeerName, nickName string) *Router {
|
|||||||
router.Peers = NewPeers(router.Ourself, onPeerGC)
|
router.Peers = NewPeers(router.Ourself, onPeerGC)
|
||||||
router.Peers.FetchWithDefault(router.Ourself.Peer)
|
router.Peers.FetchWithDefault(router.Ourself.Peer)
|
||||||
router.Routes = NewRoutes(router.Ourself, router.Peers)
|
router.Routes = NewRoutes(router.Ourself, router.Peers)
|
||||||
router.ConnectionMaker = NewConnectionMaker(router.Ourself, router.Peers, router.Port)
|
router.ConnectionMaker = NewConnectionMaker(router.Ourself, router.Peers, router.Port, router.PeerDiscovery)
|
||||||
router.TopologyGossip = router.NewGossip("topology", router)
|
router.TopologyGossip = router.NewGossip("topology", router)
|
||||||
return router
|
return router
|
||||||
}
|
}
|
||||||
@@ -116,6 +117,7 @@ func (router *Router) Status() string {
|
|||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
fmt.Fprintln(&buf, "Our name is", router.Ourself)
|
fmt.Fprintln(&buf, "Our name is", router.Ourself)
|
||||||
fmt.Fprintln(&buf, "Encryption", OnOff(router.UsingPassword()))
|
fmt.Fprintln(&buf, "Encryption", OnOff(router.UsingPassword()))
|
||||||
|
fmt.Fprintln(&buf, "Peer discovery", OnOff(router.PeerDiscovery))
|
||||||
fmt.Fprintln(&buf, "Sniffing traffic on", router.Iface)
|
fmt.Fprintln(&buf, "Sniffing traffic on", router.Iface)
|
||||||
fmt.Fprintf(&buf, "MACs:\n%s", router.Macs)
|
fmt.Fprintf(&buf, "MACs:\n%s", router.Macs)
|
||||||
fmt.Fprintf(&buf, "Peers:\n%s", router.Peers)
|
fmt.Fprintf(&buf, "Peers:\n%s", router.Peers)
|
||||||
|
|||||||
@@ -377,6 +377,11 @@ and the new hosts will be added, when one runs
|
|||||||
|
|
||||||
host# weave connect --replace $NEW_HOST1 $NEW_HOST2
|
host# weave connect --replace $NEW_HOST1 $NEW_HOST2
|
||||||
|
|
||||||
|
For complete control over the peer topology, automatic discovery can
|
||||||
|
be disabled with the `-nodiscovery` option to `weave launch`. In this
|
||||||
|
mode, weave will only connect to the addresses specified at launch
|
||||||
|
time and with `weave connect`.
|
||||||
|
|
||||||
### <a name="container-mobility"></a>Container mobility
|
### <a name="container-mobility"></a>Container mobility
|
||||||
|
|
||||||
Containers can be moved between hosts without requiring any
|
Containers can be moved between hosts without requiring any
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ This produces output like:
|
|||||||
weave router 0.7.0
|
weave router 0.7.0
|
||||||
Our name is 7a:f4:56:87:76:3b(weave01)
|
Our name is 7a:f4:56:87:76:3b(weave01)
|
||||||
Encryption off
|
Encryption off
|
||||||
|
Peer discovery on
|
||||||
Sniffing traffic on &{39 65535 ethwe ae:e3:07:9c:8c:d4 up|broadcast|multicast}
|
Sniffing traffic on &{39 65535 ethwe ae:e3:07:9c:8c:d4 up|broadcast|multicast}
|
||||||
MACs:
|
MACs:
|
||||||
ba:8c:b9:dc:e1:c9 -> 7a:f4:56:87:76:3b(weave01) (2014-10-23 16:39:19.482338935 +0000 UTC)
|
ba:8c:b9:dc:e1:c9 -> 7a:f4:56:87:76:3b(weave01) (2014-10-23 16:39:19.482338935 +0000 UTC)
|
||||||
@@ -104,6 +105,10 @@ The 'Encryption' line indicates whether
|
|||||||
[encryption](features.html#security) is in use for communication
|
[encryption](features.html#security) is in use for communication
|
||||||
between peers.
|
between peers.
|
||||||
|
|
||||||
|
The 'Peer discovery' line indicates whether
|
||||||
|
[automatic peer discovery](features.html#dynamic-topologies) is
|
||||||
|
enabled (which is the default).
|
||||||
|
|
||||||
The 'MACs' section lists all MAC addresses known to this router. These
|
The 'MACs' section lists all MAC addresses known to this router. These
|
||||||
identify containers in the weave network, as well as points for
|
identify containers in the weave network, as well as points for
|
||||||
[host network integration](features.html#host-network-integration). For
|
[host network integration](features.html#host-network-integration). For
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ CIDR_REGEXP="$IP_REGEXP/[0-9]{1,2}"
|
|||||||
usage() {
|
usage() {
|
||||||
echo "Usage:"
|
echo "Usage:"
|
||||||
echo "weave setup"
|
echo "weave setup"
|
||||||
echo "weave launch [-password <password>] [-nickname <nickname>] [-iprange <cidr>] <peer> ..."
|
echo "weave launch [-password <password>] [-nickname <nickname>] [-nodiscovery]"
|
||||||
|
echo " [-iprange <cidr>] <peer> ..."
|
||||||
echo "weave launch-dns <cidr>"
|
echo "weave launch-dns <cidr>"
|
||||||
echo "weave launch-proxy [-H <docker_endpoint>] [--with-dns] [--with-ipam]"
|
echo "weave launch-proxy [-H <docker_endpoint>] [--with-dns] [--with-ipam]"
|
||||||
echo "weave connect [--replace] [<peer> ...]"
|
echo "weave connect [--replace] [<peer> ...]"
|
||||||
|
|||||||
Reference in new issue
Block a user