-
Notifications
You must be signed in to change notification settings - Fork 2
/
name.go
52 lines (48 loc) · 1.32 KB
/
name.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
44
45
46
47
48
49
50
51
52
package i2ptunconf
// GetSaveFile takes an argument and a default. If the argument differs from the
// default, the argument is always returned. If the argument and default are
// the same and the key exists, the key is returned. If the key is absent, the
// default is returned.
func (c *Conf) GetSaveFile(arg, def bool, label ...string) bool {
if arg != def {
return arg
}
//if c.Config == nil {
// return arg
//}
return c.SaveFile
}
// GetKeys takes an argument and a default. If the argument differs from the
// default, the argument is always returned. If the argument and default are
// the same and the key exists, the key is returned. If the key is absent, the
// default is returned.
func (c *Conf) GetKeys(arg, def string, label ...string) string {
if arg != def {
return arg
}
//if c.Config == nil {
// return arg
//}
if x, o := c.Get("keys", label...); o {
return x
}
return arg
}
// SetKeys sets the key name from the config file
func (c *Conf) SetKeys(label ...string) {
if v, ok := c.Get("keys", label...); ok {
c.TunName = v
c.SaveFile = true
} else {
c.TunName = "forwarder"
c.SaveFile = false
}
}
// SetTunName sets the tunnel name from the config file
func (c *Conf) SetTunName(label ...string) {
if v, ok := c.Get("keys", label...); ok {
c.TunName = v
} else {
c.TunName = "forwarder"
}
}