Commit a62c9889 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 4c91dc61
......@@ -50,25 +50,29 @@ func (nodeUUID NodeUUID) String() string {
// Addr converts network address string into NEO Address
// TODO make neo.Address just string without host:port split
func AddrString(network, addr string) (Address, error) {
// e.g. on unix, pipenet, etc networks there is no host/port split - the address there
// e.g. on unix, networks there is no host/port split - the address there
// is single string -> we put it into .Host and set .Port=0 to indicate such cases
if strings.HasPrefix(network, "tcp") || strings.HasPrefix(network, "udp") {
// networks that have host:port split
host, portstr, err := net.SplitHostPort(addr)
if err != nil {
return Address{}, err
}
// XXX also lookup portstr in /etc/services (net.LookupPort) ?
port, err := strconv.ParseUint(portstr, 10, 16)
if err != nil {
return Address{}, &net.AddrError{Err: "invalid port", Addr: addr}
}
return Address{Host: host, Port: uint16(port)}, nil
switch {
default:
return Address{Host: addr, Port: 0}, nil
// networks that have host:port split
case strings.HasPrefix(network, "tcp"):
case strings.HasPrefix(network, "udp"):
case strings.HasPrefix(network, "pipe"):
}
host, portstr, err := net.SplitHostPort(addr)
if err != nil {
return Address{}, err
}
// XXX also lookup portstr in /etc/services (net.LookupPort) ?
port, err := strconv.ParseUint(portstr, 10, 16)
if err != nil {
return Address{}, &net.AddrError{Err: "invalid port", Addr: addr}
}
return Address{Host: addr, Port: 0}, nil
return Address{Host: host, Port: uint16(port)}, nil
}
// Addr converts net.Addr into NEO Address
......
......@@ -217,7 +217,13 @@ func TestMasterStorage(t *testing.T) {
//)
_ = nettx
tc.Expect(conntx("s:1", "m:1", 1, &neo.RequestIdentification{})) // XXX
tc.Expect(conntx("s:1", "m:1", 1, &neo.RequestIdentification{
NodeType: neo.STORAGE,
NodeUUID: 0,
Address: neo.Address{"s", 0}, //XXX "s:0",
ClusterName: "abc1",
IdTimestamp: 0,
}))
// XXX ... M adjust nodetab...
tc.Expect(conntx("m:1", "s:1", 1, &neo.AcceptIdentification{})) // XXX
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment