mirror of
				https://github.com/TeaOSLab/EdgeAdmin.git
				synced 2025-11-04 21:50:28 +08:00 
			
		
		
		
	安装过程中节点主机地址允许填写域名
This commit is contained in:
		@@ -10,6 +10,7 @@ import (
 | 
				
			|||||||
	"github.com/iwind/TeaGo/maps"
 | 
						"github.com/iwind/TeaGo/maps"
 | 
				
			||||||
	"github.com/iwind/TeaGo/types"
 | 
						"github.com/iwind/TeaGo/types"
 | 
				
			||||||
	"net"
 | 
						"net"
 | 
				
			||||||
 | 
						"regexp"
 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -61,7 +62,24 @@ func (this *ValidateApiAction) RunPost(params struct {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if net.ParseIP(params.NewHost) == nil {
 | 
							if net.ParseIP(params.NewHost) == nil {
 | 
				
			||||||
 | 
								// 检查是否为域名
 | 
				
			||||||
 | 
								var domainReg = regexp.MustCompile(`^[\w-]+$`) // 这里暂不支持 unicode 域名
 | 
				
			||||||
 | 
								var digitReg = regexp.MustCompile(`^\d+$`)
 | 
				
			||||||
 | 
								var isIP = true
 | 
				
			||||||
 | 
								for _, piece := range strings.Split(params.NewHost, ".") {
 | 
				
			||||||
 | 
									if !domainReg.MatchString(piece) {
 | 
				
			||||||
					this.FailField("newHost", "请输入正确的API节点主机地址")
 | 
										this.FailField("newHost", "请输入正确的API节点主机地址")
 | 
				
			||||||
 | 
										return
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									if !digitReg.MatchString(piece) {
 | 
				
			||||||
 | 
										isIP = false
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if isIP {
 | 
				
			||||||
 | 
									this.FailField("newHost", "请输入正确的API节点主机地址")
 | 
				
			||||||
 | 
									return
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		params.Must.
 | 
							params.Must.
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -89,7 +89,7 @@
 | 
				
			|||||||
                                    <input type="text" name="newHost" value="" ref="newHostRef" placeholder="x.x.x.x" v-model="currentHost"/>
 | 
					                                    <input type="text" name="newHost" value="" ref="newHostRef" placeholder="x.x.x.x" v-model="currentHost"/>
 | 
				
			||||||
								</div>
 | 
													</div>
 | 
				
			||||||
							</div>
 | 
												</div>
 | 
				
			||||||
							<p class="comment">其他节点访问此API节点的主机地址,可以是IP或者域名,第一次安装时通常是<strong>当前服务器</strong>的公网IP地址。后期可以修改这个地址。</p>
 | 
												<p class="comment">API节点IP地址或者域名。其他节点访问此API节点的主机地址,可以是IP或者域名,第一次安装时通常是<strong>当前服务器</strong>的公网IP地址。后期可以修改这个地址。</p>
 | 
				
			||||||
						</td>
 | 
											</td>
 | 
				
			||||||
					</tr>
 | 
										</tr>
 | 
				
			||||||
				</tbody>
 | 
									</tbody>
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user