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
2243abc5
Commit
2243abc5
authored
Jan 12, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
caafdbaa
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
6 deletions
+18
-6
go/neo/neonet/newlink.go
go/neo/neonet/newlink.go
+18
-6
No files found.
go/neo/neonet/newlink.go
View file @
2243abc5
...
@@ -26,7 +26,6 @@ import (
...
@@ -26,7 +26,6 @@ import (
"fmt"
"fmt"
"io"
"io"
"net"
"net"
"os"
"github.com/philhofer/fwd"
"github.com/philhofer/fwd"
"github.com/tinylib/msgp/msgp"
"github.com/tinylib/msgp/msgp"
...
@@ -38,6 +37,19 @@ import (
...
@@ -38,6 +37,19 @@ import (
"lab.nexedi.com/kirr/neo/go/neo/proto"
"lab.nexedi.com/kirr/neo/go/neo/proto"
)
)
// encTryOrder is the order of trials for encoding when establishing a NEO link from client side.
//
// NEO/go server autodetects client preferred encoding and adjusts to that, but
// NEO/py rejects connections if client encoding does not exactly match server.
//
// To autodetect what NEO/py server uses DialLink retries dial + handshake with
// client-preferred encodings in the following order.
//
// NOTE tests change this to verify that autodetection of NEO/py server
// encoding actually works.
var
encTryOrder
=
[]
proto
.
Encoding
{
'N'
,
'M'
}
/*
// encDefault is default encoding to use.
// encDefault is default encoding to use.
// XXX we don't need this? (just set encDefault = 'M')
// XXX we don't need this? (just set encDefault = 'M')
var encDefault = proto.Encoding('N') // XXX = 'M' instead?
var encDefault = proto.Encoding('N') // XXX = 'M' instead?
...
@@ -52,6 +64,7 @@ func init() {
...
@@ -52,6 +64,7 @@ func init() {
os.Exit(1)
os.Exit(1)
}
}
}
}
*/
// ---- Handshake ----
// ---- Handshake ----
...
@@ -60,7 +73,7 @@ func init() {
...
@@ -60,7 +73,7 @@ func init() {
// do not have such uses.
// do not have such uses.
func
_HandshakeClient
(
ctx
context
.
Context
,
conn
net
.
Conn
)
(
*
NodeLink
,
error
)
{
func
_HandshakeClient
(
ctx
context
.
Context
,
conn
net
.
Conn
)
(
*
NodeLink
,
error
)
{
return
handshakeClient
(
ctx
,
conn
,
proto
.
Version
,
enc
Default
)
return
handshakeClient
(
ctx
,
conn
,
proto
.
Version
,
enc
TryOrder
[
0
]
)
}
}
func
_HandshakeServer
(
ctx
context
.
Context
,
conn
net
.
Conn
)
(
*
NodeLink
,
error
)
{
func
_HandshakeServer
(
ctx
context
.
Context
,
conn
net
.
Conn
)
(
*
NodeLink
,
error
)
{
...
@@ -291,10 +304,9 @@ func DialLink(ctx context.Context, net xnet.Networker, addr string) (*NodeLink,
...
@@ -291,10 +304,9 @@ func DialLink(ctx context.Context, net xnet.Networker, addr string) (*NodeLink,
return
nil
,
err
return
nil
,
err
}
}
// // TODO if handshake fails with "closed" (= might be unexpected encoding)
// TODO if handshake fails with "closed" (= might be unexpected encoding)
// // -> try redial and handshaking with different encoding (= autodetect encoding)
// -> try redial and handshaking with different encoding (= autodetect encoding)
// return _Handshake(ctx, peerConn, _LinkClient)
return
handshakeClient
(
ctx
,
peerConn
,
proto
.
Version
,
encTryOrder
[
0
])
return
handshakeClient
(
ctx
,
peerConn
,
proto
.
Version
,
encDefault
)
}
}
// ListenLink starts listening on laddr for incoming connections and wraps them as NodeLink.
// ListenLink starts listening on laddr for incoming connections and wraps them as NodeLink.
...
...
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