add support for the config file

This commit is contained in:
idk
2020-09-19 23:21:56 -04:00
parent 3ab932c170
commit 8e0af0c4f6
4 changed files with 115 additions and 3 deletions

View File

@ -103,3 +103,29 @@ func (c *Conf) SetLeasesetPrivateSigningKey(label ...string) {
c.LeaseSetPrivateSigningKey = ""
}
}
// GetLeaseSetEncType 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) GetLeaseSetEncType(arg, def string, label ...string) string {
if arg != def {
return arg
}
if c.Config == nil {
return arg
}
if x, o := c.Get("i2cp.leaseSetEncType", label...); o {
return x
}
return arg
}
// SetLeaseSetEncType tells the conf to use encrypted leasesets the from the config file
func (c *Conf) SetLeaseSetEncType(label ...string) {
if v, ok := c.Get("i2cp.leaseSetEncType", label...); ok {
c.LeaseSetEncType = v
} else {
c.LeaseSetEncType = ""
}
}

View File

@ -39,6 +39,7 @@ type Conf struct {
TunName string
EncryptLeaseSet bool
LeaseSetKey string
LeaseSetEncType string
LeaseSetPrivateKey string
LeaseSetPrivateSigningKey string
InAllowZeroHop bool