MCPcopy
hub / github.com/fatedier/frp / APIProxyByName

Method APIProxyByName

server/http/controller.go:192–219  ·  view source on GitHub ↗

api/proxies/:name

(ctx *httppkg.Context)

Source from the content-addressed store, hash-verified

190
191// /api/proxies/:name
192func (c *Controller) APIProxyByName(ctx *httppkg.Context) (any, error) {
193 name := ctx.Param("name")
194
195 ps := mem.StatsCollector.GetProxyByName(name)
196 if ps == nil {
197 return nil, httppkg.NewError(http.StatusNotFound, "no proxy info found")
198 }
199
200 proxyInfo := model.GetProxyStatsResp{
201 Name: ps.Name,
202 User: ps.User,
203 ClientID: ps.ClientID,
204 TodayTrafficIn: ps.TodayTrafficIn,
205 TodayTrafficOut: ps.TodayTrafficOut,
206 CurConns: ps.CurConns,
207 LastStartTime: ps.LastStartTime,
208 LastCloseTime: ps.LastCloseTime,
209 }
210
211 if pxy, ok := c.pxyManager.GetByName(name); ok {
212 proxyInfo.Conf = getConfFromConfigurer(pxy.GetConfigurer())
213 proxyInfo.Status = "online"
214 } else {
215 proxyInfo.Status = "offline"
216 }
217
218 return proxyInfo, nil
219}
220
221// DELETE /api/proxies?status=offline
222func (c *Controller) DeleteProxies(ctx *httppkg.Context) (any, error) {

Callers

nothing calls this directly

Calls 5

getConfFromConfigurerFunction · 0.85
ParamMethod · 0.80
GetProxyByNameMethod · 0.65
GetByNameMethod · 0.65
GetConfigurerMethod · 0.65

Tested by

no test coverage detected