mirror of
				https://github.com/TeaOSLab/EdgeNode.git
				synced 2025-11-04 07:40:56 +08:00 
			
		
		
		
	* 信息加密使用struct代替map,以缩短加密后内容长度 * 拦截动作、人机识别动作增加是否尝试全局封禁选项 * JSCookie识别动作增加默认设置选项 * 人机识别中传入info参数异常时,尝试跳转到来源地址,避免直接提示invalid request
		
			
				
	
	
		
			47 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			47 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
 | 
						|
 | 
						|
package waf
 | 
						|
 | 
						|
import (
 | 
						|
	"github.com/TeaOSLab/EdgeNode/internal/utils"
 | 
						|
	"github.com/TeaOSLab/EdgeNode/internal/utils/fasttime"
 | 
						|
	"net/url"
 | 
						|
)
 | 
						|
 | 
						|
type InfoArg struct {
 | 
						|
	ActionId         int64  `json:"1,omitempty"`
 | 
						|
	Timestamp        int64  `json:"2,omitempty"`
 | 
						|
	URL              string `json:"3,omitempty"`
 | 
						|
	PolicyId         int64  `json:"4,omitempty"`
 | 
						|
	GroupId          int64  `json:"5,omitempty"`
 | 
						|
	SetId            int64  `json:"6,omitempty"`
 | 
						|
	UseLocalFirewall bool   `json:"7,omitempty"`
 | 
						|
	Life             int32  `json:"8,omitempty"`
 | 
						|
	Scope            string `json:"9,omitempty"`
 | 
						|
	RemoteIP         string `json:"10,omitempty"`
 | 
						|
}
 | 
						|
 | 
						|
func (this *InfoArg) IsValid() bool {
 | 
						|
	return this.Timestamp > 0
 | 
						|
}
 | 
						|
 | 
						|
func (this *InfoArg) Encode() (string, error) {
 | 
						|
	if this.Timestamp <= 0 {
 | 
						|
		this.Timestamp = fasttime.Now().Unix()
 | 
						|
	}
 | 
						|
 | 
						|
	return utils.SimpleEncryptObject(this)
 | 
						|
}
 | 
						|
 | 
						|
func (this *InfoArg) URLEncoded() (string, error) {
 | 
						|
	encodedString, err := this.Encode()
 | 
						|
	if err != nil {
 | 
						|
		return "", err
 | 
						|
	}
 | 
						|
	return url.QueryEscape(encodedString), nil
 | 
						|
}
 | 
						|
 | 
						|
func (this *InfoArg) Decode(encodedString string) error {
 | 
						|
	return utils.SimpleDecryptObjet(encodedString, this)
 | 
						|
}
 |