2015-02-13 11:46:14 -08:00
|
|
|
// +build windows
|
2015-04-17 18:05:30 +08:00
|
|
|
|
2015-02-13 11:46:14 -08:00
|
|
|
package server
|
|
|
|
|
|
|
|
import (
|
2015-03-31 13:37:49 -07:00
|
|
|
"errors"
|
|
|
|
"net"
|
2015-04-17 14:32:18 -07:00
|
|
|
"net/http"
|
2015-02-13 11:46:14 -08:00
|
|
|
)
|
|
|
|
|
|
|
|
// NewServer sets up the required Server and does protocol specific checking.
|
2015-10-05 09:32:08 -07:00
|
|
|
func (s *Server) newServer(proto, addr string) ([]*HTTPServer, error) {
|
2015-03-31 13:37:49 -07:00
|
|
|
var (
|
2015-05-29 21:25:27 -07:00
|
|
|
ls []net.Listener
|
2015-03-31 13:37:49 -07:00
|
|
|
)
|
2015-02-13 11:46:14 -08:00
|
|
|
switch proto {
|
|
|
|
case "tcp":
|
2015-07-29 20:08:51 -07:00
|
|
|
l, err := s.initTCPSocket(addr)
|
2015-05-20 16:48:39 -07:00
|
|
|
if err != nil {
|
2015-03-31 13:37:49 -07:00
|
|
|
return nil, err
|
|
|
|
}
|
2015-05-29 21:25:27 -07:00
|
|
|
ls = append(ls, l)
|
2015-05-15 13:05:35 -07:00
|
|
|
|
2015-02-13 11:46:14 -08:00
|
|
|
default:
|
|
|
|
return nil, errors.New("Invalid protocol format. Windows only supports tcp.")
|
|
|
|
}
|
2015-05-29 21:25:27 -07:00
|
|
|
|
2015-10-05 09:32:08 -07:00
|
|
|
var res []*HTTPServer
|
2015-05-29 21:25:27 -07:00
|
|
|
for _, l := range ls {
|
2015-07-29 20:08:51 -07:00
|
|
|
res = append(res, &HTTPServer{
|
2015-05-29 21:25:27 -07:00
|
|
|
&http.Server{
|
2015-10-05 09:32:08 -07:00
|
|
|
Addr: addr,
|
2015-05-29 21:25:27 -07:00
|
|
|
},
|
|
|
|
l,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
return res, nil
|
|
|
|
|
2015-02-13 11:46:14 -08:00
|
|
|
}
|
2015-02-13 15:08:42 -08:00
|
|
|
|
2015-05-15 13:05:35 -07:00
|
|
|
func allocateDaemonPort(addr string) error {
|
|
|
|
return nil
|
|
|
|
}
|