Skip to content

Commit

Permalink
Merge pull request #117 from samwafgo/feat_moredomain
Browse files Browse the repository at this point in the history
fix:host more domain wildcard
  • Loading branch information
samwafgo authored Jan 9, 2025
2 parents 9a2d09d + 7bde7c8 commit 2553447
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,10 @@ func (m *wafSystenService) run() {
if hosts[0].Ssl != hostsOld.Ssl || hosts[0].Keyfile != hostsOld.Keyfile || hosts[0].Certfile != hostsOld.Certfile {
globalobj.GWAF_RUNTIME_OBJ_WAF_ENGINE.RemoveHost(hosts[0])
}
//绑定更多域名变更了
if hosts[0].BindMoreHost != hostsOld.BindMoreHost {
globalobj.GWAF_RUNTIME_OBJ_WAF_ENGINE.RemoveHost(hosts[0])
}
globalobj.GWAF_RUNTIME_OBJ_WAF_ENGINE.LoadHost(hosts[0])
globalobj.GWAF_RUNTIME_OBJ_WAF_ENGINE.StartAllProxyServer()
} else if hosts[0].Host == hostsOld.Host && hosts[0].Port != hostsOld.Port {
Expand Down
7 changes: 6 additions & 1 deletion wafenginecore/wafengine.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ func (waf *WafEngine) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// 看看是不是泛域名情况
target, ok = waf.HostTarget[domaintool.MaskSubdomain(host)]
if ok {
host = domaintool.MaskSubdomain(host)
findHost = true
targetCode = target.Host.Code
}
Expand All @@ -116,6 +115,12 @@ func (waf *WafEngine) ServeHTTP(w http.ResponseWriter, r *http.Request) {
targetCode, ok = waf.HostTargetMoreDomain[host]
if ok {
findHost = true
} else {
// 看看是不是泛域名情况
targetCode, ok = waf.HostTargetMoreDomain[domaintool.MaskSubdomain(host)]
if ok {
findHost = true
}
}
}

Expand Down
6 changes: 6 additions & 0 deletions wafenginecore/wafworker.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,12 @@ func (waf *WafEngine) RemoveHost(host model.Hosts) {
delete(waf.HostTarget, host.Host+":"+strconv.Itoa(host.Port))
//c.移除某个端口下的证书数据
waf.AllCertificate.RemoveSSL(host.Host)
//d.删除更多内容里面域名信息
for moreHost, hostCode := range waf.HostTargetMoreDomain {
if hostCode == host.Code {
delete(waf.HostTargetMoreDomain, moreHost)
}
}
//检测如果端口已经没有关联服务就直接关闭掉
waf.RemovePortServer()
}
Expand Down

0 comments on commit 2553447

Please sign in to comment.