You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.1 KiB
Go
38 lines
1.1 KiB
Go
8 years ago
|
package main
|
||
|
|
||
|
import (
|
||
|
"github.com/go-yaml/yaml"
|
||
|
"io/ioutil"
|
||
|
)
|
||
|
|
||
|
type config struct {
|
||
|
Host string `yaml:"host"`
|
||
|
Port int `yaml:"port"`
|
||
|
PrivateKey string `yaml:"private_key"`
|
||
|
ObfsMethod string `yaml:"obfs_method"`
|
||
|
ObfsKey string `yaml:"obfs_key"`
|
||
|
Username string `yaml:"username"`
|
||
|
Password string `yaml:"password"`
|
||
|
KeepaliveInterval int `yaml:"keepalive_interval"`
|
||
|
KeepaliveMax int `yaml:"keepalive_max"`
|
||
|
Debug bool `yaml:"debug"`
|
||
|
DisableObfsAfterHandshake bool `yaml:"disable_obfs_after_handshake"`
|
||
|
NotRunCmd bool `yaml:"not_run_cmd"`
|
||
|
LocalForward []string `yaml:"local_forward"`
|
||
|
RemoteForward []string `yaml:"remote_forward"`
|
||
|
DynamicForward []string `yaml:"dynamic_forward"`
|
||
|
}
|
||
|
|
||
|
func loadConfig(f string) (*config, error) {
|
||
|
buf, err := ioutil.ReadFile(f)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
var c config
|
||
|
err = yaml.Unmarshal(buf, &c)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
return &c, nil
|
||
|
}
|