diff --git a/commands/resource.go b/commands/resource.go index 76ec4ef..0842fad 100644 --- a/commands/resource.go +++ b/commands/resource.go @@ -352,15 +352,6 @@ func addNode(c *cli.Context) error { nodename = n } - endpoint := c.String("endpoint") - if endpoint == "" { - ip := getLocalIP() - if ip == "" { - return cli.Exit(fmt.Errorf("unable to get local ip"), -1) - } - endpoint = fmt.Sprintf("tcp://%s:2376", ip) - } - ca := c.String("ca") if ca == "" { defaultPath := "/etc/docker/tls/ca.crt" @@ -409,6 +400,19 @@ func addNode(c *cli.Context) error { keyContent = string(f) } + endpoint := c.String("endpoint") + if endpoint == "" { + ip := getLocalIP() + if ip == "" { + return cli.Exit(fmt.Errorf("unable to get local ip"), -1) + } + port := 2376 + if caContent == "" { + port = 2375 + } + endpoint = fmt.Sprintf("tcp://%s:%d", ip, port) + } + share := c.Int64("share") if share == 0 { share = int64(100)