5 Commits

Author SHA1 Message Date
idk
c427d576cb more prep to reduce the amount of repeated configuration code 2019-08-31 00:13:20 -04:00
idk
383fafea25 more prep to reduce the amount of repeated configuration code 2019-08-31 00:13:10 -04:00
idk
9254afc776 move config stuff around 2019-08-25 20:32:50 -04:00
idk
29c48f906c begin config cleanup 2019-08-25 19:21:11 -04:00
idk
38a4e1b3ad begin config cleanup 2019-08-25 19:20:54 -04:00
180 changed files with 39062 additions and 23 deletions

View File

@@ -7,6 +7,7 @@ network = host
samhost = sam-host
samport = 7656
args = -r
USER_GH=eyedeekay
PREFIX := /
VAR := var/
@@ -16,7 +17,7 @@ LOG := log/
ETC := etc/
USR := usr/
LOCAL := local/
VERSION := 0.1
VERSION := 0.32.01
GO111MODULE=on
@@ -222,3 +223,10 @@ tar:
--exclude .go \
--exclude bin \
-cJvf ../$(packagename)_$(VERSION).orig.tar.xz .
tag:
gothub release -s $(GITHUB_TOKEN) -u $(USER_GH) -r $(packagename) -t v$(VERSION) -d "I2P Tunnel Management tool for Go applications"
sed:
sed -i 's|func(\*Conf)|func(samtunnel.SAMTunnel)|g' ./config/*.go
sed -i 's|func(c \*Conf)|func(c samtunnel.SAMTunnel)|g' ./config/*.go

View File

@@ -1,6 +1,11 @@
package i2ptunconf
import "strings"
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
@@ -64,3 +69,36 @@ 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
}
}

View File

@@ -1,5 +1,8 @@
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
@@ -51,3 +54,25 @@ 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")
}
}

View File

@@ -1,5 +1,7 @@
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
// the same and the key exists, the key is returned. If the key is absent, the
@@ -25,3 +27,15 @@ 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
}
}

237
config/conf.go Normal file
View File

@@ -0,0 +1,237 @@
package i2ptunconf
import (
"fmt"
"strings"
)
import (
"github.com/eyedeekay/sam-forwarder/i2pkeys"
"github.com/eyedeekay/sam-forwarder/interface"
"github.com/eyedeekay/sam3/i2pkeys"
)
var err error
func (f *Conf) ID() string {
return f.TunName
}
func (f *Conf) Keys() i2pkeys.I2PKeys {
return f.LoadedKeys
}
func (f *Conf) Cleanup() {
}
func (f *Conf) GetType() string {
return f.Type
}
/*func (f *Conf) targetForPort443() string {
if f.TargetForPort443 != "" {
return "targetForPort.4443=" + f.TargetHost + ":" + f.TargetForPort443
}
return ""
}*/
func (f *Conf) print() []string {
lsk, lspk, lspsk := f.leasesetsettings()
return []string{
//f.targetForPort443(),
"inbound.length=" + fmt.Sprintf("%d", f.InLength),
"outbound.length=" + fmt.Sprintf("%d", f.OutLength),
"inbound.lengthVariance=" + fmt.Sprintf("%d", f.InVariance),
"outbound.lengthVariance=" + fmt.Sprintf("%d", f.OutVariance),
"inbound.backupQuantity=" + fmt.Sprintf("%d", f.InBackupQuantity),
"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),
"i2cp.reduceIdleTime=" + fmt.Sprintf("%d", f.ReduceIdleTime),
"i2cp.reduceQuantity=" + fmt.Sprintf("%d", f.ReduceIdleQuantity),
"i2cp.closeOnIdle=" + fmt.Sprintf("%b", f.CloseIdle),
"i2cp.closeIdleTime=" + fmt.Sprintf("%d", f.CloseIdleTime),
"i2cp.messageReliability=" + f.MessageReliability,
"i2cp.encryptLeaseSet=" + fmt.Sprintf("%b", f.EncryptLeaseSet),
lsk, lspk, lspsk,
f.accesslisttype(),
f.accesslist(),
}
}
func (f *Conf) Props() map[string]string {
r := make(map[string]string)
print := f.print()
print = append(print, "base32="+f.Base32())
print = append(print, "base64="+f.Base64())
print = append(print, "base32words="+f.Base32Readable())
for _, prop := range print {
k, v := sfi2pkeys.Prop(prop)
r[k] = v
}
return r
}
func (f *Conf) Print() string {
var r string
r += "name=" + f.TunName + "\n"
r += "type=" + f.Type + "\n"
if f.Type == "http" {
r += "httpserver\n"
} else {
r += "ntcpserver\n"
}
for _, s := range f.print() {
r += s + "\n"
}
return strings.Replace(r, "\n\n", "\n", -1)
}
func (f *Conf) Search(search string) string {
terms := strings.Split(search, ",")
if search == "" {
return f.Print()
}
for _, value := range terms {
if !strings.Contains(f.Print(), value) {
return ""
}
}
return f.Print()
}
/*
func (f *Conf) accesslisttype() string {
if f.accessListType == "whitelist" {
return "i2cp.enableAccessList=true"
} else if f.accessListType == "blacklist" {
return "i2cp.enableBlackList=true"
} else if f.accessListType == "none" {
return ""
}
return ""
}
func (f *Conf) accesslist() string {
if f.accessListType != "" && len(f.accessList) > 0 {
r := ""
for _, s := range f.accessList {
r += s + ","
}
return "i2cp.accessList=" + strings.TrimSuffix(r, ",")
}
return ""
}
*/
func (f *Conf) leasesetsettings() (string, string, string) {
var r, s, t string
if f.LeaseSetKey != "" {
r = "i2cp.leaseSetKey=" + f.LeaseSetKey
}
if f.LeaseSetPrivateKey != "" {
s = "i2cp.leaseSetPrivateKey=" + f.LeaseSetPrivateKey
}
if f.LeaseSetPrivateSigningKey != "" {
t = "i2cp.leaseSetPrivateSigningKey=" + f.LeaseSetPrivateSigningKey
}
return r, s, t
}
// Target returns the host:port of the local service you want to forward to i2p
func (f *Conf) Target() string {
return f.TargetHost + ":" + f.TargetPort
}
func (f *Conf) sam() string {
return f.SamHost + ":" + f.SamPort
}
//Base32 returns the base32 address where the local service is being forwarded
func (f *Conf) Base32() string {
return f.LoadedKeys.Addr().Base32()
}
//Base32Readable will always be an empty string when used here.
func (f *Conf) Base32Readable() string {
return ""
}
//Base64 returns the base64 address where the local service is being forwarded
func (f *Conf) Base64() string {
return f.LoadedKeys.Addr().Base64()
}
//Serve starts the SAM connection and and forwards the local host:port to i2p
func (f *Conf) Serve() error {
return nil
}
func (f *Conf) Up() bool {
return false
}
//Close shuts the whole thing down.
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
}

30
config/config-options.go Normal file
View File

@@ -0,0 +1,30 @@
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
}
}
//SetTargetForPort sets the port of the Conf's SAM bridge using a string
/*func SetTargetForPort443(s string) func(samtunnel.SAMTunnel) error {
return func(c samtunnel.SAMTunnel) error {
port, err := strconv.Atoi(s)
if err != nil {
return fmt.Errorf("Invalid Target Port %s; non-number ", s)
}
if port < 65536 && port > -1 {
c.TargetForPort443 = s
return nil
}
return fmt.Errorf("Invalid port")
}
}
*/

View File

@@ -1,5 +1,12 @@
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
// the same and the key exists, the key is returned. If the key is absent, the
@@ -51,3 +58,26 @@ 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")
}
}

View File

@@ -1,5 +1,7 @@
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
// the same and the key exists, the key is returned. If the key is absent, the
@@ -25,3 +27,11 @@ 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
}
}

View File

@@ -1,5 +1,7 @@
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
// the same and the key exists, the key is returned. If the key is absent, the
@@ -25,3 +27,11 @@ 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
}
}

View File

@@ -1,5 +1,7 @@
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
// the same and the key exists, the key is returned. If the key is absent, the

View File

@@ -1,5 +1,7 @@
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
// the same and the key exists, the key is returned. If the key is absent, the
@@ -25,3 +27,11 @@ 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
}
}

View File

@@ -1,5 +1,7 @@
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
// the same and the key exists, the key is returned. If the key is absent, the
@@ -25,3 +27,11 @@ 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
}
}

View File

@@ -1,5 +1,12 @@
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
// the same and the key exists, the key is returned. If the key is absent, the
@@ -51,3 +58,26 @@ 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")
}
}

View File

@@ -1,5 +1,7 @@
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
// the same and the key exists, the key is returned. If the key is absent, the
@@ -103,3 +105,39 @@ 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
}
}

View File

@@ -1,5 +1,8 @@
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
// the same and the key exists, the key is returned. If the key is absent, the
@@ -51,3 +54,25 @@ 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")
}
}

View File

@@ -1,5 +1,7 @@
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
// the same and the key exists, the key is returned. If the key is absent, the
@@ -47,6 +49,22 @@ func (c *Conf) SetTunName(label ...string) {
if v, ok := c.Get("keys", label...); ok {
c.TunName = v
} else {
c.TunName = "fowarder"
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
}
}

View File

@@ -1,5 +1,7 @@
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
// the same and the key exists, the key is returned. If the key is absent, the
@@ -25,3 +27,11 @@ 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
}
}

View File

@@ -1,5 +1,9 @@
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
@@ -51,3 +55,25 @@ 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")
}
}

View File

@@ -1,5 +1,11 @@
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
// the same and the key exists, the key is returned. If the key is absent, the
@@ -129,3 +135,78 @@ 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)
}
}

View File

@@ -1,5 +1,7 @@
package i2ptunconf
import "github.com/eyedeekay/sam-forwarder/interface"
//i2cp.messageReliability
// GetMessageReliability takes an argument and a default. If the argument differs from the
// default, the argument is always returned. If the argument and default are
@@ -31,3 +33,11 @@ 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
}
}

View File

@@ -1,5 +1,12 @@
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
@@ -51,3 +58,26 @@ 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")
}
}

View File

@@ -1,5 +1,7 @@
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
// the same and the key exists, the key is returned. If the key is absent, the
@@ -43,3 +45,24 @@ 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
}
}

View File

@@ -10,6 +10,7 @@ import (
)
import (
"github.com/eyedeekay/sam3/i2pkeys"
"github.com/zieckey/goini"
)
@@ -62,10 +63,11 @@ type Conf struct {
exists bool
UserName string
Password string
LoadedKeys i2pkeys.I2PKeys
}
// Print returns and prints a formatted list of configured tunnel settings.
func (c *Conf) Print() []string {
// PrintSlice returns and prints a formatted list of configured tunnel settings.
func (c *Conf) PrintSlice() []string {
confstring := []string{
c.SignatureType(),
"inbound.length=" + strconv.Itoa(c.InLength),

View File

@@ -4,11 +4,13 @@ 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
// the same and the key exists, the key is returned. If the key is absent, the
// default is returned.
func (c *Conf) GetType(argc, argu, argh bool, def string, label ...string) string {
func (c *Conf) GetTypes(argc, argu, argh bool, def string, label ...string) string {
var typ string
if argu {
typ += "udp"
@@ -63,10 +65,66 @@ func (c *Conf) SetType(label ...string) {
if strings.Contains(v, "client") {
c.Client = true
}
if c.Type == "server" || c.Type == "http" || c.Type == "client" || c.Type == "httpclient" || c.Type == "udpserver" || c.Type == "udpclient" || c.Type == "kcpclient" || c.Type == "kcpserver" {
switch c.Type {
case "server":
c.Type = v
case "http":
c.Type = v
case "client":
c.Type = v
case "httpclient":
c.Type = v
case "browserclient":
c.Type = v
case "udpserver":
c.Type = v
case "udpclient":
c.Type = v
case "vpnserver":
c.Type = v
case "vpnclient":
c.Type = v
case "kcpclient":
c.Type = v
case "kcpserver":
c.Type = v
default:
c.Type = "browserclient"
}
} else {
c.Type = "server"
c.Type = "browserclient"
}
}
//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
}
}

View File

@@ -1,5 +1,7 @@
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
// the same and the key exists, the key is returned. If the key is absent, the
@@ -25,3 +27,11 @@ 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
}
}

View File

@@ -1,5 +1,9 @@
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
@@ -51,3 +55,25 @@ 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")
}
}

View File

@@ -1,5 +1,7 @@
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
// the same and the key exists, the key is returned. If the key is absent, the
@@ -51,3 +53,19 @@ 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
}
}

View File

@@ -0,0 +1,27 @@
// Copyright 2015 The Chromium Authors. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@@ -0,0 +1 @@
[{"description":"treehash per file","signed_content":{"payload":"eyJjb250ZW50X2hhc2hlcyI6W3siYmxvY2tfc2l6ZSI6NDA5NiwiZGlnZXN0Ijoic2hhMjU2IiwiZmlsZXMiOlt7InBhdGgiOiJMSUNFTlNFIiwicm9vdF9oYXNoIjoiUGIwc2tBVUxaUzFqWldTQnctV0hIRkltRlhVcExiZDlUcVkwR2ZHSHBWcyJ9LHsicGF0aCI6ImNybC1zZXQiLCJyb290X2hhc2giOiJxZVQyMjMyaGhpQmdVellVbDg5NV9zYkJXbnFVeGR1Y2prX3dvVzAtWHdnIn0seyJwYXRoIjoibWFuaWZlc3QuanNvbiIsInJvb3RfaGFzaCI6IjRmLUdfbmRDY3p3Y3pMVWo4Y1lNODVsTnpKZ0R4VzZnNk10TXdfU0Jvb0kifV0sImZvcm1hdCI6InRyZWVoYXNoIiwiaGFzaF9ibG9ja19zaXplIjo0MDk2fV0sIml0ZW1faWQiOiJoZm5rcGltbGhoZ2llYWRkZ2ZlbWpob2ZtZmJsbW5pYiIsIml0ZW1fdmVyc2lvbiI6IjUzNDUiLCJwcm90b2NvbF92ZXJzaW9uIjoxfQ","signatures":[{"header":{"kid":"publisher"},"protected":"eyJhbGciOiJSUzI1NiJ9","signature":"DkCqhqZtm5nn1tYnzpbcothSNvmVdpOJaZW4m3Dhe188iM1tD2OkNtGJrPa6kbAZ3csxiEnv6tyGmF9CUeFskfQunyRLxHhXw3yWXR1e89qcZJMNZisopmrGjlHwXwCmuM7RRo5Qcjb2yIuTnAPg3gWBAcuoUsMoFVkGFxF77FpBnexNkh74V6-mQ-PwmhF1snqCI_mUUXlt9CDgVtCpIeHYgfGyqYIXRS-joe6D8z9OiWa9UsD2gxZPtxPjP4-6Hqs6RR1rUD7JkHKUoqdPbCvKFTjwkso1N39lsD6Eg0tWnxRZseY178aDKc-D3uFnYQsKSA632gFYMHQ28eTrIA"},{"header":{"kid":"webstore"},"protected":"eyJhbGciOiJSUzI1NiJ9","signature":"LM43s6rOa8znJq_YQ4Gc_IM4gMNIB4lVHpcv5fCLJ8OPLLcLiAebdbaxqPlGMk8a98j5_1dpU3DzKaEudJaJZfrefS_lJXEX6N345OPJSCcGYxaKoePb3JAs6ck9pd__FhTDJ2RfwT4H2OBbbv6CwkQtRFmuFyRnGMMCIbUPPJd1Ip08odVqC14RqdefeNHGxVdx_zoeBKWFAgYFSoDsZn38PbHzUeVR3JIXHO49VhLfv-Tra7vJoHHiLSlAt2Tfffn2DwEm3ptmaCfbtgxIsOceb7Mos9jGPwbUJQ8XSGoeWXyVly3qCjaOd8BOU6mitSgntcX0ZN7_h3olw17QGw"}]}}]

Binary file not shown.

View File

@@ -0,0 +1 @@
1.1eee3e2bc90919b1b754fd95f8f6cb37c378f7227fb724b6ffb5233bcf5c3788

View File

@@ -0,0 +1,5 @@
{
"manifest_version": 2,
"name": "crl-set-9716886282698058642.data",
"version": "5345"
}

View File

@@ -0,0 +1,8 @@
{
"8/RrMmQlCD2Gsp14wUCE1P8r7B2C5+yE0+g79IPyRsc=": {
"expiry": 1597868021.744813,
"mode": "force-https",
"sts_include_subdomains": false,
"sts_observed": 1566332021.744818
}
}

View File

@@ -0,0 +1,8 @@
{
"8/RrMmQlCD2Gsp14wUCE1P8r7B2C5+yE0+g79IPyRsc=": {
"expiry": 1597866661.90759,
"mode": "force-https",
"sts_include_subdomains": false,
"sts_observed": 1566330661.907595
}
}

View File

@@ -0,0 +1,8 @@
{
"8/RrMmQlCD2Gsp14wUCE1P8r7B2C5+yE0+g79IPyRsc=": {
"expiry": 1597879473.799381,
"mode": "force-https",
"sts_include_subdomains": false,
"sts_observed": 1566343473.799385
}
}

View File

@@ -0,0 +1 @@
MANIFEST-000001

View File

@@ -0,0 +1,3 @@
2019/08/23-20:02:50.028 7bf Reusing MANIFEST /media/longterm/go/src/github.com/eyedeekay/sam-forwarder/etc/samcatd/samcatd/Default/AutofillStrikeDatabase/MANIFEST-000001
2019/08/23-20:02:50.028 7bf Recovering log #3
2019/08/23-20:02:50.028 7bf Reusing old log /media/longterm/go/src/github.com/eyedeekay/sam-forwarder/etc/samcatd/samcatd/Default/AutofillStrikeDatabase/000003.log

View File

@@ -0,0 +1,3 @@
2019/08/20-19:24:33.126 40bb Reusing MANIFEST /media/longterm/go/src/github.com/eyedeekay/sam-forwarder/etc/samcatd/samcatd/Default/AutofillStrikeDatabase/MANIFEST-000001
2019/08/20-19:24:33.127 40bb Recovering log #3
2019/08/20-19:24:33.127 40bb Reusing old log /media/longterm/go/src/github.com/eyedeekay/sam-forwarder/etc/samcatd/samcatd/Default/AutofillStrikeDatabase/000003.log

View File

@@ -0,0 +1 @@
MANIFEST-000001

View File

@@ -0,0 +1,3 @@
2019/08/23-20:02:50.020 7bf Reusing MANIFEST /media/longterm/go/src/github.com/eyedeekay/sam-forwarder/etc/samcatd/samcatd/Default/BudgetDatabase/MANIFEST-000001
2019/08/23-20:02:50.020 7bf Recovering log #3
2019/08/23-20:02:50.020 7bf Reusing old log /media/longterm/go/src/github.com/eyedeekay/sam-forwarder/etc/samcatd/samcatd/Default/BudgetDatabase/000003.log

View File

@@ -0,0 +1,3 @@
2019/08/20-19:24:33.112 40bb Reusing MANIFEST /media/longterm/go/src/github.com/eyedeekay/sam-forwarder/etc/samcatd/samcatd/Default/BudgetDatabase/MANIFEST-000001
2019/08/20-19:24:33.112 40bb Recovering log #3
2019/08/20-19:24:33.112 40bb Reusing old log /media/longterm/go/src/github.com/eyedeekay/sam-forwarder/etc/samcatd/samcatd/Default/BudgetDatabase/000003.log

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1 @@
MANIFEST-000001

View File

@@ -0,0 +1,3 @@
2019/08/23-20:02:51.766 7be Reusing MANIFEST /media/longterm/go/src/github.com/eyedeekay/sam-forwarder/etc/samcatd/samcatd/Default/Extension State/MANIFEST-000001
2019/08/23-20:02:51.766 7be Recovering log #3
2019/08/23-20:02:51.767 7be Reusing old log /media/longterm/go/src/github.com/eyedeekay/sam-forwarder/etc/samcatd/samcatd/Default/Extension State/000003.log

View File

@@ -0,0 +1,3 @@
2019/08/20-19:24:35.492 40b9 Reusing MANIFEST /media/longterm/go/src/github.com/eyedeekay/sam-forwarder/etc/samcatd/samcatd/Default/Extension State/MANIFEST-000001
2019/08/20-19:24:35.492 40b9 Recovering log #3
2019/08/20-19:24:35.493 40b9 Reusing old log /media/longterm/go/src/github.com/eyedeekay/sam-forwarder/etc/samcatd/samcatd/Default/Extension State/000003.log

Binary file not shown.

View File

@@ -0,0 +1 @@
MANIFEST-000001

View File

@@ -0,0 +1,3 @@
2019/08/23-20:02:49.913 7bf Reusing MANIFEST /media/longterm/go/src/github.com/eyedeekay/sam-forwarder/etc/samcatd/samcatd/Default/Feature Engagement Tracker/AvailabilityDB/MANIFEST-000001
2019/08/23-20:02:49.914 7bf Recovering log #3
2019/08/23-20:02:49.918 7bf Reusing old log /media/longterm/go/src/github.com/eyedeekay/sam-forwarder/etc/samcatd/samcatd/Default/Feature Engagement Tracker/AvailabilityDB/000003.log

View File

@@ -0,0 +1,3 @@
2019/08/20-19:24:32.932 40bb Reusing MANIFEST /media/longterm/go/src/github.com/eyedeekay/sam-forwarder/etc/samcatd/samcatd/Default/Feature Engagement Tracker/AvailabilityDB/MANIFEST-000001
2019/08/20-19:24:32.932 40bb Recovering log #3
2019/08/20-19:24:32.933 40bb Reusing old log /media/longterm/go/src/github.com/eyedeekay/sam-forwarder/etc/samcatd/samcatd/Default/Feature Engagement Tracker/AvailabilityDB/000003.log

View File

@@ -0,0 +1 @@
MANIFEST-000001

View File

@@ -0,0 +1,3 @@
2019/08/23-20:02:49.902 7bf Reusing MANIFEST /media/longterm/go/src/github.com/eyedeekay/sam-forwarder/etc/samcatd/samcatd/Default/Feature Engagement Tracker/EventDB/MANIFEST-000001
2019/08/23-20:02:49.902 7bf Recovering log #3
2019/08/23-20:02:49.902 7bf Reusing old log /media/longterm/go/src/github.com/eyedeekay/sam-forwarder/etc/samcatd/samcatd/Default/Feature Engagement Tracker/EventDB/000003.log

View File

@@ -0,0 +1,3 @@
2019/08/20-19:24:32.928 40bb Reusing MANIFEST /media/longterm/go/src/github.com/eyedeekay/sam-forwarder/etc/samcatd/samcatd/Default/Feature Engagement Tracker/EventDB/MANIFEST-000001
2019/08/20-19:24:32.928 40bb Recovering log #3
2019/08/20-19:24:32.929 40bb Reusing old log /media/longterm/go/src/github.com/eyedeekay/sam-forwarder/etc/samcatd/samcatd/Default/Feature Engagement Tracker/EventDB/000003.log

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1 @@
{"net":{"http_server_properties":{"servers":[{"https://accounts.google.com":{"supports_spdy":true}}],"version":5},"network_qualities":{"CAISE21lc2hhYmxlX21haW5fbm9tYXAYgICAgPj/////AQ==":"4G"}}}

View File

@@ -0,0 +1 @@
MANIFEST-000001

Some files were not shown because too many files have changed in this diff Show More