mirror of https://github.com/docker/docs.git
make port 0 invalid in checkAddrFormat
Signed-off-by: Sun Hongliang <allen.sun@daocloud.io>
This commit is contained in:
parent
d2bbd6bc19
commit
e60b93aef3
|
@ -18,7 +18,7 @@ func checkAddrFormat(addr string) bool {
|
|||
return false
|
||||
}
|
||||
portNum, err := strconv.Atoi(port)
|
||||
return err == nil && portNum >= 0 && portNum <= 65535
|
||||
return err == nil && portNum > 0 && portNum <= 65535
|
||||
}
|
||||
|
||||
func join(c *cli.Context) {
|
||||
|
|
|
@ -25,6 +25,7 @@ func TestCheckAddrFormat(t *testing.T) {
|
|||
assert.True(t, checkAddrFormat("hostname: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:0"))
|
||||
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: 4000"))
|
||||
|
|
|
@ -15,6 +15,14 @@ DISCOVERY="consul://127.0.0.1:5555/test"
|
|||
[ "$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: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
|
||||
run swarm join --heartbeat=1s --ttl=10s --delay=asdf --advertise=127.0.0.1:2376 "$DISCOVERY"
|
||||
[ "$status" -ne 0 ]
|
||||
|
|
Loading…
Reference in New Issue