MCPcopy Index your code
hub / github.com/GoEdgeLab/EdgeNode / Process

Method Process

internal/utils/agents/queue.go:71–110  ·  view source on GitHub ↗

Process 处理IP

(ip string)

Source from the content-addressed store, hash-verified

69
70// Process 处理IP
71func (this *Queue) Process(ip string) error {
72 // 是否已经在库中
73 if SharedManager.ContainsIP(ip) {
74 return nil
75 }
76
77 ptr, err := this.ParseIP(ip)
78 if err != nil {
79 return err
80 }
81 if len(ptr) == 0 || ptr == "." {
82 return nil
83 }
84
85 //remotelogs.Debug("AGENT", ip+" => "+ptr)
86
87 var agentCode = this.ParsePtr(ptr)
88 if len(agentCode) == 0 {
89 return nil
90 }
91
92 // 加入到本地
93 SharedManager.AddIP(ip, agentCode)
94
95 var pbAgentIP = &pb.CreateClientAgentIPsRequest_AgentIPInfo{
96 AgentCode: agentCode,
97 Ip: ip,
98 Ptr: ptr,
99 }
100 rpcClient, err := rpc.SharedRPC()
101 if err != nil {
102 return err
103 }
104 _, err = rpcClient.ClientAgentIPRPC.CreateClientAgentIPs(rpcClient.Context(), &pb.CreateClientAgentIPsRequest{AgentIPs: []*pb.CreateClientAgentIPsRequest_AgentIPInfo{pbAgentIP}})
105 if err != nil {
106 return err
107 }
108
109 return nil
110}
111
112// ParseIP 分析IP的PTR值
113func (this *Queue) ParseIP(ip string) (ptr string, err error) {

Callers 1

StartMethod · 0.95

Calls 6

ParseIPMethod · 0.95
ParsePtrMethod · 0.95
SharedRPCFunction · 0.92
ContainsIPMethod · 0.80
ContextMethod · 0.80
AddIPMethod · 0.45

Tested by

no test coverage detected