common/pkg/proxy/option.go

30 lines
515 B
Go
Raw Normal View History

2024-05-13 20:09:13 +08:00
package proxy
2024-12-04 19:30:22 +08:00
import (
"os"
"time"
"gopkg.in/yaml.v3"
)
const (
ProxyConfigEnv = "PROXY_CONFIG_PATH"
DefaultProxyConfigPath = "/cfg/proxy.yaml"
)
2024-05-13 20:09:13 +08:00
type Option struct {
Subscribes []string `yaml:"subscribes"`
2024-12-04 19:30:22 +08:00
Clash []string `yaml:"clash"`
2024-05-13 20:09:13 +08:00
Interval time.Duration `yaml:"interval"`
}
2024-12-04 19:30:22 +08:00
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)
}