1.3 KiB
1.3 KiB
Mellaris
Mellaris is a Go library for network stream analysis and filtering.
Usage
package main
import (
"context"
"git.difuse.io/Difuse/Mellaris"
)
func main() {
cfg := mellaris.Config{
IO: mellaris.IOConfig{
// QueueSize, ReadBuffer, WriteBuffer, Local, RST
},
Workers: mellaris.WorkersConfig{
// Count, QueueSize, TCPMaxBufferedPagesTotal, TCPMaxBufferedPagesPerConn, UDPMaxStreams
},
Ruleset: mellaris.RulesetConfig{
GeoIp: "/path/to/geoip.dat",
GeoSite: "/path/to/geosite.dat",
},
}
app, err := mellaris.New(cfg, mellaris.Options{
RulesFile: "rules.yaml",
Analyzers: mellaris.DefaultAnalyzers(),
Modifiers: mellaris.DefaultModifiers(),
})
if err != nil {
panic(err)
}
defer app.Close()
_ = app.Run(context.Background())
}
Testing
Run all tests:
go test ./...
Run tests with coverage:
go test -cover ./... # per-package summary
go test -coverprofile=coverage.out ./... # full profile
go tool cover -html=coverage.out -o coverage.html # HTML report
Run tests for a specific package:
go test -v ./analyzer/tcp/
go test -v -run TestSSH ./analyzer/tcp/
Based on OpenGFW by apernet: https://github.com/apernet/OpenGFW