Skip to content

Commit

Permalink
[sub] back to merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Alireza Ahmadi committed Mar 28, 2023
1 parent 1780f06 commit f3df93a
Show file tree
Hide file tree
Showing 4 changed files with 554 additions and 0 deletions.
41 changes: 41 additions & 0 deletions web/controller/sub.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package controller

import (
"encoding/base64"
"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 := c.Request.Host
subs, err := a.subService.GetSubs(subId, host)
if err != nil {
c.String(400, "Error!")
} else {
result := ""
for _, sub := range subs {
result += sub + "\n"
}
c.String(200, base64.StdEncoding.EncodeToString([]byte(result)))
}
}
6 changes: 6 additions & 0 deletions web/html/xui/form/client.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@
<a-form-item label='{{ i18n "additional" }} ID' v-if="inbound.protocol === Protocols.VMESS">
<a-input type="number" v-model.number="client.alterId"></a-input>
</a-form-item>
<a-form-item label="Subscription" v-if="client.email">
<a-input v-model.trim="client.subId"></a-input>
</a-form-item>
<a-form-item label="Telegram ID" v-if="client.email">
<a-input v-model.trim="client.tgId"></a-input>
</a-form-item>
<a-form-item v-if="inbound.xtls" label="flow">
<a-select v-model="client.flow" style="width: 150px" :dropdown-class-name="siderDrawer.isDarkTheme ? 'ant-card-dark' : ''">
<a-select-option value="">{{ i18n "none" }}</a-select-option>
Expand Down
Loading

0 comments on commit f3df93a

Please sign in to comment.