bandwidth limits for TCP
This commit is contained in:
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
|
||||
}
|
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
|
||||
}
|
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"
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user