-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
43 lines (38 loc) · 888 Bytes
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package gobonding
import (
"os"
"gopkg.in/yaml.v2"
)
const (
CONFFILE = "gobonding.yml"
)
type Config struct {
// Name of the TUN adapter
TunName string
// If not empty the path to a monitor file
MonitorPath string
// The Tick interval to update the monitor file
MonitorTick string
// The name of the channel balancer
Balancer string
// The start Port the proxy is listening to
ProxyStartPort int
// A map ifacename or ipaddress of the wan device to ip address of proxy server
Channels map[string]string
// Public Key for authentication
PublicKey string
// Private key for authentication
PrivateKey string `yaml:",omitempty"`
}
func LoadConfig(path string) (*Config, error) {
data, err := os.ReadFile(path)
if err != nil {
return nil, err
}
config := Config{}
err = yaml.Unmarshal(data, &config)
if err != nil {
return nil, err
}
return &config, nil
}