mirror of
				https://github.com/TeaOSLab/EdgeNode.git
				synced 2025-11-04 16:00:25 +08:00 
			
		
		
		
	增加注释
This commit is contained in:
		@@ -13,7 +13,7 @@ func (this *BaseAction) Close() error {
 | 
				
			|||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// 处理HTTP请求
 | 
					// DoHTTP 处理HTTP请求
 | 
				
			||||||
func (this *BaseAction) DoHTTP(req *http.Request, resp http.ResponseWriter) (goNext bool, err error) {
 | 
					func (this *BaseAction) DoHTTP(req *http.Request, resp http.ResponseWriter) (goNext bool, err error) {
 | 
				
			||||||
	return true, nil
 | 
						return true, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,6 @@
 | 
				
			|||||||
package iplibrary
 | 
					package iplibrary
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// 是否是致命错误
 | 
					// FataError 是否是致命错误
 | 
				
			||||||
type FataError struct {
 | 
					type FataError struct {
 | 
				
			||||||
	err string
 | 
						err string
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -6,19 +6,19 @@ import (
 | 
				
			|||||||
	"net/http"
 | 
						"net/http"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// HTML动作
 | 
					// HTMLAction HTML动作
 | 
				
			||||||
type HTMLAction struct {
 | 
					type HTMLAction struct {
 | 
				
			||||||
	BaseAction
 | 
						BaseAction
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	config *firewallconfigs.FirewallActionHTMLConfig
 | 
						config *firewallconfigs.FirewallActionHTMLConfig
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// 获取新对象
 | 
					// NewHTMLAction 获取新对象
 | 
				
			||||||
func NewHTMLAction() *HTMLAction {
 | 
					func NewHTMLAction() *HTMLAction {
 | 
				
			||||||
	return &HTMLAction{}
 | 
						return &HTMLAction{}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// 初始化
 | 
					// Init 初始化
 | 
				
			||||||
func (this *HTMLAction) Init(config *firewallconfigs.FirewallActionConfig) error {
 | 
					func (this *HTMLAction) Init(config *firewallconfigs.FirewallActionConfig) error {
 | 
				
			||||||
	this.config = &firewallconfigs.FirewallActionHTMLConfig{}
 | 
						this.config = &firewallconfigs.FirewallActionHTMLConfig{}
 | 
				
			||||||
	err := this.convertParams(config.Params, this.config)
 | 
						err := this.convertParams(config.Params, this.config)
 | 
				
			||||||
@@ -28,22 +28,22 @@ func (this *HTMLAction) Init(config *firewallconfigs.FirewallActionConfig) error
 | 
				
			|||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// 添加
 | 
					// AddItem 添加
 | 
				
			||||||
func (this *HTMLAction) AddItem(listType IPListType, item *pb.IPItem) error {
 | 
					func (this *HTMLAction) AddItem(listType IPListType, item *pb.IPItem) error {
 | 
				
			||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// 删除
 | 
					// DeleteItem 删除
 | 
				
			||||||
func (this *HTMLAction) DeleteItem(listType IPListType, item *pb.IPItem) error {
 | 
					func (this *HTMLAction) DeleteItem(listType IPListType, item *pb.IPItem) error {
 | 
				
			||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// 关闭
 | 
					// Close 关闭
 | 
				
			||||||
func (this *HTMLAction) Close() error {
 | 
					func (this *HTMLAction) Close() error {
 | 
				
			||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// 处理HTTP请求
 | 
					// DoHTTP 处理HTTP请求
 | 
				
			||||||
func (this *HTMLAction) DoHTTP(req *http.Request, resp http.ResponseWriter) (goNext bool, err error) {
 | 
					func (this *HTMLAction) DoHTTP(req *http.Request, resp http.ResponseWriter) (goNext bool, err error) {
 | 
				
			||||||
	if this.config == nil {
 | 
						if this.config == nil {
 | 
				
			||||||
		goNext = true
 | 
							goNext = true
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,18 +7,18 @@ import (
 | 
				
			|||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type ActionInterface interface {
 | 
					type ActionInterface interface {
 | 
				
			||||||
	// 初始化
 | 
						// Init 初始化
 | 
				
			||||||
	Init(config *firewallconfigs.FirewallActionConfig) error
 | 
						Init(config *firewallconfigs.FirewallActionConfig) error
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// 添加
 | 
						// AddItem 添加
 | 
				
			||||||
	AddItem(listType IPListType, item *pb.IPItem) error
 | 
						AddItem(listType IPListType, item *pb.IPItem) error
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// 删除
 | 
						// DeleteItem 删除
 | 
				
			||||||
	DeleteItem(listType IPListType, item *pb.IPItem) error
 | 
						DeleteItem(listType IPListType, item *pb.IPItem) error
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// 关闭
 | 
						// Close 关闭
 | 
				
			||||||
	Close() error
 | 
						Close() error
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// 处理HTTP请求
 | 
						// DoHTTP 处理HTTP请求
 | 
				
			||||||
	DoHTTP(req *http.Request, resp http.ResponseWriter) (goNext bool, err error)
 | 
						DoHTTP(req *http.Request, resp http.ResponseWriter) (goNext bool, err error)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,11 +9,12 @@ import (
 | 
				
			|||||||
	"runtime"
 | 
						"runtime"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// IPTables动作
 | 
					// IPTablesAction IPTables动作
 | 
				
			||||||
// 相关命令:
 | 
					// 相关命令:
 | 
				
			||||||
//   iptables -A INPUT -s "192.168.2.32" -j ACCEPT
 | 
					//   iptables -A INPUT -s "192.168.2.32" -j ACCEPT
 | 
				
			||||||
//   iptables -A INPUT -s "192.168.2.32" -j REJECT
 | 
					//   iptables -A INPUT -s "192.168.2.32" -j REJECT
 | 
				
			||||||
//   iptables -D ...
 | 
					//   iptables -D INPUT ...
 | 
				
			||||||
 | 
					//   iptables -F INPUT
 | 
				
			||||||
type IPTablesAction struct {
 | 
					type IPTablesAction struct {
 | 
				
			||||||
	BaseAction
 | 
						BaseAction
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -10,7 +10,7 @@ import (
 | 
				
			|||||||
	"path/filepath"
 | 
						"path/filepath"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// 脚本命令动作
 | 
					// ScriptAction 脚本命令动作
 | 
				
			||||||
type ScriptAction struct {
 | 
					type ScriptAction struct {
 | 
				
			||||||
	BaseAction
 | 
						BaseAction
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -28,7 +28,7 @@ func (this *IPItem) Contains(ip uint64) bool {
 | 
				
			|||||||
	case IPItemTypeIPv6:
 | 
						case IPItemTypeIPv6:
 | 
				
			||||||
		return this.containsIPv6(ip)
 | 
							return this.containsIPv6(ip)
 | 
				
			||||||
	case IPItemTypeAll:
 | 
						case IPItemTypeAll:
 | 
				
			||||||
		return this.containsAll(ip)
 | 
							return this.containsAll()
 | 
				
			||||||
	default:
 | 
						default:
 | 
				
			||||||
		return this.containsIPv4(ip)
 | 
							return this.containsIPv4(ip)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -63,7 +63,7 @@ func (this *IPItem) containsIPv6(ip uint64) bool {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// 检查是否包所有IP
 | 
					// 检查是否包所有IP
 | 
				
			||||||
func (this *IPItem) containsAll(ip uint64) bool {
 | 
					func (this *IPItem) containsAll() bool {
 | 
				
			||||||
	if this.ExpiredAt > 0 && this.ExpiredAt < utils.UnixTime() {
 | 
						if this.ExpiredAt > 0 && this.ExpiredAt < utils.UnixTime() {
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user