set enough defaults to validate new config
This commit is contained in:
@ -47,17 +47,17 @@ func (f *Conf) print() []string {
|
||||
"outbound.backupQuantity=" + fmt.Sprintf("%d", f.OutBackupQuantity),
|
||||
"inbound.quantity=" + fmt.Sprintf("%d", f.InQuantity),
|
||||
"outbound.quantity=" + fmt.Sprintf("%d", f.OutQuantity),
|
||||
"inbound.allowZeroHop=" + fmt.Sprintf("%b", f.InAllowZeroHop),
|
||||
"outbound.allowZeroHop=" + fmt.Sprintf("%b", f.OutAllowZeroHop),
|
||||
"i2cp.fastRecieve=" + fmt.Sprintf("%b", f.FastRecieve),
|
||||
"i2cp.gzip=" + fmt.Sprintf("%b", f.UseCompression),
|
||||
"i2cp.reduceOnIdle=" + fmt.Sprintf("%b", f.ReduceIdle),
|
||||
"inbound.allowZeroHop=" + fmt.Sprintf("%t", f.InAllowZeroHop),
|
||||
"outbound.allowZeroHop=" + fmt.Sprintf("%t", f.OutAllowZeroHop),
|
||||
"i2cp.fastRecieve=" + fmt.Sprintf("%t", f.FastRecieve),
|
||||
"i2cp.gzip=" + fmt.Sprintf("%t", f.UseCompression),
|
||||
"i2cp.reduceOnIdle=" + fmt.Sprintf("%t", f.ReduceIdle),
|
||||
"i2cp.reduceIdleTime=" + fmt.Sprintf("%d", f.ReduceIdleTime),
|
||||
"i2cp.reduceQuantity=" + fmt.Sprintf("%d", f.ReduceIdleQuantity),
|
||||
"i2cp.closeOnIdle=" + fmt.Sprintf("%b", f.CloseIdle),
|
||||
"i2cp.closeOnIdle=" + fmt.Sprintf("%t", f.CloseIdle),
|
||||
"i2cp.closeIdleTime=" + fmt.Sprintf("%d", f.CloseIdleTime),
|
||||
"i2cp.messageReliability=" + f.MessageReliability,
|
||||
"i2cp.encryptLeaseSet=" + fmt.Sprintf("%b", f.EncryptLeaseSet),
|
||||
"i2cp.encryptLeaseSet=" + fmt.Sprintf("%t", f.EncryptLeaseSet),
|
||||
lsk, lspk, lspsk,
|
||||
f.accesslisttype(),
|
||||
f.accesslist(),
|
||||
|
@ -164,10 +164,10 @@ func NewSAMClientForwarderFromConfig(iniFile, SamHost, SamPort string, label ...
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// NewSAMSSUClientForwarderFromConf generates a SAMSSUforwarder from *i2ptunconf.Conf
|
||||
func NewSAMSSUClientForwarderFromConf(config *i2ptunconf.Conf) (*samforwarderudp.SAMSSUClientForwarder, error) {
|
||||
// NewSAMDGClientForwarderFromConf generates a SAMSSUforwarder from *i2ptunconf.Conf
|
||||
func NewSAMDGClientForwarderFromConf(config *i2ptunconf.Conf) (*samforwarderudp.SAMDGClientForwarder, error) {
|
||||
if config != nil {
|
||||
return samforwarderudp.NewSAMSSUClientForwarderFromOptions(
|
||||
return samforwarderudp.NewSAMDGClientForwarderFromOptions(
|
||||
samforwarderudp.SetClientSaveFile(config.SaveFile),
|
||||
samforwarderudp.SetClientFilePath(config.SaveDirectory),
|
||||
samforwarderudp.SetClientHost(config.TargetHost),
|
||||
@ -207,7 +207,7 @@ func NewSAMSSUClientForwarderFromConf(config *i2ptunconf.Conf) (*samforwarderudp
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func NewSAMSSUClientForwarderFromConfig(iniFile, SamHost, SamPort string, label ...string) (*samforwarderudp.SAMSSUClientForwarder, error) {
|
||||
func NewSAMDGClientForwarderFromConfig(iniFile, SamHost, SamPort string, label ...string) (*samforwarderudp.SAMDGClientForwarder, error) {
|
||||
if iniFile != "none" {
|
||||
config, err := i2ptunconf.NewI2PTunConf(iniFile, label...)
|
||||
if err != nil {
|
||||
@ -219,7 +219,7 @@ func NewSAMSSUClientForwarderFromConfig(iniFile, SamHost, SamPort string, label
|
||||
if SamPort != "" && SamPort != "7656" {
|
||||
config.SamPort = config.GetSAMPort(SamPort, config.SamPort)
|
||||
}
|
||||
return NewSAMSSUClientForwarderFromConf(config)
|
||||
return NewSAMDGClientForwarderFromConf(config)
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
@ -69,10 +69,10 @@ func NewSAMForwarderFromConfig(iniFile, SamHost, SamPort string, label ...string
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// NewSAMSSUForwarderFromConf generates a SAMSSUforwarder from *i2ptunconf.Conf
|
||||
func NewSAMSSUForwarderFromConf(config *i2ptunconf.Conf) (*samforwarderudp.SAMSSUForwarder, error) {
|
||||
// NewSAMDGForwarderFromConf generates a SAMSSUforwarder from *i2ptunconf.Conf
|
||||
func NewSAMDGForwarderFromConf(config *i2ptunconf.Conf) (*samforwarderudp.SAMDGForwarder, error) {
|
||||
if config != nil {
|
||||
return samforwarderudp.NewSAMSSUForwarderFromOptions(
|
||||
return samforwarderudp.NewSAMDGForwarderFromOptions(
|
||||
samforwarderudp.SetSaveFile(config.SaveFile),
|
||||
samforwarderudp.SetFilePath(config.SaveDirectory),
|
||||
samforwarderudp.SetHost(config.TargetHost),
|
||||
@ -111,8 +111,8 @@ func NewSAMSSUForwarderFromConf(config *i2ptunconf.Conf) (*samforwarderudp.SAMSS
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// NewSAMSSUForwarderFromConfig generates a new SAMSSUForwarder from a config file
|
||||
func NewSAMSSUForwarderFromConfig(iniFile, SamHost, SamPort string, label ...string) (*samforwarderudp.SAMSSUForwarder, error) {
|
||||
// NewSAMDGForwarderFromConfig generates a new SAMDGForwarder from a config file
|
||||
func NewSAMDGForwarderFromConfig(iniFile, SamHost, SamPort string, label ...string) (*samforwarderudp.SAMDGForwarder, error) {
|
||||
if iniFile != "none" {
|
||||
config, err := i2ptunconf.NewI2PTunConf(iniFile, label...)
|
||||
if err != nil {
|
||||
@ -124,7 +124,7 @@ func NewSAMSSUForwarderFromConfig(iniFile, SamHost, SamPort string, label ...str
|
||||
if SamPort != "" && SamPort != "7656" {
|
||||
config.SamPort = config.GetSAMPort(SamPort, config.SamPort)
|
||||
}
|
||||
return NewSAMSSUForwarderFromConf(config)
|
||||
return NewSAMDGForwarderFromConf(config)
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import (
|
||||
)
|
||||
|
||||
import (
|
||||
// "github.com/eyedeekay/sam3"
|
||||
"github.com/eyedeekay/sam3/i2pkeys"
|
||||
"github.com/zieckey/goini"
|
||||
)
|
||||
@ -17,54 +18,54 @@ import (
|
||||
// Conf is a tructure containing an ini config, with some functions to help
|
||||
// when you use it for in conjunction with command-line flags
|
||||
type Conf struct {
|
||||
Config *goini.INI
|
||||
FilePath string
|
||||
KeyFilePath string
|
||||
Labels []string
|
||||
Client bool
|
||||
ClientDest string
|
||||
SigType string
|
||||
Type string
|
||||
SaveDirectory string
|
||||
ServeDirectory string
|
||||
SaveFile bool
|
||||
TargetHost string
|
||||
TargetPort string
|
||||
SamHost string
|
||||
SamPort string
|
||||
TunnelHost string
|
||||
ControlHost string
|
||||
ControlPort string
|
||||
TargetForPort443 string
|
||||
TunName string
|
||||
EncryptLeaseSet bool
|
||||
LeaseSetKey string
|
||||
LeaseSetEncType string
|
||||
LeaseSetPrivateKey string
|
||||
LeaseSetPrivateSigningKey string
|
||||
InAllowZeroHop bool
|
||||
OutAllowZeroHop bool
|
||||
InLength int
|
||||
OutLength int
|
||||
InQuantity int
|
||||
OutQuantity int
|
||||
InVariance int
|
||||
OutVariance int
|
||||
InBackupQuantity int
|
||||
OutBackupQuantity int
|
||||
UseCompression bool
|
||||
FastRecieve bool
|
||||
ReduceIdle bool
|
||||
ReduceIdleTime int
|
||||
ReduceIdleQuantity int
|
||||
CloseIdle bool
|
||||
CloseIdleTime int
|
||||
AccessListType string
|
||||
AccessList []string
|
||||
MessageReliability string
|
||||
exists bool
|
||||
UserName string
|
||||
Password string
|
||||
Config *goini.INI `default:&goini.INI{}`
|
||||
FilePath string `default:"./"`
|
||||
KeyFilePath string `default:"./"`
|
||||
Labels []string `default:{""}`
|
||||
Client bool `default:true`
|
||||
ClientDest string `default:"idk.i2p"`
|
||||
SigType string `default:"SIGNATURE_TYPE=EdDSA_SHA512_Ed25519"`
|
||||
Type string `default:"client"`
|
||||
SaveDirectory string `default:"./"`
|
||||
ServeDirectory string `default:"./www"`
|
||||
SaveFile bool `default:false`
|
||||
TargetHost string `default:"127.0.0.1"`
|
||||
TargetPort string `default:"7778"`
|
||||
SamHost string `default:"127.0.0.1"`
|
||||
SamPort string `default:"7656"`
|
||||
TunnelHost string `default:"127.0.0.1"`
|
||||
ControlHost string `default:"127.0.0.1"`
|
||||
ControlPort string `default:"7951"`
|
||||
TargetForPort443 string `default:""`
|
||||
TunName string `default:"goi2ptunnel"`
|
||||
EncryptLeaseSet bool `default:false`
|
||||
LeaseSetKey string `default:""`
|
||||
LeaseSetEncType string `default:"4,0"`
|
||||
LeaseSetPrivateKey string `default:""`
|
||||
LeaseSetPrivateSigningKey string `default:""`
|
||||
InAllowZeroHop bool `default:false`
|
||||
OutAllowZeroHop bool `default:false`
|
||||
InLength int `default:3`
|
||||
OutLength int `default:3`
|
||||
InQuantity int `default:1`
|
||||
OutQuantity int `default:1`
|
||||
InVariance int `default:0`
|
||||
OutVariance int `default:0`
|
||||
InBackupQuantity int `default:1`
|
||||
OutBackupQuantity int `default:1`
|
||||
UseCompression bool `default:true`
|
||||
FastRecieve bool `default:true`
|
||||
ReduceIdle bool `default:false`
|
||||
ReduceIdleTime int `default:36000000`
|
||||
ReduceIdleQuantity int `default:1`
|
||||
CloseIdle bool `default:false`
|
||||
CloseIdleTime int `default:36000000`
|
||||
AccessListType string `default:"none"`
|
||||
AccessList []string `default:{""}`
|
||||
MessageReliability string `default:""`
|
||||
exists bool `default:false`
|
||||
UserName string `default:""`
|
||||
Password string `default:""`
|
||||
LoadedKeys i2pkeys.I2PKeys
|
||||
}
|
||||
|
||||
@ -288,11 +289,18 @@ func (c *Conf) I2PINILoad(iniFile string, label ...string) error {
|
||||
|
||||
// NewI2PBlankTunConf returns an empty but intialized tunconf
|
||||
func NewI2PBlankTunConf() *Conf {
|
||||
var c Conf
|
||||
// var c Conf
|
||||
c := new(Conf)
|
||||
c.SamHost = "127.0.0.1"
|
||||
c.SamPort = "7656"
|
||||
c.TunName = "unksam"
|
||||
c.TargetHost = "127.0.0.1"
|
||||
c.TargetPort = "0"
|
||||
c.ClientDest = "idk.i2p"
|
||||
c.Config = &goini.INI{}
|
||||
c.Config = goini.New()
|
||||
c.Config.Parse([]byte(""), "\n", "=")
|
||||
return &c
|
||||
c.Config.Parse([]byte("[client]\nsamhost=\"127.0.0.1\"\nsamport=\"7656\"\n"), "\n", "=")
|
||||
return c
|
||||
}
|
||||
|
||||
// NewI2PTunConf returns a Conf structure from an ini file, for modification
|
||||
|
Reference in New Issue
Block a user