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

Method doACME

internal/nodes/http_request_acme.go:10–39  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

8)
9
10func (this *HTTPRequest) doACME() (shouldStop bool) {
11 // TODO 对请求进行校验,防止恶意攻击
12
13 var token = filepath.Base(this.RawReq.URL.Path)
14 if token == "acme-challenge" || len(token) <= 32 {
15 return false
16 }
17
18 rpcClient, err := rpc.SharedRPC()
19 if err != nil {
20 remotelogs.Error("RPC", "[ACME]rpc failed: "+err.Error())
21 return false
22 }
23
24 keyResp, err := rpcClient.ACMEAuthenticationRPC.FindACMEAuthenticationKeyWithToken(rpcClient.Context(), &pb.FindACMEAuthenticationKeyWithTokenRequest{Token: token})
25 if err != nil {
26 remotelogs.Error("RPC", "[ACME]read key for token failed: "+err.Error())
27 return false
28 }
29 if len(keyResp.Key) == 0 {
30 return false
31 }
32
33 this.tags = append(this.tags, "ACME")
34
35 this.writer.Header().Set("Content-Type", "text/plain")
36 _, _ = this.writer.WriteString(keyResp.Key)
37
38 return true
39}

Callers 1

DoMethod · 0.95

Calls 7

SharedRPCFunction · 0.92
ErrorFunction · 0.92
ContextMethod · 0.80
WriteStringMethod · 0.80
ErrorMethod · 0.45
SetMethod · 0.45
HeaderMethod · 0.45

Tested by

no test coverage detected