mirror of
				https://github.com/MHSanaei/3x-ui.git
				synced 2025-10-29 19:32:51 +00:00 
			
		
		
		
	6 / new sub headers
This commit is contained in:
		
							parent
							
								
									8dab4a5d78
								
							
						
					
					
						commit
						67cd83ec66
					
				
					 3 changed files with 72 additions and 5 deletions
				
			
		|  | @ -4,4 +4,7 @@ BUILD_WITH_ANTIZAPRET="0" | |||
| XUI_SERVER_IP="" | ||||
| XUI_PANEL_DOMAIN="" | ||||
| XUI_SUB_DOMAIN="" | ||||
| XUI_VLESS_SNI="" | ||||
| XUI_VLESS_SNI="" | ||||
| #XUI_SUB_PROFILE_TITLE="" | ||||
| #XUI_SUB_SUPPORT_URL="" | ||||
| #XUI_SUB_PROFILE_WEB_PAGE_URL="" | ||||
|  | @ -32,14 +32,18 @@ services: | |||
|       - "traefik.tcp.routers.vless.service=3x-ui-inbound-443" | ||||
|       - "traefik.tcp.services.3x-ui-inbound-443.loadbalancer.server.port=443" | ||||
|     volumes: | ||||
|       - $PWD/db/:/etc/x-ui/ | ||||
|       - $PWD/cert/:/root/cert/ | ||||
|       - ./db/:/etc/x-ui/ | ||||
|       - ./cert/:/root/cert/ | ||||
|       - ./announce.txt:/etc/x-ui/announce.txt | ||||
|     environment: | ||||
|       PUID: 1000 | ||||
|       PGID: 1000 | ||||
|       XRAY_VMESS_AEAD_FORCED: "false" | ||||
|       TZ: Europe/Moscow | ||||
|       XUI_SERVER_IP: "${XUI_SERVER_IP}" | ||||
|       XUI_SUB_PROFILE_TITLE: "${XUI_SUB_PROFILE_TITLE:-}" | ||||
|       XUI_SUB_SUPPORT_URL: "${XUI_SUB_SUPPORT_URL:-}" | ||||
|       XUI_SUB_PROFILE_WEB_PAGE_URL: "${XUI_SUB_PROFILE_WEB_PAGE_URL:-}" | ||||
|     tty: true | ||||
|     restart: unless-stopped | ||||
| 
 | ||||
