create a web interface

This commit is contained in:
idk
2019-05-11 00:26:54 -04:00
parent df3c2edac0
commit 00488deee3
5 changed files with 333 additions and 0 deletions

27
config/password.go Normal file
View File

@ -0,0 +1,27 @@
package i2ptunconf
// GetPassword 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) GetPassword(arg, def string, label ...string) string {
if arg != def {
return arg
}
if c.Config == nil {
return arg
}
if x, o := c.Get("username", label...); o {
return x
}
return arg
}
// SetKeys sets the key name from the config file
func (c *Conf) SetPassword(label ...string) {
if v, ok := c.Get("username", label...); ok {
c.Password = v
} else {
c.Password = "samcatd"
}
}

27
config/user.go Normal file
View File

@ -0,0 +1,27 @@
package i2ptunconf
// GetUserName 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) GetUserName(arg, def string, label ...string) string {
if arg != def {
return arg
}
if c.Config == nil {
return arg
}
if x, o := c.Get("username", label...); o {
return x
}
return arg
}
// SetKeys sets the key name from the config file
func (c *Conf) SetUserName(label ...string) {
if v, ok := c.Get("username", label...); ok {
c.UserName = v
} else {
c.UserName = "samcatd"
}
}