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
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
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
Hide 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 {
...
@@ -82,8 +82,6 @@ func ListenAndServe(ctx context.Context, net_, laddr string, srv Server) error {
// Identify identifies peer on the link
// Identify identifies peer on the link
// it expects peer to send RequestIdentification packet and TODO
// it expects peer to send RequestIdentification packet and TODO
func
Identify
(
link
*
NodeLink
)
(
nodeInfo
RequestIdentification
/*TODO -> NodeInfo*/
,
err
error
)
{
func
Identify
(
link
*
NodeLink
)
(
nodeInfo
RequestIdentification
/*TODO -> NodeInfo*/
,
err
error
)
{
nodeInfo
:=
RequestIdentification
{}
// the first conn must come with RequestIdentification packet
// the first conn must come with RequestIdentification packet
conn
,
err
:=
link
.
Accept
()
conn
,
err
:=
link
.
Accept
()
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -112,6 +110,8 @@ func Identify(link *NodeLink) (nodeInfo RequestIdentification /*TODO -> NodeInfo
...
@@ -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
)
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
{
err
=
EncodeAndSend
(
conn
,
&
AcceptIdentification
{
NodeType
:
pkt
.
NodeType
,
NodeType
:
pkt
.
NodeType
,
MyUUID
:
0
,
// XXX
MyUUID
:
0
,
// XXX
...
...
go/neo/storage.go
View file @
a024d393
...
@@ -63,29 +63,32 @@ func (stor *Storage) ServeLink(ctx context.Context, link *NodeLink) {
...
@@ -63,29 +63,32 @@ func (stor *Storage) ServeLink(ctx context.Context, link *NodeLink) {
nodeInfo
,
err
:=
Identify
(
link
)
nodeInfo
,
err
:=
Identify
(
link
)
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Printf
(
"
stor:
peer identification failed: %v
\n
"
,
err
)
fmt
.
Printf
(
"peer identification failed: %v
\n
"
,
err
)
return
return
}
}
/*
var
serveConn
func
(
context
.
Context
,
*
Conn
)
pktri, err := expect(RequestIdentification)
switch
nodeInfo
.
NodeType
{
if err != nil {
case
CLIENT
:
send(err)
serveConn
=
stor
.
ServeClient
return
}
if pktri.ProtocolVersion != PROTOCOL_VERSION {
default
:
sendErr("..."
)
fmt
.
Printf
(
"unexpected peer type: %v
\n
"
,
nodeInfo
.
NodeType
)
return
return
}
}
(.NodeType, .UUID, .Address, .Name, .IdTimestamp) -> check + register to NM
// identification passed, now serve other requests
for
{
send(AcceptIdentification{...})
conn
,
err
:=
link
.
Accept
()
// TODO mark link as identified
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