improve addr validation

Signed-off-by: Victor Vieux <vieux@docker.com>
This commit is contained in:
Victor Vieux 2015-01-12 22:18:59 +00:00
parent c76c29fd11
commit 3cc61b728f
1 changed files with 2 additions and 3 deletions

View File

@ -1,7 +1,7 @@
package main
import (
"strings"
"regexp"
"time"
log "github.com/Sirupsen/logrus"
@ -21,8 +21,7 @@ func join(c *cli.Context) {
}
addr := c.String("addr")
addrParts := strings.SplitN(addr, ":", 2)
if len(addrParts) != 2 {
if m, _ := regexp.MatchString("^[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}:[0-9]{1,5}$", addr); !m {
log.Fatal("--addr should be of the form ip:port")
}