Commit 2243abc5 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent caafdbaa
......@@ -26,7 +26,6 @@ import (
"fmt"
"io"
"net"
"os"
"github.com/philhofer/fwd"
"github.com/tinylib/msgp/msgp"
......@@ -38,6 +37,19 @@ import (
"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.
// XXX we don't need this? (just set encDefault = 'M')
var encDefault = proto.Encoding('N') // XXX = 'M' instead?
......@@ -52,6 +64,7 @@ func init() {
os.Exit(1)
}
}
*/
// ---- Handshake ----
......@@ -60,7 +73,7 @@ func init() {
// do not have such uses.
func _HandshakeClient(ctx context.Context, conn net.Conn) (*NodeLink, error) {
return handshakeClient(ctx, conn, proto.Version, encDefault)
return handshakeClient(ctx, conn, proto.Version, encTryOrder[0])
}
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,
return nil, err
}
// // TODO if handshake fails with "closed" (= might be unexpected encoding)
// // -> try redial and handshaking with different encoding (= autodetect encoding)
// return _Handshake(ctx, peerConn, _LinkClient)
return handshakeClient(ctx, peerConn, proto.Version, encDefault)
// TODO if handshake fails with "closed" (= might be unexpected encoding)
// -> try redial and handshaking with different encoding (= autodetect encoding)
return handshakeClient(ctx, peerConn, proto.Version, encTryOrder[0])
}
// ListenLink starts listening on laddr for incoming connections and wraps them as NodeLink.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment