Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Levin Zimmermann
neoppod
Commits
a024d393
Commit
a024d393
authored
Apr 26, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
b50f771e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
17 deletions
+20
-17
go/neo/server.go
go/neo/server.go
+2
-2
go/neo/storage.go
go/neo/storage.go
+18
-15
No files found.
go/neo/server.go
View file @
a024d393
...
...
@@ -82,8 +82,6 @@ func ListenAndServe(ctx context.Context, net_, laddr string, srv Server) error {
// Identify identifies peer on the link
// it expects peer to send RequestIdentification packet and TODO
func
Identify
(
link
*
NodeLink
)
(
nodeInfo
RequestIdentification
/*TODO -> NodeInfo*/
,
err
error
)
{
nodeInfo
:=
RequestIdentification
{}
// the first conn must come with RequestIdentification packet
conn
,
err
:=
link
.
Accept
()
if
err
!=
nil
{
...
...
@@ -112,6 +110,8 @@ func Identify(link *NodeLink) (nodeInfo RequestIdentification /*TODO -> NodeInfo
return
nodeInfo
,
fmt
.
Errorf
(
"protocol version mismatch: peer = %d ; our side = %d"
,
pkt
.
ProtocolVersion
,
PROTOCOL_VERSION
)
}
// TODO (.NodeType, .UUID, .Address, .Name, .IdTimestamp) -> check + register to NM
err
=
EncodeAndSend
(
conn
,
&
AcceptIdentification
{
NodeType
:
pkt
.
NodeType
,
MyUUID
:
0
,
// XXX
...
...
go/neo/storage.go
View file @
a024d393
...
...
@@ -63,29 +63,32 @@ func (stor *Storage) ServeLink(ctx context.Context, link *NodeLink) {
nodeInfo
,
err
:=
Identify
(
link
)
if
err
!=
nil
{
fmt
.
Printf
(
"
stor:
peer identification failed: %v
\n
"
,
err
)
fmt
.
Printf
(
"peer identification failed: %v
\n
"
,
err
)
return
}
/*
pktri, err := expect(RequestIdentification)
if err != nil {
send(err)
return
}
var
serveConn
func
(
context
.
Context
,
*
Conn
)
switch
nodeInfo
.
NodeType
{
case
CLIENT
:
serveConn
=
stor
.
ServeClient
if pktri.ProtocolVersion != PROTOCOL_VERSION {
sendErr("..."
)
default
:
fmt
.
Printf
(
"unexpected peer type: %v
\n
"
,
nodeInfo
.
NodeType
)
return
}
(.NodeType, .UUID, .Address, .Name, .IdTimestamp) -> check + register to NM
send(AcceptIdentification{...})
// TODO mark link as identified
// identification passed, now serve other requests
for
{
conn
,
err
:=
link
.
Accept
()
if
err
!=
nil
{
fmt
.
Printf
(
"accept: %v
\n
"
,
err
)
// XXX err ctx
continue
}
*/
// XXX adjust ctx ?
// XXX wrap conn close to happen here, not in ServeClient ?
go
serveConn
(
ctx
,
conn
)
}
}
...
...
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