|  |  | |||
|  | @ -4,6 +4,7 @@ import ( | |||
| 	"encoding/base64" | ||||
| 	"net" | ||||
| 	"strings" | ||||
| 	"io/ioutil" | ||||
| 	"os" | ||||
| 
 | ||||
| 	"github.com/gin-gonic/gin" | ||||
|  | @ -74,6 +75,23 @@ func (a *SUBController) subs(c *gin.Context) { | |||
| 			host = c.Request.Host | ||||
| 		} | ||||
| 	} | ||||
| 	var profileTitle string | ||||
| 	profileTitle = os.Getenv("XUI_SUB_PROFILE_TITLE") | ||||
| 	if profileTitle == "" { | ||||
| 		profileTitle = subId | ||||
| 	} | ||||
| 	var supportUrl string | ||||
| 	supportUrl = os.Getenv("XUI_SUB_PROFILE_TITLE") | ||||
| 	if supportUrl == "" { | ||||
| 		supportUrl = os.Getenv("XUI_SUB_DOMAIN") | ||||
| 	} | ||||
| 	var profileWebPageUrl string | ||||
| 	profileWebPageUrl = os.Getenv("XUI_SUB_PROFILE_WEB_PAGE_URL") | ||||
| 	if profileWebPageUrl == "" { | ||||
| 		profileWebPageUrl = os.Getenv("XUI_SUB_DOMAIN") | ||||
| 	} | ||||
| 	var announceText string | ||||
| 	announceText = getAnnounceText() | ||||
| 	subs, header, err := a.subService.GetSubs(subId, host) | ||||
| 	if err != nil || len(subs) == 0 { | ||||
| 		c.String(400, "Error!") | ||||
|  | @ -86,7 +104,12 @@ func (a *SUBController) subs(c *gin.Context) { | |||
| 		// Add headers
 | ||||
| 		c.Writer.Header().Set("Subscription-Userinfo", header) | ||||
| 		c.Writer.Header().Set("Profile-Update-Interval", a.updateInterval) | ||||
| 		c.Writer.Header().Set("Profile-Title", subId) | ||||
| 		c.Writer.Header().Set("Profile-Title", profileTitle) | ||||
| 		c.Writer.Header().Set("Support-Url", supportUrl) | ||||
| 		c.Writer.Header().Set("Profile-Web-Page-Url", profileWebPageUrl) | ||||
| 		if announceText != "" { | ||||
| 			c.Writer.Header().Set("Announce", announceText) | ||||
| 		} | ||||
| 
 | ||||
| 		if a.subEncrypt { | ||||
| 			c.String(200, base64.StdEncoding.EncodeToString([]byte(result))) | ||||
|  | @ -115,6 +138,23 @@ func (a *SUBController) subJsons(c *gin.Context) { | |||
| 			host = c.Request.Host | ||||
| 		} | ||||
| 	} | ||||
| 	var profileTitle string | ||||
| 	profileTitle = os.Getenv("XUI_SUB_PROFILE_TITLE") | ||||
| 	if profileTitle == "" { | ||||
| 		profileTitle = subId | ||||
| 	} | ||||
| 	var supportUrl string | ||||
| 	supportUrl = os.Getenv("XUI_SUB_PROFILE_TITLE") | ||||
| 	if supportUrl == "" { | ||||
| 		supportUrl = os.Getenv("XUI_SUB_DOMAIN") | ||||
| 	} | ||||
| 	var profileWebPageUrl string | ||||
| 	profileWebPageUrl = os.Getenv("XUI_SUB_PROFILE_WEB_PAGE_URL") | ||||
| 	if profileWebPageUrl == "" { | ||||
| 		profileWebPageUrl = os.Getenv("XUI_SUB_DOMAIN") | ||||
| 	} | ||||
| 	var announceText string | ||||
| 	announceText = getAnnounceText() | ||||
| 	jsonSub, header, err := a.subJsonService.GetJson(subId, host) | ||||
| 	if err != nil || len(jsonSub) == 0 { | ||||
| 		c.String(400, "Error!") | ||||
|  | @ -123,12 +163,32 @@ func (a *SUBController) subJsons(c *gin.Context) { | |||
| 		// Add headers
 | ||||
| 		c.Writer.Header().Set("Subscription-Userinfo", header) | ||||
| 		c.Writer.Header().Set("Profile-Update-Interval", a.updateInterval) | ||||
| 		c.Writer.Header().Set("Profile-Title", subId) | ||||
| 		c.Writer.Header().Set("Profile-Title", profileTitle) | ||||
| 		c.Writer.Header().Set("Support-Url", supportUrl) | ||||
| 		c.Writer.Header().Set("Profile-Web-Page-Url", profileWebPageUrl) | ||||
| 		if announceText != "" { | ||||
| 			c.Writer.Header().Set("Announce", announceText) | ||||
| 		} | ||||
| 
 | ||||
| 		c.String(200, jsonSub) | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| func getAnnounceText() (string) { | ||||
| 	announceFilePath := "/etc/x-ui/announce.txt" | ||||
| 	_, err := os.Stat(announceFilePath) | ||||
|     if os.IsNotExist(err) { | ||||
|         return "" | ||||
|     } | ||||
| 
 | ||||
|     content, err := ioutil.ReadFile(announceFilePath) | ||||
|     if err != nil { | ||||
|         return "" | ||||
|     } | ||||
| 
 | ||||
|     return string(content) | ||||
| } | ||||
| 
 | ||||
| func getHostFromXFH(s string) (string, error) { | ||||
| 	if strings.Contains(s, ":") { | ||||
| 		realHost, _, err := net.SplitHostPort(s) | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue
	
	 serogaq
						serogaq