Skip to content

Commit 139f297

Browse files
committed
update
1 parent 3ceef3f commit 139f297

7 files changed

+8
-8
lines changed

crpc/client.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ func (c *CrpcClient) start(server *ServerForPick, reconnect bool) {
146146
}
147147
}
148148

149-
func (c *CrpcClient) verifyfunc(ctx context.Context, peerVerifyData []byte) ([]byte, bool) {
149+
func (c *CrpcClient) verifyfunc(ctx context.Context, peerVerifyData []byte, p *stream.Peer) ([]byte, bool) {
150150
//verify success
151151
return nil, true
152152
}

crpc/server.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ func (s *CrpcServer) insidehandler(path string, handlers ...OutsideHandler) func
349349
}
350350

351351
// return false will close the connection
352-
func (s *CrpcServer) verifyfunc(ctx context.Context, peerVerifyData []byte) ([]byte, bool) {
352+
func (s *CrpcServer) verifyfunc(ctx context.Context, peerVerifyData []byte, p *stream.Peer) ([]byte, bool) {
353353
if s.stop.Closing() {
354354
//self closing
355355
return nil, false

stream/config.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
// server's response will write back to the client for client to verify the server
1515
// client's response is useless and it will be dropped,you can just return nil
1616
// Warning!!!Don't reuse the data in 'peerVerifyData',it will change when this function return,if you want to use it,copy it first
17-
type HandleVerifyFunc func(ctx context.Context, peerVerifyData []byte) (response []byte, success bool)
17+
type HandleVerifyFunc func(ctx context.Context, peerVerifyData []byte, p *Peer) (response []byte, success bool)
1818

1919
// This is a notice func after verify each other success
2020
// success = true means online success

stream/conn.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func (this *Instance) StartServer(listenaddr string, tlsc *tls.Config) error {
5252
p := newPeer(this.c.TcpC.MaxMsgLen, _PEER_CLIENT, "")
5353
conn, e := tmplistener.AcceptTCP()
5454
if e != nil {
55-
if ee, ok := e.(net.Error); ok && ee.Temporary() {
55+
if ee, ok := e.(interface{ Temporary() bool }); ok && ee.Temporary() {
5656
log.Error(nil, "[Stream.StartServer] accept tcp connection failed", log.CError(e))
5757
continue
5858
}
@@ -365,7 +365,7 @@ func (this *Instance) verifypeer(ctx context.Context, p *Peer) []byte {
365365
p.recvidlestart = p.lastactive
366366
p.sendidlestart = p.lastactive
367367
p.peerMaxMsgLen = senderMaxRecvMsgLen
368-
r, success := this.c.VerifyFunc(ctx, data[4:])
368+
r, success := this.c.VerifyFunc(ctx, data[4:], p)
369369
if !success {
370370
if p.peertype == _PEER_CLIENT {
371371
log.Error(nil, "[Stream.verifypeer] verify client failed", log.String("cip", p.c.RemoteAddr().String()))

stream/server_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func Test_Server(t *testing.T) {
4141
}()
4242
http.ListenAndServe(":8080", nil)
4343
}
44-
func serverhandleVerify(ctx context.Context, peerVerifyData []byte) ([]byte, bool) {
44+
func serverhandleVerify(ctx context.Context, peerVerifyData []byte, p *Peer) ([]byte, bool) {
4545
if !bytes.Equal([]byte{'t', 'e', 's', 't', 'c'}, peerVerifyData) {
4646
fmt.Println("verify error")
4747
return nil, false

stream/tcpclient_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func Test_Tcpclient(t *testing.T) {
3434
}()
3535
http.ListenAndServe(":8081", nil)
3636
}
37-
func tcpclienthandleVerify(ctx context.Context, peerVerifyData []byte) ([]byte, bool) {
37+
func tcpclienthandleVerify(ctx context.Context, peerVerifyData []byte, p *Peer) ([]byte, bool) {
3838
if !bytes.Equal([]byte{'t', 'e', 's', 't'}, peerVerifyData) {
3939
fmt.Println("verify error")
4040
return nil, false

stream/wsclient_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func Test_Wsclient(t *testing.T) {
3434
}()
3535
http.ListenAndServe(":8082", nil)
3636
}
37-
func wsclienthandleVerify(ctx context.Context, peerVerifyData []byte) ([]byte, bool) {
37+
func wsclienthandleVerify(ctx context.Context, peerVerifyData []byte, p *Peer) ([]byte, bool) {
3838
if !bytes.Equal([]byte{'t', 'e', 's', 't'}, peerVerifyData) {
3939
fmt.Println("verify error")
4040
return nil, false

0 commit comments

Comments
 (0)