add link for all proxies

This commit is contained in:
zu1k
2020-09-04 17:13:19 +08:00
parent 6b769ef998
commit 5fde0b6658

View File

@@ -4,6 +4,7 @@ import (
"html/template"
"net/http"
"os"
"strconv"
"github.com/gin-gonic/gin"
_ "github.com/heroku/x/hmetrics/onload"
@@ -181,6 +182,18 @@ func setupRouter() {
}
c.String(200, vmessSub.Provide())
})
router.GET("/link/:id", func(c *gin.Context) {
idx := c.Param("id")
proxies := cache.GetProxies("allproxies")
id, err := strconv.Atoi(idx)
if err != nil {
c.String(500, err.Error())
}
if id >= proxies.Len() {
c.String(500, "id too big")
}
c.String(200, proxies[id].Link())
})
}
func Run() {