MCPcopy Create free account
hub / github.com/SenseUnit/dumbproxy / Access

Method Access

access/jsfilter.go:85–106  ·  view source on GitHub ↗
(ctx context.Context, req *http.Request, username, network, address string)

Source from the content-addressed store, hash-verified

83}
84
85func (j *JSFilter) Access(ctx context.Context, req *http.Request, username, network, address string) error {
86 ri := jsext.JSRequestInfoFromRequest(req)
87 di, err := jsext.JSDstInfoFromContext(ctx, network, address)
88 if err != nil {
89 return fmt.Errorf("unable to construct dst info: %w", err)
90 }
91 var res bool
92 func() {
93 f := <-j.funcPool
94 defer func(pool chan JSFilterFunc, f JSFilterFunc) {
95 pool <- f
96 }(j.funcPool, f)
97 res, err = f(ri, di, username)
98 }()
99 if err != nil {
100 return fmt.Errorf("JS access script exception: %w", err)
101 }
102 if !res {
103 return ErrJSDenied
104 }
105 return j.next.Access(ctx, req, username, network, address)
106}

Callers

nothing calls this directly

Calls 4

JSRequestInfoFromRequestFunction · 0.92
JSDstInfoFromContextFunction · 0.92
ErrorfMethod · 0.80
AccessMethod · 0.65

Tested by

no test coverage detected