Skip to content

Commit

Permalink
add link for all proxies
Browse files Browse the repository at this point in the history
  • Loading branch information
zu1k committed Sep 4, 2020
1 parent 6b769ef commit 5fde0b6
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions api/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"html/template"
"net/http"
"os"
"strconv"

"github.com/gin-gonic/gin"
_ "github.com/heroku/x/hmetrics/onload"
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit 5fde0b6

Please sign in to comment.