use sigtypes from conig files

This commit is contained in:
idk
2019-04-25 23:52:08 -04:00
parent 7135facd9c
commit 790f01be80
12 changed files with 151 additions and 2 deletions

View File

@ -7,7 +7,7 @@ package i2ptunconf
func (c *Conf) GetSigType(argt, def string, label ...string) string {
var typ string
if argt == "" {
typ += ""
typ = ""
} else if argt == "DSA_SHA1" {
typ = "DSA_SHA1"
} else if argt == "ECDSA_SHA256_P256" {

View File

@ -1,10 +1,59 @@
package i2ptunconf
import (
"github.com/eyedeekay/httptunnel"
"github.com/eyedeekay/sam-forwarder/tcp"
"github.com/eyedeekay/sam-forwarder/udp"
)
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
}
// NewSAMClientForwarderFromConfig generates a new SAMForwarder from a config file
func NewSAMHTTPClientFromConfig(iniFile, SamHost, SamPort string, label ...string) (*i2phttpproxy.SAMHTTPProxy, error) {
if iniFile != "none" {
config, err := NewI2PTunConf(iniFile, label...)
if err != nil {
return nil, err
}
if SamHost != "" && SamHost != "127.0.0.1" && SamHost != "localhost" {
config.SamHost = config.GetSAMHost(SamHost, config.SamHost)
}
if SamPort != "" && SamPort != "7656" {
config.SamPort = config.GetSAMPort(SamPort, config.SamPort)
}
return NewSAMHTTPClientFromConf(config)
}
return nil, nil
}
// NewSAMClientForwarderFromConf generates a SAMforwarder from *i2ptunconf.Conf
func NewSAMClientForwarderFromConf(config *Conf) (*samforwarder.SAMClientForwarder, error) {
if config != nil {
@ -15,6 +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.SetClientName(config.TunName),
samforwarder.SetClientInLength(config.InLength),
samforwarder.SetClientOutLength(config.OutLength),
@ -75,6 +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.SetClientName(config.TunName),
samforwarderudp.SetClientInLength(config.InLength),
samforwarderudp.SetClientOutLength(config.OutLength),

View File

@ -16,6 +16,7 @@ func NewSAMForwarderFromConf(config *Conf) (*samforwarder.SAMForwarder, error) {
samforwarder.SetPort(config.TargetPort),
samforwarder.SetSAMHost(config.SamHost),
samforwarder.SetSAMPort(config.SamPort),
samforwarder.SetSigType(config.SigType),
samforwarder.SetName(config.TunName),
samforwarder.SetInLength(config.InLength),
samforwarder.SetOutLength(config.OutLength),
@ -76,6 +77,7 @@ func NewSAMSSUForwarderFromConf(config *Conf) (*samforwarderudp.SAMSSUForwarder,
samforwarderudp.SetPort(config.TargetPort),
samforwarderudp.SetSAMHost(config.SamHost),
samforwarderudp.SetSAMPort(config.SamPort),
samforwarderudp.SetSigType(config.SigType),
samforwarderudp.SetName(config.TunName),
samforwarderudp.SetInLength(config.InLength),
samforwarderudp.SetOutLength(config.OutLength),

View File

@ -15,6 +15,9 @@ func (c *Conf) GetType(argc, argu, argh bool, def string, label ...string) strin
typ += "udp"
}
if argc {
if argh == true {
typ += "http"
}
typ += "client"
c.Client = true
} else {
@ -45,7 +48,7 @@ func (c *Conf) SetType(label ...string) {
if strings.Contains(v, "vpn") {
c.VPN = true
}
if c.Type == "server" || c.Type == "http" || c.Type == "client" || c.Type == "udpserver" || c.Type == "udpclient" {
if c.Type == "server" || c.Type == "http" || c.Type == "client" || c.Type == "httpclient" || c.Type == "udpserver" || c.Type == "udpclient" {
c.Type = v
}
} else {