Documentation
¶
Index ¶
- Constants
- Variables
- func FixProtocol(oldProtocol string) string
- func GetCacheKey(fileName string, versionIntensity int) string
- func GetDefaultProbeFilePath() string
- func InitDefaultStore() error
- func ParseRegexPattern(pattern string) string
- func RegexStringUnescape(s string) string
- type FingerprintOptions
- type Match
- type MatchResult
- type Probe
- type Store
- func (ps *Store) AddProbe(probe *Probe)
- func (ps *Store) Clear()
- func (ps *Store) GetAllProbes() []*Probe
- func (ps *Store) GetProbe(protocol, name string) *Probe
- func (ps *Store) GetProbeForPort(protocol string, port int, ssl bool) []*Probe
- func (ps *Store) GetProbesByName(name string) *Probe
- func (ps *Store) GetTCPProbes() []*Probe
- func (ps *Store) GetUDPProbes() []*Probe
- func (ps *Store) Load() error
- func (ps *Store) LoadFromContent(content string) error
- func (ps *Store) LoadFromFile(filePath string) error
- func (ps *Store) SetFallbackProbes() error
- type StoreOption
- type TemplateProcessor
- type VersionInfo
Constants ¶
View Source
const ( // TCP 协议 TCP = "tcp" // UDP 协议 UDP = "udp" )
定义协议类型常量
View Source
const DefaultRegexpTimeout = 500 * time.Millisecond
DefaultRegexpTimeout 默认正则表达式匹配超时时间,防止灾难性回溯
Variables ¶
View Source
var DefaultVersionIntensity = 7
Functions ¶
func GetCacheKey ¶
GetCacheKey 根据文件名和版本强度生成缓存键
func GetDefaultProbeFilePath ¶
func GetDefaultProbeFilePath() string
GetDefaultProbeFilePath 获取默认的探针文件路径
func InitDefaultStore ¶
func InitDefaultStore() error
func RegexStringUnescape ¶
Types ¶
type FingerprintOptions ¶
type FingerprintOptions struct {
// 指纹文件路径(可选,默认使用内置指纹)
ProbeFilePath string
// 版本检测强度(0-9)
VersionIntensity int
}
FingerprintOptions 指纹库配置选项
type Match ¶
type Match struct {
// 行号
Line int
// 是否为软匹配
Soft bool
// 服务名称
Service string
// 匹配模式
Pattern string
// 版本信息
VersionInfo *VersionInfo
// contains filtered or unexported fields
}
Match 表示一个匹配规则
type MatchResult ¶
type Probe ¶
type Probe struct {
// 探针名称
Name string
// 探针适用的默认端口
Ports []int
// 探针适用的SSL端口
SSLPorts []int
// 探针总等待时间
TotalWaitMS time.Duration
// TCP包装等待时间
TCPWrappedMS time.Duration
// 探针稀有度(值越小优先级越高)
Rarity int
// 使用字符串表示协议类型
Protocol string
// 探针发送数据
SendData []byte
// 匹配组
MatchGroup []*Match
// 回退探针名称
Fallback []string
// 回退探针引用
FallbackProbes []*Probe
// 探针的匹配超时时间
MatchTimeout time.Duration
}
Probe 表示一个服务探针
func ParseProbes ¶
ParseProbes 解析探针文件内容并添加到指定的探针存储中
func (*Probe) HasExactPort ¶
HasExactPort 检查探针是否精确匹配指定端口(单独列出而非端口范围)
func (*Probe) HasExactSSLPort ¶
HasExactSSLPort 检查探针是否精确匹配SSL端口(单独列出而非端口范围)
type Store ¶
type Store struct {
// 按名称索引的探针映射
ProbesByName map[string]*Probe
// TCP探针列表
TCPProbes []*Probe
// UDP探针列表
UDPProbes []*Probe
// contains filtered or unexported fields
}
var (
DefaultStore *Store
)
默认探针存储实例
func GetDefaultStore ¶
func GetDefaultStore() *Store
func GetStoreWithOptions ¶
GetStoreWithOptions GetStoreWithIntensity 获取指定版本强度的探针存储
func (*Store) GetProbeForPort ¶
GetProbeForPort 获取适用于指定端口的探针列表,先按端口精确匹配度排序,再按稀有度排序
func (*Store) GetProbesByName ¶
GetProbesByName 根据名称获取探针
func (*Store) LoadFromContent ¶
LoadFromContent 从字符串内容加载探针
func (*Store) LoadFromFile ¶
LoadFromFile 从文件加载探针
func (*Store) SetFallbackProbes ¶
SetFallbackProbes 设置探针的fallback引用
type StoreOption ¶
type StoreOption func(*Store)
func WithFileName ¶
func WithFileName(fileName string) StoreOption
func WithVersionIntensity ¶
func WithVersionIntensity(versionIntensity int) StoreOption
type TemplateProcessor ¶
type TemplateProcessor struct {
// contains filtered or unexported fields
}
TemplateProcessor 处理版本信息模板替换
func NewTemplateProcessor ¶
func NewTemplateProcessor(groups map[string]string) *TemplateProcessor
NewTemplateProcessor 创建一个新的模板处理器
func (*TemplateProcessor) ProcessTemplate ¶
func (p *TemplateProcessor) ProcessTemplate(template string) string
ProcessTemplate 处理模板字符串,替换其中的变量
Click to show internal directories.
Click to hide internal directories.