mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-03-02 01:30:51 +03:00

split xtls from tls - remove iran warp - remove old setting reality from franzkafka (it was a messy code) -and other improvement Co-Authored-By: Alireza Ahmadi <alireza7@gmail.com>
47 lines
892 B
Go
47 lines
892 B
Go
package controller
|
|
|
|
import (
|
|
"encoding/base64"
|
|
"strings"
|
|
"x-ui/web/service"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
type SUBController struct {
|
|
BaseController
|
|
|
|
subService service.SubService
|
|
}
|
|
|
|
func NewSUBController(g *gin.RouterGroup) *SUBController {
|
|
a := &SUBController{}
|
|
a.initRouter(g)
|
|
return a
|
|
}
|
|
|
|
func (a *SUBController) initRouter(g *gin.RouterGroup) {
|
|
g = g.Group("/sub")
|
|
|
|
g.GET("/:subid", a.subs)
|
|
}
|
|
|
|
func (a *SUBController) subs(c *gin.Context) {
|
|
subId := c.Param("subid")
|
|
host := strings.Split(c.Request.Host, ":")[0]
|
|
subs, header, err := a.subService.GetSubs(subId, host)
|
|
if err != nil || len(subs) == 0 {
|
|
c.String(400, "Error!")
|
|
} else {
|
|
result := ""
|
|
for _, sub := range subs {
|
|
result += sub + "\n"
|
|
}
|
|
|
|
// Add subscription-userinfo
|
|
c.Writer.Header().Set("subscription-userinfo", header)
|
|
|
|
c.String(200, base64.StdEncoding.EncodeToString([]byte(result)))
|
|
}
|
|
}
|