mirror of
https://github.com/bjdgyc/anylink.git
synced 2025-08-08 08:11:49 +08:00
支持分割DNS功能
This commit is contained in:
@@ -75,6 +75,10 @@ func GroupDetail(w http.ResponseWriter, r *http.Request) {
|
||||
if len(data.Auth) == 0 {
|
||||
data.Auth["type"] = "local"
|
||||
}
|
||||
// 兼容旧数据
|
||||
if data.SplitDns == nil {
|
||||
data.SplitDns = []dbdata.ValData{}
|
||||
}
|
||||
RespSucess(w, data)
|
||||
}
|
||||
|
||||
|
@@ -9,6 +9,7 @@
|
||||
<RestrictTunnelProtocols>IPSec</RestrictTunnelProtocols>
|
||||
<BypassDownloader>true</BypassDownloader>
|
||||
<AutoUpdate UserControllable="false">false</AutoUpdate>
|
||||
<LocalLanAccess UserControllable="true">true</LocalLanAccess>
|
||||
<WindowsVPNEstablishment>AllowRemoteUsers</WindowsVPNEstablishment>
|
||||
<LinuxVPNEstablishment>AllowRemoteUsers</LinuxVPNEstablishment>
|
||||
<CertEnrollmentPin>pinAllowed</CertEnrollmentPin>
|
||||
|
@@ -215,6 +215,7 @@ func SetGroup(g *Group) error {
|
||||
// DNS 判断
|
||||
clientDns := []ValData{}
|
||||
for _, v := range g.ClientDns {
|
||||
v.Val = strings.TrimSpace(v.Val)
|
||||
if v.Val != "" {
|
||||
ip := net.ParseIP(v.Val)
|
||||
if ip.String() != v.Val {
|
||||
@@ -229,6 +230,20 @@ func SetGroup(g *Group) error {
|
||||
return errors.New("默认路由,必须设置一个DNS")
|
||||
}
|
||||
g.ClientDns = clientDns
|
||||
|
||||
splitDns := []ValData{}
|
||||
for _, v := range g.SplitDns {
|
||||
v.Val = strings.TrimSpace(v.Val)
|
||||
if v.Val != "" {
|
||||
ValidateDomainName(v.Val)
|
||||
if !ValidateDomainName(v.Val) {
|
||||
return errors.New("域名 错误")
|
||||
}
|
||||
splitDns = append(splitDns, v)
|
||||
}
|
||||
}
|
||||
g.SplitDns = splitDns
|
||||
|
||||
// 域名拆分隧道,不能同时填写
|
||||
g.DsIncludeDomains = strings.TrimSpace(g.DsIncludeDomains)
|
||||
g.DsExcludeDomains = strings.TrimSpace(g.DsExcludeDomains)
|
||||
|
@@ -11,6 +11,7 @@ type Group struct {
|
||||
Note string `json:"note" xorm:"varchar(255)"`
|
||||
AllowLan bool `json:"allow_lan" xorm:"Bool"`
|
||||
ClientDns []ValData `json:"client_dns" xorm:"Text"`
|
||||
SplitDns []ValData `json:"split_dns" xorm:"Text"`
|
||||
RouteInclude []ValData `json:"route_include" xorm:"Text"`
|
||||
RouteExclude []ValData `json:"route_exclude" xorm:"Text"`
|
||||
DsExcludeDomains string `json:"ds_exclude_domains" xorm:"Text"`
|
||||
|
@@ -131,6 +131,11 @@ func LinkTunnel(w http.ResponseWriter, r *http.Request) {
|
||||
for _, v := range cSess.Group.ClientDns {
|
||||
HttpAddHeader(w, "X-CSTP-DNS", v.Val)
|
||||
}
|
||||
// 分割dns
|
||||
for _, v := range cSess.Group.SplitDns {
|
||||
HttpAddHeader(w, "X-CSTP-Split-DNS", v.Val)
|
||||
}
|
||||
|
||||
// 允许的路由
|
||||
for _, v := range cSess.Group.RouteInclude {
|
||||
if strings.ToLower(v.Val) == dbdata.All {
|
||||
|
Reference in New Issue
Block a user