mirror of
https://github.com/chainreactors/spray.git
synced 2026-10-24 08:54:30 +00:00
- go:generate now uses -embed flag to produce //go:embed binary data - templates.go reduced from 125KB base64 source to 0.9KB + 93KB .bin files - binary saves ~28KB (removes base64 decode overhead at runtime) - templates submodule updated with embed-aware generator Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
43 lines
911 B
Go
43 lines
911 B
Go
//go:build !emptytemplates
|
|
// +build !emptytemplates
|
|
|
|
package pkg
|
|
|
|
import (
|
|
_ "embed"
|
|
|
|
"github.com/chainreactors/utils/encode"
|
|
)
|
|
|
|
//go:embed data/spray_rule.bin
|
|
var sprayRuleData []byte
|
|
|
|
//go:embed data/spray_common.bin
|
|
var sprayCommonData []byte
|
|
|
|
//go:embed data/spray_dict.bin
|
|
var sprayDictData []byte
|
|
|
|
//go:embed data/extract.bin
|
|
var extractData []byte
|
|
|
|
//go:embed data/port.bin
|
|
var portData []byte
|
|
|
|
var RandomDir = "/g8kZMwp4oeKsL2in"
|
|
|
|
func loadEmbeddedConfig(typ string) []byte {
|
|
if typ == "spray_rule" {
|
|
return encode.MustDeflateDeCompress(sprayRuleData)
|
|
}else if typ == "spray_common" {
|
|
return encode.MustDeflateDeCompress(sprayCommonData)
|
|
}else if typ == "spray_dict" {
|
|
return encode.MustDeflateDeCompress(sprayDictData)
|
|
}else if typ == "extract" {
|
|
return encode.MustDeflateDeCompress(extractData)
|
|
}else if typ == "port" {
|
|
return encode.MustDeflateDeCompress(portData)
|
|
}
|
|
return nil
|
|
}
|