435c0d9fc8
This PR switches the Nomad repository from using govendor to Go modules for managing dependencies. Aspects of the Nomad workflow remain pretty much the same. The usual Makefile targets should continue to work as they always did. The API submodule simply defers to the parent Nomad version on the repository, keeping the semantics of API versioning that currently exists.
44 lines
816 B
Go
44 lines
816 B
Go
//+build !windows
|
|
|
|
package dbus
|
|
|
|
import (
|
|
"errors"
|
|
"net"
|
|
)
|
|
|
|
func init() {
|
|
transports["tcp"] = newTcpTransport
|
|
}
|
|
|
|
func tcpFamily(keys string) (string, error) {
|
|
switch getKey(keys, "family") {
|
|
case "":
|
|
return "tcp", nil
|
|
case "ipv4":
|
|
return "tcp4", nil
|
|
case "ipv6":
|
|
return "tcp6", nil
|
|
default:
|
|
return "", errors.New("dbus: invalid tcp family (must be ipv4 or ipv6)")
|
|
}
|
|
}
|
|
|
|
func newTcpTransport(keys string) (transport, error) {
|
|
host := getKey(keys, "host")
|
|
port := getKey(keys, "port")
|
|
if host == "" || port == "" {
|
|
return nil, errors.New("dbus: unsupported address (must set host and port)")
|
|
}
|
|
|
|
protocol, err := tcpFamily(keys)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
socket, err := net.Dial(protocol, net.JoinHostPort(host, port))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return NewConn(socket)
|
|
}
|