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
99ea2b93
Commit
99ea2b93
authored
Jan 15, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
X unexport neonet.DialEncTryOrder
parent
c3fb22a4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
11 deletions
+41
-11
go/neo/client_test.go
go/neo/client_test.go
+5
-4
go/neo/internal/tneonet/tneonet.go
go/neo/internal/tneonet/tneonet.go
+27
-0
go/neo/neonet/newlink.go
go/neo/neonet/newlink.go
+9
-7
No files found.
go/neo/client_test.go
View file @
99ea2b93
...
...
@@ -39,6 +39,7 @@ import (
"lab.nexedi.com/kirr/go123/xnet"
"lab.nexedi.com/kirr/go123/xsync"
"lab.nexedi.com/kirr/neo/go/neo/internal/tneonet"
"lab.nexedi.com/kirr/neo/go/neo/neonet"
"lab.nexedi.com/kirr/neo/go/neo/proto"
bsqlite
"lab.nexedi.com/kirr/neo/go/neo/storage/sqlite"
...
...
@@ -514,9 +515,9 @@ func withNEO(t *testing.T, f func(t *testing.T, nsrv NEOSrv, ndrv *Client), optv
// For example if NEO/py server implments only M encoding,
// testing with N,M verifies retry after handshaking with
// enc=N.
encTryOrder0
:=
neonet
.
DialEncTryOrder
encTryOrder0
:=
*
t
neonet
.
DialEncTryOrder
defer
func
()
{
neonet
.
DialEncTryOrder
=
encTryOrder0
*
t
neonet
.
DialEncTryOrder
=
encTryOrder0
}()
for
i
:=
range
encTryOrder0
{
...
...
@@ -551,7 +552,7 @@ func withNEO(t *testing.T, f func(t *testing.T, nsrv NEOSrv, ndrv *Client), optv
}
neonet
.
DialEncTryOrder
=
encv
*
t
neonet
.
DialEncTryOrder
=
encv
ndrv
,
_
,
err
:=
neoOpen
(
nsrv
.
URL
(),
&
zodb
.
DriverOptions
{
ReadOnly
:
true
});
X
(
err
)
defer
func
()
{
...
...
@@ -561,7 +562,7 @@ func withNEO(t *testing.T, f func(t *testing.T, nsrv NEOSrv, ndrv *Client), optv
// verify that link was established with either:
// - encv[0] encoding (NEO/go = server supports autodetection)
// - server encoding (NEO/py)
encOK
:=
neonet
.
DialEncTryOrder
[
0
]
encOK
:=
(
*
tneonet
.
DialEncTryOrder
)
[
0
]
if
noautodetect
{
encOK
=
srvEnc
}
...
...
go/neo/internal/tneonet/tneonet.go
0 → 100644
View file @
99ea2b93
// Copyright (C) 2021 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
//
// This program is free software: you can Use, Study, Modify and Redistribute
// it under the terms of the GNU General Public License version 3, or (at your
// option) any later version, as published by the Free Software Foundation.
//
// You can also Link and Combine this program with other software covered by
// the terms of any of the Free Software licenses or any of the Open Source
// Initiative approved licenses and Convey the resulting work. Corresponding
// source of such a combination shall include the source code for all other
// software used.
//
// This program is distributed WITHOUT ANY WARRANTY; without even the implied
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//
// See COPYING file for full licensing terms.
// See https://www.nexedi.com/licensing for rationale and options.
// Package tneonet provides testing hooks for neonet package.
package
tneonet
import
(
"lab.nexedi.com/kirr/neo/go/neo/proto"
)
var
DialEncTryOrder
*
[]
proto
.
Encoding
// = &neonet.dialEncTryOrder
go/neo/neonet/newlink.go
View file @
99ea2b93
...
...
@@ -34,6 +34,7 @@ import (
"lab.nexedi.com/kirr/go123/xnet"
"lab.nexedi.com/kirr/neo/go/internal/xcontext"
"lab.nexedi.com/kirr/neo/go/internal/xio"
"lab.nexedi.com/kirr/neo/go/neo/internal/tneonet"
"lab.nexedi.com/kirr/neo/go/neo/proto"
)
...
...
@@ -44,7 +45,7 @@ import (
// do not have such uses.
func
_HandshakeClient
(
ctx
context
.
Context
,
conn
net
.
Conn
)
(
*
NodeLink
,
error
)
{
return
handshakeClient
(
ctx
,
conn
,
proto
.
Version
,
D
ialEncTryOrder
[
0
])
return
handshakeClient
(
ctx
,
conn
,
proto
.
Version
,
d
ialEncTryOrder
[
0
])
}
func
_HandshakeServer
(
ctx
context
.
Context
,
conn
net
.
Conn
)
(
*
NodeLink
,
error
)
{
...
...
@@ -274,24 +275,25 @@ func rxHello(errctx string, rx *xbufReader) (enc proto.Encoding, version uint32,
// ---- Dial & Listen at NodeLink level ----
//
D
ialEncTryOrder is the order of trials for encoding when establishing a NEO link from client side.
//
d
ialEncTryOrder 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 order specified by
D
ialEncTryOrder.
// client-preferred encodings in the order specified by
d
ialEncTryOrder.
//
// NOTE tests change this to verify that autodetection of NEO/py server
// encoding actually works.
//
// XXX unexport
var
DialEncTryOrder
=
[]
proto
.
Encoding
{
'N'
,
'M'
}
var
dialEncTryOrder
=
[]
proto
.
Encoding
{
'N'
,
'M'
}
func
init
()
{
tneonet
.
DialEncTryOrder
=
&
dialEncTryOrder
}
// DialLink connects to address on given network, performs NEO protocol
// handshake and wraps the connection as NodeLink.
func
DialLink
(
ctx
context
.
Context
,
net
xnet
.
Networker
,
addr
string
)
(
link
*
NodeLink
,
err
error
)
{
for
_
,
enc
:=
range
D
ialEncTryOrder
{
for
_
,
enc
:=
range
d
ialEncTryOrder
{
peerConn
,
err
:=
net
.
Dial
(
ctx
,
addr
)
if
err
!=
nil
{
return
nil
,
err
...
...
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