2024-04-12 15:29:43 +08:00
|
|
|
package server
|
|
|
|
|
|
|
|
import (
|
2024-05-13 20:18:13 +08:00
|
|
|
"gitea.timerzz.com/kedaya_haitao/common/pkg/proxy"
|
2024-04-12 15:29:43 +08:00
|
|
|
"github.com/gofiber/fiber/v3"
|
|
|
|
)
|
|
|
|
|
|
|
|
type ProxySvc struct {
|
2024-05-13 20:18:13 +08:00
|
|
|
pool *proxy.ProxyPool
|
2024-04-12 15:29:43 +08:00
|
|
|
}
|
|
|
|
|
2024-05-13 20:18:13 +08:00
|
|
|
func NewProxySvc(pool *proxy.ProxyPool) *ProxySvc {
|
2024-04-12 15:29:43 +08:00
|
|
|
return &ProxySvc{
|
|
|
|
pool: pool,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *ProxySvc) RegistryRouter(r fiber.Router) {
|
|
|
|
r.Get("proxies/status", s.GetStatusInfo)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *ProxySvc) GetStatusInfo(ctx fiber.Ctx) error {
|
|
|
|
list, updated := s.pool.Status()
|
|
|
|
return ctx.JSON(map[string]interface{}{
|
|
|
|
"list": list,
|
|
|
|
"updated": updated,
|
|
|
|
})
|
|
|
|
}
|