engine

package
v0.0.0-...-6bdff43 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 19, 2023 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

type Engine struct {
	Context   *context.Context   // 上下文
	Wg        *sync.WaitGroup    // Wg
	Pool      int                // 线程池
	PoolFunc  *ants.PoolWithFunc // 线程调用
	EventData chan *EventData    // 数据队列
}

引擎对象,全局单实例

var G_Engine *Engine

全局引擎

func NewEngine

func NewEngine(c *context.Context, pool int) *Engine

创建引擎

默认每个 goroutine 占用 8KB 内存
一台 8GB 内存的机器满打满算也只能创建 8GB/8KB = 1000000 个 goroutine
更何况系统还需要保留一部分内存运行日常管理任务,go 运行时需要内存运行 gc、处理 goroutine 切换等

func (*Engine) Close

func (e *Engine) Close()

释放资源

func (*Engine) DoCase

func (e *Engine) DoCase(ed *EventData) interface{}

case 扫描使用的函数

func (*Engine) DoEvent

func (e *Engine) DoEvent(ed *EventData)

执行事件代码 内部用

每个事件自己做防重处理
每个事件异步执行
每种事件类型可以独立控制并发数

type EventData

type EventData struct {
	EventType string        // 类型:masscan、nmap、
	EventData []interface{} // func,parms
}

事件数据

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL