add network for node

This commit is contained in:
ginuerzh
2023-10-09 21:26:41 +08:00
parent bf3b76a273
commit 4525630abb
2 changed files with 14 additions and 0 deletions

View File

@ -26,6 +26,7 @@ type NodeOptions struct {
HostMapper hosts.HostMapper HostMapper hosts.HostMapper
Metadata metadata.Metadata Metadata metadata.Metadata
Host string Host string
Network string
Protocol string Protocol string
HTTP *HTTPNodeSettings HTTP *HTTPNodeSettings
TLS *TLSNodeSettings TLS *TLSNodeSettings
@ -64,6 +65,12 @@ func HostNodeOption(host string) NodeOption {
} }
} }
func NetworkNodeOption(network string) NodeOption {
return func(o *NodeOptions) {
o.Network = network
}
}
func ProtocolNodeOption(protocol string) NodeOption { func ProtocolNodeOption(protocol string) NodeOption {
return func(o *NodeOptions) { return func(o *NodeOptions) {
o.Protocol = protocol o.Protocol = protocol

View File

@ -47,6 +47,13 @@ func (d *NetDialer) Dial(ctx context.Context, network, addr string) (conn net.Co
log = logger.Default() log = logger.Default()
} }
switch network {
case "unix":
netd := net.Dialer{}
return netd.DialContext(ctx, network, addr)
default:
}
deadline := time.Now().Add(timeout) deadline := time.Now().Add(timeout)
ifces := strings.Split(d.Interface, ",") ifces := strings.Split(d.Interface, ",")
for _, ifce := range ifces { for _, ifce := range ifces {