mirror of https://github.com/docker/docs.git
Merge pull request #2053 from allencloud/make-port-0-in-checkAddrFormat-invalid
make port 0 invalid in checkAddrFormat
This commit is contained in:
commit
248cc597c0
|
|
@ -18,7 +18,7 @@ func checkAddrFormat(addr string) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
portNum, err := strconv.Atoi(port)
|
portNum, err := strconv.Atoi(port)
|
||||||
return err == nil && portNum >= 0 && portNum <= 65535
|
return err == nil && portNum > 0 && portNum <= 65535
|
||||||
}
|
}
|
||||||
|
|
||||||
func join(c *cli.Context) {
|
func join(c *cli.Context) {
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ func TestCheckAddrFormat(t *testing.T) {
|
||||||
assert.True(t, checkAddrFormat("hostname:1111"))
|
assert.True(t, checkAddrFormat("hostname:1111"))
|
||||||
assert.True(t, checkAddrFormat("host-name_42:1111"))
|
assert.True(t, checkAddrFormat("host-name_42:1111"))
|
||||||
assert.False(t, checkAddrFormat("1.1.1.1:-1"))
|
assert.False(t, checkAddrFormat("1.1.1.1:-1"))
|
||||||
|
assert.False(t, checkAddrFormat("1.1.1.1:0"))
|
||||||
assert.True(t, checkAddrFormat("1.1.1.1:65535"))
|
assert.True(t, checkAddrFormat("1.1.1.1:65535"))
|
||||||
assert.False(t, checkAddrFormat("1.1.1.1:65536"))
|
assert.False(t, checkAddrFormat("1.1.1.1:65536"))
|
||||||
assert.False(t, checkAddrFormat("1.1.1.1: 4000"))
|
assert.False(t, checkAddrFormat("1.1.1.1: 4000"))
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,14 @@ DISCOVERY="consul://127.0.0.1:5555/test"
|
||||||
[ "$status" -ne 0 ]
|
[ "$status" -ne 0 ]
|
||||||
[[ "${output}" == *"--advertise should be of the form ip:port or hostname:port"* ]]
|
[[ "${output}" == *"--advertise should be of the form ip:port or hostname:port"* ]]
|
||||||
|
|
||||||
|
run swarm join --heartbeat=1s --ttl=10s --delay=1s --advertise=127.0.0.1:0 "$DISCOVERY"
|
||||||
|
[ "$status" -ne 0 ]
|
||||||
|
[[ "${output}" == *"--advertise should be of the form ip:port or hostname:port"* ]]
|
||||||
|
|
||||||
|
run swarm join --heartbeat=1s --ttl=10s --delay=1s --advertise=127.0.0.1:65536 "$DISCOVERY"
|
||||||
|
[ "$status" -ne 0 ]
|
||||||
|
[[ "${output}" == *"--advertise should be of the form ip:port or hostname:port"* ]]
|
||||||
|
|
||||||
# --delay
|
# --delay
|
||||||
run swarm join --heartbeat=1s --ttl=10s --delay=asdf --advertise=127.0.0.1:2376 "$DISCOVERY"
|
run swarm join --heartbeat=1s --ttl=10s --delay=asdf --advertise=127.0.0.1:2376 "$DISCOVERY"
|
||||||
[ "$status" -ne 0 ]
|
[ "$status" -ne 0 ]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue