Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
a62c9889
Commit
a62c9889
authored
Jul 17, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
4c91dc61
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
16 deletions
+26
-16
go/neo/proto-str.go
go/neo/proto-str.go
+19
-15
go/neo/server/cluster_test.go
go/neo/server/cluster_test.go
+7
-1
No files found.
go/neo/proto-str.go
View file @
a62c9889
...
...
@@ -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
...
...
go/neo/server/cluster_test.go
View file @
a62c9889
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment