From 9b72a679f12ce17cbd490c53d6b37b204ce5013e Mon Sep 17 00:00:00 2001 From: Sir Darkrengarius Date: Mon, 13 Jan 2020 09:29:56 +0300 Subject: [PATCH] Update vendor --- .../github.com/SkycoinProject/dmsg/client.go | 15 ++++- .../SkycoinProject/dmsg/client_session.go | 2 +- .../github.com/SkycoinProject/dmsg/dump.rdb | Bin 0 -> 7718 bytes .../github.com/SkycoinProject/dmsg/errors.go | 60 +++++++++--------- .../SkycoinProject/dmsg/listener.go | 3 + .../github.com/SkycoinProject/dmsg/types.go | 2 +- vendor/golang.org/x/net/nettest/conntest.go | 6 +- 7 files changed, 50 insertions(+), 38 deletions(-) create mode 100644 vendor/github.com/SkycoinProject/dmsg/dump.rdb diff --git a/vendor/github.com/SkycoinProject/dmsg/client.go b/vendor/github.com/SkycoinProject/dmsg/client.go index 178db86041..3a3b037b26 100644 --- a/vendor/github.com/SkycoinProject/dmsg/client.go +++ b/vendor/github.com/SkycoinProject/dmsg/client.go @@ -35,7 +35,8 @@ type Client struct { done chan struct{} once sync.Once - sesMx sync.Mutex + sesMx sync.Mutex + dialMx sync.Mutex // stream dial mutex. } // NewClient creates a dmsg client entity. @@ -171,6 +172,14 @@ func (ce *Client) Dial(ctx context.Context, addr Addr) (net.Conn, error) { // DialStream dials to a remote client entity with the given address. func (ce *Client) DialStream(ctx context.Context, addr Addr) (*Stream, error) { + + safeDialStream := func(dSes ClientSession) (*Stream, error) { + ce.dialMx.Lock() + str, err := dSes.DialStream(addr) + ce.dialMx.Unlock() + return str, err + } + entry, err := getClientEntry(ctx, ce.dc, addr.PK) if err != nil { return nil, err @@ -180,7 +189,7 @@ func (ce *Client) DialStream(ctx context.Context, addr Addr) (*Stream, error) { // See if we are already connected to a delegated server. for _, srvPK := range entry.Client.DelegatedServers { if dSes, ok := ce.ClientSession(ce.porter, srvPK); ok { - return dSes.DialStream(addr) + return safeDialStream(dSes) } } @@ -191,7 +200,7 @@ func (ce *Client) DialStream(ctx context.Context, addr Addr) (*Stream, error) { if err != nil { continue } - return dSes.DialStream(addr) + return safeDialStream(dSes) } return nil, ErrCannotConnectToDelegated diff --git a/vendor/github.com/SkycoinProject/dmsg/client_session.go b/vendor/github.com/SkycoinProject/dmsg/client_session.go index 71a8c43785..14b73bc2f5 100644 --- a/vendor/github.com/SkycoinProject/dmsg/client_session.go +++ b/vendor/github.com/SkycoinProject/dmsg/client_session.go @@ -24,7 +24,7 @@ func makeClientSession(entity *EntityCommon, porter *netutil.Porter, conn net.Co return cSes, nil } -// DialStream attempts to dial a stream to a remote client via the dsmg server that this session is connected to. +// DialStream attempts to dial a stream to a remote client via the dmsg server that this session is connected to. func (cs *ClientSession) DialStream(dst Addr) (dStr *Stream, err error) { if dStr, err = newInitiatingStream(cs); err != nil { return nil, err diff --git a/vendor/github.com/SkycoinProject/dmsg/dump.rdb b/vendor/github.com/SkycoinProject/dmsg/dump.rdb new file mode 100644 index 0000000000000000000000000000000000000000..d565348a4b423458e4b925c5bea8fac16d3544e2 GIT binary patch literal 7718 zcmc(kOOISf6~`^4@KRW?X4mT^I#qS*|g%v*^hqz;``5Te7*nJAAkAxU%va`#k=-ozyIk|x5wj= zfAQd-5B~Av2M<2{sl**5<FHs}wf59oYm#$M8gk;| zTf4oQ$G0zD4L>~}UHSFx>EY+6<&XRmyY=<)jXyosczXET6HnVio<;huVF?eqBmcGR zv-CE7n#>VP%v~%i&l)|A!G*K5)p~64^t=k$rOUM8kcDv$7DtL_C@hAS6ItJ5D6Y+r!G<= z=ULO*d968TYt#DbY-?UpWbRlv>?LQQHf@I(Ls;rPMCZ&i_0c$FHCUGLYL@(Z)6gvC zkXoEAGOrog>88%Ik}l5DDBCzY+9IbU@NJ8+fn%_l&zj{+TsG;UWN`Z*Twc7Idzq!O zg=v8qfSc4xm)L^0Wm_5}XcBCN$hHqQc2=~hcP#w$6hPf@5BreyW4Z9Ougp4 zA&snF*!B^`W*Z(%fW5i(!sr9+_!^fNGtNhUJcnaLR-Uu6^n7QQ7xN!?d&#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7d4287b67f 100644 --- a/vendor/github.com/SkycoinProject/dmsg/errors.go +++ b/vendor/github.com/SkycoinProject/dmsg/errors.go @@ -5,42 +5,42 @@ import ( "sync" ) -// Entity Errors (10-19). +// Errors for dmsg discovery (1xx). var ( - ErrEntityClosed = NewError(10, "local entity closed", nil) - ErrSessionClosed = NewError(11, "local session closed", nil) - ErrCannotConnectToDelegated = NewError(12, "cannot connect to delegated server", nil) - ErrSessionHandshakeExtraBytes = NewError(13, "extra bytes received during session handshake", nil) + ErrDiscEntryNotFound = NewError(100, "discovery entry is not found", nil) + ErrDiscEntryIsNotServer = NewError(101, "discovery entry is not of server", nil) + ErrDiscEntryIsNotClient = NewError(102, "discovery entry is not of client", nil) + ErrDiscEntryHasNoDelegated = NewError(103, "discovery client entry has no delegated servers", nil) ) -// Errors for dmsg discovery (30-39). +// Entity Errors (2xx). var ( - ErrDiscEntryNotFound = NewError(30, "discovery entry is not found", nil) - ErrDiscEntryIsNotServer = NewError(31, "discovery entry is not of server", nil) - ErrDiscEntryIsNotClient = NewError(32, "discovery entry is not of client", nil) - ErrDiscEntryHasNoDelegated = NewError(33, "discovery client entry has no delegated servers", nil) + ErrEntityClosed = NewError(200, "local entity closed", nil) + ErrSessionClosed = NewError(201, "local session closed", nil) + ErrCannotConnectToDelegated = NewError(202, "cannot connect to delegated server", nil) + ErrSessionHandshakeExtraBytes = NewError(203, "extra bytes received during session handshake", nil) ) -// Errors for dial request/response (50-69). +// Errors for dial request/response (3xx). var ( - ErrReqInvalidSig = NewError(50, "request has invalid signature", nil) - ErrReqInvalidTimestamp = NewError(51, "request timestamp should be higher than last", nil) - ErrReqInvalidSrcPK = NewError(52, "request has invalid source public key", nil) - ErrReqInvalidDstPK = NewError(53, "request has invalid destination public key", nil) - ErrReqInvalidSrcPort = NewError(54, "request has invalid source port", nil) - ErrReqInvalidDstPort = NewError(55, "request has invalid destination port", nil) - ErrReqNoListener = NewError(56, "request has no associated listener", nil) - ErrReqNoSession = NewError(57, "request has no associated session on the dmsg server", nil) + ErrReqInvalidSig = NewError(300, "request has invalid signature", nil) + ErrReqInvalidTimestamp = NewError(301, "request timestamp should be higher than last", nil) + ErrReqInvalidSrcPK = NewError(302, "request has invalid source public key", nil) + ErrReqInvalidDstPK = NewError(303, "request has invalid destination public key", nil) + ErrReqInvalidSrcPort = NewError(304, "request has invalid source port", nil) + ErrReqInvalidDstPort = NewError(305, "request has invalid destination port", nil) + ErrReqNoListener = NewError(306, "request has no associated listener", nil) + ErrReqNoSession = NewError(307, "request has no associated session on the dmsg server", nil) - ErrDialRespInvalidSig = NewError(60, "response has invalid signature", nil) - ErrDialRespInvalidHash = NewError(61, "response has invalid hash of associated request", nil) - ErrDialRespNotAccepted = NewError(62, "response rejected associated request without reason", nil) + ErrDialRespInvalidSig = NewError(350, "response has invalid signature", nil) + ErrDialRespInvalidHash = NewError(351, "response has invalid hash of associated request", nil) + ErrDialRespNotAccepted = NewError(352, "response rejected associated request without reason", nil) ) -// Listener errors (80-89). +// Listener errors (4xx). var ( - ErrPortOccupied = NewError(80, "port already occupied", nil) - ErrAcceptChanMaxed = NewError(81, "listener accept chan maxed", nil) + ErrPortOccupied = NewError(400, "port already occupied", nil) + ErrAcceptChanMaxed = NewError(401, "listener accept chan maxed", nil) ) // NetworkErrorOptions provides 'timeout' and 'temporary' options for NetworkError. @@ -66,15 +66,15 @@ func (err NetworkError) Temporary() bool { return err.Opts.Temporary } var ( errFmt = "code %d - %s" - errMap = make(map[uint8]error) - codeMap = make(map[error]uint8) + errMap = make(map[uint16]error) + codeMap = make(map[error]uint16) errMx sync.RWMutex ) // NewError creates a new dmsg error. // - code '0' represents a miscellaneous error and is not saved in 'errMap'. // - netOpts is only needed if it needs to implement 'net.Error'. -func NewError(code uint8, msg string, netOpts *NetworkErrorOptions) error { +func NewError(code uint16, msg string, netOpts *NetworkErrorOptions) error { // No need to check errMap if code 0. if code != 0 { errMx.Lock() @@ -96,7 +96,7 @@ func NewError(code uint8, msg string, netOpts *NetworkErrorOptions) error { } // ErrorFromCode returns a saved error (if exists) from given error code. -func ErrorFromCode(code uint8) (bool, error) { +func ErrorFromCode(code uint16) (bool, error) { errMx.RLock() err, ok := errMap[code] errMx.RUnlock() @@ -104,7 +104,7 @@ func ErrorFromCode(code uint8) (bool, error) { } // CodeFromError returns code from a given error. -func CodeFromError(err error) uint8 { +func CodeFromError(err error) uint16 { errMx.RLock() code, ok := codeMap[err] errMx.RUnlock() diff --git a/vendor/github.com/SkycoinProject/dmsg/listener.go b/vendor/github.com/SkycoinProject/dmsg/listener.go index 8e25d4621b..dc4f5376ae 100644 --- a/vendor/github.com/SkycoinProject/dmsg/listener.go +++ b/vendor/github.com/SkycoinProject/dmsg/listener.go @@ -115,5 +115,8 @@ func (l *Listener) isClosed() bool { // Addr returns the listener's address. func (l *Listener) Addr() net.Addr { return l.addr } +// DmsgAddr returns the listener's address in as `dmsg.Addr`. +func (l *Listener) DmsgAddr() Addr { return l.addr } + // Type returns the stream type. func (l *Listener) Type() string { return Type } diff --git a/vendor/github.com/SkycoinProject/dmsg/types.go b/vendor/github.com/SkycoinProject/dmsg/types.go index 2851f72f73..d59fea1807 100644 --- a/vendor/github.com/SkycoinProject/dmsg/types.go +++ b/vendor/github.com/SkycoinProject/dmsg/types.go @@ -116,7 +116,7 @@ func (dr StreamDialRequest) Verify(lastTimestamp int64) error { type StreamDialResponse struct { ReqHash cipher.SHA256 // Hash of associated dial request. Accepted bool // Whether the request is accepted. - ErrCode uint8 // Check if not accepted. + ErrCode uint16 // Check if not accepted. NoiseMsg []byte Sig cipher.Sig // Signature of this DialRequest, signed with public key of receiving node. } diff --git a/vendor/golang.org/x/net/nettest/conntest.go b/vendor/golang.org/x/net/nettest/conntest.go index 0427987e7d..39cc6a631e 100644 --- a/vendor/golang.org/x/net/nettest/conntest.go +++ b/vendor/golang.org/x/net/nettest/conntest.go @@ -37,9 +37,9 @@ func TestConn(t *testing.T, mp MakePipe) { t.Run("WriteTimeout", func(t *testing.T) { timeoutWrapper(t, mp, testWriteTimeout) }) t.Run("PastTimeout", func(t *testing.T) { timeoutWrapper(t, mp, testPastTimeout) }) t.Run("PresentTimeout", func(t *testing.T) { timeoutWrapper(t, mp, testPresentTimeout) }) - //t.Run("FutureTimeout", func(t *testing.T) { timeoutWrapper(t, mp, testFutureTimeout) }) - //t.Run("CloseTimeout", func(t *testing.T) { timeoutWrapper(t, mp, testCloseTimeout) }) - //t.Run("ConcurrentMethods", func(t *testing.T) { timeoutWrapper(t, mp, testConcurrentMethods) }) + t.Run("FutureTimeout", func(t *testing.T) { timeoutWrapper(t, mp, testFutureTimeout) }) + t.Run("CloseTimeout", func(t *testing.T) { timeoutWrapper(t, mp, testCloseTimeout) }) + t.Run("ConcurrentMethods", func(t *testing.T) { timeoutWrapper(t, mp, testConcurrentMethods) }) } type connTester func(t *testing.T, c1, c2 net.Conn)