Add --proxy option to enable/disable proxy.

Weave Net initially had the ability to start a single component at a time with `launch-proxy` and `launch-router`.
This change enables this again via `--proxy=false` despite the merge of the proxy and the router.
Note that by default:
- `launch` passes `--proxy` which enables the proxy and keeps behaviour consistent with `launch` pre-merge,
- `weaver` defaults `--proxy` to `false` which disables the proxy and keeps behaviour consistent with `weaver` pre-merge (as it was `weaveproxy`'s responsibility).
This commit is contained in:
Marc CARRE authored and Bryan Boreham committed 2017-05-10 10:25:36 +00:00
1 parent 2c7693b2c5
commit 5cf973f03a
3 files changed
+16 -11

No files matched your search

+12 -9
View File
@@ -252,16 +252,18 @@ func main() {
}
config.ProtocolMinVersion = byte(protocolMinVersion)
// Start Weave Proxy:
proxy, err := weaveproxy.NewProxy(*proxyConfig)
if err != nil {
Log.Fatalf("Could not start proxy: %s", err)
if proxyConfig.Enabled {
// Start Weave Proxy:
proxy, err := weaveproxy.NewProxy(*proxyConfig)
if err != nil {
Log.Fatalf("Could not start proxy: %s", err)
}
defer proxy.Stop()
listeners := proxy.Listen()
proxy.AttachExistingContainers()
go proxy.Serve(listeners)
go proxy.ListenAndServeStatus("/home/weave/status.sock")
}
defer proxy.Stop()
listeners := proxy.Listen()
proxy.AttachExistingContainers()
go proxy.Serve(listeners)
go proxy.ListenAndServeStatus("/home/weave/status.sock")
if pktdebug {
networkConfig.PacketLogging = packetLogging{}
@@ -521,6 +523,7 @@ func configureProxy(version string, defaultDockerHost string) *weaveproxy.Config
DockerBridge: getenvOrDefault("DOCKER_BRIDGE", "docker0"),
DockerHost: defaultDockerHost,
}
mflag.BoolVar(&proxyConfig.Enabled, []string{"-proxy"}, false, "instruct Weave Net to start its Docker proxy")
mflagext.ListVar(&proxyConfig.ListenAddrs, []string{"H"}, nil, "addresses on which to listen")
mflag.StringVar(&proxyConfig.HostnameFromLabel, []string{"-hostname-from-label"}, "", "Key of container label from which to obtain the container's hostname")
mflag.StringVar(&proxyConfig.HostnameMatch, []string{"-hostname-match"}, "(.*)", "Regexp pattern to apply on container names (e.g. '^aws-[0-9]+-(.*)$')")
+1
View File
@@ -50,6 +50,7 @@ func dockerAPIEndpoint(endpoint string) *regexp.Regexp {
}
type Config struct {
Enabled bool
HostnameFromLabel string
HostnameMatch string
HostnameReplacement string
+3 -2
View File
@@ -48,7 +48,7 @@ weave launch [--password <pass>] [--trusted-subnets <cidr>,...]
[--no-restart] [--resume] [--no-discovery] [--no-dns]
[--ipalloc-init <mode>]
[--ipalloc-range <cidr> [--ipalloc-default-subnet <cidr>]]
[--plugin]
[--plugin=false] [--proxy=false]
[-H <endpoint>] [--without-dns] [--no-multicast-route]
[--no-rewrite-hosts] [--no-default-ipalloc]
[--hostname-from-label <labelkey>]
@@ -1509,7 +1509,8 @@ EOF
deprecation_warnings "$@"
check_not_running router $CONTAINER_NAME $BASE_IMAGE
check_not_running_plugin_v2
launch --plugin "$@"
# Plugin and proxy are started by default. Should users additionally pass --plugin=false or --proxy=false, their overrides will take precedence when parsed by Go.
launch --plugin --proxy "$@"
echo "$WEAVE_CONTAINER"
;;
env)