mirror of https://github.com/docker/docs.git
rewrite protocol check with switch-case in Server.Daemon
This commit is contained in:
parent
e3c49843d7
commit
7848007c3a
18
server.go
18
server.go
|
@ -6,10 +6,10 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/dotcloud/docker/auth"
|
"github.com/dotcloud/docker/auth"
|
||||||
|
"github.com/dotcloud/docker/engine"
|
||||||
"github.com/dotcloud/docker/gograph"
|
"github.com/dotcloud/docker/gograph"
|
||||||
"github.com/dotcloud/docker/registry"
|
"github.com/dotcloud/docker/registry"
|
||||||
"github.com/dotcloud/docker/utils"
|
"github.com/dotcloud/docker/utils"
|
||||||
"github.com/dotcloud/docker/engine"
|
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
|
@ -17,14 +17,14 @@ import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"os/signal"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
|
||||||
"syscall"
|
"syscall"
|
||||||
"os/signal"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (srv *Server) Close() error {
|
func (srv *Server) Close() error {
|
||||||
|
@ -70,13 +70,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() {
|
||||||
|
@ -92,7 +95,6 @@ func (srv *Server) Daemon() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (srv *Server) DockerVersion() APIVersion {
|
func (srv *Server) DockerVersion() APIVersion {
|
||||||
return APIVersion{
|
return APIVersion{
|
||||||
Version: VERSION,
|
Version: VERSION,
|
||||||
|
|
Loading…
Reference in New Issue