common/pkg/proxy/option.go
2024-12-04 19:30:22 +08:00

30 lines
515 B
Go

package proxy
import (
"os"
"time"
"gopkg.in/yaml.v3"
)
const (
ProxyConfigEnv = "PROXY_CONFIG_PATH"
DefaultProxyConfigPath = "/cfg/proxy.yaml"
)
type Option struct {
Subscribes []string `yaml:"subscribes"`
Clash []string `yaml:"clash"`
Interval time.Duration `yaml:"interval"`
}
func LoadProxyConfig(path string) (*Option, error) {
f, err := os.Open(path)
if err != nil {
return nil, err
}
defer f.Close()
var opt Option
return &opt, yaml.NewDecoder(f).Decode(&opt)
}