Skip to content

Commit

Permalink
opts.IPVal returns an error on incorrect input
Browse files Browse the repository at this point in the history
Signed-off-by: Solomon Hykes <[email protected]>
  • Loading branch information
Solomon Hykes committed Aug 13, 2014
1 parent 353b7c8 commit ca11b77
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
6 changes: 0 additions & 6 deletions docker/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@ func mainDaemon() {
if !daemonCfg.EnableIptables && !daemonCfg.InterContainerCommunication {
log.Fatal("You specified --iptables=false with --icc=false. ICC uses iptables to function. Please set --icc or --iptables to true.")
}

// FIXME: move this validation to opts.IpOpt
if daemonCfg.DefaultIp == nil {
log.Fatalf("Specified --ip is not in correct format \"0.0.0.0\".")
}

eng := engine.New()
signal.Trap(eng.Shutdown)
// Load builtins
Expand Down
7 changes: 5 additions & 2 deletions opts/ip.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package opts

import (
"fmt"
"net"
)

Expand All @@ -17,8 +18,10 @@ func NewIpOpt(ref *net.IP, defaultVal string) *IpOpt {
}

func (o *IpOpt) Set(val string) error {
// FIXME: return a parse error if the value is not a valid IP?
// We are not changing this now to preserve behavior while refactoring.
ip := net.ParseIP(val)
if ip == nil {
return fmt.Errorf("incorrect IP format")
}
(*o.IP) = net.ParseIP(val)
return nil
}
Expand Down

0 comments on commit ca11b77

Please sign in to comment.