feat: Allows passing in base64-encoded configuration strings

This commit is contained in:
xishang0128
2024-09-03 17:55:11 +08:00
parent 43f21c0b41
commit faaa90f8a6
2 changed files with 57 additions and 20 deletions

View File

@@ -64,8 +64,16 @@ func applyRoute(cfg *config.Config) {
}
// Parse call at the beginning of mihomo
func Parse(options ...Option) error {
cfg, err := executor.Parse()
func Parse(configBytes []byte, options ...Option) error {
var cfg *config.Config
var err error
if len(configBytes) != 0 {
cfg, err = executor.ParseWithBytes(configBytes)
} else {
cfg, err = executor.Parse()
}
if err != nil {
return err
}