Skip to content

Commit

Permalink
Add some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Asim committed Jun 6, 2016
1 parent 05596cf commit 69aa853
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions transport/http_transport.go
Expand Up @@ -410,14 +410,17 @@ func (h *httpTransport) Listen(addr string, opts ...ListenOption) (Listener, err
fn := func(addr string) (net.Listener, error) {
if config == nil {
hosts := []string{addr}
if h, _, e := net.SplitHostPort(addr); e == nil {
if len(h) == 0 {

// check if its a valid host:port
if host, _, err := net.SplitHostPort(addr); err == nil {
if len(host) == 0 {
hosts = getIPAddrs()
} else {
hosts = []string{h}
hosts = []string{host}
}
}

// generate a certificate
cert, err := mls.Certificate(hosts...)
if err != nil {
return nil, err
Expand Down Expand Up @@ -449,14 +452,6 @@ func (h *httpTransport) String() string {
return "http"
}

func newHTTPTransport(opts ...Option) *httpTransport {
var options Options
for _, o := range opts {
o(&options)
}
return &httpTransport{opts: options}
}

func getIPAddrs() []string {
ifaces, err := net.Interfaces()
if err != nil {
Expand Down Expand Up @@ -492,5 +487,14 @@ func getIPAddrs() []string {
ipAddrs = append(ipAddrs, ip.String())
}
}

return ipAddrs
}

func newHTTPTransport(opts ...Option) *httpTransport {
var options Options
for _, o := range opts {
o(&options)
}
return &httpTransport{opts: options}
}

0 comments on commit 69aa853

Please sign in to comment.