mirror of https://github.com/dnomd343/XProxy.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
843 B
39 lines
843 B
package config
|
|
|
|
import (
|
|
"XProxy/cmd/common"
|
|
log "github.com/sirupsen/logrus"
|
|
"os"
|
|
)
|
|
|
|
type Config struct {
|
|
// asset update
|
|
|
|
DNS []string
|
|
|
|
V4Address string
|
|
V4Gateway string
|
|
V4Bypass []string
|
|
|
|
V6Address string
|
|
V6Gateway string
|
|
V6Bypass []string
|
|
|
|
// httpInbounds
|
|
// socksInbounds
|
|
// addOnInbounds
|
|
|
|
}
|
|
|
|
func Load(configFile string) Config {
|
|
if !common.IsFileExist(configFile) { // configure not exist -> load default
|
|
log.Infof("Load default configure -> %s", configFile)
|
|
common.WriteFile(configFile, defaultConfig, false)
|
|
}
|
|
raw, err := os.ReadFile(configFile) // read configure content
|
|
if err != nil {
|
|
log.Panicf("Failed to open %s -> %v", configFile, err)
|
|
}
|
|
rawConfig := yamlDecode(raw) // decode yaml content
|
|
return decode(rawConfig)
|
|
}
|
|
|