增加一些注释、测试等

This commit is contained in:
刘祥超
2021-01-21 11:00:46 +08:00
parent 25e75d9078
commit ec47fc560c
4 changed files with 13 additions and 1 deletions

View File

@@ -49,7 +49,7 @@ func (this *IPListManager) Start() {
remotelogs.Println("IP_LIST_MANAGER", err.Error()) remotelogs.Println("IP_LIST_MANAGER", err.Error())
} }
ticker := time.NewTicker(60 * time.Second) // TODO 未来改成可以手动触发IP变更事件 ticker := time.NewTicker(60 * time.Second)
events.On(events.EventQuit, func() { events.On(events.EventQuit, func() {
ticker.Stop() ticker.Stop()
}) })

View File

@@ -853,6 +853,7 @@ func (this *HTTPRequest) requestServerPort() int {
// 设置代理相关头部信息 // 设置代理相关头部信息
// 参考https://tools.ietf.org/html/rfc7239 // 参考https://tools.ietf.org/html/rfc7239
// TODO X-Forwarded-* 系列做成可选项,避免有些源站屏蔽此项
func (this *HTTPRequest) setForwardHeaders(header http.Header) { func (this *HTTPRequest) setForwardHeaders(header http.Header) {
if this.RawReq.Header.Get("Connection") == "close" { if this.RawReq.Header.Get("Connection") == "close" {
this.RawReq.Header.Set("Connection", "keep-alive") this.RawReq.Header.Set("Connection", "keep-alive")

View File

@@ -84,6 +84,7 @@ func (this *HTTPRequest) checkWAFRequest(firewallPolicy *firewallconfigs.HTTPFir
countryId := iplibrary.SharedCountryManager.Lookup(result.Country) countryId := iplibrary.SharedCountryManager.Lookup(result.Country)
if countryId > 0 && lists.ContainsInt64(regionConfig.DenyCountryIds, countryId) { if countryId > 0 && lists.ContainsInt64(regionConfig.DenyCountryIds, countryId) {
// TODO 可以配置对封禁的处理方式等 // TODO 可以配置对封禁的处理方式等
// TODO 需要记录日志信息
this.writer.WriteHeader(http.StatusForbidden) this.writer.WriteHeader(http.StatusForbidden)
this.writer.Close() this.writer.Close()
@@ -99,6 +100,7 @@ func (this *HTTPRequest) checkWAFRequest(firewallPolicy *firewallconfigs.HTTPFir
provinceId := iplibrary.SharedProvinceManager.Lookup(result.Province) provinceId := iplibrary.SharedProvinceManager.Lookup(result.Province)
if provinceId > 0 && lists.ContainsInt64(regionConfig.DenyProvinceIds, provinceId) { if provinceId > 0 && lists.ContainsInt64(regionConfig.DenyProvinceIds, provinceId) {
// TODO 可以配置对封禁的处理方式等 // TODO 可以配置对封禁的处理方式等
// TODO 需要记录日志信息
this.writer.WriteHeader(http.StatusForbidden) this.writer.WriteHeader(http.StatusForbidden)
this.writer.Close() this.writer.Close()

View File

@@ -0,0 +1,9 @@
package utils
import "testing"
func TestIP2Long(t *testing.T) {
t.Log(IP2Long("0.0.0.0"))
t.Log(IP2Long("1.0.0.0"))
t.Log(IP2Long("0.0.0.0.0"))
}