mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #2502 from hamo/unlink_err_v4
rewrite protocol check with switch-case in Server.Daemon
This commit is contained in:
commit
c5d4459a02
1 changed files with 7 additions and 4 deletions
11
server.go
11
server.go
|
@ -71,13 +71,16 @@ func (srv *Server) Daemon() error {
|
||||||
chErrors := make(chan error, len(protoAddrs))
|
chErrors := make(chan error, len(protoAddrs))
|
||||||
for _, protoAddr := range protoAddrs {
|
for _, protoAddr := range protoAddrs {
|
||||||
protoAddrParts := strings.SplitN(protoAddr, "://", 2)
|
protoAddrParts := strings.SplitN(protoAddr, "://", 2)
|
||||||
if protoAddrParts[0] == "unix" {
|
switch protoAddrParts[0] {
|
||||||
syscall.Unlink(protoAddrParts[1])
|
case "unix":
|
||||||
} else if protoAddrParts[0] == "tcp" {
|
if err := syscall.Unlink(protoAddrParts[1]); err != nil && !os.IsNotExist(err) {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
case "tcp":
|
||||||
if !strings.HasPrefix(protoAddrParts[1], "127.0.0.1") {
|
if !strings.HasPrefix(protoAddrParts[1], "127.0.0.1") {
|
||||||
log.Println("/!\\ DON'T BIND ON ANOTHER IP ADDRESS THAN 127.0.0.1 IF YOU DON'T KNOW WHAT YOU'RE DOING /!\\")
|
log.Println("/!\\ DON'T BIND ON ANOTHER IP ADDRESS THAN 127.0.0.1 IF YOU DON'T KNOW WHAT YOU'RE DOING /!\\")
|
||||||
}
|
}
|
||||||
} else {
|
default:
|
||||||
return fmt.Errorf("Invalid protocol format.")
|
return fmt.Errorf("Invalid protocol format.")
|
||||||
}
|
}
|
||||||
go func() {
|
go func() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue