forked from HXSecurity/DongTai-agent-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Fliv
committed
Aug 8, 2022
1 parent
def9706
commit 86f1e44
Showing
7 changed files
with
113 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package unaryInterceptor | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/HXSecurity/DongTai-agent-go/model" | ||
"github.com/brahma-adshonor/gohook" | ||
"google.golang.org/grpc" | ||
) | ||
|
||
func init() { | ||
model.HookMap["grpcUnaryInterceptor"] = new(GrpcUnaryInterceptor) | ||
} | ||
|
||
type GrpcUnaryInterceptor struct { | ||
} | ||
|
||
func (h *GrpcUnaryInterceptor) Hook() { | ||
err := gohook.Hook(grpc.UnaryInterceptor, UnaryInterceptor, nil) | ||
if err != nil { | ||
fmt.Println(err, "GrpcUnaryInterceptor") | ||
} else { | ||
fmt.Println("GrpcUnaryInterceptor") | ||
} | ||
} | ||
|
||
func (h *GrpcUnaryInterceptor) UnHook() { | ||
gohook.UnHook(grpc.UnaryInterceptor) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package unaryInterceptor | ||
|
||
import ( | ||
"google.golang.org/grpc" | ||
) | ||
|
||
const ( | ||
TraceId = iota | ||
AgentId | ||
RoutineId | ||
NextKey | ||
OnlyKey | ||
) | ||
|
||
var UnaryServerInterceptors []grpc.UnaryServerInterceptor | ||
|
||
func UnaryInterceptor(i grpc.UnaryServerInterceptor) grpc.ServerOption { | ||
|
||
UnaryServerInterceptors = append(UnaryServerInterceptors, i) | ||
return nil | ||
} | ||
|
||
func UnaryInterceptorT(i grpc.UnaryServerInterceptor) grpc.ServerOption { | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters