update the interface
This commit is contained in:
2
Makefile
2
Makefile
@ -17,7 +17,7 @@ LOG := log/
|
||||
ETC := etc/
|
||||
USR := usr/
|
||||
LOCAL := local/
|
||||
VERSION := 0.32.01
|
||||
VERSION := 0.32.02
|
||||
|
||||
GO111MODULE=on
|
||||
|
||||
|
@ -1,11 +1,10 @@
|
||||
package i2ptunconf
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
import "github.com/eyedeekay/sam-forwarder/interface"
|
||||
|
||||
|
||||
// GetAccessListType takes an argument and a default. If the argument differs from the
|
||||
// default, the argument is always returned. If the argument and default are
|
||||
@ -69,36 +68,3 @@ func (c *Conf) accesslist() string {
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
//SetAccessListType tells the system to treat the accessList as a whitelist
|
||||
func SetAccessListType(s string) func(samtunnel.SAMTunnel) error {
|
||||
return func(c samtunnel.SAMTunnel) error {
|
||||
if s == "whitelist" {
|
||||
c.(*Conf).AccessListType = "whitelist"
|
||||
return nil
|
||||
} else if s == "blacklist" {
|
||||
c.(*Conf).AccessListType = "blacklist"
|
||||
return nil
|
||||
} else if s == "none" {
|
||||
c.(*Conf).AccessListType = ""
|
||||
return nil
|
||||
} else if s == "" {
|
||||
c.(*Conf).AccessListType = ""
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Invalid Access list type(whitelist, blacklist, none)")
|
||||
}
|
||||
}
|
||||
|
||||
//SetAccessList tells the system to treat the accessList as a whitelist
|
||||
func SetAccessList(s []string) func(samtunnel.SAMTunnel) error {
|
||||
return func(c samtunnel.SAMTunnel) error {
|
||||
if len(s) > 0 {
|
||||
for _, a := range s {
|
||||
c.(*Conf).AccessList = append(c.(*Conf).AccessList, a)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,5 @@
|
||||
package i2ptunconf
|
||||
|
||||
import "fmt"
|
||||
import "github.com/eyedeekay/sam-forwarder/interface"
|
||||
|
||||
// GetInBackups takes an argument and a default. If the argument differs from the
|
||||
// default, the argument is always returned. If the argument and default are
|
||||
// the same and the key exists, the key is returned. If the key is absent, the
|
||||
@ -54,25 +51,3 @@ func (c *Conf) SetOutBackups(label ...string) {
|
||||
c.OutBackupQuantity = 2
|
||||
}
|
||||
}
|
||||
|
||||
//SetInBackups sets the inbound tunnel backups
|
||||
func SetInBackups(u int) func(samtunnel.SAMTunnel) error {
|
||||
return func(c samtunnel.SAMTunnel) error {
|
||||
if u < 6 && u >= 0 {
|
||||
c.(*Conf).InBackupQuantity = u // strconv.Itoa(u)
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Invalid inbound tunnel backup quantity")
|
||||
}
|
||||
}
|
||||
|
||||
//SetOutBackups sets the inbound tunnel backups
|
||||
func SetOutBackups(u int) func(samtunnel.SAMTunnel) error {
|
||||
return func(c samtunnel.SAMTunnel) error {
|
||||
if u < 6 && u >= 0 {
|
||||
c.(*Conf).OutBackupQuantity = u // strconv.Itoa(u)
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Invalid outbound tunnel backup quantity")
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package i2ptunconf
|
||||
|
||||
import "github.com/eyedeekay/sam-forwarder/interface"
|
||||
|
||||
|
||||
// GetUseCompression takes an argument and a default. If the argument differs from the
|
||||
// default, the argument is always returned. If the argument and default are
|
||||
@ -27,15 +27,3 @@ func (c *Conf) SetCompressed(label ...string) {
|
||||
c.UseCompression = true
|
||||
}
|
||||
}
|
||||
|
||||
//SetCompress tells clients to use compression
|
||||
func SetCompress(b bool) func(samtunnel.SAMTunnel) error {
|
||||
return func(c samtunnel.SAMTunnel) error {
|
||||
if b {
|
||||
c.(*Conf).UseCompression = b // "true"
|
||||
return nil
|
||||
}
|
||||
c.(*Conf).UseCompression = b // "false"
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ import (
|
||||
|
||||
import (
|
||||
"github.com/eyedeekay/sam-forwarder/i2pkeys"
|
||||
"github.com/eyedeekay/sam-forwarder/interface"
|
||||
"github.com/eyedeekay/sam3/i2pkeys"
|
||||
)
|
||||
|
||||
@ -180,58 +179,3 @@ func (f *Conf) Up() bool {
|
||||
func (f *Conf) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Conf) Load() (samtunnel.SAMTunnel, error) {
|
||||
return s, nil
|
||||
}
|
||||
|
||||
//NewConf makes a new SAM forwarder with default options, accepts host:port arguments
|
||||
func NewConf(host, port string) (*Conf, error) {
|
||||
return NewConfFromOptions(SetHost(host), SetPort(port))
|
||||
}
|
||||
|
||||
//NewConfFromOptions makes a new SAM forwarder with default options, accepts host:port arguments
|
||||
func NewConfFromOptions(opts ...func(samtunnel.SAMTunnel) error) (*Conf, error) {
|
||||
var s Conf
|
||||
s.SamHost = "127.0.0.1"
|
||||
s.SamPort = "7656"
|
||||
s.FilePath = ""
|
||||
s.SaveFile = false
|
||||
s.TargetHost = "127.0.0.1"
|
||||
s.TargetPort = "8081"
|
||||
s.TunName = "samForwarder"
|
||||
s.Type = "server"
|
||||
s.InLength = 3
|
||||
s.OutLength = 3
|
||||
s.InQuantity = 2
|
||||
s.OutQuantity = 2
|
||||
s.InVariance = 1
|
||||
s.OutVariance = 1
|
||||
s.InBackupQuantity = 3
|
||||
s.OutBackupQuantity = 3
|
||||
s.InAllowZeroHop = false
|
||||
s.OutAllowZeroHop = false
|
||||
s.EncryptLeaseSet = false
|
||||
s.LeaseSetKey = ""
|
||||
s.LeaseSetPrivateKey = ""
|
||||
s.LeaseSetPrivateSigningKey = ""
|
||||
s.FastRecieve = false
|
||||
s.UseCompression = true
|
||||
s.ReduceIdle = false
|
||||
s.ReduceIdleTime = 15
|
||||
s.ReduceIdleQuantity = 4
|
||||
s.CloseIdle = false
|
||||
s.CloseIdleTime = 300000
|
||||
s.MessageReliability = "none"
|
||||
s.KeyFilePath = ""
|
||||
for _, o := range opts {
|
||||
if err := o(&s); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
//l, e := s.Load()
|
||||
//if e != nil {
|
||||
//return nil, e
|
||||
//}
|
||||
return &s, nil //l.(*Conf), nil
|
||||
}
|
||||
|
@ -1,17 +1,9 @@
|
||||
package i2ptunconf
|
||||
|
||||
import "github.com/eyedeekay/sam-forwarder/interface"
|
||||
|
||||
|
||||
//Option is a Conf Option
|
||||
type Option func(samtunnel.SAMTunnel) error
|
||||
|
||||
//SetFilePath sets the path to save the config file at.
|
||||
func SetFilePath(s string) func(samtunnel.SAMTunnel) error {
|
||||
return func(c samtunnel.SAMTunnel) error {
|
||||
c.(*Conf).FilePath = s
|
||||
return nil
|
||||
}
|
||||
}
|
||||
type Option func(*Conf) error
|
||||
|
||||
//SetTargetForPort sets the port of the Conf's SAM bridge using a string
|
||||
/*func SetTargetForPort443(s string) func(samtunnel.SAMTunnel) error {
|
||||
|
@ -1,11 +1,5 @@
|
||||
package i2ptunconf
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
import "github.com/eyedeekay/sam-forwarder/interface"
|
||||
|
||||
// GetHost takes an argument and a default. If the argument differs from the
|
||||
// default, the argument is always returned. If the argument and default are
|
||||
@ -58,26 +52,3 @@ func (c *Conf) SetControlPort(label ...string) {
|
||||
c.ControlPort = ""
|
||||
}
|
||||
}
|
||||
|
||||
//SetControlHost sets the host of the service to forward
|
||||
func SetControlHost(s string) func(samtunnel.SAMTunnel) error {
|
||||
return func(c samtunnel.SAMTunnel) error {
|
||||
c.(*Conf).ControlHost = s
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
//SetControlPort sets the port of the service to forward
|
||||
func SetControlPort(s string) func(samtunnel.SAMTunnel) error {
|
||||
return func(c samtunnel.SAMTunnel) error {
|
||||
port, err := strconv.Atoi(s)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Invalid TCP Server Target Port %s; non-number ", s)
|
||||
}
|
||||
if port < 65536 && port > -1 {
|
||||
c.(*Conf).ControlPort = s
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Invalid port")
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package i2ptunconf
|
||||
|
||||
import "github.com/eyedeekay/sam-forwarder/interface"
|
||||
|
||||
|
||||
// GetKeyFile takes an argument and a default. If the argument differs from the
|
||||
// default, the argument is always returned. If the argument and default are
|
||||
@ -27,11 +27,3 @@ func (c *Conf) SetKeyFile(label ...string) {
|
||||
c.KeyFilePath = "./"
|
||||
}
|
||||
}
|
||||
|
||||
//SetKeyFile sets
|
||||
func SetKeyFile(s string) func(samtunnel.SAMTunnel) error {
|
||||
return func(c samtunnel.SAMTunnel) error {
|
||||
c.(*Conf).KeyFilePath = s
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package i2ptunconf
|
||||
|
||||
import "github.com/eyedeekay/sam-forwarder/interface"
|
||||
|
||||
|
||||
// GetClientDest takes an argument and a default. If the argument differs from the
|
||||
// default, the argument is always returned. If the argument and default are
|
||||
@ -27,11 +27,3 @@ func (c *Conf) SetClientDest(label ...string) {
|
||||
c.ClientDest = v
|
||||
}
|
||||
}
|
||||
|
||||
//SetSaveFile tells the router to save the tunnel's keys long-term
|
||||
func SetDestination(b string) func(samtunnel.SAMTunnel) error {
|
||||
return func(c samtunnel.SAMTunnel) error {
|
||||
c.(*Conf).ClientDest = b
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package i2ptunconf
|
||||
|
||||
//import "github.com/eyedeekay/sam-forwarder/interface"
|
||||
//
|
||||
|
||||
// GetDir takes an argument and a default. If the argument differs from the
|
||||
// default, the argument is always returned. If the argument and default are
|
||||
|
@ -1,6 +1,6 @@
|
||||
package i2ptunconf
|
||||
|
||||
import "github.com/eyedeekay/sam-forwarder/interface"
|
||||
|
||||
|
||||
// GetEndpointHost takes an argument and a default. If the argument differs from the
|
||||
// default, the argument is always returned. If the argument and default are
|
||||
@ -27,11 +27,3 @@ func (c *Conf) SetEndpointHost(label ...string) {
|
||||
c.TunnelHost = "10.79.0.1"
|
||||
}
|
||||
}
|
||||
|
||||
//SetTunnelHost is used for VPN endpoints
|
||||
func SetTunnelHost(s string) func(samtunnel.SAMTunnel) error {
|
||||
return func(c samtunnel.SAMTunnel) error {
|
||||
c.(*Conf).TunnelHost = s
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package i2ptunconf
|
||||
|
||||
import "github.com/eyedeekay/sam-forwarder/interface"
|
||||
|
||||
|
||||
// GetFastRecieve takes an argument and a default. If the argument differs from the
|
||||
// default, the argument is always returned. If the argument and default are
|
||||
@ -27,11 +27,3 @@ func (c *Conf) SetFastRecieve(label ...string) {
|
||||
c.FastRecieve = false
|
||||
}
|
||||
}
|
||||
|
||||
//SetFastRecieve tells clients to recieve all messages as quicky as possible
|
||||
func SetFastRecieve(b bool) func(samtunnel.SAMTunnel) error {
|
||||
return func(c samtunnel.SAMTunnel) error {
|
||||
c.(*Conf).FastRecieve = b
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,5 @@
|
||||
package i2ptunconf
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
import "github.com/eyedeekay/sam-forwarder/interface"
|
||||
|
||||
// GetHost takes an argument and a default. If the argument differs from the
|
||||
// default, the argument is always returned. If the argument and default are
|
||||
@ -58,26 +52,3 @@ func (c *Conf) SetPort(label ...string) {
|
||||
c.TargetPort = "8081"
|
||||
}
|
||||
}
|
||||
|
||||
//SetHost sets the host of the service to forward
|
||||
func SetHost(s string) func(samtunnel.SAMTunnel) error {
|
||||
return func(c samtunnel.SAMTunnel) error {
|
||||
c.(*Conf).TargetHost = s
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
//SetPort sets the port of the service to forward
|
||||
func SetPort(s string) func(samtunnel.SAMTunnel) error {
|
||||
return func(c samtunnel.SAMTunnel) error {
|
||||
port, err := strconv.Atoi(s)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Invalid TCP Server Target Port %s; non-number ", s)
|
||||
}
|
||||
if port < 65536 && port > -1 {
|
||||
c.(*Conf).TargetPort = s
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Invalid port")
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package i2ptunconf
|
||||
|
||||
import "github.com/eyedeekay/sam-forwarder/interface"
|
||||
|
||||
|
||||
// GetEncryptLeaseset takes an argument and a default. If the argument differs from the
|
||||
// default, the argument is always returned. If the argument and default are
|
||||
@ -105,39 +105,3 @@ func (c *Conf) SetLeasesetPrivateSigningKey(label ...string) {
|
||||
c.LeaseSetPrivateSigningKey = ""
|
||||
}
|
||||
}
|
||||
|
||||
//SetEncrypt tells the router to use an encrypted leaseset
|
||||
func SetEncrypt(b bool) func(samtunnel.SAMTunnel) error {
|
||||
return func(c samtunnel.SAMTunnel) error {
|
||||
if b {
|
||||
c.(*Conf).EncryptLeaseSet = b //"true"
|
||||
return nil
|
||||
}
|
||||
c.(*Conf).EncryptLeaseSet = b //"false"
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
//SetLeaseSetKey sets the host of the Conf's SAM bridge
|
||||
func SetLeaseSetKey(s string) func(samtunnel.SAMTunnel) error {
|
||||
return func(c samtunnel.SAMTunnel) error {
|
||||
c.(*Conf).LeaseSetKey = s
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
//SetLeaseSetPrivateKey sets the host of the Conf's SAM bridge
|
||||
func SetLeaseSetPrivateKey(s string) func(samtunnel.SAMTunnel) error {
|
||||
return func(c samtunnel.SAMTunnel) error {
|
||||
c.(*Conf).LeaseSetPrivateKey = s
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
//SetLeaseSetPrivateSigningKey sets the host of the Conf's SAM bridge
|
||||
func SetLeaseSetPrivateSigningKey(s string) func(samtunnel.SAMTunnel) error {
|
||||
return func(c samtunnel.SAMTunnel) error {
|
||||
c.(*Conf).LeaseSetPrivateSigningKey = s
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
package i2ptunconf
|
||||
|
||||
import "fmt"
|
||||
import "github.com/eyedeekay/sam-forwarder/interface"
|
||||
|
||||
// GetInLength takes an argument and a default. If the argument differs from the
|
||||
// default, the argument is always returned. If the argument and default are
|
||||
@ -54,25 +52,3 @@ func (c *Conf) SetOutLength(label ...string) {
|
||||
c.InLength = 3
|
||||
}
|
||||
}
|
||||
|
||||
//SetInLength sets the number of hops inbound
|
||||
func SetInLength(u int) func(samtunnel.SAMTunnel) error {
|
||||
return func(c samtunnel.SAMTunnel) error {
|
||||
if u < 7 && u >= 0 {
|
||||
c.(*Conf).InLength = u // strconv.Itoa(u)
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Invalid inbound tunnel length")
|
||||
}
|
||||
}
|
||||
|
||||
//SetOutLength sets the number of hops outbound
|
||||
func SetOutLength(u int) func(samtunnel.SAMTunnel) error {
|
||||
return func(c samtunnel.SAMTunnel) error {
|
||||
if u < 7 && u >= 0 {
|
||||
c.(*Conf).OutLength = u // strconv.Itoa(u)
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Invalid outbound tunnel length")
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package i2ptunconf
|
||||
|
||||
import "github.com/eyedeekay/sam-forwarder/interface"
|
||||
|
||||
|
||||
// GetSaveFile takes an argument and a default. If the argument differs from the
|
||||
// default, the argument is always returned. If the argument and default are
|
||||
@ -52,19 +52,3 @@ func (c *Conf) SetTunName(label ...string) {
|
||||
c.TunName = "forwarder"
|
||||
}
|
||||
}
|
||||
|
||||
//SetName sets the host of the Conf's SAM bridge
|
||||
func SetName(s string) func(samtunnel.SAMTunnel) error {
|
||||
return func(c samtunnel.SAMTunnel) error {
|
||||
c.(*Conf).TunName = s
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
//SetSaveFile tells the router to save the tunnel's keys long-term
|
||||
func SetSaveFile(b bool) func(samtunnel.SAMTunnel) error {
|
||||
return func(c samtunnel.SAMTunnel) error {
|
||||
c.(*Conf).SaveFile = b
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package i2ptunconf
|
||||
|
||||
import "github.com/eyedeekay/sam-forwarder/interface"
|
||||
|
||||
|
||||
// GetPassword takes an argument and a default. If the argument differs from the
|
||||
// default, the argument is always returned. If the argument and default are
|
||||
@ -27,11 +27,3 @@ func (c *Conf) SetPassword(label ...string) {
|
||||
c.Password = "samcatd"
|
||||
}
|
||||
}
|
||||
|
||||
//SetPassword sets the host of the Conf's SAM bridge
|
||||
func SetPassword(s string) func(samtunnel.SAMTunnel) error {
|
||||
return func(c samtunnel.SAMTunnel) error {
|
||||
c.(*Conf).Password = s
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,5 @@
|
||||
package i2ptunconf
|
||||
|
||||
import "fmt"
|
||||
|
||||
import "github.com/eyedeekay/sam-forwarder/interface"
|
||||
|
||||
// GetInQuantity takes an argument and a default. If the argument differs from the
|
||||
// default, the argument is always returned. If the argument and default are
|
||||
// the same and the key exists, the key is returned. If the key is absent, the
|
||||
@ -55,25 +51,3 @@ func (c *Conf) SetOutQuantity(label ...string) {
|
||||
c.OutQuantity = 1
|
||||
}
|
||||
}
|
||||
|
||||
//SetInQuantity sets the inbound tunnel quantity
|
||||
func SetInQuantity(u int) func(samtunnel.SAMTunnel) error {
|
||||
return func(c samtunnel.SAMTunnel) error {
|
||||
if u <= 16 && u > 0 {
|
||||
c.(*Conf).InQuantity = u //strconv.Itoa(u)
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Invalid inbound tunnel quantity")
|
||||
}
|
||||
}
|
||||
|
||||
//SetOutQuantity sets the outbound tunnel quantity
|
||||
func SetOutQuantity(u int) func(samtunnel.SAMTunnel) error {
|
||||
return func(c samtunnel.SAMTunnel) error {
|
||||
if u <= 16 && u > 0 {
|
||||
c.(*Conf).OutQuantity = u // strconv.Itoa(u)
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Invalid outbound tunnel quantity")
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,5 @@
|
||||
package i2ptunconf
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
import "github.com/eyedeekay/sam-forwarder/interface"
|
||||
|
||||
// GetReduceOnIdle takes an argument and a default. If the argument differs from the
|
||||
// default, the argument is always returned. If the argument and default are
|
||||
@ -135,78 +130,3 @@ func (c *Conf) SetCloseIdleTime(label ...string) {
|
||||
c.CloseIdleTime = 300000
|
||||
}
|
||||
}
|
||||
|
||||
//SetReduceIdle tells the connection to reduce it's tunnels during extended idle time.
|
||||
func SetReduceIdle(b bool) func(samtunnel.SAMTunnel) error {
|
||||
return func(c samtunnel.SAMTunnel) error {
|
||||
c.(*Conf).ReduceIdle = b // "false"
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
//SetReduceIdleTime sets the time to wait before reducing tunnels to idle levels
|
||||
func SetReduceIdleTime(u int) func(samtunnel.SAMTunnel) error {
|
||||
return func(c samtunnel.SAMTunnel) error {
|
||||
c.(*Conf).ReduceIdleTime = 300000
|
||||
if u >= 6 {
|
||||
c.(*Conf).ReduceIdleTime = (u * 60) * 1000 // strconv.Itoa((u * 60) * 1000)
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Invalid reduce idle timeout(Measured in minutes) %v", u)
|
||||
}
|
||||
}
|
||||
|
||||
//SetReduceIdleTimeMs sets the time to wait before reducing tunnels to idle levels in milliseconds
|
||||
func SetReduceIdleTimeMs(u int) func(samtunnel.SAMTunnel) error {
|
||||
return func(c samtunnel.SAMTunnel) error {
|
||||
c.(*Conf).ReduceIdleTime = 300000
|
||||
if u >= 300000 {
|
||||
c.(*Conf).ReduceIdleTime = u // strconv.Itoa(u)
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Invalid reduce idle timeout(Measured in milliseconds) %v", u)
|
||||
}
|
||||
}
|
||||
|
||||
//SetReduceIdleQuantity sets minimum number of tunnels to reduce to during idle time
|
||||
func SetReduceIdleQuantity(u int) func(samtunnel.SAMTunnel) error {
|
||||
return func(c samtunnel.SAMTunnel) error {
|
||||
if u < 5 {
|
||||
c.(*Conf).ReduceIdleQuantity = u // strconv.Itoa(u)
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Invalid reduce tunnel quantity")
|
||||
}
|
||||
}
|
||||
|
||||
//SetCloseIdle tells the connection to close it's tunnels during extended idle time.
|
||||
func SetCloseIdle(b bool) func(samtunnel.SAMTunnel) error {
|
||||
return func(c samtunnel.SAMTunnel) error {
|
||||
c.(*Conf).CloseIdle = b // "false"
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
//SetCloseIdleTime sets the time to wait before closing tunnels to idle levels
|
||||
func SetCloseIdleTime(u int) func(samtunnel.SAMTunnel) error {
|
||||
return func(c samtunnel.SAMTunnel) error {
|
||||
c.(*Conf).CloseIdleTime = 300000
|
||||
if u >= 6 {
|
||||
c.(*Conf).CloseIdleTime = (u * 60) * 1000 // strconv.Itoa((u * 60) * 1000)
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Invalid close idle timeout(Measured in minutes) %v", u)
|
||||
}
|
||||
}
|
||||
|
||||
//SetCloseIdleTimeMs sets the time to wait before closing tunnels to idle levels in milliseconds
|
||||
func SetCloseIdleTimeMs(u int) func(samtunnel.SAMTunnel) error {
|
||||
return func(c samtunnel.SAMTunnel) error {
|
||||
c.(*Conf).CloseIdleTime = 300000
|
||||
if u >= 300000 {
|
||||
c.(*Conf).CloseIdleTime = u //strconv.Itoa(u)
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Invalid close idle timeout(Measured in milliseconds) %v", u)
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package i2ptunconf
|
||||
|
||||
import "github.com/eyedeekay/sam-forwarder/interface"
|
||||
|
||||
|
||||
//i2cp.messageReliability
|
||||
// GetMessageReliability takes an argument and a default. If the argument differs from the
|
||||
@ -33,11 +33,3 @@ func (c *Conf) reliability() string {
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
//SetMessageReliability sets the host of the Conf's SAM bridge
|
||||
func SetMessageReliability(s string) func(samtunnel.SAMTunnel) error {
|
||||
return func(c samtunnel.SAMTunnel) error {
|
||||
c.(*Conf).MessageReliability = s
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,5 @@
|
||||
package i2ptunconf
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
import "github.com/eyedeekay/sam-forwarder/interface"
|
||||
|
||||
// GetSAMHost takes an argument and a default. If the argument differs from the
|
||||
// default, the argument is always returned. If the argument and default are
|
||||
// the same and the key exists, the key is returned. If the key is absent, the
|
||||
@ -58,26 +51,3 @@ func (c *Conf) SetSAMPort(label ...string) {
|
||||
c.SamPort = "7656"
|
||||
}
|
||||
}
|
||||
|
||||
//SetSAMHost sets the host of the Conf's SAM bridge
|
||||
func SetSAMHost(s string) func(samtunnel.SAMTunnel) error {
|
||||
return func(c samtunnel.SAMTunnel) error {
|
||||
c.(*Conf).SamHost = s
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
//SetSAMPort sets the port of the Conf's SAM bridge using a string
|
||||
func SetSAMPort(s string) func(samtunnel.SAMTunnel) error {
|
||||
return func(c samtunnel.SAMTunnel) error {
|
||||
port, err := strconv.Atoi(s)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Invalid SAM Port %s; non-number", s)
|
||||
}
|
||||
if port < 65536 && port > -1 {
|
||||
c.(*Conf).SamPort = s
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Invalid port")
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package i2ptunconf
|
||||
|
||||
import "github.com/eyedeekay/sam-forwarder/interface"
|
||||
|
||||
|
||||
// GetSigType takes an argument and a default. If the argument differs from the
|
||||
// default, the argument is always returned. If the argument and default are
|
||||
@ -45,24 +45,3 @@ func (c *Conf) SetSigType(label ...string) {
|
||||
c.SigType = "EdDSA_SHA512_Ed25519"
|
||||
}
|
||||
}
|
||||
|
||||
//SetSigType sets the type of the forwarder server
|
||||
func SetSigType(s string) func(samtunnel.SAMTunnel) error {
|
||||
return func(c samtunnel.SAMTunnel) error {
|
||||
switch s {
|
||||
case "DSA_SHA1":
|
||||
c.(*Conf).SigType = "DSA_SHA1"
|
||||
case "ECDSA_SHA256_P256":
|
||||
c.(*Conf).SigType = "ECDSA_SHA256_P256"
|
||||
case "ECDSA_SHA384_P384":
|
||||
c.(*Conf).SigType = "ECDSA_SHA384_P384"
|
||||
case "ECDSA_SHA512_P521":
|
||||
c.(*Conf).SigType = "ECDSA_SHA512_P521"
|
||||
case "EdDSA_SHA512_Ed25519":
|
||||
c.(*Conf).SigType = "EdDSA_SHA512_Ed25519"
|
||||
default:
|
||||
c.(*Conf).SigType = "EdDSA_SHA512_Ed25519"
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
@ -1,224 +0,0 @@
|
||||
package i2ptunconf
|
||||
|
||||
import (
|
||||
"github.com/eyedeekay/httptunnel"
|
||||
"github.com/eyedeekay/httptunnel/multiproxy"
|
||||
"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.SetName(config.TunName),
|
||||
i2phttpproxy.SetKeysPath(config.KeyFilePath),
|
||||
i2phttpproxy.SetHost(config.SamHost),
|
||||
i2phttpproxy.SetPort(config.SamPort),
|
||||
i2phttpproxy.SetProxyAddr(config.TargetHost+":"+config.TargetPort),
|
||||
i2phttpproxy.SetControlHost(config.ControlHost),
|
||||
i2phttpproxy.SetControlPort(config.ControlPort),
|
||||
i2phttpproxy.SetInLength(uint(config.InLength)),
|
||||
i2phttpproxy.SetOutLength(uint(config.OutLength)),
|
||||
i2phttpproxy.SetInQuantity(uint(config.InQuantity)),
|
||||
i2phttpproxy.SetOutQuantity(uint(config.OutQuantity)),
|
||||
i2phttpproxy.SetInBackups(uint(config.InBackupQuantity)),
|
||||
i2phttpproxy.SetOutBackups(uint(config.OutBackupQuantity)),
|
||||
i2phttpproxy.SetInVariance(config.InVariance),
|
||||
i2phttpproxy.SetOutVariance(config.OutVariance),
|
||||
i2phttpproxy.SetUnpublished(config.Client),
|
||||
i2phttpproxy.SetReduceIdle(config.ReduceIdle),
|
||||
i2phttpproxy.SetCompression(config.UseCompression),
|
||||
i2phttpproxy.SetReduceIdleTime(uint(config.ReduceIdleTime)),
|
||||
i2phttpproxy.SetReduceIdleQuantity(uint(config.ReduceIdleQuantity)),
|
||||
i2phttpproxy.SetCloseIdle(config.CloseIdle),
|
||||
i2phttpproxy.SetCloseIdleTime(uint(config.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
|
||||
}
|
||||
|
||||
func NewSAMBrowserClientFromConf(config *Conf) (*i2pbrowserproxy.SAMMultiProxy, error) {
|
||||
if config != nil {
|
||||
return i2pbrowserproxy.NewHttpProxy(
|
||||
i2pbrowserproxy.SetName(config.TunName),
|
||||
i2pbrowserproxy.SetKeysPath(config.KeyFilePath),
|
||||
i2pbrowserproxy.SetHost(config.SamHost),
|
||||
i2pbrowserproxy.SetPort(config.SamPort),
|
||||
i2pbrowserproxy.SetProxyAddr(config.TargetHost+":"+config.TargetPort),
|
||||
i2pbrowserproxy.SetControlHost(config.ControlHost),
|
||||
i2pbrowserproxy.SetControlPort(config.ControlPort),
|
||||
i2pbrowserproxy.SetInLength(uint(config.InLength)),
|
||||
i2pbrowserproxy.SetOutLength(uint(config.OutLength)),
|
||||
i2pbrowserproxy.SetInQuantity(uint(config.InQuantity)),
|
||||
i2pbrowserproxy.SetOutQuantity(uint(config.OutQuantity)),
|
||||
i2pbrowserproxy.SetInBackups(uint(config.InBackupQuantity)),
|
||||
i2pbrowserproxy.SetOutBackups(uint(config.OutBackupQuantity)),
|
||||
i2pbrowserproxy.SetInVariance(config.InVariance),
|
||||
i2pbrowserproxy.SetOutVariance(config.OutVariance),
|
||||
i2pbrowserproxy.SetUnpublished(config.Client),
|
||||
i2pbrowserproxy.SetReduceIdle(config.ReduceIdle),
|
||||
i2pbrowserproxy.SetCompression(config.UseCompression),
|
||||
i2pbrowserproxy.SetReduceIdleTime(uint(config.ReduceIdleTime)),
|
||||
i2pbrowserproxy.SetReduceIdleQuantity(uint(config.ReduceIdleQuantity)),
|
||||
//i2pbrowserproxy.SetCloseIdle(config.CloseIdle),
|
||||
//i2pbrowserproxy.SetCloseIdleTime(uint(config.CloseIdleTime)),
|
||||
)
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func NewSAMBrowserClientFromConfig(iniFile, SamHost, SamPort string, label ...string) (*i2pbrowserproxy.SAMMultiProxy, 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 NewSAMBrowserClientFromConf(config)
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// NewSAMClientForwarderFromConf generates a SAMforwarder from *i2ptunconf.Conf
|
||||
func NewSAMClientForwarderFromConf(config *Conf) (*samforwarder.SAMClientForwarder, error) {
|
||||
if config != nil {
|
||||
return samforwarder.NewSAMClientForwarderFromOptions(
|
||||
samforwarder.SetClientSaveFile(config.SaveFile),
|
||||
samforwarder.SetClientFilePath(config.SaveDirectory),
|
||||
samforwarder.SetClientHost(config.TargetHost),
|
||||
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),
|
||||
samforwarder.SetClientInVariance(config.InVariance),
|
||||
samforwarder.SetClientOutVariance(config.OutVariance),
|
||||
samforwarder.SetClientInQuantity(config.InQuantity),
|
||||
samforwarder.SetClientOutQuantity(config.OutQuantity),
|
||||
samforwarder.SetClientInBackups(config.InBackupQuantity),
|
||||
samforwarder.SetClientOutBackups(config.OutBackupQuantity),
|
||||
samforwarder.SetClientEncrypt(config.EncryptLeaseSet),
|
||||
samforwarder.SetClientLeaseSetKey(config.LeaseSetKey),
|
||||
samforwarder.SetClientLeaseSetPrivateKey(config.LeaseSetPrivateKey),
|
||||
samforwarder.SetClientLeaseSetPrivateSigningKey(config.LeaseSetPrivateSigningKey),
|
||||
samforwarder.SetClientAllowZeroIn(config.InAllowZeroHop),
|
||||
samforwarder.SetClientAllowZeroOut(config.OutAllowZeroHop),
|
||||
samforwarder.SetClientFastRecieve(config.FastRecieve),
|
||||
samforwarder.SetClientCompress(config.UseCompression),
|
||||
samforwarder.SetClientReduceIdle(config.ReduceIdle),
|
||||
samforwarder.SetClientReduceIdleTimeMs(config.ReduceIdleTime),
|
||||
samforwarder.SetClientReduceIdleQuantity(config.ReduceIdleQuantity),
|
||||
samforwarder.SetClientCloseIdle(config.CloseIdle),
|
||||
samforwarder.SetClientCloseIdleTimeMs(config.CloseIdleTime),
|
||||
samforwarder.SetClientAccessListType(config.AccessListType),
|
||||
samforwarder.SetClientAccessList(config.AccessList),
|
||||
samforwarder.SetClientMessageReliability(config.MessageReliability),
|
||||
samforwarder.SetClientPassword(config.KeyFilePath),
|
||||
samforwarder.SetClientDestination(config.ClientDest),
|
||||
)
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// NewSAMClientForwarderFromConfig generates a new SAMForwarder from a config file
|
||||
func NewSAMClientForwarderFromConfig(iniFile, SamHost, SamPort string, label ...string) (*samforwarder.SAMClientForwarder, 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 NewSAMClientForwarderFromConf(config)
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// NewSAMSSUClientForwarderFromConf generates a SAMSSUforwarder from *i2ptunconf.Conf
|
||||
func NewSAMSSUClientForwarderFromConf(config *Conf) (*samforwarderudp.SAMSSUClientForwarder, error) {
|
||||
if config != nil {
|
||||
return samforwarderudp.NewSAMSSUClientForwarderFromOptions(
|
||||
samforwarderudp.SetClientSaveFile(config.SaveFile),
|
||||
samforwarderudp.SetClientFilePath(config.SaveDirectory),
|
||||
samforwarderudp.SetClientHost(config.TargetHost),
|
||||
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),
|
||||
samforwarderudp.SetClientInVariance(config.InVariance),
|
||||
samforwarderudp.SetClientOutVariance(config.OutVariance),
|
||||
samforwarderudp.SetClientInQuantity(config.InQuantity),
|
||||
samforwarderudp.SetClientOutQuantity(config.OutQuantity),
|
||||
samforwarderudp.SetClientInBackups(config.InBackupQuantity),
|
||||
samforwarderudp.SetClientOutBackups(config.OutBackupQuantity),
|
||||
samforwarderudp.SetClientEncrypt(config.EncryptLeaseSet),
|
||||
samforwarderudp.SetClientLeaseSetKey(config.LeaseSetKey),
|
||||
samforwarderudp.SetClientLeaseSetPrivateKey(config.LeaseSetPrivateKey),
|
||||
samforwarderudp.SetClientLeaseSetPrivateSigningKey(config.LeaseSetPrivateSigningKey),
|
||||
samforwarderudp.SetClientAllowZeroIn(config.InAllowZeroHop),
|
||||
samforwarderudp.SetClientAllowZeroOut(config.OutAllowZeroHop),
|
||||
samforwarderudp.SetClientFastRecieve(config.FastRecieve),
|
||||
samforwarderudp.SetClientCompress(config.UseCompression),
|
||||
samforwarderudp.SetClientReduceIdle(config.ReduceIdle),
|
||||
samforwarderudp.SetClientReduceIdleTimeMs(config.ReduceIdleTime),
|
||||
samforwarderudp.SetClientReduceIdleQuantity(config.ReduceIdleQuantity),
|
||||
samforwarderudp.SetClientCloseIdle(config.CloseIdle),
|
||||
samforwarderudp.SetClientCloseIdleTimeMs(config.CloseIdleTime),
|
||||
samforwarderudp.SetClientAccessListType(config.AccessListType),
|
||||
samforwarderudp.SetClientAccessList(config.AccessList),
|
||||
samforwarderudp.SetClientMessageReliability(config.MessageReliability),
|
||||
samforwarderudp.SetClientPassword(config.KeyFilePath),
|
||||
samforwarderudp.SetClientDestination(config.ClientDest),
|
||||
)
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func NewSAMSSUClientForwarderFromConfig(iniFile, SamHost, SamPort string, label ...string) (*samforwarderudp.SAMSSUClientForwarder, 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 NewSAMSSUClientForwarderFromConf(config)
|
||||
}
|
||||
return nil, nil
|
||||
}
|
@ -1,128 +0,0 @@
|
||||
package i2ptunconf
|
||||
|
||||
import (
|
||||
"github.com/eyedeekay/sam-forwarder/tcp"
|
||||
"github.com/eyedeekay/sam-forwarder/udp"
|
||||
)
|
||||
|
||||
// NewSAMForwarderFromConf generates a SAMforwarder from *i2ptunconf.Conf
|
||||
func NewSAMForwarderFromConf(config *Conf) (*samforwarder.SAMForwarder, error) {
|
||||
if config != nil {
|
||||
return samforwarder.NewSAMForwarderFromOptions(
|
||||
samforwarder.SetType(config.Type),
|
||||
samforwarder.SetSaveFile(config.SaveFile),
|
||||
samforwarder.SetFilePath(config.SaveDirectory),
|
||||
samforwarder.SetHost(config.TargetHost),
|
||||
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),
|
||||
samforwarder.SetInVariance(config.InVariance),
|
||||
samforwarder.SetOutVariance(config.OutVariance),
|
||||
samforwarder.SetInQuantity(config.InQuantity),
|
||||
samforwarder.SetOutQuantity(config.OutQuantity),
|
||||
samforwarder.SetInBackups(config.InBackupQuantity),
|
||||
samforwarder.SetOutBackups(config.OutBackupQuantity),
|
||||
samforwarder.SetEncrypt(config.EncryptLeaseSet),
|
||||
samforwarder.SetLeaseSetKey(config.LeaseSetKey),
|
||||
samforwarder.SetLeaseSetPrivateKey(config.LeaseSetPrivateKey),
|
||||
samforwarder.SetLeaseSetPrivateSigningKey(config.LeaseSetPrivateSigningKey),
|
||||
samforwarder.SetAllowZeroIn(config.InAllowZeroHop),
|
||||
samforwarder.SetAllowZeroOut(config.OutAllowZeroHop),
|
||||
samforwarder.SetFastRecieve(config.FastRecieve),
|
||||
samforwarder.SetCompress(config.UseCompression),
|
||||
samforwarder.SetReduceIdle(config.ReduceIdle),
|
||||
samforwarder.SetReduceIdleTimeMs(config.ReduceIdleTime),
|
||||
samforwarder.SetReduceIdleQuantity(config.ReduceIdleQuantity),
|
||||
samforwarder.SetCloseIdle(config.CloseIdle),
|
||||
samforwarder.SetCloseIdleTimeMs(config.CloseIdleTime),
|
||||
samforwarder.SetAccessListType(config.AccessListType),
|
||||
samforwarder.SetAccessList(config.AccessList),
|
||||
samforwarder.SetMessageReliability(config.MessageReliability),
|
||||
samforwarder.SetKeyFile(config.KeyFilePath),
|
||||
//samforwarder.SetTargetForPort443(config.TargetForPort443),
|
||||
)
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// NewSAMForwarderFromConfig generates a new SAMForwarder from a config file
|
||||
func NewSAMForwarderFromConfig(iniFile, SamHost, SamPort string, label ...string) (*samforwarder.SAMForwarder, 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 NewSAMForwarderFromConf(config)
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// NewSAMSSUForwarderFromConf generates a SAMSSUforwarder from *i2ptunconf.Conf
|
||||
func NewSAMSSUForwarderFromConf(config *Conf) (*samforwarderudp.SAMSSUForwarder, error) {
|
||||
if config != nil {
|
||||
return samforwarderudp.NewSAMSSUForwarderFromOptions(
|
||||
samforwarderudp.SetSaveFile(config.SaveFile),
|
||||
samforwarderudp.SetFilePath(config.SaveDirectory),
|
||||
samforwarderudp.SetHost(config.TargetHost),
|
||||
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),
|
||||
samforwarderudp.SetInVariance(config.InVariance),
|
||||
samforwarderudp.SetOutVariance(config.OutVariance),
|
||||
samforwarderudp.SetInQuantity(config.InQuantity),
|
||||
samforwarderudp.SetOutQuantity(config.OutQuantity),
|
||||
samforwarderudp.SetInBackups(config.InBackupQuantity),
|
||||
samforwarderudp.SetOutBackups(config.OutBackupQuantity),
|
||||
samforwarderudp.SetEncrypt(config.EncryptLeaseSet),
|
||||
samforwarderudp.SetLeaseSetKey(config.LeaseSetKey),
|
||||
samforwarderudp.SetLeaseSetPrivateKey(config.LeaseSetPrivateKey),
|
||||
samforwarderudp.SetLeaseSetPrivateSigningKey(config.LeaseSetPrivateSigningKey),
|
||||
samforwarderudp.SetAllowZeroIn(config.InAllowZeroHop),
|
||||
samforwarderudp.SetAllowZeroOut(config.OutAllowZeroHop),
|
||||
samforwarderudp.SetFastRecieve(config.FastRecieve),
|
||||
samforwarderudp.SetCompress(config.UseCompression),
|
||||
samforwarderudp.SetReduceIdle(config.ReduceIdle),
|
||||
samforwarderudp.SetReduceIdleTimeMs(config.ReduceIdleTime),
|
||||
samforwarderudp.SetReduceIdleQuantity(config.ReduceIdleQuantity),
|
||||
samforwarderudp.SetCloseIdle(config.CloseIdle),
|
||||
samforwarderudp.SetCloseIdleTimeMs(config.CloseIdleTime),
|
||||
samforwarderudp.SetAccessListType(config.AccessListType),
|
||||
samforwarderudp.SetAccessList(config.AccessList),
|
||||
samforwarderudp.SetMessageReliability(config.MessageReliability),
|
||||
samforwarderudp.SetKeyFile(config.KeyFilePath),
|
||||
)
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// NewSAMSSUForwarderFromConfig generates a new SAMSSUForwarder from a config file
|
||||
func NewSAMSSUForwarderFromConfig(iniFile, SamHost, SamPort string, label ...string) (*samforwarderudp.SAMSSUForwarder, 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 NewSAMSSUForwarderFromConf(config)
|
||||
}
|
||||
return nil, nil
|
||||
}
|
@ -4,7 +4,7 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
import "github.com/eyedeekay/sam-forwarder/interface"
|
||||
|
||||
|
||||
// GetType takes an argument and a default. If the argument differs from the
|
||||
// default, the argument is always returned. If the argument and default are
|
||||
@ -96,35 +96,3 @@ func (c *Conf) SetType(label ...string) {
|
||||
}
|
||||
}
|
||||
|
||||
//SetType sets the type of the forwarder server
|
||||
func SetType(s string) func(samtunnel.SAMTunnel) error {
|
||||
return func(c samtunnel.SAMTunnel) error {
|
||||
switch c.(*Conf).Type {
|
||||
case "server":
|
||||
c.(*Conf).Type = s
|
||||
case "http":
|
||||
c.(*Conf).Type = s
|
||||
case "client":
|
||||
c.(*Conf).Type = s
|
||||
case "httpclient":
|
||||
c.(*Conf).Type = s
|
||||
case "browserclient":
|
||||
c.(*Conf).Type = s
|
||||
case "udpserver":
|
||||
c.(*Conf).Type = s
|
||||
case "udpclient":
|
||||
c.(*Conf).Type = s
|
||||
case "vpnserver":
|
||||
c.(*Conf).Type = s
|
||||
case "vpnclient":
|
||||
c.(*Conf).Type = s
|
||||
case "kcpclient":
|
||||
c.(*Conf).Type = s
|
||||
case "kcpserver":
|
||||
c.(*Conf).Type = s
|
||||
default:
|
||||
c.(*Conf).Type = "browserclient"
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package i2ptunconf
|
||||
|
||||
import "github.com/eyedeekay/sam-forwarder/interface"
|
||||
|
||||
|
||||
// GetUserName takes an argument and a default. If the argument differs from the
|
||||
// default, the argument is always returned. If the argument and default are
|
||||
@ -27,11 +27,3 @@ func (c *Conf) SetUserName(label ...string) {
|
||||
c.UserName = "samcatd"
|
||||
}
|
||||
}
|
||||
|
||||
//SetUserName sets the host of the Conf's SAM bridge
|
||||
func SetUserName(s string) func(samtunnel.SAMTunnel) error {
|
||||
return func(c samtunnel.SAMTunnel) error {
|
||||
c.(*Conf).UserName = s
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,5 @@
|
||||
package i2ptunconf
|
||||
|
||||
import "fmt"
|
||||
|
||||
import "github.com/eyedeekay/sam-forwarder/interface"
|
||||
|
||||
// GetInVariance takes an argument and a default. If the argument differs from the
|
||||
// default, the argument is always returned. If the argument and default are
|
||||
// the same and the key exists, the key is returned. If the key is absent, the
|
||||
@ -55,25 +51,3 @@ func (c *Conf) SetOutVariance(label ...string) {
|
||||
c.OutVariance = 0
|
||||
}
|
||||
}
|
||||
|
||||
//SetInVariance sets the variance of a number of hops inbound
|
||||
func SetInVariance(i int) func(samtunnel.SAMTunnel) error {
|
||||
return func(c samtunnel.SAMTunnel) error {
|
||||
if i < 7 && i > -7 {
|
||||
c.(*Conf).InVariance = i //strconv.Itoa(i)
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Invalid inbound tunnel length")
|
||||
}
|
||||
}
|
||||
|
||||
//SetOutVariance sets the variance of a number of hops outbound
|
||||
func SetOutVariance(i int) func(samtunnel.SAMTunnel) error {
|
||||
return func(c samtunnel.SAMTunnel) error {
|
||||
if i < 7 && i > -7 {
|
||||
c.(*Conf).OutVariance = i //strconv.Itoa(i)
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Invalid outbound tunnel variance")
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package i2ptunconf
|
||||
|
||||
import "github.com/eyedeekay/sam-forwarder/interface"
|
||||
|
||||
|
||||
// GetInAllowZeroHop takes an argument and a default. If the argument differs from the
|
||||
// default, the argument is always returned. If the argument and default are
|
||||
@ -53,19 +53,3 @@ func (c *Conf) SetAllowZeroHopOut(label ...string) {
|
||||
c.OutAllowZeroHop = false
|
||||
}
|
||||
}
|
||||
|
||||
//SetAllowZeroIn tells the tunnel to accept zero-hop peers
|
||||
func SetAllowZeroIn(b bool) func(samtunnel.SAMTunnel) error {
|
||||
return func(c samtunnel.SAMTunnel) error {
|
||||
c.(*Conf).InAllowZeroHop = b // "false"
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
//SetAllowZeroOut tells the tunnel to accept zero-hop peers
|
||||
func SetAllowZeroOut(b bool) func(samtunnel.SAMTunnel) error {
|
||||
return func(c samtunnel.SAMTunnel) error {
|
||||
c.(*Conf).OutAllowZeroHop = b // "false"
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
@ -2,9 +2,11 @@ package samtunnel
|
||||
|
||||
import (
|
||||
"github.com/eyedeekay/sam3/i2pkeys"
|
||||
"github.com/eyedeekay/sam-forwarder/config"
|
||||
)
|
||||
|
||||
type SAMTunnel interface {
|
||||
Config() *i2ptunconf.Conf
|
||||
// Tunnel Options
|
||||
GetType() string // Get the type of the tunnel in use(server, client, http, udp, etc)
|
||||
Print() string // Print all the tunnel options as a string
|
||||
|
@ -12,6 +12,7 @@ import (
|
||||
import (
|
||||
"github.com/eyedeekay/portcheck"
|
||||
"github.com/eyedeekay/sam-forwarder/config"
|
||||
"github.com/eyedeekay/sam-forwarder/config/helpers"
|
||||
"github.com/eyedeekay/sam-forwarder/handler"
|
||||
"github.com/justinas/nosurf"
|
||||
)
|
||||
@ -135,42 +136,42 @@ func NewSAMManagerFromOptions(opts ...func(*SAMManager) error) (*SAMManager, err
|
||||
if t, e := s.config.Get("type", label); e {
|
||||
switch t {
|
||||
case "http":
|
||||
if f, e := samtunnelhandler.NewTunnelHandler(i2ptunconf.NewSAMForwarderFromConfig(s.FilePath, s.SamHost, s.SamPort, label)); e == nil {
|
||||
if f, e := samtunnelhandler.NewTunnelHandler(i2ptunnelhelper.NewSAMForwarderFromConfig(s.FilePath, s.SamHost, s.SamPort, label)); e == nil {
|
||||
log.Println("found http under", label)
|
||||
s.handlerMux = s.handlerMux.Append(f)
|
||||
} else {
|
||||
return nil, e
|
||||
}
|
||||
case "httpclient":
|
||||
if f, e := samtunnelhandler.NewTunnelHandler(i2ptunconf.NewSAMHTTPClientFromConfig(s.FilePath, s.SamHost, s.SamPort, label)); e == nil {
|
||||
if f, e := samtunnelhandler.NewTunnelHandler(i2ptunnelhelper.NewSAMHTTPClientFromConfig(s.FilePath, s.SamHost, s.SamPort, label)); e == nil {
|
||||
log.Println("found http under", label)
|
||||
s.handlerMux = s.handlerMux.Append(f)
|
||||
} else {
|
||||
return nil, e
|
||||
}
|
||||
case "server":
|
||||
if f, e := samtunnelhandler.NewTunnelHandler(i2ptunconf.NewSAMForwarderFromConfig(s.FilePath, s.SamHost, s.SamPort, label)); e == nil {
|
||||
if f, e := samtunnelhandler.NewTunnelHandler(i2ptunnelhelper.NewSAMForwarderFromConfig(s.FilePath, s.SamHost, s.SamPort, label)); e == nil {
|
||||
log.Println("found server under", label)
|
||||
s.handlerMux = s.handlerMux.Append(f)
|
||||
} else {
|
||||
return nil, e
|
||||
}
|
||||
case "client":
|
||||
if f, e := samtunnelhandler.NewTunnelHandler(i2ptunconf.NewSAMClientForwarderFromConfig(s.FilePath, s.SamHost, s.SamPort, label)); e == nil {
|
||||
if f, e := samtunnelhandler.NewTunnelHandler(i2ptunnelhelper.NewSAMClientForwarderFromConfig(s.FilePath, s.SamHost, s.SamPort, label)); e == nil {
|
||||
log.Println("found client under", label)
|
||||
s.handlerMux = s.handlerMux.Append(f)
|
||||
} else {
|
||||
return nil, e
|
||||
}
|
||||
case "udpserver":
|
||||
if f, e := samtunnelhandler.NewTunnelHandler(i2ptunconf.NewSAMSSUForwarderFromConfig(s.FilePath, s.SamHost, s.SamPort, label)); e == nil {
|
||||
if f, e := samtunnelhandler.NewTunnelHandler(i2ptunnelhelper.NewSAMSSUForwarderFromConfig(s.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(i2ptunconf.NewSAMSSUClientForwarderFromConfig(s.FilePath, s.SamHost, s.SamPort, label)); e == nil {
|
||||
if f, e := samtunnelhandler.NewTunnelHandler(i2ptunnelhelper.NewSAMSSUClientForwarderFromConfig(s.FilePath, s.SamHost, s.SamPort, label)); e == nil {
|
||||
log.Println("found udpclient under", label)
|
||||
s.handlerMux = s.handlerMux.Append(f)
|
||||
} else {
|
||||
@ -191,7 +192,7 @@ func NewSAMManagerFromOptions(opts ...func(*SAMManager) error) (*SAMManager, err
|
||||
return nil, e
|
||||
}*/
|
||||
default:
|
||||
if f, e := samtunnelhandler.NewTunnelHandler(i2ptunconf.NewSAMForwarderFromConfig(s.FilePath, s.SamHost, s.SamPort, label)); e == nil {
|
||||
if f, e := samtunnelhandler.NewTunnelHandler(i2ptunnelhelper.NewSAMForwarderFromConfig(s.FilePath, s.SamHost, s.SamPort, label)); e == nil {
|
||||
log.Println("found server under", label)
|
||||
s.handlerMux = s.handlerMux.Append(f)
|
||||
} else {
|
||||
@ -208,49 +209,49 @@ func NewSAMManagerFromOptions(opts ...func(*SAMManager) error) (*SAMManager, err
|
||||
}
|
||||
switch t {
|
||||
case "http":
|
||||
if f, e := samtunnelhandler.NewTunnelHandler(i2ptunconf.NewSAMForwarderFromConf(s.config)); e == nil {
|
||||
if f, e := samtunnelhandler.NewTunnelHandler(i2ptunnelhelper.NewSAMForwarderFromConf(s.config)); e == nil {
|
||||
log.Println("found default http")
|
||||
s.handlerMux = s.handlerMux.Append(f)
|
||||
} else {
|
||||
return nil, e
|
||||
}
|
||||
case "httpclient":
|
||||
if f, e := samtunnelhandler.NewTunnelHandler(i2ptunconf.NewSAMHTTPClientFromConf(s.config)); e == nil {
|
||||
if f, e := samtunnelhandler.NewTunnelHandler(i2ptunnelhelper.NewSAMHTTPClientFromConf(s.config)); e == nil {
|
||||
log.Println("found default httpclient")
|
||||
s.handlerMux = s.handlerMux.Append(f)
|
||||
} else {
|
||||
return nil, e
|
||||
}
|
||||
case "browserclient":
|
||||
if f, e := samtunnelhandler.NewTunnelHandler(i2ptunconf.NewSAMBrowserClientFromConf(s.config)); e == nil {
|
||||
if f, e := samtunnelhandler.NewTunnelHandler(i2ptunnelhelper.NewSAMBrowserClientFromConf(s.config)); e == nil {
|
||||
log.Println("found default browserclient")
|
||||
s.handlerMux = s.handlerMux.Append(f)
|
||||
} else {
|
||||
return nil, e
|
||||
}
|
||||
case "server":
|
||||
if f, e := samtunnelhandler.NewTunnelHandler(i2ptunconf.NewSAMForwarderFromConf(s.config)); e == nil {
|
||||
if f, e := samtunnelhandler.NewTunnelHandler(i2ptunnelhelper.NewSAMForwarderFromConf(s.config)); e == nil {
|
||||
log.Println("found default server")
|
||||
s.handlerMux = s.handlerMux.Append(f)
|
||||
} else {
|
||||
return nil, e
|
||||
}
|
||||
case "client":
|
||||
if f, e := samtunnelhandler.NewTunnelHandler(i2ptunconf.NewSAMClientForwarderFromConf(s.config)); e == nil {
|
||||
if f, e := samtunnelhandler.NewTunnelHandler(i2ptunnelhelper.NewSAMClientForwarderFromConf(s.config)); e == nil {
|
||||
log.Println("found default client")
|
||||
s.handlerMux = s.handlerMux.Append(f)
|
||||
} else {
|
||||
return nil, e
|
||||
}
|
||||
case "udpserver":
|
||||
if f, e := samtunnelhandler.NewTunnelHandler(i2ptunconf.NewSAMSSUForwarderFromConf(s.config)); e == nil {
|
||||
if f, e := samtunnelhandler.NewTunnelHandler(i2ptunnelhelper.NewSAMSSUForwarderFromConf(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(i2ptunconf.NewSAMSSUClientForwarderFromConf(s.config)); e == nil {
|
||||
if f, e := samtunnelhandler.NewTunnelHandler(i2ptunnelhelper.NewSAMSSUClientForwarderFromConf(s.config)); e == nil {
|
||||
log.Println("found default udpclient")
|
||||
s.handlerMux = s.handlerMux.Append(f)
|
||||
} else {
|
||||
@ -271,7 +272,7 @@ func NewSAMManagerFromOptions(opts ...func(*SAMManager) error) (*SAMManager, err
|
||||
return nil, e
|
||||
}*/
|
||||
default:
|
||||
if f, e := samtunnelhandler.NewTunnelHandler(i2ptunconf.NewSAMClientForwarderFromConf(s.config)); e == nil {
|
||||
if f, e := samtunnelhandler.NewTunnelHandler(i2ptunnelhelper.NewSAMClientForwarderFromConf(s.config)); e == nil {
|
||||
log.Println("found default client")
|
||||
s.handlerMux = s.handlerMux.Append(f)
|
||||
} else {
|
||||
|
@ -16,6 +16,7 @@ import (
|
||||
"github.com/eyedeekay/sam-forwarder/interface"
|
||||
"github.com/eyedeekay/sam3"
|
||||
"github.com/eyedeekay/sam3/i2pkeys"
|
||||
"github.com/eyedeekay/sam-forwarder/config"
|
||||
)
|
||||
|
||||
// SAMClientForwarder is a tcp proxy that automatically forwards ports to i2p
|
||||
@ -41,6 +42,9 @@ type SAMClientForwarder struct {
|
||||
save bool
|
||||
up bool
|
||||
|
||||
// config
|
||||
Conf *i2ptunconf.Conf
|
||||
|
||||
// samcatd options
|
||||
passfile string
|
||||
sigType string
|
||||
@ -75,6 +79,10 @@ type SAMClientForwarder struct {
|
||||
accessList []string
|
||||
}
|
||||
|
||||
func (f *SAMClientForwarder) Config() *i2ptunconf.Conf {
|
||||
return f.Conf
|
||||
}
|
||||
|
||||
func (f *SAMClientForwarder) GetType() string {
|
||||
return f.Type
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ import (
|
||||
"github.com/eyedeekay/sam-forwarder/hashhash"
|
||||
"github.com/eyedeekay/sam-forwarder/i2pkeys"
|
||||
"github.com/eyedeekay/sam-forwarder/interface"
|
||||
"github.com/eyedeekay/sam-forwarder/config"
|
||||
"github.com/eyedeekay/sam3"
|
||||
"github.com/eyedeekay/sam3/i2pkeys"
|
||||
)
|
||||
@ -42,6 +43,9 @@ type SAMForwarder struct {
|
||||
save bool
|
||||
up bool
|
||||
|
||||
// conf
|
||||
Conf *i2ptunconf.Conf
|
||||
|
||||
Type string
|
||||
|
||||
// samcatd options
|
||||
@ -86,6 +90,10 @@ type SAMForwarder struct {
|
||||
|
||||
var err error
|
||||
|
||||
func (f *SAMForwarder) Config() *i2ptunconf.Conf {
|
||||
return f.Conf
|
||||
}
|
||||
|
||||
func (f *SAMForwarder) ID() string {
|
||||
return f.TunName
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ import (
|
||||
"github.com/eyedeekay/sam-forwarder/interface"
|
||||
"github.com/eyedeekay/sam3"
|
||||
"github.com/eyedeekay/sam3/i2pkeys"
|
||||
"github.com/eyedeekay/sam-forwarder/config"
|
||||
)
|
||||
|
||||
//SAMSSUClientForwarder is a structure which automatically configured the forwarding of
|
||||
@ -43,6 +44,9 @@ type SAMSSUClientForwarder struct {
|
||||
save bool
|
||||
up bool
|
||||
|
||||
// config
|
||||
Conf *i2ptunconf.Conf
|
||||
|
||||
// samcatd options
|
||||
passfile string
|
||||
sigType string
|
||||
@ -76,6 +80,10 @@ type SAMSSUClientForwarder struct {
|
||||
accessList []string
|
||||
}
|
||||
|
||||
func (f *SAMSSUClientForwarder) Config() *i2ptunconf.Conf {
|
||||
return f.Conf
|
||||
}
|
||||
|
||||
func (f *SAMSSUClientForwarder) GetType() string {
|
||||
return f.Type
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ import (
|
||||
"github.com/eyedeekay/sam-forwarder/interface"
|
||||
"github.com/eyedeekay/sam3"
|
||||
"github.com/eyedeekay/sam3/i2pkeys"
|
||||
"github.com/eyedeekay/sam-forwarder/config"
|
||||
)
|
||||
|
||||
//SAMSSUForwarder is a structure which automatically configured the forwarding of
|
||||
@ -41,6 +42,9 @@ type SAMSSUForwarder struct {
|
||||
save bool
|
||||
up bool
|
||||
|
||||
// config
|
||||
Conf *i2ptunconf.Conf
|
||||
|
||||
// samcatd options
|
||||
passfile string
|
||||
sigType string
|
||||
@ -76,6 +80,10 @@ type SAMSSUForwarder struct {
|
||||
|
||||
var err error
|
||||
|
||||
func (f *SAMSSUForwarder) Config() *i2ptunconf.Conf {
|
||||
return f.Conf
|
||||
}
|
||||
|
||||
func (f *SAMSSUForwarder) GetType() string {
|
||||
return f.Type
|
||||
}
|
||||
|
Reference in New Issue
Block a user