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
|
||||
|
@ -164,14 +164,14 @@ func NewSAMManagerFromOptions(opts ...func(*SAMManager) error) (*SAMManager, err
|
||||
return nil, e
|
||||
}
|
||||
case "udpserver":
|
||||
if f, e := samtunnelhandler.NewTunnelHandler(i2ptunhelper.NewSAMSSUForwarderFromConfig(s.config.FilePath, s.SamHost, s.SamPort, label)); e == nil {
|
||||
if f, e := samtunnelhandler.NewTunnelHandler(i2ptunhelper.NewSAMDGForwarderFromConfig(s.config.FilePath, s.SamHost, s.SamPort, label)); e == nil {
|
||||
log.Println("found udpserver under", label)
|
||||
s.handlerMux = s.handlerMux.Append(f)
|
||||
} else {
|
||||
return nil, e
|
||||
}
|
||||
case "udpclient":
|
||||
if f, e := samtunnelhandler.NewTunnelHandler(i2ptunhelper.NewSAMSSUClientForwarderFromConfig(s.config.FilePath, s.SamHost, s.SamPort, label)); e == nil {
|
||||
if f, e := samtunnelhandler.NewTunnelHandler(i2ptunhelper.NewSAMDGClientForwarderFromConfig(s.config.FilePath, s.SamHost, s.SamPort, label)); e == nil {
|
||||
log.Println("found udpclient under", label)
|
||||
s.handlerMux = s.handlerMux.Append(f)
|
||||
} else {
|
||||
@ -265,14 +265,14 @@ func NewSAMManagerFromOptions(opts ...func(*SAMManager) error) (*SAMManager, err
|
||||
return nil, e
|
||||
}
|
||||
case "udpserver":
|
||||
if f, e := samtunnelhandler.NewTunnelHandler(i2ptunhelper.NewSAMSSUForwarderFromConf(s.config)); e == nil {
|
||||
if f, e := samtunnelhandler.NewTunnelHandler(i2ptunhelper.NewSAMDGForwarderFromConf(s.config)); e == nil {
|
||||
log.Println("found default udpserver")
|
||||
s.handlerMux = s.handlerMux.Append(f)
|
||||
} else {
|
||||
return nil, e
|
||||
}
|
||||
case "udpclient":
|
||||
if f, e := samtunnelhandler.NewTunnelHandler(i2ptunhelper.NewSAMSSUClientForwarderFromConf(s.config)); e == nil {
|
||||
if f, e := samtunnelhandler.NewTunnelHandler(i2ptunhelper.NewSAMDGClientForwarderFromConf(s.config)); e == nil {
|
||||
log.Println("found default udpclient")
|
||||
s.handlerMux = s.handlerMux.Append(f)
|
||||
} else {
|
||||
|
@ -111,7 +111,7 @@ func echoclient() {
|
||||
}
|
||||
|
||||
func serveudp() {
|
||||
ssuforwarder, err = samforwarderudp.NewSAMSSUForwarderFromOptions(
|
||||
ssuforwarder, err = samforwarderudp.NewSAMDGForwarderFromOptions(
|
||||
samforwarderudp.SetHost("127.0.0.1"),
|
||||
samforwarderudp.SetPort(UDPServerPort),
|
||||
samforwarderudp.SetSAMHost("127.0.0.1"),
|
||||
@ -130,7 +130,7 @@ func serveudp() {
|
||||
}
|
||||
|
||||
func clientudp() {
|
||||
ssuforwarderclient, err = samforwarderudp.NewSAMSSUClientForwarderFromOptions(
|
||||
ssuforwarderclient, err = samforwarderudp.NewSAMDGClientForwarderFromOptions(
|
||||
samforwarderudp.SetClientHost("127.0.0.1"),
|
||||
samforwarderudp.SetClientPort(UDPClientPort),
|
||||
samforwarderudp.SetClientSAMHost("127.0.0.1"),
|
||||
|
@ -5,36 +5,36 @@ import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
//ClientOption is a SAMSSUClientForwarder Option
|
||||
type ClientOption func(*SAMSSUClientForwarder) error
|
||||
//ClientOption is a SAMDGClientForwarder Option
|
||||
type ClientOption func(*SAMDGClientForwarder) error
|
||||
|
||||
//SetClientFilePath sets the host of the SAMSSUForwarder's SAM bridge
|
||||
func SetClientFilePath(s string) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
//SetClientFilePath sets the host of the SAMDGForwarder's SAM bridge
|
||||
func SetClientFilePath(s string) func(*SAMDGClientForwarder) error {
|
||||
return func(c *SAMDGClientForwarder) error {
|
||||
c.Conf.FilePath = s
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
//SetClientSaveFile tells the router to use an encrypted leaseset
|
||||
func SetClientSaveFile(b bool) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
func SetClientSaveFile(b bool) func(*SAMDGClientForwarder) error {
|
||||
return func(c *SAMDGClientForwarder) error {
|
||||
c.Conf.SaveFile = b
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
//SetClientHost sets the host of the SAMSSUForwarder's SAM bridge
|
||||
func SetClientHost(s string) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
//SetClientHost sets the host of the SAMDGForwarder's SAM bridge
|
||||
func SetClientHost(s string) func(*SAMDGClientForwarder) error {
|
||||
return func(c *SAMDGClientForwarder) error {
|
||||
c.Conf.TargetHost = s
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
//SetClientPort sets the port of the SAMSSUForwarder's SAM bridge using a string
|
||||
func SetClientPort(s string) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
//SetClientPort sets the port of the SAMDGForwarder's SAM bridge using a string
|
||||
func SetClientPort(s string) func(*SAMDGClientForwarder) error {
|
||||
return func(c *SAMDGClientForwarder) error {
|
||||
port, err := strconv.Atoi(s)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Invalid SSU Client Target Port %s; non-number ", s)
|
||||
@ -47,17 +47,17 @@ func SetClientPort(s string) func(*SAMSSUClientForwarder) error {
|
||||
}
|
||||
}
|
||||
|
||||
//SetClientSAMHost sets the host of the SAMSSUForwarder's SAM bridge
|
||||
func SetClientSAMHost(s string) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
//SetClientSAMHost sets the host of the SAMDGForwarder's SAM bridge
|
||||
func SetClientSAMHost(s string) func(*SAMDGClientForwarder) error {
|
||||
return func(c *SAMDGClientForwarder) error {
|
||||
c.Conf.SamHost = s
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
//SetClientSAMPort sets the port of the SAMSSUForwarder's SAM bridge using a string
|
||||
func SetClientSAMPort(s string) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
//SetClientSAMPort sets the port of the SAMDGForwarder's SAM bridge using a string
|
||||
func SetClientSAMPort(s string) func(*SAMDGClientForwarder) error {
|
||||
return func(c *SAMDGClientForwarder) error {
|
||||
port, err := strconv.Atoi(s)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Invalid SAM Port %s; non-number", s)
|
||||
@ -71,24 +71,24 @@ func SetClientSAMPort(s string) func(*SAMSSUClientForwarder) error {
|
||||
}
|
||||
|
||||
//SetClientDestination sets the destination to forwarder SAMClientForwarder's to
|
||||
func SetClientDestination(s string) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
func SetClientDestination(s string) func(*SAMDGClientForwarder) error {
|
||||
return func(c *SAMDGClientForwarder) error {
|
||||
c.Conf.ClientDest = s
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
//SetClientName sets the host of the SAMSSUForwarder's SAM bridge
|
||||
func SetClientName(s string) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
//SetClientName sets the host of the SAMDGForwarder's SAM bridge
|
||||
func SetClientName(s string) func(*SAMDGClientForwarder) error {
|
||||
return func(c *SAMDGClientForwarder) error {
|
||||
c.Conf.TunName = s
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
//SetClientSigType sets the type of the forwarder server
|
||||
func SetClientSigType(s string) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
func SetClientSigType(s string) func(*SAMDGClientForwarder) error {
|
||||
return func(c *SAMDGClientForwarder) error {
|
||||
if s == "" {
|
||||
c.Conf.SigType = ""
|
||||
} else if s == "DSA_SHA1" {
|
||||
@ -109,8 +109,8 @@ func SetClientSigType(s string) func(*SAMSSUClientForwarder) error {
|
||||
}
|
||||
|
||||
//SetClientInLength sets the number of hops inbound
|
||||
func SetClientInLength(u int) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
func SetClientInLength(u int) func(*SAMDGClientForwarder) error {
|
||||
return func(c *SAMDGClientForwarder) error {
|
||||
if u < 7 && u >= 0 {
|
||||
c.Conf.InLength = u
|
||||
return nil
|
||||
@ -120,8 +120,8 @@ func SetClientInLength(u int) func(*SAMSSUClientForwarder) error {
|
||||
}
|
||||
|
||||
//SetClientOutLength sets the number of hops outbound
|
||||
func SetClientOutLength(u int) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
func SetClientOutLength(u int) func(*SAMDGClientForwarder) error {
|
||||
return func(c *SAMDGClientForwarder) error {
|
||||
if u < 7 && u >= 0 {
|
||||
c.Conf.OutLength = u
|
||||
return nil
|
||||
@ -131,8 +131,8 @@ func SetClientOutLength(u int) func(*SAMSSUClientForwarder) error {
|
||||
}
|
||||
|
||||
//SetClientInVariance sets the variance of a number of hops inbound
|
||||
func SetClientInVariance(i int) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
func SetClientInVariance(i int) func(*SAMDGClientForwarder) error {
|
||||
return func(c *SAMDGClientForwarder) error {
|
||||
if i < 7 && i > -7 {
|
||||
c.Conf.InVariance = i
|
||||
return nil
|
||||
@ -142,8 +142,8 @@ func SetClientInVariance(i int) func(*SAMSSUClientForwarder) error {
|
||||
}
|
||||
|
||||
//SetClientOutVariance sets the variance of a number of hops outbound
|
||||
func SetClientOutVariance(i int) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
func SetClientOutVariance(i int) func(*SAMDGClientForwarder) error {
|
||||
return func(c *SAMDGClientForwarder) error {
|
||||
if i < 7 && i > -7 {
|
||||
c.Conf.OutVariance = i
|
||||
return nil
|
||||
@ -153,8 +153,8 @@ func SetClientOutVariance(i int) func(*SAMSSUClientForwarder) error {
|
||||
}
|
||||
|
||||
//SetClientInQuantity sets the inbound tunnel quantity
|
||||
func SetClientInQuantity(u int) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
func SetClientInQuantity(u int) func(*SAMDGClientForwarder) error {
|
||||
return func(c *SAMDGClientForwarder) error {
|
||||
if u <= 16 && u > 0 {
|
||||
c.Conf.InQuantity = u
|
||||
return nil
|
||||
@ -164,8 +164,8 @@ func SetClientInQuantity(u int) func(*SAMSSUClientForwarder) error {
|
||||
}
|
||||
|
||||
//SetClientOutQuantity sets the outbound tunnel quantity
|
||||
func SetClientOutQuantity(u int) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
func SetClientOutQuantity(u int) func(*SAMDGClientForwarder) error {
|
||||
return func(c *SAMDGClientForwarder) error {
|
||||
if u <= 16 && u > 0 {
|
||||
c.Conf.OutQuantity = u
|
||||
return nil
|
||||
@ -175,8 +175,8 @@ func SetClientOutQuantity(u int) func(*SAMSSUClientForwarder) error {
|
||||
}
|
||||
|
||||
//SetClientInBackups sets the inbound tunnel backups
|
||||
func SetClientInBackups(u int) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
func SetClientInBackups(u int) func(*SAMDGClientForwarder) error {
|
||||
return func(c *SAMDGClientForwarder) error {
|
||||
if u < 6 && u >= 0 {
|
||||
c.Conf.InBackupQuantity = u
|
||||
return nil
|
||||
@ -186,8 +186,8 @@ func SetClientInBackups(u int) func(*SAMSSUClientForwarder) error {
|
||||
}
|
||||
|
||||
//SetClientOutBackups sets the inbound tunnel backups
|
||||
func SetClientOutBackups(u int) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
func SetClientOutBackups(u int) func(*SAMDGClientForwarder) error {
|
||||
return func(c *SAMDGClientForwarder) error {
|
||||
if u < 6 && u >= 0 {
|
||||
c.Conf.OutBackupQuantity = u
|
||||
return nil
|
||||
@ -197,8 +197,8 @@ func SetClientOutBackups(u int) func(*SAMSSUClientForwarder) error {
|
||||
}
|
||||
|
||||
//SetClientEncrypt tells the router to use an encrypted leaseset
|
||||
func SetClientEncrypt(b bool) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
func SetClientEncrypt(b bool) func(*SAMDGClientForwarder) error {
|
||||
return func(c *SAMDGClientForwarder) error {
|
||||
if b {
|
||||
c.Conf.EncryptLeaseSet = true
|
||||
return nil
|
||||
@ -209,40 +209,40 @@ func SetClientEncrypt(b bool) func(*SAMSSUClientForwarder) error {
|
||||
}
|
||||
|
||||
//SetClientLeaseSetKey sets the host of the SAMForwarder's SAM bridge
|
||||
func SetClientLeaseSetKey(s string) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
func SetClientLeaseSetKey(s string) func(*SAMDGClientForwarder) error {
|
||||
return func(c *SAMDGClientForwarder) error {
|
||||
c.Conf.LeaseSetKey = s
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
//SetClientLeaseSetPrivateKey sets the host of the SAMForwarder's SAM bridge
|
||||
func SetClientLeaseSetPrivateKey(s string) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
func SetClientLeaseSetPrivateKey(s string) func(*SAMDGClientForwarder) error {
|
||||
return func(c *SAMDGClientForwarder) error {
|
||||
c.Conf.LeaseSetPrivateKey = s
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
//SetClientLeaseSetPrivateSigningKey sets the host of the SAMForwarder's SAM bridge
|
||||
func SetClientLeaseSetPrivateSigningKey(s string) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
func SetClientLeaseSetPrivateSigningKey(s string) func(*SAMDGClientForwarder) error {
|
||||
return func(c *SAMDGClientForwarder) error {
|
||||
c.Conf.LeaseSetPrivateSigningKey = s
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
//SetClientMessageReliability sets
|
||||
func SetClientMessageReliability(s string) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
func SetClientMessageReliability(s string) func(*SAMDGClientForwarder) error {
|
||||
return func(c *SAMDGClientForwarder) error {
|
||||
c.Conf.MessageReliability = s
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
//SetClientAllowZeroIn tells the tunnel to accept zero-hop peers
|
||||
func SetClientAllowZeroIn(b bool) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
func SetClientAllowZeroIn(b bool) func(*SAMDGClientForwarder) error {
|
||||
return func(c *SAMDGClientForwarder) error {
|
||||
if b {
|
||||
c.Conf.InAllowZeroHop = true
|
||||
return nil
|
||||
@ -253,8 +253,8 @@ func SetClientAllowZeroIn(b bool) func(*SAMSSUClientForwarder) error {
|
||||
}
|
||||
|
||||
//SetClientAllowZeroOut tells the tunnel to accept zero-hop peers
|
||||
func SetClientAllowZeroOut(b bool) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
func SetClientAllowZeroOut(b bool) func(*SAMDGClientForwarder) error {
|
||||
return func(c *SAMDGClientForwarder) error {
|
||||
if b {
|
||||
c.Conf.OutAllowZeroHop = true
|
||||
return nil
|
||||
@ -265,8 +265,8 @@ func SetClientAllowZeroOut(b bool) func(*SAMSSUClientForwarder) error {
|
||||
}
|
||||
|
||||
//SetFastRecieve tells clients to use i2cp.fastRecieve
|
||||
func SetClientFastRecieve(b bool) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
func SetClientFastRecieve(b bool) func(*SAMDGClientForwarder) error {
|
||||
return func(c *SAMDGClientForwarder) error {
|
||||
if b {
|
||||
c.Conf.FastRecieve = true
|
||||
return nil
|
||||
@ -277,8 +277,8 @@ func SetClientFastRecieve(b bool) func(*SAMSSUClientForwarder) error {
|
||||
}
|
||||
|
||||
//SetClientCompress tells clients to use compression
|
||||
func SetClientCompress(b bool) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
func SetClientCompress(b bool) func(*SAMDGClientForwarder) error {
|
||||
return func(c *SAMDGClientForwarder) error {
|
||||
if b {
|
||||
c.Conf.UseCompression = true
|
||||
return nil
|
||||
@ -289,8 +289,8 @@ func SetClientCompress(b bool) func(*SAMSSUClientForwarder) error {
|
||||
}
|
||||
|
||||
//SetClientReduceIdle tells the connection to reduce it's tunnels during extended idle time.
|
||||
func SetClientReduceIdle(b bool) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
func SetClientReduceIdle(b bool) func(*SAMDGClientForwarder) error {
|
||||
return func(c *SAMDGClientForwarder) error {
|
||||
if b {
|
||||
c.Conf.ReduceIdle = true
|
||||
return nil
|
||||
@ -301,8 +301,8 @@ func SetClientReduceIdle(b bool) func(*SAMSSUClientForwarder) error {
|
||||
}
|
||||
|
||||
//SetClientReduceIdleTime sets the time to wait before reducing tunnels to idle levels
|
||||
func SetClientReduceIdleTime(u int) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
func SetClientReduceIdleTime(u int) func(*SAMDGClientForwarder) error {
|
||||
return func(c *SAMDGClientForwarder) error {
|
||||
c.Conf.ReduceIdleTime = 300000
|
||||
if u >= 6 {
|
||||
c.Conf.ReduceIdleTime = (u * 60) * 1000
|
||||
@ -313,8 +313,8 @@ func SetClientReduceIdleTime(u int) func(*SAMSSUClientForwarder) error {
|
||||
}
|
||||
|
||||
//SetClientReduceIdleTimeMs sets the time to wait before reducing tunnels to idle levels in milliseconds
|
||||
func SetClientReduceIdleTimeMs(u int) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
func SetClientReduceIdleTimeMs(u int) func(*SAMDGClientForwarder) error {
|
||||
return func(c *SAMDGClientForwarder) error {
|
||||
c.Conf.ReduceIdleTime = 300000
|
||||
if u >= 300000 {
|
||||
c.Conf.ReduceIdleTime = u
|
||||
@ -325,8 +325,8 @@ func SetClientReduceIdleTimeMs(u int) func(*SAMSSUClientForwarder) error {
|
||||
}
|
||||
|
||||
//SetClientReduceIdleQuantity sets minimum number of tunnels to reduce to during idle time
|
||||
func SetClientReduceIdleQuantity(u int) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
func SetClientReduceIdleQuantity(u int) func(*SAMDGClientForwarder) error {
|
||||
return func(c *SAMDGClientForwarder) error {
|
||||
if u < 5 {
|
||||
c.Conf.ReduceIdleQuantity = u
|
||||
return nil
|
||||
@ -336,8 +336,8 @@ func SetClientReduceIdleQuantity(u int) func(*SAMSSUClientForwarder) error {
|
||||
}
|
||||
|
||||
//SetClientCloseIdle tells the connection to close it's tunnels during extended idle time.
|
||||
func SetClientCloseIdle(b bool) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
func SetClientCloseIdle(b bool) func(*SAMDGClientForwarder) error {
|
||||
return func(c *SAMDGClientForwarder) error {
|
||||
if b {
|
||||
c.Conf.CloseIdle = true
|
||||
return nil
|
||||
@ -348,8 +348,8 @@ func SetClientCloseIdle(b bool) func(*SAMSSUClientForwarder) error {
|
||||
}
|
||||
|
||||
//SetClientCloseIdleTime sets the time to wait before closing tunnels to idle levels
|
||||
func SetClientCloseIdleTime(u int) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
func SetClientCloseIdleTime(u int) func(*SAMDGClientForwarder) error {
|
||||
return func(c *SAMDGClientForwarder) error {
|
||||
c.Conf.CloseIdleTime = 300000
|
||||
if u >= 6 {
|
||||
c.Conf.CloseIdleTime = (u * 60) * 1000
|
||||
@ -360,8 +360,8 @@ func SetClientCloseIdleTime(u int) func(*SAMSSUClientForwarder) error {
|
||||
}
|
||||
|
||||
//SetClientCloseIdleTimeMs sets the time to wait before closing tunnels to idle levels in milliseconds
|
||||
func SetClientCloseIdleTimeMs(u int) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
func SetClientCloseIdleTimeMs(u int) func(*SAMDGClientForwarder) error {
|
||||
return func(c *SAMDGClientForwarder) error {
|
||||
c.Conf.CloseIdleTime = 300000
|
||||
if u >= 300000 {
|
||||
c.Conf.CloseIdleTime = u
|
||||
@ -372,8 +372,8 @@ func SetClientCloseIdleTimeMs(u int) func(*SAMSSUClientForwarder) error {
|
||||
}
|
||||
|
||||
//SetClientAccessListType tells the system to treat the accessList as a whitelist
|
||||
func SetClientAccessListType(s string) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
func SetClientAccessListType(s string) func(*SAMDGClientForwarder) error {
|
||||
return func(c *SAMDGClientForwarder) error {
|
||||
if s == "whitelist" {
|
||||
c.Conf.AccessListType = "whitelist"
|
||||
return nil
|
||||
@ -392,8 +392,8 @@ func SetClientAccessListType(s string) func(*SAMSSUClientForwarder) error {
|
||||
}
|
||||
|
||||
//SetClientAccessList tells the system to treat the accessList as a whitelist
|
||||
func SetClientAccessList(s []string) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
func SetClientAccessList(s []string) func(*SAMDGClientForwarder) error {
|
||||
return func(c *SAMDGClientForwarder) error {
|
||||
if len(s) > 0 {
|
||||
for _, a := range s {
|
||||
c.Conf.AccessList = append(c.Conf.AccessList, a)
|
||||
@ -405,8 +405,8 @@ func SetClientAccessList(s []string) func(*SAMSSUClientForwarder) error {
|
||||
}
|
||||
|
||||
//SetKeyFile sets
|
||||
func SetClientPassword(s string) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
func SetClientPassword(s string) func(*SAMDGClientForwarder) error {
|
||||
return func(c *SAMDGClientForwarder) error {
|
||||
c.Conf.KeyFilePath = s
|
||||
return nil
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package samforwarderudp
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net"
|
||||
@ -18,9 +19,9 @@ import (
|
||||
i2pkeys "github.com/eyedeekay/sam3/i2pkeys"
|
||||
)
|
||||
|
||||
//SAMSSUClientForwarder is a structure which automatically configured the forwarding of
|
||||
//SAMDGClientForwarder is a structure which automatically configured the forwarding of
|
||||
//a local port to i2p over the SAM API.
|
||||
type SAMSSUClientForwarder struct {
|
||||
type SAMDGClientForwarder struct {
|
||||
samConn *sam3.SAM
|
||||
SamKeys i2pkeys.I2PKeys
|
||||
Hasher *hashhash.Hasher
|
||||
@ -35,42 +36,42 @@ type SAMSSUClientForwarder struct {
|
||||
Conf *i2ptunconf.Conf
|
||||
}
|
||||
|
||||
func (f *SAMSSUClientForwarder) Config() *i2ptunconf.Conf {
|
||||
func (f *SAMDGClientForwarder) Config() *i2ptunconf.Conf {
|
||||
if f.Conf == nil {
|
||||
f.Conf = i2ptunconf.NewI2PBlankTunConf()
|
||||
}
|
||||
return f.Conf
|
||||
}
|
||||
|
||||
func (f *SAMSSUClientForwarder) GetType() string {
|
||||
func (f *SAMDGClientForwarder) GetType() string {
|
||||
return f.Config().Type
|
||||
}
|
||||
|
||||
func (f *SAMSSUClientForwarder) ID() string {
|
||||
func (f *SAMDGClientForwarder) ID() string {
|
||||
return f.Config().TunName
|
||||
}
|
||||
|
||||
func (f *SAMSSUClientForwarder) Keys() i2pkeys.I2PKeys {
|
||||
func (f *SAMDGClientForwarder) Keys() i2pkeys.I2PKeys {
|
||||
return f.SamKeys
|
||||
}
|
||||
|
||||
func (f *SAMSSUClientForwarder) Cleanup() {
|
||||
func (f *SAMDGClientForwarder) Cleanup() {
|
||||
f.publishConnection.Close()
|
||||
f.connectStream.Close()
|
||||
f.samConn.Close()
|
||||
}
|
||||
|
||||
func (f *SAMSSUClientForwarder) Close() error {
|
||||
func (f *SAMDGClientForwarder) Close() error {
|
||||
f.Cleanup()
|
||||
f.up = false
|
||||
return nil
|
||||
}
|
||||
|
||||
func (f *SAMSSUClientForwarder) print() []string {
|
||||
func (f *SAMDGClientForwarder) print() []string {
|
||||
return f.Config().PrintSlice()
|
||||
}
|
||||
|
||||
func (f *SAMSSUClientForwarder) Props() map[string]string {
|
||||
func (f *SAMDGClientForwarder) Props() map[string]string {
|
||||
r := make(map[string]string)
|
||||
print := f.print()
|
||||
print = append(print, "base32="+f.Base32())
|
||||
@ -83,7 +84,7 @@ func (f *SAMSSUClientForwarder) Props() map[string]string {
|
||||
return r
|
||||
}
|
||||
|
||||
func (f *SAMSSUClientForwarder) Print() string {
|
||||
func (f *SAMDGClientForwarder) Print() string {
|
||||
var r string
|
||||
r += "name=" + f.Config().TunName + "\n"
|
||||
r += "type=" + f.Config().Type + "\n"
|
||||
@ -97,7 +98,7 @@ func (f *SAMSSUClientForwarder) Print() string {
|
||||
return strings.Replace(r, "\n\n", "\n", -1)
|
||||
}
|
||||
|
||||
func (f *SAMSSUClientForwarder) Search(search string) string {
|
||||
func (f *SAMDGClientForwarder) Search(search string) string {
|
||||
terms := strings.Split(search, ",")
|
||||
if search == "" {
|
||||
return f.Print()
|
||||
@ -110,7 +111,7 @@ func (f *SAMSSUClientForwarder) Search(search string) string {
|
||||
return f.Print()
|
||||
}
|
||||
|
||||
func (f *SAMSSUClientForwarder) accesslisttype() string {
|
||||
func (f *SAMDGClientForwarder) accesslisttype() string {
|
||||
if f.Config().AccessListType == "whitelist" {
|
||||
return "i2cp.enableAccessList=true"
|
||||
} else if f.Config().AccessListType == "blacklist" {
|
||||
@ -121,7 +122,7 @@ func (f *SAMSSUClientForwarder) accesslisttype() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (f *SAMSSUClientForwarder) accesslist() string {
|
||||
func (f *SAMDGClientForwarder) accesslist() string {
|
||||
if f.Config().AccessListType != "" && len(f.Config().AccessList) > 0 {
|
||||
r := ""
|
||||
for _, s := range f.Config().AccessList {
|
||||
@ -132,7 +133,7 @@ func (f *SAMSSUClientForwarder) accesslist() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (f *SAMSSUClientForwarder) leasesetsettings() (string, string, string) {
|
||||
func (f *SAMDGClientForwarder) leasesetsettings() (string, string, string) {
|
||||
var r, s, t string
|
||||
if f.Config().LeaseSetKey != "" {
|
||||
r = "i2cp.leaseSetKey=" + f.Config().LeaseSetKey
|
||||
@ -147,37 +148,37 @@ func (f *SAMSSUClientForwarder) leasesetsettings() (string, string, string) {
|
||||
}
|
||||
|
||||
// Destination returns the destination of the i2p service you want to forward locally
|
||||
func (f *SAMSSUClientForwarder) Destination() string {
|
||||
func (f *SAMDGClientForwarder) Destination() string {
|
||||
return f.addr.Base32()
|
||||
}
|
||||
|
||||
// Target returns the host:port of the local service you want to forward to i2p
|
||||
func (f *SAMSSUClientForwarder) Target() string {
|
||||
func (f *SAMDGClientForwarder) Target() string {
|
||||
return f.Config().TargetHost + ":" + f.Config().TargetPort
|
||||
}
|
||||
|
||||
func (f *SAMSSUClientForwarder) sam() string {
|
||||
func (f *SAMDGClientForwarder) sam() string {
|
||||
return f.Config().SamHost + ":" + f.Config().SamPort
|
||||
}
|
||||
|
||||
//Base32 returns the base32 address of the local destination
|
||||
func (f *SAMSSUClientForwarder) Base32() string {
|
||||
func (f *SAMDGClientForwarder) Base32() string {
|
||||
return f.SamKeys.Addr().Base32()
|
||||
}
|
||||
|
||||
//Base32Readable returns the base32 address where the local service is being forwarded
|
||||
func (f *SAMSSUClientForwarder) Base32Readable() string {
|
||||
func (f *SAMDGClientForwarder) Base32Readable() string {
|
||||
b32 := strings.Replace(f.Base32(), ".b32.i2p", "", 1)
|
||||
rhash, _ := f.Hasher.Friendly(b32)
|
||||
return rhash + " " + strconv.Itoa(len(b32))
|
||||
}
|
||||
|
||||
//Base64 returns the base64 address of the local destination
|
||||
func (f *SAMSSUClientForwarder) Base64() string {
|
||||
func (f *SAMDGClientForwarder) Base64() string {
|
||||
return f.SamKeys.Addr().Base64()
|
||||
}
|
||||
|
||||
func (f *SAMSSUClientForwarder) forward(conn net.PacketConn) {
|
||||
func (f *SAMDGClientForwarder) forward(conn net.PacketConn) {
|
||||
// go func() {
|
||||
// defer f.connectStream.Close()
|
||||
// defer f.publishConnection.Close()
|
||||
@ -202,11 +203,11 @@ func (f *SAMSSUClientForwarder) forward(conn net.PacketConn) {
|
||||
// }()
|
||||
}
|
||||
|
||||
func (f *SAMSSUClientForwarder) Up() bool {
|
||||
func (f *SAMDGClientForwarder) Up() bool {
|
||||
return f.up
|
||||
}
|
||||
|
||||
func (f *SAMSSUClientForwarder) errSleep(err error) bool {
|
||||
func (f *SAMDGClientForwarder) errSleep(err error) bool {
|
||||
if err != nil {
|
||||
log.Printf("Dial failed: %v, waiting 5 minutes to try again\n", err)
|
||||
time.Sleep(5 * time.Minute)
|
||||
@ -217,11 +218,11 @@ func (f *SAMSSUClientForwarder) errSleep(err error) bool {
|
||||
}
|
||||
|
||||
//Serve starts the SAM connection and and forwards the local host:port to i2p
|
||||
func (f *SAMSSUClientForwarder) Serve() error {
|
||||
func (f *SAMDGClientForwarder) Serve() error {
|
||||
var err error
|
||||
log.Println("Establishing a SAM datagram session.")
|
||||
if f.publishConnection, err = net.ListenPacket("udp", f.Config().Target()); err != nil {
|
||||
return err
|
||||
return fmt.Errorf("Listener creation Error%s", err)
|
||||
}
|
||||
//p, _ := strconv.Atoi(f.Config().TargetPort)
|
||||
sp, _ := strconv.Atoi(f.Config().SamPort)
|
||||
@ -251,48 +252,48 @@ func (f *SAMSSUClientForwarder) Serve() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *SAMSSUClientForwarder) Load() (samtunnel.SAMTunnel, error) {
|
||||
func (s *SAMDGClientForwarder) Load() (samtunnel.SAMTunnel, error) {
|
||||
if s.samConn, err = sam3.NewSAM(s.sam()); err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("SAM connection error %s", err)
|
||||
}
|
||||
if s.addr, err = s.samConn.Lookup(s.Config().ClientDest); err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("%s", err)
|
||||
}
|
||||
log.Println("SAM Bridge connection established.")
|
||||
if s.Config().SaveFile {
|
||||
log.Println("Saving i2p keys")
|
||||
}
|
||||
if s.SamKeys, err = sfi2pkeys.Load(s.Config().FilePath, s.Config().TunName, s.Config().KeyFilePath, s.samConn, s.Config().SaveFile); err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("I2P key load/generate error%s", err)
|
||||
}
|
||||
log.Println("Destination keys generated, tunnel name:", s.Config().TunName)
|
||||
if s.Config().SaveFile {
|
||||
if err := sfi2pkeys.Save(s.Config().FilePath, s.Config().TunName, s.Config().KeyFilePath, s.SamKeys); err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("I2P key storage error %s", err)
|
||||
}
|
||||
log.Println("Saved tunnel keys for", s.Conf.TunName, "in", s.Conf.FilePath)
|
||||
}
|
||||
s.Hasher, err = hashhash.NewHasher(len(strings.Replace(s.Base32(), ".b32.i2p", "", 1)))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("Human-readable hasher error %s", err)
|
||||
}
|
||||
s.up = true
|
||||
return s, nil
|
||||
}
|
||||
|
||||
//NewSAMSSUClientForwarderFromOptions makes a new SAM forwarder with default options, accepts host:port arguments
|
||||
func NewSAMSSUClientForwarderFromOptions(opts ...func(*SAMSSUClientForwarder) error) (*SAMSSUClientForwarder, error) {
|
||||
var s SAMSSUClientForwarder
|
||||
//NewSAMDGClientForwarderFromOptions makes a new SAM forwarder with default options, accepts host:port arguments
|
||||
func NewSAMDGClientForwarderFromOptions(opts ...func(*SAMDGClientForwarder) error) (*SAMDGClientForwarder, error) {
|
||||
var s SAMDGClientForwarder
|
||||
s.Conf = i2ptunconf.NewI2PBlankTunConf()
|
||||
s.Conf.Type = "udpclient"
|
||||
for _, o := range opts {
|
||||
if err := o(&s); err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("Option setting error %s", err)
|
||||
}
|
||||
}
|
||||
l, e := s.Load()
|
||||
if e != nil {
|
||||
return nil, e
|
||||
return nil, fmt.Errorf("Tunnel loading error %s", e)
|
||||
}
|
||||
return l.(*SAMSSUClientForwarder), nil
|
||||
return l.(*SAMDGClientForwarder), nil
|
||||
}
|
||||
|
@ -5,36 +5,36 @@ import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
//Option is a SAMSSUForwarder Option
|
||||
type Option func(*SAMSSUForwarder) error
|
||||
//Option is a SAMDGForwarder Option
|
||||
type Option func(*SAMDGForwarder) error
|
||||
|
||||
//SetFilePath sets the host of the SAMSSUForwarder's SAM bridge
|
||||
func SetFilePath(s string) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
//SetFilePath sets the host of the SAMDGForwarder's SAM bridge
|
||||
func SetFilePath(s string) func(*SAMDGForwarder) error {
|
||||
return func(c *SAMDGForwarder) error {
|
||||
c.Conf.FilePath = s
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
//SetSaveFile tells the router to use an encrypted leaseset
|
||||
func SetSaveFile(b bool) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
func SetSaveFile(b bool) func(*SAMDGForwarder) error {
|
||||
return func(c *SAMDGForwarder) error {
|
||||
c.Conf.SaveFile = b
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
//SetHost sets the host of the SAMSSUForwarder's SAM bridge
|
||||
func SetHost(s string) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
//SetHost sets the host of the SAMDGForwarder's SAM bridge
|
||||
func SetHost(s string) func(*SAMDGForwarder) error {
|
||||
return func(c *SAMDGForwarder) error {
|
||||
c.Conf.TargetHost = s
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
//SetPort sets the port of the SAMSSUForwarder's SAM bridge using a string
|
||||
func SetPort(s string) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
//SetPort sets the port of the SAMDGForwarder's SAM bridge using a string
|
||||
func SetPort(s string) func(*SAMDGForwarder) error {
|
||||
return func(c *SAMDGForwarder) error {
|
||||
port, err := strconv.Atoi(s)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Invalid SSU Server Target Port %s; non-number ", s)
|
||||
@ -47,17 +47,17 @@ func SetPort(s string) func(*SAMSSUForwarder) error {
|
||||
}
|
||||
}
|
||||
|
||||
//SetSAMHost sets the host of the SAMSSUForwarder's SAM bridge
|
||||
func SetSAMHost(s string) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
//SetSAMHost sets the host of the SAMDGForwarder's SAM bridge
|
||||
func SetSAMHost(s string) func(*SAMDGForwarder) error {
|
||||
return func(c *SAMDGForwarder) error {
|
||||
c.Conf.SamHost = s
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
//SetSAMPort sets the port of the SAMSSUForwarder's SAM bridge using a string
|
||||
func SetSAMPort(s string) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
//SetSAMPort sets the port of the SAMDGForwarder's SAM bridge using a string
|
||||
func SetSAMPort(s string) func(*SAMDGForwarder) error {
|
||||
return func(c *SAMDGForwarder) error {
|
||||
port, err := strconv.Atoi(s)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Invalid SAM Port %s; non-number", s)
|
||||
@ -70,17 +70,17 @@ func SetSAMPort(s string) func(*SAMSSUForwarder) error {
|
||||
}
|
||||
}
|
||||
|
||||
//SetName sets the host of the SAMSSUForwarder's SAM bridge
|
||||
func SetName(s string) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
//SetName sets the host of the SAMDGForwarder's SAM bridge
|
||||
func SetName(s string) func(*SAMDGForwarder) error {
|
||||
return func(c *SAMDGForwarder) error {
|
||||
c.Conf.TunName = s
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
//SetSigType sets the type of the forwarder server
|
||||
func SetSigType(s string) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
func SetSigType(s string) func(*SAMDGForwarder) error {
|
||||
return func(c *SAMDGForwarder) error {
|
||||
if s == "" {
|
||||
c.Conf.SigType = ""
|
||||
} else if s == "DSA_SHA1" {
|
||||
@ -101,8 +101,8 @@ func SetSigType(s string) func(*SAMSSUForwarder) error {
|
||||
}
|
||||
|
||||
//SetInLength sets the number of hops inbound
|
||||
func SetInLength(u int) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
func SetInLength(u int) func(*SAMDGForwarder) error {
|
||||
return func(c *SAMDGForwarder) error {
|
||||
if u < 7 && u >= 0 {
|
||||
c.Conf.InLength = u
|
||||
return nil
|
||||
@ -112,8 +112,8 @@ func SetInLength(u int) func(*SAMSSUForwarder) error {
|
||||
}
|
||||
|
||||
//SetOutLength sets the number of hops outbound
|
||||
func SetOutLength(u int) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
func SetOutLength(u int) func(*SAMDGForwarder) error {
|
||||
return func(c *SAMDGForwarder) error {
|
||||
if u < 7 && u >= 0 {
|
||||
c.Conf.OutLength = u
|
||||
return nil
|
||||
@ -123,8 +123,8 @@ func SetOutLength(u int) func(*SAMSSUForwarder) error {
|
||||
}
|
||||
|
||||
//SetInVariance sets the variance of a number of hops inbound
|
||||
func SetInVariance(i int) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
func SetInVariance(i int) func(*SAMDGForwarder) error {
|
||||
return func(c *SAMDGForwarder) error {
|
||||
if i < 7 && i > -7 {
|
||||
c.Conf.InVariance = i
|
||||
return nil
|
||||
@ -134,8 +134,8 @@ func SetInVariance(i int) func(*SAMSSUForwarder) error {
|
||||
}
|
||||
|
||||
//SetOutVariance sets the variance of a number of hops outbound
|
||||
func SetOutVariance(i int) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
func SetOutVariance(i int) func(*SAMDGForwarder) error {
|
||||
return func(c *SAMDGForwarder) error {
|
||||
if i < 7 && i > -7 {
|
||||
c.Conf.OutVariance = i
|
||||
return nil
|
||||
@ -145,8 +145,8 @@ func SetOutVariance(i int) func(*SAMSSUForwarder) error {
|
||||
}
|
||||
|
||||
//SetInQuantity sets the inbound tunnel quantity
|
||||
func SetInQuantity(u int) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
func SetInQuantity(u int) func(*SAMDGForwarder) error {
|
||||
return func(c *SAMDGForwarder) error {
|
||||
if u <= 16 && u > 0 {
|
||||
c.Conf.InQuantity = u
|
||||
return nil
|
||||
@ -156,8 +156,8 @@ func SetInQuantity(u int) func(*SAMSSUForwarder) error {
|
||||
}
|
||||
|
||||
//SetOutQuantity sets the outbound tunnel quantity
|
||||
func SetOutQuantity(u int) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
func SetOutQuantity(u int) func(*SAMDGForwarder) error {
|
||||
return func(c *SAMDGForwarder) error {
|
||||
if u <= 16 && u > 0 {
|
||||
c.Conf.OutQuantity = u
|
||||
return nil
|
||||
@ -167,8 +167,8 @@ func SetOutQuantity(u int) func(*SAMSSUForwarder) error {
|
||||
}
|
||||
|
||||
//SetInBackups sets the inbound tunnel backups
|
||||
func SetInBackups(u int) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
func SetInBackups(u int) func(*SAMDGForwarder) error {
|
||||
return func(c *SAMDGForwarder) error {
|
||||
if u < 6 && u >= 0 {
|
||||
c.Conf.InBackupQuantity = u
|
||||
return nil
|
||||
@ -178,8 +178,8 @@ func SetInBackups(u int) func(*SAMSSUForwarder) error {
|
||||
}
|
||||
|
||||
//SetOutBackups sets the inbound tunnel backups
|
||||
func SetOutBackups(u int) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
func SetOutBackups(u int) func(*SAMDGForwarder) error {
|
||||
return func(c *SAMDGForwarder) error {
|
||||
if u < 6 && u >= 0 {
|
||||
c.Conf.OutBackupQuantity = u
|
||||
return nil
|
||||
@ -189,8 +189,8 @@ func SetOutBackups(u int) func(*SAMSSUForwarder) error {
|
||||
}
|
||||
|
||||
//SetEncrypt tells the router to use an encrypted leaseset
|
||||
func SetEncrypt(b bool) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
func SetEncrypt(b bool) func(*SAMDGForwarder) error {
|
||||
return func(c *SAMDGForwarder) error {
|
||||
if b {
|
||||
c.Conf.EncryptLeaseSet = true
|
||||
return nil
|
||||
@ -201,40 +201,40 @@ func SetEncrypt(b bool) func(*SAMSSUForwarder) error {
|
||||
}
|
||||
|
||||
//SetLeaseSetKey sets
|
||||
func SetLeaseSetKey(s string) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
func SetLeaseSetKey(s string) func(*SAMDGForwarder) error {
|
||||
return func(c *SAMDGForwarder) error {
|
||||
c.Conf.LeaseSetKey = s
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
//SetLeaseSetPrivateKey sets
|
||||
func SetLeaseSetPrivateKey(s string) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
func SetLeaseSetPrivateKey(s string) func(*SAMDGForwarder) error {
|
||||
return func(c *SAMDGForwarder) error {
|
||||
c.Conf.LeaseSetPrivateKey = s
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
//SetLeaseSetPrivateSigningKey sets
|
||||
func SetLeaseSetPrivateSigningKey(s string) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
func SetLeaseSetPrivateSigningKey(s string) func(*SAMDGForwarder) error {
|
||||
return func(c *SAMDGForwarder) error {
|
||||
c.Conf.LeaseSetPrivateSigningKey = s
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
//SetMessageReliability sets
|
||||
func SetMessageReliability(s string) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
func SetMessageReliability(s string) func(*SAMDGForwarder) error {
|
||||
return func(c *SAMDGForwarder) error {
|
||||
c.Conf.MessageReliability = s
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
//SetAllowZeroIn tells the tunnel to accept zero-hop peers
|
||||
func SetAllowZeroIn(b bool) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
func SetAllowZeroIn(b bool) func(*SAMDGForwarder) error {
|
||||
return func(c *SAMDGForwarder) error {
|
||||
if b {
|
||||
c.Conf.InAllowZeroHop = true
|
||||
return nil
|
||||
@ -245,8 +245,8 @@ func SetAllowZeroIn(b bool) func(*SAMSSUForwarder) error {
|
||||
}
|
||||
|
||||
//SetAllowZeroOut tells the tunnel to accept zero-hop peers
|
||||
func SetAllowZeroOut(b bool) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
func SetAllowZeroOut(b bool) func(*SAMDGForwarder) error {
|
||||
return func(c *SAMDGForwarder) error {
|
||||
if b {
|
||||
c.Conf.OutAllowZeroHop = true
|
||||
return nil
|
||||
@ -257,8 +257,8 @@ func SetAllowZeroOut(b bool) func(*SAMSSUForwarder) error {
|
||||
}
|
||||
|
||||
//SetFastRecieve tells clients to use compression
|
||||
func SetFastRecieve(b bool) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
func SetFastRecieve(b bool) func(*SAMDGForwarder) error {
|
||||
return func(c *SAMDGForwarder) error {
|
||||
if b {
|
||||
c.Conf.FastRecieve = true
|
||||
return nil
|
||||
@ -269,8 +269,8 @@ func SetFastRecieve(b bool) func(*SAMSSUForwarder) error {
|
||||
}
|
||||
|
||||
//SetCompress tells clients to use compression
|
||||
func SetCompress(b bool) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
func SetCompress(b bool) func(*SAMDGForwarder) error {
|
||||
return func(c *SAMDGForwarder) error {
|
||||
if b {
|
||||
c.Conf.UseCompression = true
|
||||
return nil
|
||||
@ -281,8 +281,8 @@ func SetCompress(b bool) func(*SAMSSUForwarder) error {
|
||||
}
|
||||
|
||||
//SetReduceIdle tells the connection to reduce it's tunnels during extended idle time.
|
||||
func SetReduceIdle(b bool) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
func SetReduceIdle(b bool) func(*SAMDGForwarder) error {
|
||||
return func(c *SAMDGForwarder) error {
|
||||
if b {
|
||||
c.Conf.ReduceIdle = true
|
||||
return nil
|
||||
@ -293,8 +293,8 @@ func SetReduceIdle(b bool) func(*SAMSSUForwarder) error {
|
||||
}
|
||||
|
||||
//SetReduceIdleTime sets the time to wait before reducing tunnels to idle levels
|
||||
func SetReduceIdleTime(u int) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
func SetReduceIdleTime(u int) func(*SAMDGForwarder) error {
|
||||
return func(c *SAMDGForwarder) error {
|
||||
c.Conf.ReduceIdleTime = 300000
|
||||
if u >= 6 {
|
||||
c.Conf.ReduceIdleTime = (u * 60) * 1000
|
||||
@ -305,8 +305,8 @@ func SetReduceIdleTime(u int) func(*SAMSSUForwarder) error {
|
||||
}
|
||||
|
||||
//SetReduceIdleTimeMs sets the time to wait before reducing tunnels to idle levels in milliseconds
|
||||
func SetReduceIdleTimeMs(u int) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
func SetReduceIdleTimeMs(u int) func(*SAMDGForwarder) error {
|
||||
return func(c *SAMDGForwarder) error {
|
||||
c.Conf.ReduceIdleTime = 300000
|
||||
if u >= 300000 {
|
||||
c.Conf.ReduceIdleTime = u
|
||||
@ -317,8 +317,8 @@ func SetReduceIdleTimeMs(u int) func(*SAMSSUForwarder) error {
|
||||
}
|
||||
|
||||
//SetReduceIdleQuantity sets minimum number of tunnels to reduce to during idle time
|
||||
func SetReduceIdleQuantity(u int) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
func SetReduceIdleQuantity(u int) func(*SAMDGForwarder) error {
|
||||
return func(c *SAMDGForwarder) error {
|
||||
if u < 5 {
|
||||
c.Conf.ReduceIdleQuantity = u
|
||||
return nil
|
||||
@ -328,8 +328,8 @@ func SetReduceIdleQuantity(u int) func(*SAMSSUForwarder) error {
|
||||
}
|
||||
|
||||
//SetCloseIdle tells the connection to close it's tunnels during extended idle time.
|
||||
func SetCloseIdle(b bool) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
func SetCloseIdle(b bool) func(*SAMDGForwarder) error {
|
||||
return func(c *SAMDGForwarder) error {
|
||||
if b {
|
||||
c.Conf.CloseIdle = true
|
||||
return nil
|
||||
@ -340,8 +340,8 @@ func SetCloseIdle(b bool) func(*SAMSSUForwarder) error {
|
||||
}
|
||||
|
||||
//SetCloseIdleTime sets the time to wait before closing tunnels to idle levels
|
||||
func SetCloseIdleTime(u int) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
func SetCloseIdleTime(u int) func(*SAMDGForwarder) error {
|
||||
return func(c *SAMDGForwarder) error {
|
||||
c.Conf.CloseIdleTime = 300000
|
||||
if u >= 6 {
|
||||
c.Conf.CloseIdleTime = (u * 60) * 1000
|
||||
@ -352,8 +352,8 @@ func SetCloseIdleTime(u int) func(*SAMSSUForwarder) error {
|
||||
}
|
||||
|
||||
//SetCloseIdleTimeMs sets the time to wait before closing tunnels to idle levels in milliseconds
|
||||
func SetCloseIdleTimeMs(u int) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
func SetCloseIdleTimeMs(u int) func(*SAMDGForwarder) error {
|
||||
return func(c *SAMDGForwarder) error {
|
||||
c.Conf.CloseIdleTime = 300000
|
||||
if u >= 300000 {
|
||||
c.Conf.CloseIdleTime = u
|
||||
@ -364,8 +364,8 @@ func SetCloseIdleTimeMs(u int) func(*SAMSSUForwarder) error {
|
||||
}
|
||||
|
||||
//SetAccessListType tells the system to treat the accessList as a whitelist
|
||||
func SetAccessListType(s string) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
func SetAccessListType(s string) func(*SAMDGForwarder) error {
|
||||
return func(c *SAMDGForwarder) error {
|
||||
if s == "whitelist" {
|
||||
c.Conf.AccessListType = "whitelist"
|
||||
return nil
|
||||
@ -384,8 +384,8 @@ func SetAccessListType(s string) func(*SAMSSUForwarder) error {
|
||||
}
|
||||
|
||||
//SetAccessList tells the system to treat the accessList as a whitelist
|
||||
func SetAccessList(s []string) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
func SetAccessList(s []string) func(*SAMDGForwarder) error {
|
||||
return func(c *SAMDGForwarder) error {
|
||||
if len(s) > 0 {
|
||||
for _, a := range s {
|
||||
c.Conf.AccessList = append(c.Conf.AccessList, a)
|
||||
@ -397,8 +397,8 @@ func SetAccessList(s []string) func(*SAMSSUForwarder) error {
|
||||
}
|
||||
|
||||
//SetKeyFile sets
|
||||
func SetKeyFile(s string) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
func SetKeyFile(s string) func(*SAMDGForwarder) error {
|
||||
return func(c *SAMDGForwarder) error {
|
||||
c.Conf.KeyFilePath = s
|
||||
return nil
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package samforwarderudp
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net"
|
||||
@ -18,9 +19,9 @@ import (
|
||||
"github.com/eyedeekay/sam3/i2pkeys"
|
||||
)
|
||||
|
||||
//SAMSSUForwarder is a structure which automatically configured the forwarding of
|
||||
//SAMDGForwarder is a structure which automatically configured the forwarding of
|
||||
//a local service to i2p over the SAM API.
|
||||
type SAMSSUForwarder struct {
|
||||
type SAMDGForwarder struct {
|
||||
samConn *sam3.SAM
|
||||
SamKeys i2pkeys.I2PKeys
|
||||
Hasher *hashhash.Hasher
|
||||
@ -36,36 +37,36 @@ type SAMSSUForwarder struct {
|
||||
|
||||
var err error
|
||||
|
||||
func (f *SAMSSUForwarder) Config() *i2ptunconf.Conf {
|
||||
func (f *SAMDGForwarder) Config() *i2ptunconf.Conf {
|
||||
if f.Conf == nil {
|
||||
f.Conf = i2ptunconf.NewI2PBlankTunConf()
|
||||
}
|
||||
return f.Conf
|
||||
}
|
||||
|
||||
func (f *SAMSSUForwarder) GetType() string {
|
||||
func (f *SAMDGForwarder) GetType() string {
|
||||
return f.Config().Type
|
||||
}
|
||||
|
||||
func (f *SAMSSUForwarder) ID() string {
|
||||
func (f *SAMDGForwarder) ID() string {
|
||||
return f.Config().TunName
|
||||
}
|
||||
|
||||
func (f *SAMSSUForwarder) Keys() i2pkeys.I2PKeys {
|
||||
func (f *SAMDGForwarder) Keys() i2pkeys.I2PKeys {
|
||||
return f.SamKeys
|
||||
}
|
||||
|
||||
func (f *SAMSSUForwarder) Cleanup() {
|
||||
func (f *SAMDGForwarder) Cleanup() {
|
||||
f.publishConnection.Close()
|
||||
f.clientConnection.Close()
|
||||
f.samConn.Close()
|
||||
}
|
||||
|
||||
func (f *SAMSSUForwarder) Close() error {
|
||||
func (f *SAMDGForwarder) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (f *SAMSSUForwarder) print() []string {
|
||||
func (f *SAMDGForwarder) print() []string {
|
||||
/*lsk, lspk, lspsk := f.leasesetsettings()
|
||||
return []string{
|
||||
//f.targetForPort443(),
|
||||
@ -95,7 +96,7 @@ func (f *SAMSSUForwarder) print() []string {
|
||||
return f.Config().PrintSlice()
|
||||
}
|
||||
|
||||
func (f *SAMSSUForwarder) Props() map[string]string {
|
||||
func (f *SAMDGForwarder) Props() map[string]string {
|
||||
r := make(map[string]string)
|
||||
print := f.print()
|
||||
print = append(print, "base32="+f.Base32())
|
||||
@ -108,7 +109,7 @@ func (f *SAMSSUForwarder) Props() map[string]string {
|
||||
return r
|
||||
}
|
||||
|
||||
func (f *SAMSSUForwarder) Print() string {
|
||||
func (f *SAMDGForwarder) Print() string {
|
||||
var r string
|
||||
r += "name=" + f.Config().TunName + "\n"
|
||||
r += "type=" + f.Config().Type + "\n"
|
||||
@ -121,7 +122,7 @@ func (f *SAMSSUForwarder) Print() string {
|
||||
return strings.Replace(r, "\n\n", "\n", -1)
|
||||
}
|
||||
|
||||
func (f *SAMSSUForwarder) Search(search string) string {
|
||||
func (f *SAMDGForwarder) Search(search string) string {
|
||||
terms := strings.Split(search, ",")
|
||||
if search == "" {
|
||||
return f.Print()
|
||||
@ -134,7 +135,7 @@ func (f *SAMSSUForwarder) Search(search string) string {
|
||||
return f.Print()
|
||||
}
|
||||
|
||||
func (f *SAMSSUForwarder) accesslisttype() string {
|
||||
func (f *SAMDGForwarder) accesslisttype() string {
|
||||
if f.Config().AccessListType == "whitelist" {
|
||||
return "i2cp.enableAccessList=true"
|
||||
} else if f.Config().AccessListType == "blacklist" {
|
||||
@ -145,7 +146,7 @@ func (f *SAMSSUForwarder) accesslisttype() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (f *SAMSSUForwarder) accesslist() string {
|
||||
func (f *SAMDGForwarder) accesslist() string {
|
||||
if f.Config().AccessListType != "" && len(f.Config().AccessList) > 0 {
|
||||
r := ""
|
||||
for _, s := range f.Config().AccessList {
|
||||
@ -156,7 +157,7 @@ func (f *SAMSSUForwarder) accesslist() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (f *SAMSSUForwarder) leasesetsettings() (string, string, string) {
|
||||
func (f *SAMDGForwarder) leasesetsettings() (string, string, string) {
|
||||
var r, s, t string
|
||||
if f.Config().LeaseSetKey != "" {
|
||||
r = "i2cp.leaseSetKey=" + f.Config().LeaseSetKey
|
||||
@ -171,16 +172,16 @@ func (f *SAMSSUForwarder) leasesetsettings() (string, string, string) {
|
||||
}
|
||||
|
||||
// Target returns the host:port of the local service you want to forward to i2p
|
||||
func (f *SAMSSUForwarder) Target() string {
|
||||
func (f *SAMDGForwarder) Target() string {
|
||||
return f.Config().TargetHost + ":" + f.Config().TargetPort
|
||||
}
|
||||
|
||||
func (f *SAMSSUForwarder) sam() string {
|
||||
func (f *SAMDGForwarder) sam() string {
|
||||
return f.Config().SamHost + ":" + f.Config().SamPort
|
||||
}
|
||||
|
||||
//func (f *SAMSSUForwarder) forward(conn net.Conn) {
|
||||
func (f *SAMSSUForwarder) forward() {
|
||||
//func (f *SAMDGForwarder) forward(conn net.Conn) {
|
||||
func (f *SAMDGForwarder) forward() {
|
||||
Loop := false
|
||||
if f.clientConnection == nil {
|
||||
for !Loop {
|
||||
@ -217,23 +218,23 @@ func (f *SAMSSUForwarder) forward() {
|
||||
}
|
||||
|
||||
//Base32 returns the base32 address where the local service is being forwarded
|
||||
func (f *SAMSSUForwarder) Base32() string {
|
||||
func (f *SAMDGForwarder) Base32() string {
|
||||
return f.SamKeys.Addr().Base32()
|
||||
}
|
||||
|
||||
//Base32Readable returns the base32 address where the local service is being forwarded
|
||||
func (f *SAMSSUForwarder) Base32Readable() string {
|
||||
func (f *SAMDGForwarder) Base32Readable() string {
|
||||
b32 := strings.Replace(f.Base32(), ".b32.i2p", "", 1)
|
||||
rhash, _ := f.Hasher.Friendly(b32)
|
||||
return rhash + " " + strconv.Itoa(len(b32))
|
||||
}
|
||||
|
||||
//Base64 returns the base64 address where the local service is being forwarded
|
||||
func (f *SAMSSUForwarder) Base64() string {
|
||||
func (f *SAMDGForwarder) Base64() string {
|
||||
return f.SamKeys.Addr().Base64()
|
||||
}
|
||||
|
||||
func (f *SAMSSUForwarder) errSleep(err error) bool {
|
||||
func (f *SAMDGForwarder) errSleep(err error) bool {
|
||||
if err != nil {
|
||||
log.Printf("Dial failed: %v, waiting 5 minutes to try again\n", err)
|
||||
time.Sleep(5 * time.Minute)
|
||||
@ -244,10 +245,10 @@ func (f *SAMSSUForwarder) errSleep(err error) bool {
|
||||
}
|
||||
|
||||
//Serve starts the SAM connection and and forwards the local host:port to i2p
|
||||
func (f *SAMSSUForwarder) Serve() error {
|
||||
func (f *SAMDGForwarder) Serve() error {
|
||||
var err error
|
||||
|
||||
sp, _ := strconv.Atoi(f.Config().SamPort)
|
||||
sp, err := strconv.Atoi(f.Config().SamPort)
|
||||
f.publishConnection, err = f.samConn.NewDatagramSession(
|
||||
f.Config().TunName,
|
||||
f.SamKeys,
|
||||
@ -255,8 +256,7 @@ func (f *SAMSSUForwarder) Serve() error {
|
||||
sp-1,
|
||||
)
|
||||
if err != nil {
|
||||
log.Println("Session Creation error:", err.Error())
|
||||
return err
|
||||
return fmt.Errorf("Session creation Error%s", err)
|
||||
}
|
||||
|
||||
log.Println("SAM datagram session established.")
|
||||
@ -268,55 +268,55 @@ func (f *SAMSSUForwarder) Serve() error {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *SAMSSUForwarder) Load() (samtunnel.SAMTunnel, error) {
|
||||
func (s *SAMDGForwarder) Load() (samtunnel.SAMTunnel, error) {
|
||||
s.samConn, err = sam3.NewSAM(s.sam())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("SAM connection error%s", err)
|
||||
}
|
||||
log.Println("SAM Bridge connection established.")
|
||||
if s.Config().SaveFile {
|
||||
log.Println("Saving i2p keys")
|
||||
}
|
||||
if s.SamKeys, err = sfi2pkeys.Load(s.Config().FilePath, s.Config().TunName, s.Config().KeyFilePath, s.samConn, s.Config().SaveFile); err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("SAM key load/generate error%s", err)
|
||||
}
|
||||
log.Println("Destination keys generated, tunnel name:", s.Config().TunName)
|
||||
if s.Config().SaveFile {
|
||||
if err := sfi2pkeys.Save(s.Config().FilePath, s.Config().TunName, s.Config().KeyFilePath, s.SamKeys); err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("SAM key save error%s", err)
|
||||
}
|
||||
log.Println("Saved tunnel keys for", s.Conf.TunName, "in", s.Conf.FilePath)
|
||||
}
|
||||
s.Hasher, err = hashhash.NewHasher(len(strings.Replace(s.Base32(), ".b32.i2p", "", 1)))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("Word-hash generation error%s", err)
|
||||
}
|
||||
s.up = true
|
||||
return s, nil
|
||||
}
|
||||
|
||||
func (f *SAMSSUForwarder) Up() bool {
|
||||
func (f *SAMDGForwarder) Up() bool {
|
||||
return f.up
|
||||
}
|
||||
|
||||
//NewSAMSSUForwarder makes a new SAM forwarder with default options, accepts host:port arguments
|
||||
func NewSAMSSUForwarder(host, port string) (*SAMSSUForwarder, error) {
|
||||
return NewSAMSSUForwarderFromOptions(SetHost(host), SetPort(port))
|
||||
//NewSAMDGForwarder makes a new SAM forwarder with default options, accepts host:port arguments
|
||||
func NewSAMDGForwarder(host, port string) (*SAMDGForwarder, error) {
|
||||
return NewSAMDGForwarderFromOptions(SetHost(host), SetPort(port))
|
||||
}
|
||||
|
||||
//NewSAMSSUForwarderFromOptions makes a new SAM forwarder with default options, accepts host:port arguments
|
||||
func NewSAMSSUForwarderFromOptions(opts ...func(*SAMSSUForwarder) error) (*SAMSSUForwarder, error) {
|
||||
var s SAMSSUForwarder
|
||||
//NewSAMDGForwarderFromOptions makes a new SAM forwarder with default options, accepts host:port arguments
|
||||
func NewSAMDGForwarderFromOptions(opts ...func(*SAMDGForwarder) error) (*SAMDGForwarder, error) {
|
||||
var s SAMDGForwarder
|
||||
s.Conf = i2ptunconf.NewI2PBlankTunConf()
|
||||
s.Conf.Type = "udpserver"
|
||||
for _, o := range opts {
|
||||
if err := o(&s); err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("Option Setting Error: %s", err)
|
||||
}
|
||||
}
|
||||
l, e := s.Load()
|
||||
if e != nil {
|
||||
return nil, e
|
||||
return nil, fmt.Errorf("%s", e)
|
||||
}
|
||||
return l.(*SAMSSUForwarder), nil
|
||||
return l.(*SAMDGForwarder), nil
|
||||
}
|
||||
|
@ -6,111 +6,111 @@ import (
|
||||
)
|
||||
|
||||
func TestOptionUDPHost(t *testing.T) {
|
||||
client, err := NewSAMSSUForwarderFromOptions(SetHost("127.0.0.1"))
|
||||
client, err := NewSAMDGForwarderFromOptions(SetHost("127.0.0.1"))
|
||||
if err != nil {
|
||||
t.Fatalf("NewSAMSSUForwarder() Error: %q\n", err)
|
||||
t.Fatalf("NewSAMDGForwarder() Error: %q\n", err)
|
||||
}
|
||||
log.Println(client.Base32())
|
||||
}
|
||||
|
||||
func TestOptionUDPPort(t *testing.T) {
|
||||
client, err := NewSAMSSUForwarderFromOptions(SetPort("7656"))
|
||||
client, err := NewSAMDGForwarderFromOptions(SetPort("7656"))
|
||||
if err != nil {
|
||||
t.Fatalf("NewSAMSSUForwarder() Error: %q\n", err)
|
||||
t.Fatalf("NewSAMDGForwarder() Error: %q\n", err)
|
||||
}
|
||||
log.Println(client.Base32())
|
||||
}
|
||||
|
||||
func TestOptionUDPInLength(t *testing.T) {
|
||||
client, err := NewSAMSSUForwarderFromOptions(SetInLength(3))
|
||||
client, err := NewSAMDGForwarderFromOptions(SetInLength(3))
|
||||
if err != nil {
|
||||
t.Fatalf("NewSAMSSUForwarder() Error: %q\n", err)
|
||||
t.Fatalf("NewSAMDGForwarder() Error: %q\n", err)
|
||||
}
|
||||
log.Println(client.Base32())
|
||||
}
|
||||
|
||||
func TestOptionUDPOutLength(t *testing.T) {
|
||||
client, err := NewSAMSSUForwarderFromOptions(SetInLength(3))
|
||||
client, err := NewSAMDGForwarderFromOptions(SetInLength(3))
|
||||
if err != nil {
|
||||
t.Fatalf("NewSAMSSUForwarder() Error: %q\n", err)
|
||||
t.Fatalf("NewSAMDGForwarder() Error: %q\n", err)
|
||||
}
|
||||
log.Println(client.Base32())
|
||||
}
|
||||
|
||||
func TestOptionUDPInVariance(t *testing.T) {
|
||||
client, err := NewSAMSSUForwarderFromOptions(SetInVariance(1))
|
||||
client, err := NewSAMDGForwarderFromOptions(SetInVariance(1))
|
||||
if err != nil {
|
||||
t.Fatalf("NewSAMSSUForwarder() Error: %q\n", err)
|
||||
t.Fatalf("NewSAMDGForwarder() Error: %q\n", err)
|
||||
}
|
||||
log.Println(client.Base32())
|
||||
}
|
||||
|
||||
func TestOptionUDPOutVariance(t *testing.T) {
|
||||
client, err := NewSAMSSUForwarderFromOptions(SetOutVariance(1))
|
||||
client, err := NewSAMDGForwarderFromOptions(SetOutVariance(1))
|
||||
if err != nil {
|
||||
t.Fatalf("NewSAMSSUForwarder() Error: %q\n", err)
|
||||
t.Fatalf("NewSAMDGForwarder() Error: %q\n", err)
|
||||
}
|
||||
log.Println(client.Base32())
|
||||
}
|
||||
|
||||
func TestOptionUDPInQuantity(t *testing.T) {
|
||||
client, err := NewSAMSSUForwarderFromOptions(SetInQuantity(6))
|
||||
client, err := NewSAMDGForwarderFromOptions(SetInQuantity(6))
|
||||
if err != nil {
|
||||
t.Fatalf("NewSAMSSUForwarder() Error: %q\n", err)
|
||||
t.Fatalf("NewSAMDGForwarder() Error: %q\n", err)
|
||||
}
|
||||
log.Println(client.Base32())
|
||||
}
|
||||
|
||||
func TestOptionUDPOutQuantity(t *testing.T) {
|
||||
client, err := NewSAMSSUForwarderFromOptions(SetOutQuantity(6))
|
||||
client, err := NewSAMDGForwarderFromOptions(SetOutQuantity(6))
|
||||
if err != nil {
|
||||
t.Fatalf("NewSAMSSUForwarder() Error: %q\n", err)
|
||||
t.Fatalf("NewSAMDGForwarder() Error: %q\n", err)
|
||||
}
|
||||
log.Println(client.Base32())
|
||||
}
|
||||
|
||||
func TestOptionUDPInBackups(t *testing.T) {
|
||||
client, err := NewSAMSSUForwarderFromOptions(SetInBackups(5))
|
||||
client, err := NewSAMDGForwarderFromOptions(SetInBackups(5))
|
||||
if err != nil {
|
||||
t.Fatalf("NewSAMSSUForwarder() Error: %q\n", err)
|
||||
t.Fatalf("NewSAMDGForwarder() Error: %q\n", err)
|
||||
}
|
||||
log.Println(client.Base32())
|
||||
}
|
||||
|
||||
func TestOptionUDPOutBackups(t *testing.T) {
|
||||
client, err := NewSAMSSUForwarderFromOptions(SetOutBackups(5))
|
||||
client, err := NewSAMDGForwarderFromOptions(SetOutBackups(5))
|
||||
if err != nil {
|
||||
t.Fatalf("NewSAMSSUForwarder() Error: %q\n", err)
|
||||
t.Fatalf("NewSAMDGForwarder() Error: %q\n", err)
|
||||
}
|
||||
log.Println(client.Base32())
|
||||
}
|
||||
|
||||
func TestOptionUDPReduceIdleQuantity(t *testing.T) {
|
||||
client, err := NewSAMSSUForwarderFromOptions(SetReduceIdleQuantity(4))
|
||||
client, err := NewSAMDGForwarderFromOptions(SetReduceIdleQuantity(4))
|
||||
if err != nil {
|
||||
t.Fatalf("NewSAMSSUForwarder() Error: %q\n", err)
|
||||
t.Fatalf("NewSAMDGForwarder() Error: %q\n", err)
|
||||
}
|
||||
log.Println(client.Base32())
|
||||
}
|
||||
|
||||
func TestOptionUDPEncryptLease(t *testing.T) {
|
||||
client, err := NewSAMSSUForwarderFromOptions(SetEncrypt(true))
|
||||
client, err := NewSAMDGForwarderFromOptions(SetEncrypt(true))
|
||||
if err != nil {
|
||||
t.Fatalf("NewSAMSSUForwarder() Error: %q\n", err)
|
||||
t.Fatalf("NewSAMDGForwarder() Error: %q\n", err)
|
||||
}
|
||||
log.Println(client.Base32())
|
||||
}
|
||||
|
||||
func TestOptionUDPSaveFile(t *testing.T) {
|
||||
client, err := NewSAMSSUForwarderFromOptions(SetSaveFile(true))
|
||||
client, err := NewSAMDGForwarderFromOptions(SetSaveFile(true))
|
||||
if err != nil {
|
||||
t.Fatalf("NewSAMSSUForwarder() Error: %q\n", err)
|
||||
t.Fatalf("NewSAMDGForwarder() Error: %q\n", err)
|
||||
}
|
||||
log.Println(client.Base32())
|
||||
}
|
||||
|
||||
func TestClientOptionHost(t *testing.T) {
|
||||
client, err := NewSAMSSUClientForwarderFromOptions(SetClientHost("127.0.0.1"))
|
||||
client, err := NewSAMDGClientForwarderFromOptions(SetClientHost("127.0.0.1"))
|
||||
if err != nil {
|
||||
t.Fatalf("NewSAMForwarder() Error: %q\n", err)
|
||||
}
|
||||
@ -118,7 +118,7 @@ func TestClientOptionHost(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestClientOptionPort(t *testing.T) {
|
||||
client, err := NewSAMSSUClientForwarderFromOptions(SetClientSAMPort("7656"))
|
||||
client, err := NewSAMDGClientForwarderFromOptions(SetClientSAMPort("7656"))
|
||||
if err != nil {
|
||||
t.Fatalf("NewSAMForwarder() Error: %q\n", err)
|
||||
}
|
||||
@ -126,7 +126,7 @@ func TestClientOptionPort(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestClientOptionInLength(t *testing.T) {
|
||||
client, err := NewSAMSSUClientForwarderFromOptions(SetClientInLength(3))
|
||||
client, err := NewSAMDGClientForwarderFromOptions(SetClientInLength(3))
|
||||
if err != nil {
|
||||
t.Fatalf("NewSAMForwarder() Error: %q\n", err)
|
||||
}
|
||||
@ -134,7 +134,7 @@ func TestClientOptionInLength(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestClientOptionOutLength(t *testing.T) {
|
||||
client, err := NewSAMSSUClientForwarderFromOptions(SetClientInLength(3))
|
||||
client, err := NewSAMDGClientForwarderFromOptions(SetClientInLength(3))
|
||||
if err != nil {
|
||||
t.Fatalf("NewSAMForwarder() Error: %q\n", err)
|
||||
}
|
||||
@ -142,7 +142,7 @@ func TestClientOptionOutLength(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestClientOptionInVariance(t *testing.T) {
|
||||
client, err := NewSAMSSUClientForwarderFromOptions(SetClientInVariance(1))
|
||||
client, err := NewSAMDGClientForwarderFromOptions(SetClientInVariance(1))
|
||||
if err != nil {
|
||||
t.Fatalf("NewSAMForwarder() Error: %q\n", err)
|
||||
}
|
||||
@ -150,7 +150,7 @@ func TestClientOptionInVariance(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestClientOptionOutVariance(t *testing.T) {
|
||||
client, err := NewSAMSSUClientForwarderFromOptions(SetClientOutVariance(1))
|
||||
client, err := NewSAMDGClientForwarderFromOptions(SetClientOutVariance(1))
|
||||
if err != nil {
|
||||
t.Fatalf("NewSAMForwarder() Error: %q\n", err)
|
||||
}
|
||||
@ -158,7 +158,7 @@ func TestClientOptionOutVariance(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestClientOptionInQuantity(t *testing.T) {
|
||||
client, err := NewSAMSSUClientForwarderFromOptions(SetClientInQuantity(6))
|
||||
client, err := NewSAMDGClientForwarderFromOptions(SetClientInQuantity(6))
|
||||
if err != nil {
|
||||
t.Fatalf("NewSAMForwarder() Error: %q\n", err)
|
||||
}
|
||||
@ -166,7 +166,7 @@ func TestClientOptionInQuantity(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestClientOptionOutQuantity(t *testing.T) {
|
||||
client, err := NewSAMSSUClientForwarderFromOptions(SetClientOutQuantity(6))
|
||||
client, err := NewSAMDGClientForwarderFromOptions(SetClientOutQuantity(6))
|
||||
if err != nil {
|
||||
t.Fatalf("NewSAMForwarder() Error: %q\n", err)
|
||||
}
|
||||
@ -174,7 +174,7 @@ func TestClientOptionOutQuantity(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestClientOptionInBackups(t *testing.T) {
|
||||
client, err := NewSAMSSUClientForwarderFromOptions(SetClientInBackups(5))
|
||||
client, err := NewSAMDGClientForwarderFromOptions(SetClientInBackups(5))
|
||||
if err != nil {
|
||||
t.Fatalf("NewSAMForwarder() Error: %q\n", err)
|
||||
}
|
||||
@ -182,7 +182,7 @@ func TestClientOptionInBackups(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestClientOptionOutBackups(t *testing.T) {
|
||||
client, err := NewSAMSSUClientForwarderFromOptions(SetClientOutBackups(5))
|
||||
client, err := NewSAMDGClientForwarderFromOptions(SetClientOutBackups(5))
|
||||
if err != nil {
|
||||
t.Fatalf("NewSAMForwarder() Error: %q\n", err)
|
||||
}
|
||||
@ -190,7 +190,7 @@ func TestClientOptionOutBackups(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestClientOptionReduceIdleQuantity(t *testing.T) {
|
||||
client, err := NewSAMSSUClientForwarderFromOptions(SetClientReduceIdleQuantity(4))
|
||||
client, err := NewSAMDGClientForwarderFromOptions(SetClientReduceIdleQuantity(4))
|
||||
if err != nil {
|
||||
t.Fatalf("NewSAMForwarder() Error: %q\n", err)
|
||||
}
|
||||
@ -198,7 +198,7 @@ func TestClientOptionReduceIdleQuantity(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestClientOptionReduceIdleTimeMs(t *testing.T) {
|
||||
client, err := NewSAMSSUClientForwarderFromOptions(SetClientReduceIdleTimeMs(300000))
|
||||
client, err := NewSAMDGClientForwarderFromOptions(SetClientReduceIdleTimeMs(300000))
|
||||
if err != nil {
|
||||
t.Fatalf("NewSAMForwarder() Error: %q\n", err)
|
||||
}
|
||||
@ -206,7 +206,7 @@ func TestClientOptionReduceIdleTimeMs(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestClientOptionReduceIdleTime(t *testing.T) {
|
||||
client, err := NewSAMSSUClientForwarderFromOptions(SetClientReduceIdleTime(6))
|
||||
client, err := NewSAMDGClientForwarderFromOptions(SetClientReduceIdleTime(6))
|
||||
if err != nil {
|
||||
t.Fatalf("NewSAMForwarder() Error: %q\n", err)
|
||||
}
|
||||
@ -214,7 +214,7 @@ func TestClientOptionReduceIdleTime(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestClientOptionCloseIdleTimeMs(t *testing.T) {
|
||||
client, err := NewSAMSSUClientForwarderFromOptions(SetClientCloseIdleTimeMs(300000))
|
||||
client, err := NewSAMDGClientForwarderFromOptions(SetClientCloseIdleTimeMs(300000))
|
||||
if err != nil {
|
||||
t.Fatalf("NewSAMForwarder() Error: %q\n", err)
|
||||
}
|
||||
@ -222,7 +222,7 @@ func TestClientOptionCloseIdleTimeMs(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestClientOptionCloseIdleTime(t *testing.T) {
|
||||
client, err := NewSAMSSUClientForwarderFromOptions(SetClientCloseIdleTime(6))
|
||||
client, err := NewSAMDGClientForwarderFromOptions(SetClientCloseIdleTime(6))
|
||||
if err != nil {
|
||||
t.Fatalf("NewSAMForwarder() Error: %q\n", err)
|
||||
}
|
||||
@ -230,7 +230,7 @@ func TestClientOptionCloseIdleTime(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestClientOptionEncryptLease(t *testing.T) {
|
||||
client, err := NewSAMSSUClientForwarderFromOptions(SetClientEncrypt(true))
|
||||
client, err := NewSAMDGClientForwarderFromOptions(SetClientEncrypt(true))
|
||||
if err != nil {
|
||||
t.Fatalf("NewSAMForwarder() Error: %q\n", err)
|
||||
}
|
||||
@ -238,7 +238,7 @@ func TestClientOptionEncryptLease(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestClientOptionSaveFile(t *testing.T) {
|
||||
client, err := NewSAMSSUClientForwarderFromOptions(SetClientSaveFile(true))
|
||||
client, err := NewSAMDGClientForwarderFromOptions(SetClientSaveFile(true))
|
||||
if err != nil {
|
||||
t.Fatalf("NewSAMForwarder() Error: %q\n", err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user