diff --git a/application/rpc.go b/application/rpc.go index f3817b1..6c0f25f 100644 --- a/application/rpc.go +++ b/application/rpc.go @@ -206,7 +206,9 @@ func (sm *stream) CallAsync(ctx context.Context, method string, req geminio.Requ } func (sm *stream) Hijack(rpc geminio.HijackRPC, opts ...*options.HijackOptions) error { - pRPC := &patternRPC{} + pRPC := &patternRPC{ + match: true, + } fo := options.MergeHijackOptions(opts...) if fo.Pattern != nil { reg, err := regexp.Compile(*fo.Pattern) diff --git a/application/stream.go b/application/stream.go index 1a7eac0..53aafaa 100644 --- a/application/stream.go +++ b/application/stream.go @@ -292,6 +292,10 @@ func (sm *stream) handleInRequestPacket(pkt *packet.RequestPacket) iodefine.IORe } // hijack exist if sm.hijackRPC != nil { + if sm.hijackRPC.pattern == nil { + sm.doRPC(pkt, methodRPC(sm.hijackRPC.rpc), method, ctx, req, rsp, true) + return iodefine.IOSuccess + } matched := sm.hijackRPC.pattern.Match([]byte(method)) if (sm.hijackRPC.match && matched) || (!sm.hijackRPC.match && !matched) { // do RPC and cancel the context