7a3f6e945d6e46380824ca5d95db25aecd758895
Refactors TCP and UDP flow managers to enhance analyzer selection and flow binding accuracy, including O(1) UDP stream rebinding by 5-tuple. Introduces runtime stats tracking for engine and ruleset operations, exposing new APIs for granular performance and error metrics. Optimizes GeoMatcher with result caching and supports efficient geosite set matching, reducing redundant computation in ruleset expressions.
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
LICENSE
Languages
Go
100%