mirror of
				https://github.com/TeaOSLab/EdgeAdmin.git
				synced 2025-11-04 13:10:26 +08:00 
			
		
		
		
	集群设置--网站设置中“处理未绑定域名方式”支持跳转到网址
This commit is contained in:
		@@ -46,6 +46,9 @@ func (this *IndexAction) RunGet(params struct {
 | 
				
			|||||||
	var httpAllDomainMismatchActionCode = serverconfigs.DomainMismatchActionPage
 | 
						var httpAllDomainMismatchActionCode = serverconfigs.DomainMismatchActionPage
 | 
				
			||||||
	var httpAllDomainMismatchActionContentHTML string
 | 
						var httpAllDomainMismatchActionContentHTML string
 | 
				
			||||||
	var httpAllDomainMismatchActionStatusCode = "404"
 | 
						var httpAllDomainMismatchActionStatusCode = "404"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						var httpAllDomainMismatchActionRedirectURL = ""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if config.HTTPAll.DomainMismatchAction != nil {
 | 
						if config.HTTPAll.DomainMismatchAction != nil {
 | 
				
			||||||
		httpAllDomainMismatchActionCode = config.HTTPAll.DomainMismatchAction.Code
 | 
							httpAllDomainMismatchActionCode = config.HTTPAll.DomainMismatchAction.Code
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -56,6 +59,10 @@ func (this *IndexAction) RunGet(params struct {
 | 
				
			|||||||
			if statusCode > 0 {
 | 
								if statusCode > 0 {
 | 
				
			||||||
				httpAllDomainMismatchActionStatusCode = types.String(statusCode)
 | 
									httpAllDomainMismatchActionStatusCode = types.String(statusCode)
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if config.HTTPAll.DomainMismatchAction.Code == serverconfigs.DomainMismatchActionRedirect {
 | 
				
			||||||
 | 
									httpAllDomainMismatchActionRedirectURL = config.HTTPAll.DomainMismatchAction.Options.GetString("url")
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		httpAllDomainMismatchActionContentHTML = `<!DOCTYPE html>
 | 
							httpAllDomainMismatchActionContentHTML = `<!DOCTYPE html>
 | 
				
			||||||
@@ -83,6 +90,8 @@ p { color: grey; }
 | 
				
			|||||||
	this.Data["httpAllDomainMismatchActionContentHTML"] = httpAllDomainMismatchActionContentHTML
 | 
						this.Data["httpAllDomainMismatchActionContentHTML"] = httpAllDomainMismatchActionContentHTML
 | 
				
			||||||
	this.Data["httpAllDomainMismatchActionStatusCode"] = httpAllDomainMismatchActionStatusCode
 | 
						this.Data["httpAllDomainMismatchActionStatusCode"] = httpAllDomainMismatchActionStatusCode
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.Data["httpAllDomainMismatchActionRedirectURL"] = httpAllDomainMismatchActionRedirectURL
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	this.Show()
 | 
						this.Show()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -93,6 +102,7 @@ func (this *IndexAction) RunPost(params struct {
 | 
				
			|||||||
	HttpAllDomainMismatchActionCode        string
 | 
						HttpAllDomainMismatchActionCode        string
 | 
				
			||||||
	HttpAllDomainMismatchActionContentHTML string
 | 
						HttpAllDomainMismatchActionContentHTML string
 | 
				
			||||||
	HttpAllDomainMismatchActionStatusCode  string
 | 
						HttpAllDomainMismatchActionStatusCode  string
 | 
				
			||||||
 | 
						HttpAllDomainMismatchActionRedirectURL string
 | 
				
			||||||
	HttpAllAllowMismatchDomainsJSON        []byte
 | 
						HttpAllAllowMismatchDomainsJSON        []byte
 | 
				
			||||||
	HttpAllAllowNodeIP                     bool
 | 
						HttpAllAllowNodeIP                     bool
 | 
				
			||||||
	HttpAllDefaultDomain                   string
 | 
						HttpAllDefaultDomain                   string
 | 
				
			||||||
@@ -156,11 +166,28 @@ func (this *IndexAction) RunPost(params struct {
 | 
				
			|||||||
	var domainMisMatchStatusCode = types.Int(domainMisMatchStatusCodeString)
 | 
						var domainMisMatchStatusCode = types.Int(domainMisMatchStatusCodeString)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	config.HTTPAll.MatchDomainStrictly = params.HttpAllMatchDomainStrictly
 | 
						config.HTTPAll.MatchDomainStrictly = params.HttpAllMatchDomainStrictly
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// validate
 | 
				
			||||||
 | 
						if config.HTTPAll.MatchDomainStrictly {
 | 
				
			||||||
 | 
							// validate redirect
 | 
				
			||||||
 | 
							if params.HttpAllDomainMismatchActionCode == serverconfigs.DomainMismatchActionRedirect {
 | 
				
			||||||
 | 
								if len(params.HttpAllDomainMismatchActionRedirectURL) == 0 {
 | 
				
			||||||
 | 
									this.FailField("httpAllDomainMismatchActionRedirectURL", "请输入跳转目标网址URL")
 | 
				
			||||||
 | 
									return
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								if !regexp.MustCompile(`(?i)(http|https)://`).MatchString(params.HttpAllDomainMismatchActionRedirectURL) {
 | 
				
			||||||
 | 
									this.FailField("httpAllDomainMismatchActionRedirectURL", "目标网址URL必须以http://或https://开头")
 | 
				
			||||||
 | 
									return
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	config.HTTPAll.DomainMismatchAction = &serverconfigs.DomainMismatchAction{
 | 
						config.HTTPAll.DomainMismatchAction = &serverconfigs.DomainMismatchAction{
 | 
				
			||||||
		Code: params.HttpAllDomainMismatchActionCode,
 | 
							Code: params.HttpAllDomainMismatchActionCode,
 | 
				
			||||||
		Options: maps.Map{
 | 
							Options: maps.Map{
 | 
				
			||||||
			"statusCode":  domainMisMatchStatusCode,
 | 
								"statusCode":  domainMisMatchStatusCode,                      // page
 | 
				
			||||||
			"contentHTML": params.HttpAllDomainMismatchActionContentHTML,
 | 
								"contentHTML": params.HttpAllDomainMismatchActionContentHTML, // page
 | 
				
			||||||
 | 
								"url":         params.HttpAllDomainMismatchActionRedirectURL, // redirect
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -27,8 +27,11 @@
 | 
				
			|||||||
                    <td class="color-border">处理未绑定域名方式</td>
 | 
					                    <td class="color-border">处理未绑定域名方式</td>
 | 
				
			||||||
                    <td>
 | 
					                    <td>
 | 
				
			||||||
                        <radio name="httpAllDomainMismatchActionCode" :v-value="'page'" v-model="httpAllDomainMismatchActionCode">显示提示页面</radio>  
 | 
					                        <radio name="httpAllDomainMismatchActionCode" :v-value="'page'" v-model="httpAllDomainMismatchActionCode">显示提示页面</radio>  
 | 
				
			||||||
                          <radio name="httpAllDomainMismatchActionCode" :v-value="'close'" v-model="httpAllDomainMismatchActionCode">关闭连接</radio>
 | 
					                          <radio name="httpAllDomainMismatchActionCode" :v-value="'redirect'" v-model="httpAllDomainMismatchActionCode">跳转到网址</radio>  
 | 
				
			||||||
 | 
					                        <radio name="httpAllDomainMismatchActionCode" :v-value="'close'" v-model="httpAllDomainMismatchActionCode">关闭连接</radio>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        <p class="comment" v-if="httpAllDomainMismatchActionCode == 'page'">显示提示内容。</p>
 | 
					                        <p class="comment" v-if="httpAllDomainMismatchActionCode == 'page'">显示提示内容。</p>
 | 
				
			||||||
 | 
					                        <p class="comment" v-if="httpAllDomainMismatchActionCode == 'redirect'">跳转到一个特定URL。</p>
 | 
				
			||||||
                        <p class="comment" v-if="httpAllDomainMismatchActionCode == 'close'">直接关闭网络连接,不提示任何内容。</p>
 | 
					                        <p class="comment" v-if="httpAllDomainMismatchActionCode == 'close'">直接关闭网络连接,不提示任何内容。</p>
 | 
				
			||||||
                    </td>
 | 
					                    </td>
 | 
				
			||||||
                </tr>
 | 
					                </tr>
 | 
				
			||||||
@@ -48,6 +51,14 @@
 | 
				
			|||||||
                    </td>
 | 
					                    </td>
 | 
				
			||||||
                </tr>
 | 
					                </tr>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                <tr v-show="config.httpAll.matchDomainStrictly && httpAllDomainMismatchActionCode == 'redirect'">
 | 
				
			||||||
 | 
					                    <td class="color-border">跳转目标网址URL *</td>
 | 
				
			||||||
 | 
					                    <td>
 | 
				
			||||||
 | 
					                        <input type="text" placeholder="https://..." name="httpAllDomainMismatchActionRedirectURL" v-model="httpAllDomainMismatchActionRedirectURL"/>
 | 
				
			||||||
 | 
					                        <p class="comment">必须以http://或者https://开头,支持使用变量。</p>
 | 
				
			||||||
 | 
					                    </td>
 | 
				
			||||||
 | 
					                </tr>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                <tr v-show="config.httpAll.matchDomainStrictly">
 | 
					                <tr v-show="config.httpAll.matchDomainStrictly">
 | 
				
			||||||
                    <td>允许例外的域名</td>
 | 
					                    <td>允许例外的域名</td>
 | 
				
			||||||
                    <td>
 | 
					                    <td>
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user