Moved most of that conditional INI stuff out of the Conf constructor.

This commit is contained in:
idk
2018-08-11 01:16:00 -04:00
parent 6f47089ed7
commit d19b89a383
4 changed files with 45 additions and 19 deletions

View File

@ -144,7 +144,8 @@ existing flags should also be aliased to be more familiar and netcat-like.
I want it to be able to use poorly formed ini files, in order to accomodate the
use of INI-like labels. For now, my workaround is to comment out the labels
until I deal with this.
until I deal with this. Basically I just want it to ignore the lables and treat
the whole thing as flat.
I want it to be able to save ini files based on the settings used for a running
forwarder. Should be easy, I just need to decide how I want to do it. Also to

View File

@ -147,7 +147,8 @@ existing flags should also be aliased to be more familiar and netcat-like.
I want it to be able to use poorly formed ini files, in order to accomodate the
use of INI-like labels. For now, my workaround is to comment out the labels
until I deal with this.
until I deal with this. Basically I just want it to ignore the lables and treat
the whole thing as flat.
I want it to be able to save ini files based on the settings used for a running
forwarder. Should be easy, I just need to decide how I want to do it. Also to
@ -165,12 +166,12 @@ not that important. I'll have to look for a way to make this behavior
configurable though.
-----BEGIN PGP SIGNATURE-----
iQEzBAEBCAAdFiEEcNIGBzi++AUjrK/311wDs5teFOEFAltso6wACgkQ11wDs5te
FOFjZwf+OwDBIM62wDAyZT8waZnZp/+uSu95uaAHI1/l3z8FStreF2G9evI3rbHY
kr8BSetMwZ0CVNw09IXOKqos3JW9Sax8NjL9l59e4wdZtYcQ7VbEJVXmc92e8poT
Xl60d5+Ap/PozWry/lOVG/Abkn0EKatzD2NLUvceRo7Oe0oIlxxLo1nvBkxd7CTf
ZewEyCXnplNDCBbHFffqtiit0Si7ri/y/mH8O+Bh01X+AIJKx1FUh0i82a6Y/gQw
0sEtmhan8yu9sLu1XROx6gg3plynm4Vht4jOFuUXImwAzq+IbhXqmI2Kz6jppzBN
qgV1UBqphhGqRk9NASLsWN6rsfoH8A==
=Mo/u
iQEzBAEBCAAdFiEEcNIGBzi++AUjrK/311wDs5teFOEFAltucQ0ACgkQ11wDs5te
FOGjIwgAjkzIsKSjaPUU4Qh3GPjf0OmYfbRZIrSj8/a11OOonPeWk1yT6C1wlj7t
mOClsA8PtObQaMADb+yX1oqd+SacWjxl7rs7hlEIeN0B2WtZGIuUTVBww/JLYpOa
HboF+iqB+a0vWDMjMXk7yOMCa0dC9JRSKv5Pgh7hBJ7XwmXRPX+wcC/fJnfRsPNM
9uOZglcv2LThYuOAgbBIxMEGQSbQ7bDI1epE5rQdENz8AigxKVIdq6YMcZxdfyRR
bUN5FJ2TlP4rfa5vaZNQFfZhNUTEkhH87vgpp274Nf4RKJKv0m9TcTPlHb+0hyn8
e2zp5NnaJIRT8L9WoxA4+p8CLftIyA==
=9ZfT
-----END PGP SIGNATURE-----

View File

@ -501,16 +501,14 @@ func (c *Conf) GetReduceIdleQuantity(arg, def int) int {
return arg
}
// NewI2PTunConf returns a Conf structure from an ini file, for modification
// before starting the tunnel
func NewI2PTunConf(iniFile string) (*Conf, error) {
var err error
var c Conf
c.config = goini.New()
// I2PINILoad loads variables from an ini file into the Conf data structure.
func I2PINILoad(iniFile string, c *Conf) (error) {
var err error
if iniFile != "none" {
c.config = goini.New()
err = c.config.ParseFile(iniFile)
if err != nil {
return nil, err
return err
}
if v, ok := c.config.Get("dir"); ok {
@ -665,9 +663,20 @@ func NewI2PTunConf(iniFile string) (*Conf, error) {
c.AccessList = append(c.AccessList, z)
}
}
return &c, nil
log.Println(c.Print())
}
return nil, nil
return nil
}
// NewI2PTunConf returns a Conf structure from an ini file, for modification
// before starting the tunnel
func NewI2PTunConf(iniFile string) (*Conf, error) {
var err error
var c Conf
if err = I2PINILoad(iniFile, &c); err != nil {
return nil, err
}
return &c, nil
}
// NewSAMForwarderFromConf generates a SAMforwarder from *i2ptunconf.Conf

15
config/tunconf_test.go Normal file
View File

@ -0,0 +1,15 @@
package i2ptunconf
import (
"log"
"testing"
)
func TestConf(t *testing.T) {
log.Println("testing configuration loader")
if config, err := NewI2PTunConf("../etc/sam-forwarder/tunnels.ini"); err != nil {
log.Fatal(err)
}else{
log.Println(config.Print())
}
}