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 {

View File

@ -86,6 +86,28 @@ func SetClientName(s string) func(*SAMClientForwarder) error {
}
}
//SetSigType sets the type of the forwarder server
func SetClientSigType(s string) func(*SAMClientForwarder) error {
return func(c *SAMClientForwarder) error {
if s == "" {
c.sigType = ""
} else if s == "DSA_SHA1" {
c.sigType = "DSA_SHA1"
} else if s == "ECDSA_SHA256_P256" {
c.sigType = "ECDSA_SHA256_P256"
} else if s == "ECDSA_SHA384_P384" {
c.sigType = "ECDSA_SHA384_P384"
} else if s == "ECDSA_SHA512_P521" {
c.sigType = "ECDSA_SHA512_P521"
} else if s == "EdDSA_SHA512_Ed25519" {
c.sigType = "EdDSA_SHA512_Ed25519"
} else {
c.sigType = "EdDSA_SHA512_Ed25519"
}
return nil
}
}
//SetClientInLength sets the number of hops inbound
func SetClientInLength(u int) func(*SAMClientForwarder) error {
return func(c *SAMClientForwarder) error {

View File

@ -38,6 +38,7 @@ type SAMClientForwarder struct {
// samcatd options
passfile string
sigType string
// I2CP options
encryptLeaseSet string

View File

@ -29,6 +29,28 @@ func SetType(s string) func(*SAMForwarder) error {
}
}
//SetSigType sets the type of the forwarder server
func SetSigType(s string) func(*SAMForwarder) error {
return func(c *SAMForwarder) error {
if s == "" {
c.sigType = ""
} else if s == "DSA_SHA1" {
c.sigType = "DSA_SHA1"
} else if s == "ECDSA_SHA256_P256" {
c.sigType = "ECDSA_SHA256_P256"
} else if s == "ECDSA_SHA384_P384" {
c.sigType = "ECDSA_SHA384_P384"
} else if s == "ECDSA_SHA512_P521" {
c.sigType = "ECDSA_SHA512_P521"
} else if s == "EdDSA_SHA512_Ed25519" {
c.sigType = "EdDSA_SHA512_Ed25519"
} else {
c.sigType = "EdDSA_SHA512_Ed25519"
}
return nil
}
}
//SetSaveFile tells the router to save the tunnel's keys long-term
func SetSaveFile(b bool) func(*SAMForwarder) error {
return func(c *SAMForwarder) error {

View File

@ -43,6 +43,8 @@ type SAMForwarder struct {
// samcatd options
passfile string
sigType string
// I2CP options
encryptLeaseSet string
leaseSetKey string

View File

@ -86,6 +86,28 @@ func SetClientName(s string) func(*SAMSSUClientForwarder) error {
}
}
//SetClientSigType sets the type of the forwarder server
func SetClientSigType(s string) func(*SAMSSUClientForwarder) error {
return func(c *SAMSSUClientForwarder) error {
if s == "" {
c.sigType = ""
} else if s == "DSA_SHA1" {
c.sigType = "DSA_SHA1"
} else if s == "ECDSA_SHA256_P256" {
c.sigType = "ECDSA_SHA256_P256"
} else if s == "ECDSA_SHA384_P384" {
c.sigType = "ECDSA_SHA384_P384"
} else if s == "ECDSA_SHA512_P521" {
c.sigType = "ECDSA_SHA512_P521"
} else if s == "EdDSA_SHA512_Ed25519" {
c.sigType = "EdDSA_SHA512_Ed25519"
} else {
c.sigType = "EdDSA_SHA512_Ed25519"
}
return nil
}
}
//SetClientInLength sets the number of hops inbound
func SetClientInLength(u int) func(*SAMSSUClientForwarder) error {
return func(c *SAMSSUClientForwarder) error {

View File

@ -40,6 +40,7 @@ type SAMSSUClientForwarder struct {
// samcatd options
passfile string
sigType string
// I2CP options
encryptLeaseSet string

View File

@ -78,6 +78,28 @@ func SetName(s string) func(*SAMSSUForwarder) error {
}
}
//SetSigType sets the type of the forwarder server
func SetSigType(s string) func(*SAMSSUForwarder) error {
return func(c *SAMSSUForwarder) error {
if s == "" {
c.sigType = ""
} else if s == "DSA_SHA1" {
c.sigType = "DSA_SHA1"
} else if s == "ECDSA_SHA256_P256" {
c.sigType = "ECDSA_SHA256_P256"
} else if s == "ECDSA_SHA384_P384" {
c.sigType = "ECDSA_SHA384_P384"
} else if s == "ECDSA_SHA512_P521" {
c.sigType = "ECDSA_SHA512_P521"
} else if s == "EdDSA_SHA512_Ed25519" {
c.sigType = "EdDSA_SHA512_Ed25519"
} else {
c.sigType = "EdDSA_SHA512_Ed25519"
}
return nil
}
}
//SetInLength sets the number of hops inbound
func SetInLength(u int) func(*SAMSSUForwarder) error {
return func(c *SAMSSUForwarder) error {

View File

@ -38,6 +38,7 @@ type SAMSSUForwarder struct {
// samcatd options
passfile string
sigType string
// I2CP options
encryptLeaseSet string