Compare commits
18 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
d2f767dbe0 | ||
![]() |
b89d62e481 | ||
![]() |
06113918ea | ||
![]() |
a884fa4692 | ||
![]() |
fc36f9cf6f | ||
![]() |
3248dd789d | ||
![]() |
71ca8cd65f | ||
![]() |
60e9f15b18 | ||
![]() |
ee8617deb0 | ||
![]() |
029317222e | ||
![]() |
bcd32aa8ad | ||
![]() |
3c1a44e1d2 | ||
![]() |
7167ba3a1c | ||
![]() |
3ff494c374 | ||
![]() |
aebbe18f3b | ||
![]() |
081b25d54c | ||
![]() |
78306cc9e6 | ||
![]() |
0e40939f7d |
32
Makefile
32
Makefile
@@ -17,9 +17,9 @@ LOG := log/
|
||||
ETC := etc/
|
||||
USR := usr/
|
||||
LOCAL := local/
|
||||
VERSION := 0.32.04
|
||||
VERSION := 0.32.081
|
||||
|
||||
GO111MODULE=on
|
||||
GO111MODULE=off
|
||||
|
||||
echo:
|
||||
@echo "$(GOPATH)"
|
||||
@@ -27,6 +27,9 @@ echo:
|
||||
find . -path ./.go -prune -o -name "*.i2pkeys" -exec rm {} \;
|
||||
find . -path ./.go -prune -o -name "*.go" -exec cat {} \; | nl
|
||||
|
||||
tag:
|
||||
gothub release -s $(GITHUB_TOKEN) -u $(USER_GH) -r $(packagename) -t v$(VERSION) -d "I2P Tunnel Management tool for Go applications"
|
||||
|
||||
recopy:
|
||||
#find ./tcp/ -name '*.go' -exec cp -rv {} . \;
|
||||
#sed -i '1s|^|//AUTO-GENERATED FOR BACKWARD COMPATIBILITY, USE ./tcp in the future\n|' *.go
|
||||
@@ -85,6 +88,15 @@ daemon: clean-daemon bin/$(samcatd)
|
||||
|
||||
daemon-webview: bin/$(samcatd)-webview
|
||||
|
||||
daemon-cli: bin/$(samcatd)-cli
|
||||
|
||||
bin/$(samcatd)-cli:
|
||||
mkdir -p bin
|
||||
cd samcatd && go build -a -tags "netgo cli" \
|
||||
-ldflags '-w -extldflags "-static"' \
|
||||
-o ../bin/$(samcatd)-cli \
|
||||
./*.go
|
||||
|
||||
bin/$(samcatd):
|
||||
mkdir -p bin
|
||||
cd samcatd && go build -a -tags "netgo static" \
|
||||
@@ -101,9 +113,9 @@ bin/$(samcatd)-webview:
|
||||
update:
|
||||
git config --global url."git@github.com:RTradeLtd".insteadOf "https://github.com/RTradeLtd"
|
||||
|
||||
all: daemon daemon-webview
|
||||
all: daemon-cli daemon daemon-webview
|
||||
|
||||
clean: clean-all
|
||||
clean: clean-all echo
|
||||
|
||||
clean-all: clean-daemon
|
||||
|
||||
@@ -150,6 +162,7 @@ key-management:
|
||||
example-config:
|
||||
@echo "example config - valid for both ephsite and samcat" >> USAGE.md
|
||||
@echo "==================================================" >> USAGE.md
|
||||
@echo "" >> USAGE.md
|
||||
@echo "Options are still being added, pretty much as fast as I can put them" >> USAGE.md
|
||||
@echo "in. For up-to-the-minute options, see [the checklist](config/CHECKLIST.md)" >> USAGE.md
|
||||
@echo "" >> USAGE.md
|
||||
@@ -224,9 +237,14 @@ tar:
|
||||
--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
|
||||
|
||||
tasks:
|
||||
golint ./tcp
|
||||
#golint ./udp
|
||||
#golint ./config
|
||||
#golint ./config
|
||||
#golint ./config
|
||||
#golint ./config
|
||||
|
1
config/helpers/helper.go
Normal file
1
config/helpers/helper.go
Normal file
@@ -0,0 +1 @@
|
||||
package i2ptunhelper
|
225
config/helpers/tunconf_client.go
Normal file
225
config/helpers/tunconf_client.go
Normal file
@@ -0,0 +1,225 @@
|
||||
package i2ptunhelper
|
||||
|
||||
import (
|
||||
"github.com/eyedeekay/httptunnel"
|
||||
"github.com/eyedeekay/httptunnel/multiproxy"
|
||||
"github.com/eyedeekay/sam-forwarder/config"
|
||||
"github.com/eyedeekay/sam-forwarder/tcp"
|
||||
"github.com/eyedeekay/sam-forwarder/udp"
|
||||
)
|
||||
|
||||
func NewSAMHTTPClientFromConf(config *i2ptunconf.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 := i2ptunconf.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 *i2ptunconf.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 := i2ptunconf.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 *i2ptunconf.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 := i2ptunconf.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 *i2ptunconf.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 := i2ptunconf.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
|
||||
}
|
130
config/helpers/tunconf_outproxy.go
Normal file
130
config/helpers/tunconf_outproxy.go
Normal file
@@ -0,0 +1,130 @@
|
||||
package i2ptunhelper
|
||||
|
||||
import (
|
||||
"github.com/eyedeekay/outproxy"
|
||||
"github.com/eyedeekay/sam-forwarder/config"
|
||||
)
|
||||
|
||||
// NewOutProxyFromConf generates a SAMforwarder from *i2ptunconf.Conf
|
||||
func NewOutProxyFromConf(config *i2ptunconf.Conf) (*outproxy.OutProxy, error) {
|
||||
if config != nil {
|
||||
return outproxy.NewOutProxyFromOptions(
|
||||
outproxy.SetType(config.Type),
|
||||
outproxy.SetSaveFile(config.SaveFile),
|
||||
outproxy.SetFilePath(config.SaveDirectory),
|
||||
outproxy.SetHost(config.TargetHost),
|
||||
outproxy.SetPort(config.TargetPort),
|
||||
outproxy.SetSAMHost(config.SamHost),
|
||||
outproxy.SetSAMPort(config.SamPort),
|
||||
outproxy.SetSigType(config.SigType),
|
||||
outproxy.SetName(config.TunName),
|
||||
outproxy.SetInLength(config.InLength),
|
||||
outproxy.SetOutLength(config.OutLength),
|
||||
outproxy.SetInVariance(config.InVariance),
|
||||
outproxy.SetOutVariance(config.OutVariance),
|
||||
outproxy.SetInQuantity(config.InQuantity),
|
||||
outproxy.SetOutQuantity(config.OutQuantity),
|
||||
outproxy.SetInBackups(config.InBackupQuantity),
|
||||
outproxy.SetOutBackups(config.OutBackupQuantity),
|
||||
outproxy.SetEncrypt(config.EncryptLeaseSet),
|
||||
outproxy.SetLeaseSetKey(config.LeaseSetKey),
|
||||
outproxy.SetLeaseSetPrivateKey(config.LeaseSetPrivateKey),
|
||||
outproxy.SetLeaseSetPrivateSigningKey(config.LeaseSetPrivateSigningKey),
|
||||
outproxy.SetAllowZeroIn(config.InAllowZeroHop),
|
||||
outproxy.SetAllowZeroOut(config.OutAllowZeroHop),
|
||||
outproxy.SetFastRecieve(config.FastRecieve),
|
||||
outproxy.SetCompress(config.UseCompression),
|
||||
outproxy.SetReduceIdle(config.ReduceIdle),
|
||||
outproxy.SetReduceIdleTimeMs(config.ReduceIdleTime),
|
||||
outproxy.SetReduceIdleQuantity(config.ReduceIdleQuantity),
|
||||
outproxy.SetCloseIdle(config.CloseIdle),
|
||||
outproxy.SetCloseIdleTimeMs(config.CloseIdleTime),
|
||||
outproxy.SetAccessListType(config.AccessListType),
|
||||
outproxy.SetAccessList(config.AccessList),
|
||||
outproxy.SetMessageReliability(config.MessageReliability),
|
||||
outproxy.SetKeyFile(config.KeyFilePath),
|
||||
//outproxy.SetTargetForPort443(config.TargetForPort443),
|
||||
)
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// NewOutProxyFromConfig generates a new OutProxy from a config file
|
||||
func NewOutProxyFromConfig(iniFile, SamHost, SamPort string, label ...string) (*outproxy.HttpOutProxy, error) {
|
||||
if iniFile != "none" {
|
||||
config, err := i2ptunconf.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 NewHttpOutProxyFromConf(config)
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// NewOutProxyFromConf generates a SAMforwarder from *i2ptunconf.Conf
|
||||
func NewHttpOutProxyFromConf(config *i2ptunconf.Conf) (*outproxy.HttpOutProxy, error) {
|
||||
if config != nil {
|
||||
return outproxy.NewHttpOutProxydFromOptions(
|
||||
outproxy.SetHttpType(config.Type),
|
||||
outproxy.SetHttpSaveFile(config.SaveFile),
|
||||
outproxy.SetHttpFilePath(config.SaveDirectory),
|
||||
outproxy.SetHttpHost(config.TargetHost),
|
||||
outproxy.SetHttpPort(config.TargetPort),
|
||||
outproxy.SetHttpSAMHost(config.SamHost),
|
||||
outproxy.SetHttpSAMPort(config.SamPort),
|
||||
outproxy.SetHttpSigType(config.SigType),
|
||||
outproxy.SetHttpName(config.TunName),
|
||||
outproxy.SetHttpInLength(config.InLength),
|
||||
outproxy.SetHttpOutLength(config.OutLength),
|
||||
outproxy.SetHttpInVariance(config.InVariance),
|
||||
outproxy.SetHttpOutVariance(config.OutVariance),
|
||||
outproxy.SetHttpInQuantity(config.InQuantity),
|
||||
outproxy.SetHttpOutQuantity(config.OutQuantity),
|
||||
outproxy.SetHttpInBackups(config.InBackupQuantity),
|
||||
outproxy.SetHttpOutBackups(config.OutBackupQuantity),
|
||||
outproxy.SetHttpEncrypt(config.EncryptLeaseSet),
|
||||
outproxy.SetHttpLeaseSetKey(config.LeaseSetKey),
|
||||
outproxy.SetHttpLeaseSetPrivateKey(config.LeaseSetPrivateKey),
|
||||
outproxy.SetHttpLeaseSetPrivateSigningKey(config.LeaseSetPrivateSigningKey),
|
||||
outproxy.SetHttpAllowZeroIn(config.InAllowZeroHop),
|
||||
outproxy.SetHttpAllowZeroOut(config.OutAllowZeroHop),
|
||||
outproxy.SetHttpFastRecieve(config.FastRecieve),
|
||||
outproxy.SetHttpCompress(config.UseCompression),
|
||||
outproxy.SetHttpReduceIdle(config.ReduceIdle),
|
||||
outproxy.SetHttpReduceIdleTimeMs(config.ReduceIdleTime),
|
||||
outproxy.SetHttpReduceIdleQuantity(config.ReduceIdleQuantity),
|
||||
outproxy.SetHttpCloseIdle(config.CloseIdle),
|
||||
outproxy.SetHttpCloseIdleTimeMs(config.CloseIdleTime),
|
||||
outproxy.SetHttpAccessListType(config.AccessListType),
|
||||
outproxy.SetHttpAccessList(config.AccessList),
|
||||
outproxy.SetHttpMessageReliability(config.MessageReliability),
|
||||
outproxy.SetHttpKeyFile(config.KeyFilePath),
|
||||
//outproxy.SetHttpTargetForPort443(config.TargetForPort443),
|
||||
)
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// NewOutProxyFromConfig generates a new OutProxy from a config file
|
||||
func NewHttpOutProxyFromConfig(iniFile, SamHost, SamPort string, label ...string) (*outproxy.OutProxy, error) {
|
||||
if iniFile != "none" {
|
||||
config, err := i2ptunconf.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 NewOutProxyFromConf(config)
|
||||
}
|
||||
return nil, nil
|
||||
}
|
193
config/helpers/tunconf_server.go
Normal file
193
config/helpers/tunconf_server.go
Normal file
@@ -0,0 +1,193 @@
|
||||
package i2ptunhelper
|
||||
|
||||
import (
|
||||
"github.com/eyedeekay/eephttpd"
|
||||
"github.com/eyedeekay/sam-forwarder/config"
|
||||
"github.com/eyedeekay/sam-forwarder/tcp"
|
||||
"github.com/eyedeekay/sam-forwarder/udp"
|
||||
)
|
||||
|
||||
// NewSAMForwarderFromConf generates a SAMforwarder from *i2ptunconf.Conf
|
||||
func NewSAMForwarderFromConf(config *i2ptunconf.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 := i2ptunconf.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 *i2ptunconf.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 := i2ptunconf.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
|
||||
}
|
||||
|
||||
// NewEepHttpdFromConf generates a SAMforwarder from *i2ptunconf.Conf
|
||||
func NewEepHttpdFromConf(config *i2ptunconf.Conf) (*eephttpd.EepHttpd, error) {
|
||||
if config != nil {
|
||||
return eephttpd.NewEepHttpdFromOptions(
|
||||
eephttpd.SetType(config.Type),
|
||||
eephttpd.SetSaveFile(config.SaveFile),
|
||||
eephttpd.SetFilePath(config.SaveDirectory),
|
||||
eephttpd.SetHost(config.TargetHost),
|
||||
eephttpd.SetPort(config.TargetPort),
|
||||
eephttpd.SetSAMHost(config.SamHost),
|
||||
eephttpd.SetSAMPort(config.SamPort),
|
||||
eephttpd.SetSigType(config.SigType),
|
||||
eephttpd.SetName(config.TunName),
|
||||
eephttpd.SetInLength(config.InLength),
|
||||
eephttpd.SetOutLength(config.OutLength),
|
||||
eephttpd.SetInVariance(config.InVariance),
|
||||
eephttpd.SetOutVariance(config.OutVariance),
|
||||
eephttpd.SetInQuantity(config.InQuantity),
|
||||
eephttpd.SetOutQuantity(config.OutQuantity),
|
||||
eephttpd.SetInBackups(config.InBackupQuantity),
|
||||
eephttpd.SetOutBackups(config.OutBackupQuantity),
|
||||
eephttpd.SetEncrypt(config.EncryptLeaseSet),
|
||||
eephttpd.SetLeaseSetKey(config.LeaseSetKey),
|
||||
eephttpd.SetLeaseSetPrivateKey(config.LeaseSetPrivateKey),
|
||||
eephttpd.SetLeaseSetPrivateSigningKey(config.LeaseSetPrivateSigningKey),
|
||||
eephttpd.SetAllowZeroIn(config.InAllowZeroHop),
|
||||
eephttpd.SetAllowZeroOut(config.OutAllowZeroHop),
|
||||
eephttpd.SetFastRecieve(config.FastRecieve),
|
||||
eephttpd.SetCompress(config.UseCompression),
|
||||
eephttpd.SetReduceIdle(config.ReduceIdle),
|
||||
eephttpd.SetReduceIdleTimeMs(config.ReduceIdleTime),
|
||||
eephttpd.SetReduceIdleQuantity(config.ReduceIdleQuantity),
|
||||
eephttpd.SetCloseIdle(config.CloseIdle),
|
||||
eephttpd.SetCloseIdleTimeMs(config.CloseIdleTime),
|
||||
eephttpd.SetAccessListType(config.AccessListType),
|
||||
eephttpd.SetAccessList(config.AccessList),
|
||||
eephttpd.SetMessageReliability(config.MessageReliability),
|
||||
eephttpd.SetKeyFile(config.KeyFilePath),
|
||||
eephttpd.SetServeDir(config.ServeDirectory),
|
||||
//eephttpd.SetTargetForPort443(config.TargetForPort443),
|
||||
)
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// NewEepHttpdFromConfig generates a new EepHttpd from a config file
|
||||
func NewEepHttpdFromConfig(iniFile, SamHost, SamPort string, label ...string) (*eephttpd.EepHttpd, error) {
|
||||
if iniFile != "none" {
|
||||
config, err := i2ptunconf.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 NewEepHttpdFromConf(config)
|
||||
}
|
||||
return nil, nil
|
||||
}
|
@@ -26,6 +26,7 @@ type Conf struct {
|
||||
SigType string
|
||||
Type string
|
||||
SaveDirectory string
|
||||
ServeDirectory string
|
||||
SaveFile bool
|
||||
TargetHost string
|
||||
TargetPort string
|
||||
@@ -273,6 +274,7 @@ func (c *Conf) I2PINILoad(iniFile string, label ...string) error {
|
||||
c.SetPassword(label...)
|
||||
c.SetControlHost(label...)
|
||||
c.SetControlPort(label...)
|
||||
c.SetWWWDir(label...)
|
||||
if v, ok := c.Get("i2cp.accessList", label...); ok {
|
||||
csv := strings.Split(v, ",")
|
||||
for _, z := range csv {
|
||||
|
@@ -25,15 +25,33 @@ func (c *Conf) GetTypes(argc, argu, argh bool, def string, label ...string) stri
|
||||
} else {
|
||||
typ += "server"
|
||||
}
|
||||
if typ != def {
|
||||
return typ
|
||||
}
|
||||
}
|
||||
if def == "kcpclient" {
|
||||
typ = "kcpclient"
|
||||
return def
|
||||
}
|
||||
if def == "kcpserver" {
|
||||
typ = "kcpserver"
|
||||
return def
|
||||
}
|
||||
if typ != def {
|
||||
return typ
|
||||
if def == "eephttpd" {
|
||||
return def
|
||||
}
|
||||
if def == "vpnclient" {
|
||||
return def
|
||||
}
|
||||
if def == "vpnserver" {
|
||||
return def
|
||||
}
|
||||
if def == "outproxy" {
|
||||
return def
|
||||
}
|
||||
if def == "outproxyhttp" {
|
||||
return def
|
||||
}
|
||||
if def == "browserclient" {
|
||||
return def
|
||||
}
|
||||
if c.Config == nil {
|
||||
return typ
|
||||
@@ -78,6 +96,12 @@ func (c *Conf) SetType(label ...string) {
|
||||
c.Type = v
|
||||
case "udpclient":
|
||||
c.Type = v
|
||||
case "eephttpd":
|
||||
c.Type = v
|
||||
case "outproxy":
|
||||
c.Type = v
|
||||
case "outproxyhttp":
|
||||
c.Type = v
|
||||
case "vpnserver":
|
||||
c.Type = v
|
||||
case "vpnclient":
|
||||
|
29
config/wwwdir.go
Normal file
29
config/wwwdir.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package i2ptunconf
|
||||
|
||||
//
|
||||
|
||||
// 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
|
||||
// default is returned.
|
||||
func (c *Conf) GetWWWDir(arg, def string, label ...string) string {
|
||||
if arg != def {
|
||||
return arg
|
||||
}
|
||||
if c.Config == nil {
|
||||
return arg
|
||||
}
|
||||
if x, o := c.Get("wwwdir", label...); o {
|
||||
return x
|
||||
}
|
||||
return arg
|
||||
}
|
||||
|
||||
// SetDir sets the key save directory from the config file
|
||||
func (c *Conf) SetWWWDir(label ...string) {
|
||||
if v, ok := c.Get("wwwdir", label...); ok {
|
||||
c.ServeDirectory = v
|
||||
} else {
|
||||
c.ServeDirectory = "./www"
|
||||
}
|
||||
}
|
@@ -40,13 +40,13 @@ outbound.length = 3
|
||||
destination = i2p-projekt.i2p
|
||||
keys = tcpclient
|
||||
|
||||
[sam-forwarder-udp-server]
|
||||
type = udpserver
|
||||
host = 127.0.0.1
|
||||
port = 8084
|
||||
#[sam-forwarder-udp-server]
|
||||
#type = udpserver
|
||||
#host = 127.0.0.1
|
||||
#port = 8084
|
||||
#inbound.length = 6
|
||||
outbound.length = 3
|
||||
keys = udpserver
|
||||
#outbound.length = 3
|
||||
#keys = udpserver
|
||||
|
||||
#[sam-forwarder-udp-client]
|
||||
#type = udpclient
|
||||
@@ -72,3 +72,12 @@ keys = httpserver
|
||||
#inbound.length = 3
|
||||
#outbound.length = 3
|
||||
#keys = proxy
|
||||
|
||||
[sam-forwarder-tcp-socks-outproxy]
|
||||
type = client
|
||||
host = 127.0.0.1
|
||||
port = 8087
|
||||
inbound.length = 2
|
||||
outbound.length = 3
|
||||
destination = 4oymiquy7qobjgx36tejs35zeqt24qpemsnzgtfeswmrw6csxbkq.b32.i2p
|
||||
keys = tcpclient
|
||||
|
13
go.mod
13
go.mod
@@ -3,18 +3,19 @@ module github.com/eyedeekay/sam-forwarder
|
||||
go 1.12
|
||||
|
||||
require (
|
||||
crawshaw.io/littleboss v0.0.0-20190317185602-8957d0aedcce
|
||||
github.com/boreq/friendlyhash v0.0.0-20190522010448-1ca64b3ca69e
|
||||
github.com/eyedeekay/httptunnel v0.0.0-20190831065052-9eab288b8a82
|
||||
github.com/cryptix/goSam v0.1.0 // indirect
|
||||
github.com/eyedeekay/eephttpd v0.0.0-20190903000420-52f5a8485a4e
|
||||
github.com/eyedeekay/httptunnel v0.0.0-20190831071439-0ff3d5f798fb
|
||||
github.com/eyedeekay/i2pdig v0.0.0-20180718204453-a67cb46e2e5f // indirect
|
||||
github.com/eyedeekay/outproxy v0.0.0-20190908174238-22bd71d43733
|
||||
github.com/eyedeekay/portcheck v0.0.0-20190218044454-bb8718669680
|
||||
github.com/eyedeekay/sam3 v0.0.0-20190730185140-f8d54526ea25
|
||||
github.com/gtank/cryptopasta v0.0.0-20170601214702-1f550f6f2f69
|
||||
github.com/justinas/nosurf v0.0.0-20190416172904-05988550ea18
|
||||
github.com/spf13/pflag v1.0.3 // indirect
|
||||
github.com/zieckey/goini v0.0.0-20180118150432-0da17d361d26
|
||||
github.com/zserge/lorca v0.1.8
|
||||
github.com/zserge/webview v0.0.0-20190123072648-16c93bcaeaeb
|
||||
golang.org/x/crypto v0.0.0-20190829043050-9756ffdc2472 // indirect
|
||||
golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297 // indirect
|
||||
golang.org/x/sys v0.0.0-20190830142957-1e83adbbebd0 // indirect
|
||||
golang.org/x/text v0.3.2 // indirect
|
||||
golang.org/x/tools v0.0.0-20190830223141-573d9926052a // indirect
|
||||
)
|
||||
|
@@ -43,6 +43,20 @@ func DefaultCSS() string {
|
||||
float: left;
|
||||
overflow-wrap: break-word;
|
||||
}
|
||||
.outproxy {
|
||||
width: 63%;
|
||||
min-height: 15%;
|
||||
background-color: #265ea7;
|
||||
float: left;
|
||||
overflow-wrap: break-word;
|
||||
}
|
||||
.outproxyhttp {
|
||||
width: 63%;
|
||||
min-height: 15%;
|
||||
background-color: #265ea7;
|
||||
float: left;
|
||||
overflow-wrap: break-word;
|
||||
}
|
||||
.udpclient {
|
||||
width: 63%;
|
||||
min-height: 15%;
|
||||
|
@@ -41,10 +41,6 @@ func SetAccessList(s []string) func(SAMTunnel) error {
|
||||
//SetCompress tells clients to use compression
|
||||
func SetCompress(b bool) func(SAMTunnel) error {
|
||||
return func(c SAMTunnel) error {
|
||||
if b {
|
||||
c.Config().UseCompression = b // "true"
|
||||
return nil
|
||||
}
|
||||
c.Config().UseCompression = b // "false"
|
||||
return nil
|
||||
}
|
||||
@@ -58,7 +54,7 @@ func SetFilePath(s string) func(SAMTunnel) error {
|
||||
}
|
||||
}
|
||||
|
||||
//SetControlHost sets the host of the service to forward
|
||||
//SetControlHost sets the host of the service to present an API on
|
||||
func SetControlHost(s string) func(SAMTunnel) error {
|
||||
return func(c SAMTunnel) error {
|
||||
c.Config().ControlHost = s
|
||||
@@ -66,7 +62,7 @@ func SetControlHost(s string) func(SAMTunnel) error {
|
||||
}
|
||||
}
|
||||
|
||||
//SetControlPort sets the port of the service to forward
|
||||
//SetControlPort sets the port of the service to present an API on
|
||||
func SetControlPort(s string) func(SAMTunnel) error {
|
||||
return func(c SAMTunnel) error {
|
||||
port, err := strconv.Atoi(s)
|
||||
@@ -81,7 +77,8 @@ func SetControlPort(s string) func(SAMTunnel) error {
|
||||
}
|
||||
}
|
||||
|
||||
//SetKeyFile sets
|
||||
//SetKeyFile sets the path to a file containing a private key for decrypting
|
||||
//locally-encrypted i2p keys.
|
||||
func SetKeyFile(s string) func(SAMTunnel) error {
|
||||
return func(c SAMTunnel) error {
|
||||
c.Config().KeyFilePath = s
|
||||
@@ -89,7 +86,7 @@ func SetKeyFile(s string) func(SAMTunnel) error {
|
||||
}
|
||||
}
|
||||
|
||||
//SetSaveFile tells the router to save the tunnel's keys long-term
|
||||
//SetDestination tells the
|
||||
func SetDestination(b string) func(SAMTunnel) error {
|
||||
return func(c SAMTunnel) error {
|
||||
c.Config().ClientDest = b
|
||||
@@ -97,7 +94,7 @@ func SetDestination(b string) func(SAMTunnel) error {
|
||||
}
|
||||
}
|
||||
|
||||
//SetTunnelHost is used for VPN endpoints
|
||||
//SetTunnelHost is used for VPN endpoints only.
|
||||
func SetTunnelHost(s string) func(SAMTunnel) error {
|
||||
return func(c SAMTunnel) error {
|
||||
c.Config().TunnelHost = s
|
||||
@@ -136,19 +133,15 @@ func SetPort(s string) func(SAMTunnel) error {
|
||||
}
|
||||
}
|
||||
|
||||
//SetEncrypt tells the router to use an encrypted leaseset
|
||||
//SetEncrypt tells the outproxy.SetHttp to use an encrypted leaseset
|
||||
func SetEncrypt(b bool) func(SAMTunnel) error {
|
||||
return func(c SAMTunnel) error {
|
||||
if b {
|
||||
c.Config().EncryptLeaseSet = b //"true"
|
||||
return nil
|
||||
}
|
||||
c.Config().EncryptLeaseSet = b //"false"
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
//SetLeaseSetKey sets the host of the Conf's SAM bridge
|
||||
//SetLeaseSetKey sets key to use with the encrypted leaseset
|
||||
func SetLeaseSetKey(s string) func(SAMTunnel) error {
|
||||
return func(c SAMTunnel) error {
|
||||
c.Config().LeaseSetKey = s
|
||||
@@ -156,7 +149,7 @@ func SetLeaseSetKey(s string) func(SAMTunnel) error {
|
||||
}
|
||||
}
|
||||
|
||||
//SetLeaseSetPrivateKey sets the host of the Conf's SAM bridge
|
||||
//SetLeaseSetPrivateKey sets the private key to use with the encrypted leaseset
|
||||
func SetLeaseSetPrivateKey(s string) func(SAMTunnel) error {
|
||||
return func(c SAMTunnel) error {
|
||||
c.Config().LeaseSetPrivateKey = s
|
||||
@@ -164,7 +157,7 @@ func SetLeaseSetPrivateKey(s string) func(SAMTunnel) error {
|
||||
}
|
||||
}
|
||||
|
||||
//SetLeaseSetPrivateSigningKey sets the host of the Conf's SAM bridge
|
||||
//SetLeaseSetPrivateSigningKey sets the private signing key to use with the encrypted leaseset
|
||||
func SetLeaseSetPrivateSigningKey(s string) func(SAMTunnel) error {
|
||||
return func(c SAMTunnel) error {
|
||||
c.Config().LeaseSetPrivateSigningKey = s
|
||||
@@ -202,7 +195,7 @@ func SetName(s string) func(SAMTunnel) error {
|
||||
}
|
||||
}
|
||||
|
||||
//SetSaveFile tells the router to save the tunnel's keys long-term
|
||||
//SetSaveFile tells the application to save the tunnel's keys long-term
|
||||
func SetSaveFile(b bool) func(SAMTunnel) error {
|
||||
return func(c SAMTunnel) error {
|
||||
c.Config().SaveFile = b
|
||||
@@ -400,7 +393,7 @@ func SetType(s string) func(SAMTunnel) error {
|
||||
}
|
||||
}
|
||||
|
||||
//SetUserName sets the host of the Conf's SAM bridge
|
||||
//SetUserName sets username for authentication purposes
|
||||
func SetUserName(s string) func(SAMTunnel) error {
|
||||
return func(c SAMTunnel) error {
|
||||
c.Config().UserName = s
|
||||
|
@@ -5,31 +5,51 @@ import (
|
||||
"github.com/eyedeekay/sam3/i2pkeys"
|
||||
)
|
||||
|
||||
// SAMTunnel is an interface comprehensively representing an I2P tunnel over SAM
|
||||
// in Go
|
||||
type SAMTunnel interface {
|
||||
// Config returns the appropriate underlying config object all options, or
|
||||
// the common options passed into a compound tunnel.
|
||||
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
|
||||
Props() map[string]string //Get a full list of tunnel properties as a map for user display/analysis
|
||||
Search(search string) string //Search the Props for a common term
|
||||
Target() string //The address of the local client or service to forward with a SAM tunnel
|
||||
ID() string //The user-chosen tunnel ID
|
||||
// GetType Get the type of the tunnel in use(server, client, http, udp, etc)
|
||||
GetType() string
|
||||
// Print all the tunnel options as a string
|
||||
Print() string
|
||||
// Props Get a full list of tunnel properties as a map for user display/analysis
|
||||
Props() map[string]string
|
||||
//Search the Props for a common term
|
||||
Search(search string) string
|
||||
//Target The address of the local client or service to forward with a SAM tunnel
|
||||
Target() string
|
||||
//ID The user-chosen tunnel name
|
||||
ID() string
|
||||
//Destination() string
|
||||
|
||||
// Key handling
|
||||
Base32() string // Get the .b32.i2p address of your service
|
||||
Base32Readable() string // Create a more-readable representation of the .b32.i2p address using English words
|
||||
Base64() string // Get the public base64 address of your I2P service
|
||||
Keys() i2pkeys.I2PKeys // Get all the parts of the keys to your I2P service
|
||||
// Get the .b32.i2p address of your service
|
||||
Base32() string
|
||||
// Create a more-readable representation of the .b32.i2p address using English words
|
||||
Base32Readable() string
|
||||
// Get the public base64 address of your I2P service
|
||||
Base64() string
|
||||
// Get all the parts of the keys to your I2P service
|
||||
Keys() i2pkeys.I2PKeys
|
||||
|
||||
// Service Management
|
||||
Load() (SAMTunnel, error) // Prepare tunnel keys and tunnel options
|
||||
Serve() error // Start the tunnel
|
||||
Close() error // Stop the tunnel and close all connections
|
||||
Cleanup() // Stop the tunnel but leave the sockets alone for now
|
||||
Up() bool // Return "true" if the tunnel is ready to go up.
|
||||
// Prepare tunnel keys and tunnel options
|
||||
Load() (SAMTunnel, error)
|
||||
// Start the tunnel
|
||||
Serve() error
|
||||
// Stop the tunnel and close all connections
|
||||
Close() error
|
||||
// Stop the tunnel but leave the sockets alone for now
|
||||
Cleanup()
|
||||
// Return "true" if the tunnel is ready to go up.
|
||||
Up() bool
|
||||
}
|
||||
|
||||
// WebUI is an interface which is used to generate a minimal UI. Open to suggestions.
|
||||
type WebUI interface {
|
||||
Title() string
|
||||
URL() string
|
||||
|
@@ -177,6 +177,27 @@ func NewSAMManagerFromOptions(opts ...func(*SAMManager) error) (*SAMManager, err
|
||||
} else {
|
||||
return nil, e
|
||||
}
|
||||
case "eephttpd":
|
||||
if f, e := samtunnelhandler.NewTunnelHandler(i2ptunhelper.NewEepHttpdFromConfig(s.config.FilePath, s.SamHost, s.SamPort, label)); e == nil {
|
||||
log.Println("found eephttpd under", label)
|
||||
s.handlerMux = s.handlerMux.Append(f)
|
||||
} else {
|
||||
return nil, e
|
||||
}
|
||||
case "outproxy":
|
||||
if f, e := samtunnelhandler.NewTunnelHandler(i2ptunhelper.NewOutProxyFromConfig(s.config.FilePath, s.SamHost, s.SamPort, label)); e == nil {
|
||||
log.Println("found outproxy under", label)
|
||||
s.handlerMux = s.handlerMux.Append(f)
|
||||
} else {
|
||||
return nil, e
|
||||
}
|
||||
case "outproxyhttp":
|
||||
if f, e := samtunnelhandler.NewTunnelHandler(i2ptunhelper.NewHttpOutProxyFromConfig(s.config.FilePath, s.SamHost, s.SamPort, label)); e == nil {
|
||||
log.Println("found outproxy under", label)
|
||||
s.handlerMux = s.handlerMux.Append(f)
|
||||
} else {
|
||||
return nil, e
|
||||
}
|
||||
/*case "vpnserver":
|
||||
if f, e := samtunnelhandler.NewTunnelHandler(samforwardervpnserver.NewSAMVPNForwarderFromConfig(s.config.FilePath, s.SamHost, s.SamPort, label)); e == nil {
|
||||
log.Println("found vpnserver under", label)
|
||||
@@ -257,20 +278,41 @@ func NewSAMManagerFromOptions(opts ...func(*SAMManager) error) (*SAMManager, err
|
||||
} else {
|
||||
return nil, e
|
||||
}
|
||||
/*case "vpnserver":
|
||||
if f, e := samtunnelhandler.NewTunnelHandler(samforwardervpnserver.NewSAMVPNForwarderFromConf(s.config)); e == nil {
|
||||
log.Println("found default vpnserver")
|
||||
case "eephttpd":
|
||||
if f, e := samtunnelhandler.NewTunnelHandler(i2ptunhelper.NewEepHttpdFromConf(s.config)); e == nil {
|
||||
log.Println("found default udpclient")
|
||||
s.handlerMux = s.handlerMux.Append(f)
|
||||
} else {
|
||||
return nil, e
|
||||
}
|
||||
case "vpnclient":
|
||||
if f, e := samtunnelhandler.NewTunnelHandler(samforwardervpn.NewSAMVPNClientForwarderFromConf(s.config)); e == nil {
|
||||
log.Println("found default vpnclient")
|
||||
case "outproxy":
|
||||
if f, e := samtunnelhandler.NewTunnelHandler(i2ptunhelper.NewOutProxyFromConf(s.config)); e == nil {
|
||||
log.Println("found default udpclient")
|
||||
s.handlerMux = s.handlerMux.Append(f)
|
||||
} else {
|
||||
return nil, e
|
||||
}*/
|
||||
}
|
||||
case "outproxyhttp":
|
||||
if f, e := samtunnelhandler.NewTunnelHandler(i2ptunhelper.NewHttpOutProxyFromConf(s.config)); e == nil {
|
||||
log.Println("found default udpclient")
|
||||
s.handlerMux = s.handlerMux.Append(f)
|
||||
} else {
|
||||
return nil, e
|
||||
}
|
||||
/*case "vpnserver":
|
||||
if f, e := samtunnelhandler.NewTunnelHandler(samforwardervpnserver.NewSAMVPNForwarderFromConf(s.config)); e == nil {
|
||||
log.Println("found default vpnserver")
|
||||
s.handlerMux = s.handlerMux.Append(f)
|
||||
} else {
|
||||
return nil, e
|
||||
}
|
||||
case "vpnclient":
|
||||
if f, e := samtunnelhandler.NewTunnelHandler(samforwardervpn.NewSAMVPNClientForwarderFromConf(s.config)); e == nil {
|
||||
log.Println("found default vpnclient")
|
||||
s.handlerMux = s.handlerMux.Append(f)
|
||||
} else {
|
||||
return nil, e
|
||||
}*/
|
||||
default:
|
||||
if f, e := samtunnelhandler.NewTunnelHandler(i2ptunhelper.NewSAMClientForwarderFromConf(s.config)); e == nil {
|
||||
log.Println("found default client")
|
||||
|
@@ -1,4 +1,5 @@
|
||||
// +build nostatic
|
||||
// +build !static !cli
|
||||
|
||||
package sammanager
|
||||
|
||||
|
41
manager/noui.go
Normal file
41
manager/noui.go
Normal file
@@ -0,0 +1,41 @@
|
||||
// +build cli
|
||||
// +build !nostatic !static
|
||||
|
||||
package sammanager
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"os/signal"
|
||||
"time"
|
||||
)
|
||||
|
||||
func (s *SAMManager )RunUI() {
|
||||
}
|
||||
|
||||
func (s *SAMManager) Serve() bool {
|
||||
log.Println("Starting Tunnels()")
|
||||
for _, element := range s.handlerMux.Tunnels() {
|
||||
log.Println("Starting service tunnel", element.ID())
|
||||
go element.Serve()
|
||||
}
|
||||
|
||||
return Exit()
|
||||
}
|
||||
|
||||
func Exit() bool {
|
||||
Close := false
|
||||
for !Close {
|
||||
time.Sleep(1 * time.Second)
|
||||
c := make(chan os.Signal, 1)
|
||||
signal.Notify(c, os.Interrupt)
|
||||
go func() {
|
||||
for sig := range c {
|
||||
log.Println(sig)
|
||||
|
||||
Close = true
|
||||
}
|
||||
}()
|
||||
}
|
||||
return false
|
||||
}
|
@@ -1,4 +1,5 @@
|
||||
// +build !nostatic
|
||||
// +build static
|
||||
// +build !nostatic !cli
|
||||
|
||||
package sammanager
|
||||
|
||||
|
@@ -79,6 +79,8 @@ var (
|
||||
"custom CSS for web interface")
|
||||
webJS = flag.String("js", "js/scripts.js",
|
||||
"custom JS for web interface")
|
||||
webDir = flag.String("wwwdir", "./www",
|
||||
"Default www directory to serve if starting eephttpd")
|
||||
leaseSetKey = flag.String("k", "none",
|
||||
"key for encrypted leaseset")
|
||||
leaseSetPrivateKey = flag.String("pk", "none",
|
||||
@@ -224,6 +226,7 @@ func lbMain(ctx context.Context) {
|
||||
config.ClientDest = config.GetClientDest(*targetDest, "", "")
|
||||
config.UserName = config.GetUserName(*webUser, "samcatd")
|
||||
config.Password = config.GetPassword(*webPass, "")
|
||||
config.ServeDirectory = config.GetWWWDir(*webDir, "./www")
|
||||
|
||||
c := make(chan os.Signal, 1)
|
||||
signal.Notify(c, os.Interrupt)
|
||||
|
@@ -27,6 +27,8 @@ type SAMClientForwarder struct {
|
||||
connectStream *sam3.StreamSession
|
||||
addr i2pkeys.I2PAddr
|
||||
publishConnection net.Listener
|
||||
Bytes map[string]int
|
||||
ByteLimit int
|
||||
|
||||
file io.ReadWriter
|
||||
up bool
|
||||
@@ -36,6 +38,9 @@ type SAMClientForwarder struct {
|
||||
}
|
||||
|
||||
func (f *SAMClientForwarder) Config() *i2ptunconf.Conf {
|
||||
if f.Conf == nil {
|
||||
f.Conf = i2ptunconf.NewI2PBlankTunConf()
|
||||
}
|
||||
return f.Conf
|
||||
}
|
||||
|
||||
@@ -242,7 +247,7 @@ func (s *SAMClientForwarder) Load() (samtunnel.SAMTunnel, error) {
|
||||
if err := sfi2pkeys.Save(s.Config().FilePath, s.Config().TunName, s.Config().KeyFilePath, s.SamKeys); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
log.Println("Saved tunnel keys for", s.Config().TunName)
|
||||
log.Println("Saved tunnel keys for", s.Conf.TunName, "in", s.Conf.FilePath)
|
||||
}
|
||||
s.Hasher, err = hashhash.NewHasher(len(strings.Replace(s.Base32(), ".b32.i2p", "", 1)))
|
||||
if err != nil {
|
||||
|
@@ -432,3 +432,11 @@ func SetKeyFile(s string) func(*SAMForwarder) error {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
//SetByteLimit sets the number of hops inbound
|
||||
func SetByteLimit(u int64) func(*SAMForwarder) error {
|
||||
return func(c *SAMForwarder) error {
|
||||
c.ByteLimit = u
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
@@ -30,6 +30,8 @@ type SAMForwarder struct {
|
||||
Hasher *hashhash.Hasher
|
||||
publishStream *sam3.StreamSession
|
||||
publishListen *sam3.StreamListener
|
||||
Bytes map[string]int64
|
||||
ByteLimit int64
|
||||
|
||||
file io.ReadWriter
|
||||
up bool
|
||||
@@ -47,6 +49,9 @@ type SAMForwarder struct {
|
||||
var err error
|
||||
|
||||
func (f *SAMForwarder) Config() *i2ptunconf.Conf {
|
||||
if f.Conf == nil {
|
||||
f.Conf = i2ptunconf.NewI2PBlankTunConf()
|
||||
}
|
||||
return f.Conf
|
||||
}
|
||||
|
||||
@@ -193,6 +198,11 @@ func (f *SAMForwarder) sam() string {
|
||||
return f.Config().SamHost + ":" + f.Config().SamPort
|
||||
}
|
||||
|
||||
func (f *SAMForwarder) ClientBase64(conn *sam3.SAMConn) string {
|
||||
dest := conn.RemoteAddr().(i2pkeys.I2PAddr)
|
||||
return dest.Base32()
|
||||
}
|
||||
|
||||
func (f *SAMForwarder) HTTPRequestBytes(conn *sam3.SAMConn) ([]byte, *http.Request, error) {
|
||||
var request *http.Request
|
||||
var retrequest []byte
|
||||
@@ -280,7 +290,18 @@ func (f *SAMForwarder) forward(conn *sam3.SAMConn) { //(conn net.Conn) {
|
||||
} else {
|
||||
defer client.Close()
|
||||
defer conn.Close()
|
||||
io.Copy(client, conn)
|
||||
if f.ByteLimit > 0 {
|
||||
if val, ok := f.Bytes[f.ClientBase64(conn)]; ok == true {
|
||||
if val > f.ByteLimit {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
if count, err := io.Copy(client, conn); err == nil {
|
||||
if f.ByteLimit > 0 {
|
||||
f.Bytes[f.ClientBase64(conn)] += count
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
go func() {
|
||||
@@ -296,6 +317,11 @@ func (f *SAMForwarder) forward(conn *sam3.SAMConn) { //(conn net.Conn) {
|
||||
} else {
|
||||
defer client.Close()
|
||||
defer conn.Close()
|
||||
if val, ok := f.Bytes[f.ClientBase64(conn)]; ok == true {
|
||||
if val > f.ByteLimit {
|
||||
return
|
||||
}
|
||||
}
|
||||
io.Copy(conn, client)
|
||||
}
|
||||
}()
|
||||
@@ -379,7 +405,7 @@ func (s *SAMForwarder) Load() (samtunnel.SAMTunnel, error) {
|
||||
if err := sfi2pkeys.Save(s.Conf.FilePath, s.Conf.TunName, s.Conf.KeyFilePath, s.SamKeys); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
log.Println("Saved tunnel keys for", s.Conf.TunName)
|
||||
log.Println("Saved tunnel keys for", s.Conf.TunName, "in", s.Conf.FilePath)
|
||||
}
|
||||
s.Hasher, err = hashhash.NewHasher(len(strings.Replace(s.Base32(), ".b32.i2p", "", 1)))
|
||||
if err != nil {
|
||||
@@ -400,6 +426,8 @@ func NewSAMForwarderFromOptions(opts ...func(*SAMForwarder) error) (*SAMForwarde
|
||||
s.Conf = i2ptunconf.NewI2PBlankTunConf()
|
||||
s.clientLock = false
|
||||
s.connLock = false
|
||||
s.ByteLimit = -1
|
||||
s.Bytes = make(map[string]int64)
|
||||
for _, o := range opts {
|
||||
if err := o(&s); err != nil {
|
||||
return nil, err
|
||||
|
@@ -36,6 +36,9 @@ type SAMSSUClientForwarder struct {
|
||||
}
|
||||
|
||||
func (f *SAMSSUClientForwarder) Config() *i2ptunconf.Conf {
|
||||
if f.Conf == nil {
|
||||
f.Conf = i2ptunconf.NewI2PBlankTunConf()
|
||||
}
|
||||
return f.Conf
|
||||
}
|
||||
|
||||
@@ -267,7 +270,7 @@ func (s *SAMSSUClientForwarder) Load() (samtunnel.SAMTunnel, error) {
|
||||
if err := sfi2pkeys.Save(s.Config().FilePath, s.Config().TunName, s.Config().KeyFilePath, s.SamKeys); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
log.Println("Saved tunnel keys for", s.Config().TunName)
|
||||
log.Println("Saved tunnel keys for", s.Conf.TunName, "in", s.Conf.FilePath)
|
||||
}
|
||||
s.Hasher, err = hashhash.NewHasher(len(strings.Replace(s.Base32(), ".b32.i2p", "", 1)))
|
||||
if err != nil {
|
||||
|
@@ -37,6 +37,9 @@ type SAMSSUForwarder struct {
|
||||
var err error
|
||||
|
||||
func (f *SAMSSUForwarder) Config() *i2ptunconf.Conf {
|
||||
if f.Conf == nil {
|
||||
f.Conf = i2ptunconf.NewI2PBlankTunConf()
|
||||
}
|
||||
return f.Conf
|
||||
}
|
||||
|
||||
@@ -282,7 +285,7 @@ func (s *SAMSSUForwarder) Load() (samtunnel.SAMTunnel, error) {
|
||||
if err := sfi2pkeys.Save(s.Config().FilePath, s.Config().TunName, s.Config().KeyFilePath, s.SamKeys); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
log.Println("Saved tunnel keys for", s.Config().TunName)
|
||||
log.Println("Saved tunnel keys for", s.Conf.TunName, "in", s.Conf.FilePath)
|
||||
}
|
||||
s.Hasher, err = hashhash.NewHasher(len(strings.Replace(s.Base32(), ".b32.i2p", "", 1)))
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user