enable use of all current options

This commit is contained in:
idk
2019-04-26 00:27:43 -04:00
parent 89b42eb2bf
commit ff8389a7c9
4 changed files with 66 additions and 49 deletions

View File

@ -26,5 +26,8 @@ func (c *Conf) SetMessageReliability(label ...string) {
}
func (c *Conf) reliability() string {
return "i2cp.messageReliability" + c.MessageReliability
if c.MessageReliability != "" {
return "i2cp.messageReliability=" + c.MessageReliability
}
return ""
}

View File

@ -57,13 +57,12 @@ type Conf struct {
AccessList []string
MessageReliability string
exists bool
VPN bool
}
// Print returns and prints a formatted list of configured tunnel settings.
func (c *Conf) Print() []string {
confstring := []string{
c.sigType()
c.SignatureType(),
"inbound.length=" + strconv.Itoa(c.InLength),
"outbound.length=" + strconv.Itoa(c.OutLength),
"inbound.lengthVariance=" + strconv.Itoa(c.InVariance),
@ -81,19 +80,45 @@ func (c *Conf) Print() []string {
"i2cp.reduceQuantity=" + strconv.Itoa(c.ReduceIdleQuantity),
"i2cp.closeOnIdle=" + strconv.FormatBool(c.CloseIdle),
"i2cp.closeIdleTime=" + strconv.Itoa(c.CloseIdleTime),
"i2cp.fastRecieve=" + strconv.FormatBool(c.FastRecieve),
c.reliability(),
c.accesslisttype(),
c.accesslist(),
c.lsk(),
c.lspk(),
c.lsspk(),
}
log.Println(confstring)
return confstring
}
func (c *Conf) lsk() string {
if c.LeaseSetKey != "" {
return "i2cp.leaseSetKey=" + c.LeaseSetKey
}
return ""
}
func (c *Conf) lspk() string {
if c.LeaseSetPrivateKey != "" {
return "i2cp.leaseSetPrivateKey=" + c.LeaseSetPrivateKey
}
return ""
}
func (c *Conf) lsspk() string {
if c.LeaseSetPrivateSigningKey != "" {
return "i2cp.leaseSetSigningPrivateKey=" + c.LeaseSetPrivateSigningKey
}
return ""
}
func (c *Conf) SignatureType() string {
if c.SigType == "" {
return ""
}
return "SIGNATURE_TYPE=" + c.SigType
if c.SigType == "" {
return ""
}
return "SIGNATURE_TYPE=" + c.SigType
}
// Get passes directly through to goini.Get
@ -209,7 +234,7 @@ func (c *Conf) I2PINILoad(iniFile string, label ...string) error {
c.SetSAMHost(label...)
c.SetSAMPort(label...)
c.SetTunName(label...)
c.SetSigType(label...)
c.SetSigType(label...)
c.SetEncryptLease(label...)
c.SetLeasesetKey(label...)
c.SetLeasesetPrivateKey(label...)

View File

@ -1,39 +1,39 @@
package i2ptunconf
import (
"github.com/eyedeekay/httptunnel"
"github.com/eyedeekay/sam-forwarder/tcp"
"github.com/eyedeekay/sam-forwarder/udp"
"github.com/eyedeekay/httptunnel"
)
func NewSAMHTTPClientFromConf(config *Conf) (*i2phttpproxy.SAMHTTPProxy, error) {
if config != nil {
return i2phttpproxy.NewHttpProxy(
i2phttpproxy.SetKeysPath(config.KeyFilePath),
/*i2phttpproxy.SetHost(*samHostString),
i2phttpproxy.SetPort(*samPortString),
i2phttpproxy.SetProxyAddr(ln.Addr().String()),
i2phttpproxy.SetControlAddr(cln.Addr().String()),
i2phttpproxy.SetDebug(*debugConnection),
i2phttpproxy.SetInLength(uint(*inboundTunnelLength)),
i2phttpproxy.SetOutLength(uint(*outboundTunnelLength)),
i2phttpproxy.SetInQuantity(uint(*inboundTunnels)),
i2phttpproxy.SetOutQuantity(uint(*outboundTunnels)),
i2phttpproxy.SetInBackups(uint(*inboundBackups)),
i2phttpproxy.SetOutBackups(uint(*outboundBackups)),
i2phttpproxy.SetInVariance(*inboundVariance),
i2phttpproxy.SetOutVariance(*outboundVariance),
i2phttpproxy.SetUnpublished(*dontPublishLease),
i2phttpproxy.SetReduceIdle(*reduceIdle),
i2phttpproxy.SetCompression(*useCompression),
i2phttpproxy.SetReduceIdleTime(uint(*reduceIdleTime)),
i2phttpproxy.SetReduceIdleQuantity(uint(*reduceIdleQuantity)),
i2phttpproxy.SetCloseIdle(*closeIdle),
i2phttpproxy.SetCloseIdleTime(uint(*closeIdleTime)),
*/
)
}
return nil, nil
if config != nil {
return i2phttpproxy.NewHttpProxy(
i2phttpproxy.SetKeysPath(config.KeyFilePath),
/*i2phttpproxy.SetHost(*samHostString),
i2phttpproxy.SetPort(*samPortString),
i2phttpproxy.SetProxyAddr(ln.Addr().String()),
i2phttpproxy.SetControlAddr(cln.Addr().String()),
i2phttpproxy.SetDebug(*debugConnection),
i2phttpproxy.SetInLength(uint(*inboundTunnelLength)),
i2phttpproxy.SetOutLength(uint(*outboundTunnelLength)),
i2phttpproxy.SetInQuantity(uint(*inboundTunnels)),
i2phttpproxy.SetOutQuantity(uint(*outboundTunnels)),
i2phttpproxy.SetInBackups(uint(*inboundBackups)),
i2phttpproxy.SetOutBackups(uint(*outboundBackups)),
i2phttpproxy.SetInVariance(*inboundVariance),
i2phttpproxy.SetOutVariance(*outboundVariance),
i2phttpproxy.SetUnpublished(*dontPublishLease),
i2phttpproxy.SetReduceIdle(*reduceIdle),
i2phttpproxy.SetCompression(*useCompression),
i2phttpproxy.SetReduceIdleTime(uint(*reduceIdleTime)),
i2phttpproxy.SetReduceIdleQuantity(uint(*reduceIdleQuantity)),
i2phttpproxy.SetCloseIdle(*closeIdle),
i2phttpproxy.SetCloseIdleTime(uint(*closeIdleTime)),
*/
)
}
return nil, nil
}
// NewSAMClientForwarderFromConfig generates a new SAMForwarder from a config file
@ -64,7 +64,7 @@ func NewSAMClientForwarderFromConf(config *Conf) (*samforwarder.SAMClientForward
samforwarder.SetClientPort(config.TargetPort),
samforwarder.SetClientSAMHost(config.SamHost),
samforwarder.SetClientSAMPort(config.SamPort),
samforwarder.SetClientSigType(config.SigType),
samforwarder.SetClientSigType(config.SigType),
samforwarder.SetClientName(config.TunName),
samforwarder.SetClientInLength(config.InLength),
samforwarder.SetClientOutLength(config.OutLength),
@ -125,7 +125,7 @@ func NewSAMSSUClientForwarderFromConf(config *Conf) (*samforwarderudp.SAMSSUClie
samforwarderudp.SetClientPort(config.TargetPort),
samforwarderudp.SetClientSAMHost(config.SamHost),
samforwarderudp.SetClientSAMPort(config.SamPort),
samforwarderudp.SetClientSigType(config.SigType),
samforwarderudp.SetClientSigType(config.SigType),
samforwarderudp.SetClientName(config.TunName),
samforwarderudp.SetClientInLength(config.InLength),
samforwarderudp.SetClientOutLength(config.OutLength),

View File

@ -1,7 +1,6 @@
package i2ptunconf
import (
"fmt"
"strings"
)
@ -45,9 +44,6 @@ func (c *Conf) SetType(label ...string) {
if strings.Contains(v, "client") {
c.Client = true
}
if strings.Contains(v, "vpn") {
c.VPN = true
}
if c.Type == "server" || c.Type == "http" || c.Type == "client" || c.Type == "httpclient" || c.Type == "udpserver" || c.Type == "udpclient" {
c.Type = v
}
@ -55,10 +51,3 @@ func (c *Conf) SetType(label ...string) {
c.Type = "server"
}
}
func (c *Conf) VPNServerMode() (bool, error) {
if c.VPN == true {
return !c.Client, nil
}
return false, fmt.Errorf("VPN mode not detected.")
}