purge redundant config items!
This commit is contained in:
@ -96,7 +96,7 @@ func (c *Conf) PrintSlice() []string {
|
||||
c.lsspk(),
|
||||
}
|
||||
|
||||
log.Println(confstring)
|
||||
log.Println("Tunnel:", c.TunName, "using config:", confstring)
|
||||
return confstring
|
||||
}
|
||||
|
||||
|
@ -74,16 +74,16 @@ func (m *TunnelHandlerMux) Home(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprintf(w, "<!DOCTYPE html>\n")
|
||||
fmt.Fprintf(w, "<html>\n")
|
||||
fmt.Fprintf(w, "<head>\n")
|
||||
fmt.Fprintf(w, " <title>")
|
||||
fmt.Fprintf(w, "samcatd")
|
||||
fmt.Fprintf(w, " </title>")
|
||||
fmt.Fprintf(w, " <title>")
|
||||
fmt.Fprintf(w, "samcatd")
|
||||
fmt.Fprintf(w, " </title>")
|
||||
fmt.Fprintf(w, " <link rel=\"stylesheet\" href=\"/styles.css\">")
|
||||
fmt.Fprintf(w, "</head>\n")
|
||||
fmt.Fprintf(w, " <body>\n")
|
||||
fmt.Fprintf(w, " <h1>\n")
|
||||
w.Write([]byte(fmt.Sprintf(" <a href=\"/index.html\">Welcome %s! you are serving %d tunnels. </a>\n", m.user, len(m.tunnels))))
|
||||
//fmt.Fprintf(w, "")
|
||||
fmt.Fprintf(w, " </h1>\n")
|
||||
fmt.Fprintf(w, " </h1>\n")
|
||||
fmt.Fprintf(w, " <div id=\"toggleall\" class=\"global control\">\n")
|
||||
fmt.Fprintf(w, " <a href=\"#\" onclick=\"toggle_visibility_class('%s');\">Show/Hide %s</a>\n", "prop", "all")
|
||||
fmt.Fprintf(w, " </div>\n")
|
||||
|
@ -47,7 +47,7 @@ func PropSort(props map[string]string) []string {
|
||||
}
|
||||
|
||||
func (t *TunnelHandler) ControlForm(rw http.ResponseWriter, req *http.Request) {
|
||||
if err := req.ParseForm(); err == nil {
|
||||
if err := req.ParseForm(); err == nil {
|
||||
if action := req.PostFormValue("action"); action != "" {
|
||||
var err error
|
||||
switch action {
|
||||
@ -90,7 +90,7 @@ func (t *TunnelHandler) ControlForm(rw http.ResponseWriter, req *http.Request) {
|
||||
}
|
||||
|
||||
func (t *TunnelHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
||||
t.ControlForm(rw, req)
|
||||
t.ControlForm(rw, req)
|
||||
|
||||
if strings.HasSuffix(req.URL.Path, "color") {
|
||||
fmt.Fprintf(rw, " <div id=\"%s\" class=\"%s\" >", t.SAMTunnel.ID(), t.SAMTunnel.GetType())
|
||||
@ -112,7 +112,7 @@ func (t *TunnelHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
||||
}
|
||||
}
|
||||
if strings.HasSuffix(req.URL.Path, "color") {
|
||||
fmt.Fprintf(rw, " </div>\n\n")
|
||||
fmt.Fprintf(rw, " </div>\n\n")
|
||||
fmt.Fprintf(rw, " <div id=\"%s\" class=\"%s control panel\" >", t.SAMTunnel.ID()+".control", t.SAMTunnel.GetType())
|
||||
|
||||
fmt.Fprintf(rw, " <form class=\"linkstyle\" name=\"start\" action=\"/%s\" method=\"post\">", t.SAMTunnel.ID())
|
||||
|
@ -28,8 +28,8 @@ type SAMClientForwarder struct {
|
||||
addr i2pkeys.I2PAddr
|
||||
publishConnection net.Listener
|
||||
|
||||
file io.ReadWriter
|
||||
up bool
|
||||
file io.ReadWriter
|
||||
up bool
|
||||
|
||||
// config
|
||||
Conf *i2ptunconf.Conf
|
||||
@ -52,7 +52,7 @@ func (f *SAMClientForwarder) Keys() i2pkeys.I2PKeys {
|
||||
}
|
||||
|
||||
func (f *SAMClientForwarder) print() []string {
|
||||
return f.Config().PrintSlice()
|
||||
return f.Config().PrintSlice()
|
||||
}
|
||||
|
||||
func (f *SAMClientForwarder) Props() map[string]string {
|
||||
@ -260,8 +260,8 @@ func NewSAMClientForwarder(host, port string) (*SAMClientForwarder, error) {
|
||||
//NewSAMClientForwarderFromOptions makes a new SAM forwarder with default options, accepts host:port arguments
|
||||
func NewSAMClientForwarderFromOptions(opts ...func(*SAMClientForwarder) error) (*SAMClientForwarder, error) {
|
||||
var s SAMClientForwarder
|
||||
s.Conf = i2ptunconf.NewI2PBlankTunConf()
|
||||
s.Conf.Type = "tcpclient"
|
||||
s.Conf = i2ptunconf.NewI2PBlankTunConf()
|
||||
s.Conf.Type = "tcpclient"
|
||||
for _, o := range opts {
|
||||
if err := o(&s); err != nil {
|
||||
return nil, err
|
||||
|
@ -32,7 +32,7 @@ type SAMForwarder struct {
|
||||
publishListen *sam3.StreamListener
|
||||
|
||||
file io.ReadWriter
|
||||
up bool
|
||||
up bool
|
||||
|
||||
// conf
|
||||
Conf *i2ptunconf.Conf
|
||||
|
@ -11,7 +11,7 @@ type ClientOption func(*SAMSSUClientForwarder) error
|
||||
//SetClientFilePath sets the host of the SAMSSUForwarder's SAM bridge
|
||||
func SetClientFilePath(s string) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
c.FilePath = s
|
||||
c.Conf.FilePath = s
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@ -19,7 +19,7 @@ func SetClientFilePath(s string) func(*SAMSSUClientForwarder) error {
|
||||
//SetClientSaveFile tells the router to use an encrypted leaseset
|
||||
func SetClientSaveFile(b bool) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
c.save = b
|
||||
c.Conf.SaveFile = b
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@ -27,7 +27,7 @@ func SetClientSaveFile(b bool) func(*SAMSSUClientForwarder) error {
|
||||
//SetClientHost sets the host of the SAMSSUForwarder's SAM bridge
|
||||
func SetClientHost(s string) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
c.TargetHost = s
|
||||
c.Conf.TargetHost = s
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@ -40,7 +40,7 @@ func SetClientPort(s string) func(*SAMSSUClientForwarder) error {
|
||||
return fmt.Errorf("Invalid SSU Client Target Port %s; non-number ", s)
|
||||
}
|
||||
if port < 65536 && port > -1 {
|
||||
c.TargetPort = s
|
||||
c.Conf.TargetPort = s
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Invalid port")
|
||||
@ -50,7 +50,7 @@ func SetClientPort(s string) func(*SAMSSUClientForwarder) error {
|
||||
//SetClientSAMHost sets the host of the SAMSSUForwarder's SAM bridge
|
||||
func SetClientSAMHost(s string) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
c.SamHost = s
|
||||
c.Conf.SamHost = s
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@ -63,7 +63,7 @@ func SetClientSAMPort(s string) func(*SAMSSUClientForwarder) error {
|
||||
return fmt.Errorf("Invalid SAM Port %s; non-number", s)
|
||||
}
|
||||
if port < 65536 && port > -1 {
|
||||
c.SamPort = s
|
||||
c.Conf.SamPort = s
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Invalid port")
|
||||
@ -73,7 +73,7 @@ func SetClientSAMPort(s string) func(*SAMSSUClientForwarder) error {
|
||||
//SetClientDestination sets the destination to forwarder SAMClientForwarder's to
|
||||
func SetClientDestination(s string) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
c.dest = s
|
||||
c.Conf.ClientDest = s
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@ -81,7 +81,7 @@ func SetClientDestination(s string) func(*SAMSSUClientForwarder) error {
|
||||
//SetClientName sets the host of the SAMSSUForwarder's SAM bridge
|
||||
func SetClientName(s string) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
c.TunName = s
|
||||
c.Conf.TunName = s
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@ -90,19 +90,19 @@ func SetClientName(s string) func(*SAMSSUClientForwarder) error {
|
||||
func SetClientSigType(s string) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
if s == "" {
|
||||
c.sigType = ""
|
||||
c.Conf.SigType = ""
|
||||
} else if s == "DSA_SHA1" {
|
||||
c.sigType = "DSA_SHA1"
|
||||
c.Conf.SigType = "DSA_SHA1"
|
||||
} else if s == "ECDSA_SHA256_P256" {
|
||||
c.sigType = "ECDSA_SHA256_P256"
|
||||
c.Conf.SigType = "ECDSA_SHA256_P256"
|
||||
} else if s == "ECDSA_SHA384_P384" {
|
||||
c.sigType = "ECDSA_SHA384_P384"
|
||||
c.Conf.SigType = "ECDSA_SHA384_P384"
|
||||
} else if s == "ECDSA_SHA512_P521" {
|
||||
c.sigType = "ECDSA_SHA512_P521"
|
||||
c.Conf.SigType = "ECDSA_SHA512_P521"
|
||||
} else if s == "EdDSA_SHA512_Ed25519" {
|
||||
c.sigType = "EdDSA_SHA512_Ed25519"
|
||||
c.Conf.SigType = "EdDSA_SHA512_Ed25519"
|
||||
} else {
|
||||
c.sigType = "EdDSA_SHA512_Ed25519"
|
||||
c.Conf.SigType = "EdDSA_SHA512_Ed25519"
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -112,7 +112,7 @@ func SetClientSigType(s string) func(*SAMSSUClientForwarder) error {
|
||||
func SetClientInLength(u int) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
if u < 7 && u >= 0 {
|
||||
c.inLength = strconv.Itoa(u)
|
||||
c.Conf.InLength = u
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Invalid inbound tunnel length")
|
||||
@ -123,7 +123,7 @@ func SetClientInLength(u int) func(*SAMSSUClientForwarder) error {
|
||||
func SetClientOutLength(u int) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
if u < 7 && u >= 0 {
|
||||
c.outLength = strconv.Itoa(u)
|
||||
c.Conf.OutLength = u
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Invalid outbound tunnel length")
|
||||
@ -134,7 +134,7 @@ func SetClientOutLength(u int) func(*SAMSSUClientForwarder) error {
|
||||
func SetClientInVariance(i int) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
if i < 7 && i > -7 {
|
||||
c.inVariance = strconv.Itoa(i)
|
||||
c.Conf.InVariance = i
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Invalid inbound tunnel length")
|
||||
@ -145,7 +145,7 @@ func SetClientInVariance(i int) func(*SAMSSUClientForwarder) error {
|
||||
func SetClientOutVariance(i int) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
if i < 7 && i > -7 {
|
||||
c.outVariance = strconv.Itoa(i)
|
||||
c.Conf.OutVariance = i
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Invalid outbound tunnel variance")
|
||||
@ -156,7 +156,7 @@ func SetClientOutVariance(i int) func(*SAMSSUClientForwarder) error {
|
||||
func SetClientInQuantity(u int) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
if u <= 16 && u > 0 {
|
||||
c.inQuantity = strconv.Itoa(u)
|
||||
c.Conf.InQuantity = u
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Invalid inbound tunnel quantity")
|
||||
@ -167,7 +167,7 @@ func SetClientInQuantity(u int) func(*SAMSSUClientForwarder) error {
|
||||
func SetClientOutQuantity(u int) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
if u <= 16 && u > 0 {
|
||||
c.outQuantity = strconv.Itoa(u)
|
||||
c.Conf.OutQuantity = u
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Invalid outbound tunnel quantity")
|
||||
@ -178,7 +178,7 @@ func SetClientOutQuantity(u int) func(*SAMSSUClientForwarder) error {
|
||||
func SetClientInBackups(u int) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
if u < 6 && u >= 0 {
|
||||
c.inBackupQuantity = strconv.Itoa(u)
|
||||
c.Conf.InBackupQuantity = u
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Invalid inbound tunnel backup quantity")
|
||||
@ -189,7 +189,7 @@ func SetClientInBackups(u int) func(*SAMSSUClientForwarder) error {
|
||||
func SetClientOutBackups(u int) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
if u < 6 && u >= 0 {
|
||||
c.outBackupQuantity = strconv.Itoa(u)
|
||||
c.Conf.OutBackupQuantity = u
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Invalid outbound tunnel backup quantity")
|
||||
@ -200,10 +200,10 @@ func SetClientOutBackups(u int) func(*SAMSSUClientForwarder) error {
|
||||
func SetClientEncrypt(b bool) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
if b {
|
||||
c.encryptLeaseSet = "true"
|
||||
c.Conf.EncryptLeaseSet = true
|
||||
return nil
|
||||
}
|
||||
c.encryptLeaseSet = "false"
|
||||
c.Conf.EncryptLeaseSet = false
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@ -211,7 +211,7 @@ func SetClientEncrypt(b bool) func(*SAMSSUClientForwarder) error {
|
||||
//SetClientLeaseSetKey sets the host of the SAMForwarder's SAM bridge
|
||||
func SetClientLeaseSetKey(s string) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
c.leaseSetKey = s
|
||||
c.Conf.LeaseSetKey = s
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@ -219,7 +219,7 @@ func SetClientLeaseSetKey(s string) func(*SAMSSUClientForwarder) error {
|
||||
//SetClientLeaseSetPrivateKey sets the host of the SAMForwarder's SAM bridge
|
||||
func SetClientLeaseSetPrivateKey(s string) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
c.leaseSetPrivateKey = s
|
||||
c.Conf.LeaseSetPrivateKey = s
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@ -227,7 +227,7 @@ func SetClientLeaseSetPrivateKey(s string) func(*SAMSSUClientForwarder) error {
|
||||
//SetClientLeaseSetPrivateSigningKey sets the host of the SAMForwarder's SAM bridge
|
||||
func SetClientLeaseSetPrivateSigningKey(s string) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
c.leaseSetPrivateSigningKey = s
|
||||
c.Conf.LeaseSetPrivateSigningKey = s
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@ -235,7 +235,7 @@ func SetClientLeaseSetPrivateSigningKey(s string) func(*SAMSSUClientForwarder) e
|
||||
//SetClientMessageReliability sets
|
||||
func SetClientMessageReliability(s string) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
c.messageReliability = s
|
||||
c.Conf.MessageReliability = s
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@ -244,10 +244,10 @@ func SetClientMessageReliability(s string) func(*SAMSSUClientForwarder) error {
|
||||
func SetClientAllowZeroIn(b bool) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
if b {
|
||||
c.inAllowZeroHop = "true"
|
||||
c.Conf.InAllowZeroHop = true
|
||||
return nil
|
||||
}
|
||||
c.inAllowZeroHop = "false"
|
||||
c.Conf.InAllowZeroHop = false
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@ -256,10 +256,10 @@ func SetClientAllowZeroIn(b bool) func(*SAMSSUClientForwarder) error {
|
||||
func SetClientAllowZeroOut(b bool) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
if b {
|
||||
c.outAllowZeroHop = "true"
|
||||
c.Conf.OutAllowZeroHop = true
|
||||
return nil
|
||||
}
|
||||
c.outAllowZeroHop = "false"
|
||||
c.Conf.OutAllowZeroHop = false
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@ -268,10 +268,10 @@ func SetClientAllowZeroOut(b bool) func(*SAMSSUClientForwarder) error {
|
||||
func SetClientFastRecieve(b bool) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
if b {
|
||||
c.fastRecieve = "true"
|
||||
c.Conf.FastRecieve = true
|
||||
return nil
|
||||
}
|
||||
c.fastRecieve = "false"
|
||||
c.Conf.FastRecieve = false
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@ -280,10 +280,10 @@ func SetClientFastRecieve(b bool) func(*SAMSSUClientForwarder) error {
|
||||
func SetClientCompress(b bool) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
if b {
|
||||
c.useCompression = "true"
|
||||
c.Conf.UseCompression = true
|
||||
return nil
|
||||
}
|
||||
c.useCompression = "false"
|
||||
c.Conf.UseCompression = false
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@ -292,10 +292,10 @@ func SetClientCompress(b bool) func(*SAMSSUClientForwarder) error {
|
||||
func SetClientReduceIdle(b bool) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
if b {
|
||||
c.reduceIdle = "true"
|
||||
c.Conf.ReduceIdle = true
|
||||
return nil
|
||||
}
|
||||
c.reduceIdle = "false"
|
||||
c.Conf.ReduceIdle = false
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@ -303,9 +303,9 @@ func SetClientReduceIdle(b bool) func(*SAMSSUClientForwarder) error {
|
||||
//SetClientReduceIdleTime sets the time to wait before reducing tunnels to idle levels
|
||||
func SetClientReduceIdleTime(u int) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
c.reduceIdleTime = "300000"
|
||||
c.Conf.ReduceIdleTime = 300000
|
||||
if u >= 6 {
|
||||
c.reduceIdleTime = strconv.Itoa((u * 60) * 1000)
|
||||
c.Conf.ReduceIdleTime = (u * 60) * 1000
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Invalid reduce idle timeout(Measured in minutes)")
|
||||
@ -315,9 +315,9 @@ func SetClientReduceIdleTime(u int) func(*SAMSSUClientForwarder) error {
|
||||
//SetClientReduceIdleTimeMs sets the time to wait before reducing tunnels to idle levels in milliseconds
|
||||
func SetClientReduceIdleTimeMs(u int) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
c.reduceIdleTime = "300000"
|
||||
c.Conf.ReduceIdleTime = 300000
|
||||
if u >= 300000 {
|
||||
c.reduceIdleTime = strconv.Itoa(u)
|
||||
c.Conf.ReduceIdleTime = u
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Invalid reduce idle timeout(Measured in minutes)")
|
||||
@ -328,7 +328,7 @@ func SetClientReduceIdleTimeMs(u int) func(*SAMSSUClientForwarder) error {
|
||||
func SetClientReduceIdleQuantity(u int) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
if u < 5 {
|
||||
c.reduceIdleQuantity = strconv.Itoa(u)
|
||||
c.Conf.ReduceIdleQuantity = u
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Invalid reduce tunnel quantity")
|
||||
@ -339,10 +339,10 @@ func SetClientReduceIdleQuantity(u int) func(*SAMSSUClientForwarder) error {
|
||||
func SetClientCloseIdle(b bool) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
if b {
|
||||
c.closeIdle = "true"
|
||||
c.Conf.CloseIdle = true
|
||||
return nil
|
||||
}
|
||||
c.closeIdle = "false"
|
||||
c.Conf.CloseIdle = false
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@ -350,9 +350,9 @@ func SetClientCloseIdle(b bool) func(*SAMSSUClientForwarder) error {
|
||||
//SetClientCloseIdleTime sets the time to wait before closing tunnels to idle levels
|
||||
func SetClientCloseIdleTime(u int) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
c.closeIdleTime = "300000"
|
||||
c.Conf.CloseIdleTime = 300000
|
||||
if u >= 6 {
|
||||
c.closeIdleTime = strconv.Itoa((u * 60) * 1000)
|
||||
c.Conf.CloseIdleTime = (u * 60) * 1000
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Invalid close idle timeout(Measured in minutes) %v", u)
|
||||
@ -362,9 +362,9 @@ func SetClientCloseIdleTime(u int) func(*SAMSSUClientForwarder) error {
|
||||
//SetClientCloseIdleTimeMs sets the time to wait before closing tunnels to idle levels in milliseconds
|
||||
func SetClientCloseIdleTimeMs(u int) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
c.closeIdleTime = "300000"
|
||||
c.Conf.CloseIdleTime = 300000
|
||||
if u >= 300000 {
|
||||
c.closeIdleTime = strconv.Itoa(u)
|
||||
c.Conf.CloseIdleTime = u
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Invalid close idle timeout(Measured in milliseconds) %v", u)
|
||||
@ -375,16 +375,16 @@ func SetClientCloseIdleTimeMs(u int) func(*SAMSSUClientForwarder) error {
|
||||
func SetClientAccessListType(s string) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
if s == "whitelist" {
|
||||
c.accessListType = "whitelist"
|
||||
c.Conf.AccessListType = "whitelist"
|
||||
return nil
|
||||
} else if s == "blacklist" {
|
||||
c.accessListType = "blacklist"
|
||||
c.Conf.AccessListType = "blacklist"
|
||||
return nil
|
||||
} else if s == "none" {
|
||||
c.accessListType = ""
|
||||
c.Conf.AccessListType = ""
|
||||
return nil
|
||||
} else if s == "" {
|
||||
c.accessListType = ""
|
||||
c.Conf.AccessListType = ""
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Invalid Access list type(whitelist, blacklist, none)")
|
||||
@ -396,7 +396,7 @@ func SetClientAccessList(s []string) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
if len(s) > 0 {
|
||||
for _, a := range s {
|
||||
c.accessList = append(c.accessList, a)
|
||||
c.Conf.AccessList = append(c.Conf.AccessList, a)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -407,7 +407,7 @@ func SetClientAccessList(s []string) func(*SAMSSUClientForwarder) error {
|
||||
//SetKeyFile sets
|
||||
func SetClientPassword(s string) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
c.passfile = s
|
||||
c.Conf.KeyFilePath = s
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
@ -4,8 +4,6 @@ import (
|
||||
"io"
|
||||
"log"
|
||||
"net"
|
||||
//"os"
|
||||
//"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
@ -23,61 +21,18 @@ import (
|
||||
//SAMSSUClientForwarder is a structure which automatically configured the forwarding of
|
||||
//a local port to i2p over the SAM API.
|
||||
type SAMSSUClientForwarder struct {
|
||||
SamHost string
|
||||
SamPort string
|
||||
TunName string
|
||||
Type string
|
||||
|
||||
TargetHost string
|
||||
TargetPort string
|
||||
|
||||
samConn *sam3.SAM
|
||||
SamKeys i2pkeys.I2PKeys
|
||||
Hasher *hashhash.Hasher
|
||||
connectStream *sam3.DatagramSession
|
||||
dest string
|
||||
addr i2pkeys.I2PAddr
|
||||
publishConnection net.PacketConn
|
||||
|
||||
FilePath string
|
||||
file io.ReadWriter
|
||||
save bool
|
||||
up bool
|
||||
file io.ReadWriter
|
||||
up bool
|
||||
|
||||
// config
|
||||
Conf *i2ptunconf.Conf
|
||||
|
||||
// samcatd options
|
||||
passfile string
|
||||
sigType string
|
||||
|
||||
// I2CP options
|
||||
encryptLeaseSet string
|
||||
leaseSetKey string
|
||||
leaseSetPrivateKey string
|
||||
leaseSetPrivateSigningKey string
|
||||
inAllowZeroHop string
|
||||
outAllowZeroHop string
|
||||
inLength string
|
||||
outLength string
|
||||
inQuantity string
|
||||
outQuantity string
|
||||
inVariance string
|
||||
outVariance string
|
||||
inBackupQuantity string
|
||||
outBackupQuantity string
|
||||
fastRecieve string
|
||||
useCompression string
|
||||
messageReliability string
|
||||
closeIdle string
|
||||
closeIdleTime string
|
||||
reduceIdle string
|
||||
reduceIdleTime string
|
||||
reduceIdleQuantity string
|
||||
|
||||
//Streaming Library options
|
||||
accessListType string
|
||||
accessList []string
|
||||
}
|
||||
|
||||
func (f *SAMSSUClientForwarder) Config() *i2ptunconf.Conf {
|
||||
@ -85,11 +40,11 @@ func (f *SAMSSUClientForwarder) Config() *i2ptunconf.Conf {
|
||||
}
|
||||
|
||||
func (f *SAMSSUClientForwarder) GetType() string {
|
||||
return f.Type
|
||||
return f.Config().Type
|
||||
}
|
||||
|
||||
func (f *SAMSSUClientForwarder) ID() string {
|
||||
return f.TunName
|
||||
return f.Config().TunName
|
||||
}
|
||||
|
||||
func (f *SAMSSUClientForwarder) Keys() i2pkeys.I2PKeys {
|
||||
@ -109,32 +64,7 @@ func (f *SAMSSUClientForwarder) Close() error {
|
||||
}
|
||||
|
||||
func (f *SAMSSUClientForwarder) print() []string {
|
||||
lsk, lspk, lspsk := f.leasesetsettings()
|
||||
return []string{
|
||||
//f.targetForPort443(),
|
||||
"inbound.length=" + f.inLength,
|
||||
"outbound.length=" + f.outLength,
|
||||
"inbound.lengthVariance=" + f.inVariance,
|
||||
"outbound.lengthVariance=" + f.outVariance,
|
||||
"inbound.backupQuantity=" + f.inBackupQuantity,
|
||||
"outbound.backupQuantity=" + f.outBackupQuantity,
|
||||
"inbound.quantity=" + f.inQuantity,
|
||||
"outbound.quantity=" + f.outQuantity,
|
||||
"inbound.allowZeroHop=" + f.inAllowZeroHop,
|
||||
"outbound.allowZeroHop=" + f.outAllowZeroHop,
|
||||
"i2cp.fastRecieve=" + f.fastRecieve,
|
||||
"i2cp.gzip=" + f.useCompression,
|
||||
"i2cp.reduceOnIdle=" + f.reduceIdle,
|
||||
"i2cp.reduceIdleTime=" + f.reduceIdleTime,
|
||||
"i2cp.reduceQuantity=" + f.reduceIdleQuantity,
|
||||
"i2cp.closeOnIdle=" + f.closeIdle,
|
||||
"i2cp.closeIdleTime=" + f.closeIdleTime,
|
||||
"i2cp.messageReliability=" + f.messageReliability,
|
||||
"i2cp.encryptLeaseSet=" + f.encryptLeaseSet,
|
||||
lsk, lspk, lspsk,
|
||||
f.accesslisttype(),
|
||||
f.accesslist(),
|
||||
}
|
||||
return f.Config().PrintSlice()
|
||||
}
|
||||
|
||||
func (f *SAMSSUClientForwarder) Props() map[string]string {
|
||||
@ -152,11 +82,11 @@ func (f *SAMSSUClientForwarder) Props() map[string]string {
|
||||
|
||||
func (f *SAMSSUClientForwarder) Print() string {
|
||||
var r string
|
||||
r += "name=" + f.TunName + "\n"
|
||||
r += "type=" + f.Type + "\n"
|
||||
r += "name=" + f.Config().TunName + "\n"
|
||||
r += "type=" + f.Config().Type + "\n"
|
||||
r += "base32=" + f.Base32() + "\n"
|
||||
r += "base64=" + f.Base64() + "\n"
|
||||
r += "dest=" + f.dest + "\n"
|
||||
r += "dest=" + f.Config().ClientDest + "\n"
|
||||
r += "ssuclient\n"
|
||||
for _, s := range f.print() {
|
||||
r += s + "\n"
|
||||
@ -178,20 +108,20 @@ func (f *SAMSSUClientForwarder) Search(search string) string {
|
||||
}
|
||||
|
||||
func (f *SAMSSUClientForwarder) accesslisttype() string {
|
||||
if f.accessListType == "whitelist" {
|
||||
if f.Config().AccessListType == "whitelist" {
|
||||
return "i2cp.enableAccessList=true"
|
||||
} else if f.accessListType == "blacklist" {
|
||||
} else if f.Config().AccessListType == "blacklist" {
|
||||
return "i2cp.enableBlackList=true"
|
||||
} else if f.accessListType == "none" {
|
||||
} else if f.Config().AccessListType == "none" {
|
||||
return ""
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (f *SAMSSUClientForwarder) accesslist() string {
|
||||
if f.accessListType != "" && len(f.accessList) > 0 {
|
||||
if f.Config().AccessListType != "" && len(f.Config().AccessList) > 0 {
|
||||
r := ""
|
||||
for _, s := range f.accessList {
|
||||
for _, s := range f.Config().AccessList {
|
||||
r += s + ","
|
||||
}
|
||||
return "i2cp.accessList=" + strings.TrimSuffix(r, ",")
|
||||
@ -201,14 +131,14 @@ func (f *SAMSSUClientForwarder) accesslist() string {
|
||||
|
||||
func (f *SAMSSUClientForwarder) leasesetsettings() (string, string, string) {
|
||||
var r, s, t string
|
||||
if f.leaseSetKey != "" {
|
||||
r = "i2cp.leaseSetKey=" + f.leaseSetKey
|
||||
if f.Config().LeaseSetKey != "" {
|
||||
r = "i2cp.leaseSetKey=" + f.Config().LeaseSetKey
|
||||
}
|
||||
if f.leaseSetPrivateKey != "" {
|
||||
s = "i2cp.leaseSetPrivateKey=" + f.leaseSetPrivateKey
|
||||
if f.Config().LeaseSetPrivateKey != "" {
|
||||
s = "i2cp.leaseSetPrivateKey=" + f.Config().LeaseSetPrivateKey
|
||||
}
|
||||
if f.leaseSetPrivateSigningKey != "" {
|
||||
t = "i2cp.leaseSetPrivateSigningKey=" + f.leaseSetPrivateSigningKey
|
||||
if f.Config().LeaseSetPrivateSigningKey != "" {
|
||||
t = "i2cp.leaseSetPrivateSigningKey=" + f.Config().LeaseSetPrivateSigningKey
|
||||
}
|
||||
return r, s, t
|
||||
}
|
||||
@ -220,11 +150,11 @@ func (f *SAMSSUClientForwarder) Destination() string {
|
||||
|
||||
// Target returns the host:port of the local service you want to forward to i2p
|
||||
func (f *SAMSSUClientForwarder) Target() string {
|
||||
return f.TargetHost + ":" + f.TargetPort
|
||||
return f.Config().TargetHost + ":" + f.Config().TargetPort
|
||||
}
|
||||
|
||||
func (f *SAMSSUClientForwarder) sam() string {
|
||||
return f.SamHost + ":" + f.SamPort
|
||||
return f.Config().SamHost + ":" + f.Config().SamPort
|
||||
}
|
||||
|
||||
//Base32 returns the base32 address of the local destination
|
||||
@ -287,13 +217,13 @@ func (f *SAMSSUClientForwarder) errSleep(err error) bool {
|
||||
func (f *SAMSSUClientForwarder) Serve() error {
|
||||
var err error
|
||||
log.Println("Establishing a SAM datagram session.")
|
||||
if f.publishConnection, err = net.ListenPacket("udp", f.Target()); err != nil {
|
||||
if f.publishConnection, err = net.ListenPacket("udp", f.Config().Target()); err != nil {
|
||||
return err
|
||||
}
|
||||
//p, _ := strconv.Atoi(f.TargetPort)
|
||||
sp, _ := strconv.Atoi(f.SamPort)
|
||||
//p, _ := strconv.Atoi(f.Config().TargetPort)
|
||||
sp, _ := strconv.Atoi(f.Config().SamPort)
|
||||
f.connectStream, err = f.samConn.NewDatagramSession(
|
||||
f.TunName,
|
||||
f.Config().TunName,
|
||||
f.SamKeys,
|
||||
f.print(),
|
||||
sp-1,
|
||||
@ -306,7 +236,7 @@ func (f *SAMSSUClientForwarder) Serve() error {
|
||||
log.Println("Human-readable hash of Client:\n ", f.Base32Readable())
|
||||
/* Close := false
|
||||
for !Close {
|
||||
//addr, err := net.ResolveUDPAddr("udp", f.Target())
|
||||
//addr, err := net.ResolveUDPAddr("udp", f.Config().Target())
|
||||
Close = f.errSleep(err)
|
||||
//f.publishConnection, err = net.DialUDP("udp", nil, addr)
|
||||
Close = f.errSleep(err)
|
||||
@ -322,22 +252,22 @@ func (s *SAMSSUClientForwarder) Load() (samtunnel.SAMTunnel, error) {
|
||||
if s.samConn, err = sam3.NewSAM(s.sam()); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if s.addr, err = s.samConn.Lookup(s.dest); err != nil {
|
||||
if s.addr, err = s.samConn.Lookup(s.Config().ClientDest); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
log.Println("SAM Bridge connection established.")
|
||||
if s.save {
|
||||
if s.Config().SaveFile {
|
||||
log.Println("Saving i2p keys")
|
||||
}
|
||||
if s.SamKeys, err = sfi2pkeys.Load(s.FilePath, s.TunName, s.passfile, s.samConn, s.save); err != nil {
|
||||
if s.SamKeys, err = sfi2pkeys.Load(s.Config().FilePath, s.Config().TunName, s.Config().KeyFilePath, s.samConn, s.Config().SaveFile); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
log.Println("Destination keys generated, tunnel name:", s.TunName)
|
||||
if s.save {
|
||||
if err := sfi2pkeys.Save(s.FilePath, s.TunName, s.passfile, s.SamKeys); err != nil {
|
||||
log.Println("Destination keys generated, tunnel name:", s.Config().TunName)
|
||||
if s.Config().SaveFile {
|
||||
if err := sfi2pkeys.Save(s.Config().FilePath, s.Config().TunName, s.Config().KeyFilePath, s.SamKeys); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
log.Println("Saved tunnel keys for", s.TunName)
|
||||
log.Println("Saved tunnel keys for", s.Config().TunName)
|
||||
}
|
||||
s.Hasher, err = hashhash.NewHasher(len(strings.Replace(s.Base32(), ".b32.i2p", "", 1)))
|
||||
if err != nil {
|
||||
@ -350,39 +280,8 @@ func (s *SAMSSUClientForwarder) Load() (samtunnel.SAMTunnel, error) {
|
||||
//NewSAMSSUClientForwarderFromOptions makes a new SAM forwarder with default options, accepts host:port arguments
|
||||
func NewSAMSSUClientForwarderFromOptions(opts ...func(*SAMSSUClientForwarder) error) (*SAMSSUClientForwarder, error) {
|
||||
var s SAMSSUClientForwarder
|
||||
s.SamHost = "127.0.0.1"
|
||||
s.SamPort = "7656"
|
||||
s.FilePath = ""
|
||||
s.save = false
|
||||
s.TargetHost = "127.0.0.1"
|
||||
s.TargetPort = "0"
|
||||
s.TunName = "samSSUForwarder"
|
||||
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.fastRecieve = "false"
|
||||
s.useCompression = "true"
|
||||
s.encryptLeaseSet = "false"
|
||||
s.leaseSetKey = ""
|
||||
s.leaseSetPrivateKey = ""
|
||||
s.leaseSetPrivateSigningKey = ""
|
||||
s.reduceIdle = "false"
|
||||
s.reduceIdleTime = "15"
|
||||
s.closeIdle = "false"
|
||||
s.closeIdleTime = "30"
|
||||
s.reduceIdleQuantity = "4"
|
||||
s.dest = "none"
|
||||
s.Type = "udpclient"
|
||||
s.messageReliability = "none"
|
||||
s.passfile = ""
|
||||
s.dest = "i2p-projekt.i2p"
|
||||
s.Conf = i2ptunconf.NewI2PBlankTunConf()
|
||||
s.Conf.Type = "udpclient"
|
||||
for _, o := range opts {
|
||||
if err := o(&s); err != nil {
|
||||
return nil, err
|
||||
|
@ -11,7 +11,7 @@ type Option func(*SAMSSUForwarder) error
|
||||
//SetFilePath sets the host of the SAMSSUForwarder's SAM bridge
|
||||
func SetFilePath(s string) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
c.FilePath = s
|
||||
c.Conf.FilePath = s
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@ -19,7 +19,7 @@ func SetFilePath(s string) func(*SAMSSUForwarder) error {
|
||||
//SetSaveFile tells the router to use an encrypted leaseset
|
||||
func SetSaveFile(b bool) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
c.save = b
|
||||
c.Conf.SaveFile = b
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@ -27,7 +27,7 @@ func SetSaveFile(b bool) func(*SAMSSUForwarder) error {
|
||||
//SetHost sets the host of the SAMSSUForwarder's SAM bridge
|
||||
func SetHost(s string) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
c.TargetHost = s
|
||||
c.Conf.TargetHost = s
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@ -40,7 +40,7 @@ func SetPort(s string) func(*SAMSSUForwarder) error {
|
||||
return fmt.Errorf("Invalid SSU Server Target Port %s; non-number ", s)
|
||||
}
|
||||
if port < 65536 && port > -1 {
|
||||
c.TargetPort = s
|
||||
c.Conf.TargetPort = s
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Invalid port")
|
||||
@ -50,7 +50,7 @@ func SetPort(s string) func(*SAMSSUForwarder) error {
|
||||
//SetSAMHost sets the host of the SAMSSUForwarder's SAM bridge
|
||||
func SetSAMHost(s string) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
c.SamHost = s
|
||||
c.Conf.SamHost = s
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@ -63,7 +63,7 @@ func SetSAMPort(s string) func(*SAMSSUForwarder) error {
|
||||
return fmt.Errorf("Invalid SAM Port %s; non-number", s)
|
||||
}
|
||||
if port < 65536 && port > -1 {
|
||||
c.SamPort = s
|
||||
c.Conf.SamPort = s
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Invalid port")
|
||||
@ -73,7 +73,7 @@ func SetSAMPort(s string) func(*SAMSSUForwarder) error {
|
||||
//SetName sets the host of the SAMSSUForwarder's SAM bridge
|
||||
func SetName(s string) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
c.TunName = s
|
||||
c.Conf.TunName = s
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@ -82,19 +82,19 @@ func SetName(s string) func(*SAMSSUForwarder) error {
|
||||
func SetSigType(s string) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
if s == "" {
|
||||
c.sigType = ""
|
||||
c.Conf.SigType = ""
|
||||
} else if s == "DSA_SHA1" {
|
||||
c.sigType = "DSA_SHA1"
|
||||
c.Conf.SigType = "DSA_SHA1"
|
||||
} else if s == "ECDSA_SHA256_P256" {
|
||||
c.sigType = "ECDSA_SHA256_P256"
|
||||
c.Conf.SigType = "ECDSA_SHA256_P256"
|
||||
} else if s == "ECDSA_SHA384_P384" {
|
||||
c.sigType = "ECDSA_SHA384_P384"
|
||||
c.Conf.SigType = "ECDSA_SHA384_P384"
|
||||
} else if s == "ECDSA_SHA512_P521" {
|
||||
c.sigType = "ECDSA_SHA512_P521"
|
||||
c.Conf.SigType = "ECDSA_SHA512_P521"
|
||||
} else if s == "EdDSA_SHA512_Ed25519" {
|
||||
c.sigType = "EdDSA_SHA512_Ed25519"
|
||||
c.Conf.SigType = "EdDSA_SHA512_Ed25519"
|
||||
} else {
|
||||
c.sigType = "EdDSA_SHA512_Ed25519"
|
||||
c.Conf.SigType = "EdDSA_SHA512_Ed25519"
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -104,7 +104,7 @@ func SetSigType(s string) func(*SAMSSUForwarder) error {
|
||||
func SetInLength(u int) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
if u < 7 && u >= 0 {
|
||||
c.inLength = strconv.Itoa(u)
|
||||
c.Conf.InLength = u
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Invalid inbound tunnel length")
|
||||
@ -115,7 +115,7 @@ func SetInLength(u int) func(*SAMSSUForwarder) error {
|
||||
func SetOutLength(u int) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
if u < 7 && u >= 0 {
|
||||
c.outLength = strconv.Itoa(u)
|
||||
c.Conf.OutLength = u
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Invalid outbound tunnel length")
|
||||
@ -126,7 +126,7 @@ func SetOutLength(u int) func(*SAMSSUForwarder) error {
|
||||
func SetInVariance(i int) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
if i < 7 && i > -7 {
|
||||
c.inVariance = strconv.Itoa(i)
|
||||
c.Conf.InVariance = i
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Invalid inbound tunnel length")
|
||||
@ -137,7 +137,7 @@ func SetInVariance(i int) func(*SAMSSUForwarder) error {
|
||||
func SetOutVariance(i int) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
if i < 7 && i > -7 {
|
||||
c.outVariance = strconv.Itoa(i)
|
||||
c.Conf.OutVariance = i
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Invalid outbound tunnel variance")
|
||||
@ -148,7 +148,7 @@ func SetOutVariance(i int) func(*SAMSSUForwarder) error {
|
||||
func SetInQuantity(u int) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
if u <= 16 && u > 0 {
|
||||
c.inQuantity = strconv.Itoa(u)
|
||||
c.Conf.InQuantity = u
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Invalid inbound tunnel quantity")
|
||||
@ -159,7 +159,7 @@ func SetInQuantity(u int) func(*SAMSSUForwarder) error {
|
||||
func SetOutQuantity(u int) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
if u <= 16 && u > 0 {
|
||||
c.outQuantity = strconv.Itoa(u)
|
||||
c.Conf.OutQuantity = u
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Invalid outbound tunnel quantity")
|
||||
@ -170,7 +170,7 @@ func SetOutQuantity(u int) func(*SAMSSUForwarder) error {
|
||||
func SetInBackups(u int) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
if u < 6 && u >= 0 {
|
||||
c.inBackupQuantity = strconv.Itoa(u)
|
||||
c.Conf.InBackupQuantity = u
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Invalid inbound tunnel backup quantity")
|
||||
@ -181,7 +181,7 @@ func SetInBackups(u int) func(*SAMSSUForwarder) error {
|
||||
func SetOutBackups(u int) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
if u < 6 && u >= 0 {
|
||||
c.outBackupQuantity = strconv.Itoa(u)
|
||||
c.Conf.OutBackupQuantity = u
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Invalid outbound tunnel backup quantity")
|
||||
@ -192,10 +192,10 @@ func SetOutBackups(u int) func(*SAMSSUForwarder) error {
|
||||
func SetEncrypt(b bool) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
if b {
|
||||
c.encryptLeaseSet = "true"
|
||||
c.Conf.EncryptLeaseSet = true
|
||||
return nil
|
||||
}
|
||||
c.encryptLeaseSet = "false"
|
||||
c.Conf.EncryptLeaseSet = false
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@ -203,7 +203,7 @@ func SetEncrypt(b bool) func(*SAMSSUForwarder) error {
|
||||
//SetLeaseSetKey sets
|
||||
func SetLeaseSetKey(s string) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
c.leaseSetKey = s
|
||||
c.Conf.LeaseSetKey = s
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@ -211,7 +211,7 @@ func SetLeaseSetKey(s string) func(*SAMSSUForwarder) error {
|
||||
//SetLeaseSetPrivateKey sets
|
||||
func SetLeaseSetPrivateKey(s string) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
c.leaseSetPrivateKey = s
|
||||
c.Conf.LeaseSetPrivateKey = s
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@ -219,7 +219,7 @@ func SetLeaseSetPrivateKey(s string) func(*SAMSSUForwarder) error {
|
||||
//SetLeaseSetPrivateSigningKey sets
|
||||
func SetLeaseSetPrivateSigningKey(s string) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
c.leaseSetPrivateSigningKey = s
|
||||
c.Conf.LeaseSetPrivateSigningKey = s
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@ -227,7 +227,7 @@ func SetLeaseSetPrivateSigningKey(s string) func(*SAMSSUForwarder) error {
|
||||
//SetMessageReliability sets
|
||||
func SetMessageReliability(s string) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
c.messageReliability = s
|
||||
c.Conf.MessageReliability = s
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@ -236,10 +236,10 @@ func SetMessageReliability(s string) func(*SAMSSUForwarder) error {
|
||||
func SetAllowZeroIn(b bool) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
if b {
|
||||
c.inAllowZeroHop = "true"
|
||||
c.Conf.InAllowZeroHop = true
|
||||
return nil
|
||||
}
|
||||
c.inAllowZeroHop = "false"
|
||||
c.Conf.InAllowZeroHop = false
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@ -248,10 +248,10 @@ func SetAllowZeroIn(b bool) func(*SAMSSUForwarder) error {
|
||||
func SetAllowZeroOut(b bool) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
if b {
|
||||
c.outAllowZeroHop = "true"
|
||||
c.Conf.OutAllowZeroHop = true
|
||||
return nil
|
||||
}
|
||||
c.outAllowZeroHop = "false"
|
||||
c.Conf.OutAllowZeroHop = false
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@ -260,10 +260,10 @@ func SetAllowZeroOut(b bool) func(*SAMSSUForwarder) error {
|
||||
func SetFastRecieve(b bool) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
if b {
|
||||
c.fastRecieve = "true"
|
||||
c.Conf.FastRecieve = true
|
||||
return nil
|
||||
}
|
||||
c.fastRecieve = "false"
|
||||
c.Conf.FastRecieve = false
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@ -272,10 +272,10 @@ func SetFastRecieve(b bool) func(*SAMSSUForwarder) error {
|
||||
func SetCompress(b bool) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
if b {
|
||||
c.useCompression = "true"
|
||||
c.Conf.UseCompression = true
|
||||
return nil
|
||||
}
|
||||
c.useCompression = "false"
|
||||
c.Conf.UseCompression = false
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@ -284,10 +284,10 @@ func SetCompress(b bool) func(*SAMSSUForwarder) error {
|
||||
func SetReduceIdle(b bool) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
if b {
|
||||
c.reduceIdle = "true"
|
||||
c.Conf.ReduceIdle = true
|
||||
return nil
|
||||
}
|
||||
c.reduceIdle = "false"
|
||||
c.Conf.ReduceIdle = false
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@ -295,9 +295,9 @@ func SetReduceIdle(b bool) func(*SAMSSUForwarder) error {
|
||||
//SetReduceIdleTime sets the time to wait before reducing tunnels to idle levels
|
||||
func SetReduceIdleTime(u int) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
c.reduceIdleTime = "300000"
|
||||
c.Conf.ReduceIdleTime = 300000
|
||||
if u >= 6 {
|
||||
c.reduceIdleTime = strconv.Itoa((u * 60) * 1000)
|
||||
c.Conf.ReduceIdleTime = (u * 60) * 1000
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Invalid close idle timeout(Measured in minutes) %v", u)
|
||||
@ -307,9 +307,9 @@ func SetReduceIdleTime(u int) func(*SAMSSUForwarder) error {
|
||||
//SetReduceIdleTimeMs sets the time to wait before reducing tunnels to idle levels in milliseconds
|
||||
func SetReduceIdleTimeMs(u int) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
c.reduceIdleTime = "300000"
|
||||
c.Conf.ReduceIdleTime = 300000
|
||||
if u >= 300000 {
|
||||
c.reduceIdleTime = strconv.Itoa(u)
|
||||
c.Conf.ReduceIdleTime = u
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Invalid close idle timeout(Measured in milliseconds) %v", u)
|
||||
@ -320,7 +320,7 @@ func SetReduceIdleTimeMs(u int) func(*SAMSSUForwarder) error {
|
||||
func SetReduceIdleQuantity(u int) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
if u < 5 {
|
||||
c.reduceIdleQuantity = strconv.Itoa(u)
|
||||
c.Conf.ReduceIdleQuantity = u
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Invalid reduce tunnel quantity")
|
||||
@ -331,10 +331,10 @@ func SetReduceIdleQuantity(u int) func(*SAMSSUForwarder) error {
|
||||
func SetCloseIdle(b bool) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
if b {
|
||||
c.closeIdle = "true"
|
||||
c.Conf.CloseIdle = true
|
||||
return nil
|
||||
}
|
||||
c.closeIdle = "false"
|
||||
c.Conf.CloseIdle = false
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@ -342,9 +342,9 @@ func SetCloseIdle(b bool) func(*SAMSSUForwarder) error {
|
||||
//SetCloseIdleTime sets the time to wait before closing tunnels to idle levels
|
||||
func SetCloseIdleTime(u int) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
c.closeIdleTime = "300000"
|
||||
c.Conf.CloseIdleTime = 300000
|
||||
if u >= 6 {
|
||||
c.closeIdleTime = strconv.Itoa((u * 60) * 2000)
|
||||
c.Conf.CloseIdleTime = (u * 60) * 1000
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Invalid reduce idle timeout(Measured in minutes)")
|
||||
@ -354,9 +354,9 @@ func SetCloseIdleTime(u int) func(*SAMSSUForwarder) error {
|
||||
//SetCloseIdleTimeMs sets the time to wait before closing tunnels to idle levels in milliseconds
|
||||
func SetCloseIdleTimeMs(u int) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
c.closeIdleTime = "300000"
|
||||
c.Conf.CloseIdleTime = 300000
|
||||
if u >= 300000 {
|
||||
c.closeIdleTime = strconv.Itoa(u)
|
||||
c.Conf.CloseIdleTime = u
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Invalid reduce idle timeout(Measured in minutes)")
|
||||
@ -367,16 +367,16 @@ func SetCloseIdleTimeMs(u int) func(*SAMSSUForwarder) error {
|
||||
func SetAccessListType(s string) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
if s == "whitelist" {
|
||||
c.accessListType = "whitelist"
|
||||
c.Conf.AccessListType = "whitelist"
|
||||
return nil
|
||||
} else if s == "blacklist" {
|
||||
c.accessListType = "blacklist"
|
||||
c.Conf.AccessListType = "blacklist"
|
||||
return nil
|
||||
} else if s == "none" {
|
||||
c.accessListType = ""
|
||||
c.Conf.AccessListType = ""
|
||||
return nil
|
||||
} else if s == "" {
|
||||
c.accessListType = ""
|
||||
c.Conf.AccessListType = ""
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Invalid Access list type(whitelist, blacklist, none)")
|
||||
@ -388,7 +388,7 @@ func SetAccessList(s []string) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
if len(s) > 0 {
|
||||
for _, a := range s {
|
||||
c.accessList = append(c.accessList, a)
|
||||
c.Conf.AccessList = append(c.Conf.AccessList, a)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -399,7 +399,7 @@ func SetAccessList(s []string) func(*SAMSSUForwarder) error {
|
||||
//SetKeyFile sets
|
||||
func SetKeyFile(s string) func(*SAMSSUForwarder) error {
|
||||
return func(c *SAMSSUForwarder) error {
|
||||
c.passfile = s
|
||||
c.Conf.KeyFilePath = s
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
@ -4,8 +4,6 @@ import (
|
||||
"io"
|
||||
"log"
|
||||
"net"
|
||||
//"os"
|
||||
//"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
@ -23,59 +21,17 @@ import (
|
||||
//SAMSSUForwarder is a structure which automatically configured the forwarding of
|
||||
//a local service to i2p over the SAM API.
|
||||
type SAMSSUForwarder struct {
|
||||
SamHost string
|
||||
SamPort string
|
||||
TunName string
|
||||
Type string
|
||||
|
||||
TargetHost string
|
||||
TargetPort string
|
||||
|
||||
samConn *sam3.SAM
|
||||
SamKeys i2pkeys.I2PKeys
|
||||
Hasher *hashhash.Hasher
|
||||
publishConnection *sam3.DatagramSession
|
||||
clientConnection net.PacketConn
|
||||
|
||||
FilePath string
|
||||
file io.ReadWriter
|
||||
save bool
|
||||
up bool
|
||||
file io.ReadWriter
|
||||
up bool
|
||||
|
||||
// config
|
||||
Conf *i2ptunconf.Conf
|
||||
|
||||
// samcatd options
|
||||
passfile string
|
||||
sigType string
|
||||
|
||||
// I2CP options
|
||||
encryptLeaseSet string
|
||||
leaseSetKey string
|
||||
leaseSetPrivateKey string
|
||||
leaseSetPrivateSigningKey string
|
||||
inAllowZeroHop string
|
||||
outAllowZeroHop string
|
||||
inLength string
|
||||
outLength string
|
||||
inQuantity string
|
||||
outQuantity string
|
||||
inVariance string
|
||||
outVariance string
|
||||
inBackupQuantity string
|
||||
outBackupQuantity string
|
||||
fastRecieve string
|
||||
useCompression string
|
||||
messageReliability string
|
||||
closeIdle string
|
||||
closeIdleTime string
|
||||
reduceIdle string
|
||||
reduceIdleTime string
|
||||
reduceIdleQuantity string
|
||||
|
||||
//Streaming Library options
|
||||
accessListType string
|
||||
accessList []string
|
||||
}
|
||||
|
||||
var err error
|
||||
@ -85,11 +41,11 @@ func (f *SAMSSUForwarder) Config() *i2ptunconf.Conf {
|
||||
}
|
||||
|
||||
func (f *SAMSSUForwarder) GetType() string {
|
||||
return f.Type
|
||||
return f.Config().Type
|
||||
}
|
||||
|
||||
func (f *SAMSSUForwarder) ID() string {
|
||||
return f.TunName
|
||||
return f.Config().TunName
|
||||
}
|
||||
|
||||
func (f *SAMSSUForwarder) Keys() i2pkeys.I2PKeys {
|
||||
@ -107,7 +63,7 @@ func (f *SAMSSUForwarder) Close() error {
|
||||
}
|
||||
|
||||
func (f *SAMSSUForwarder) print() []string {
|
||||
lsk, lspk, lspsk := f.leasesetsettings()
|
||||
/*lsk, lspk, lspsk := f.leasesetsettings()
|
||||
return []string{
|
||||
//f.targetForPort443(),
|
||||
"inbound.length=" + f.inLength,
|
||||
@ -132,7 +88,8 @@ func (f *SAMSSUForwarder) print() []string {
|
||||
lsk, lspk, lspsk,
|
||||
f.accesslisttype(),
|
||||
f.accesslist(),
|
||||
}
|
||||
}*/
|
||||
return f.Config().PrintSlice()
|
||||
}
|
||||
|
||||
func (f *SAMSSUForwarder) Props() map[string]string {
|
||||
@ -150,8 +107,8 @@ func (f *SAMSSUForwarder) Props() map[string]string {
|
||||
|
||||
func (f *SAMSSUForwarder) Print() string {
|
||||
var r string
|
||||
r += "name=" + f.TunName + "\n"
|
||||
r += "type=" + f.Type + "\n"
|
||||
r += "name=" + f.Config().TunName + "\n"
|
||||
r += "type=" + f.Config().Type + "\n"
|
||||
r += "base32=" + f.Base32() + "\n"
|
||||
r += "base64=" + f.Base64() + "\n"
|
||||
r += "ssuserver\n"
|
||||
@ -175,20 +132,20 @@ func (f *SAMSSUForwarder) Search(search string) string {
|
||||
}
|
||||
|
||||
func (f *SAMSSUForwarder) accesslisttype() string {
|
||||
if f.accessListType == "whitelist" {
|
||||
if f.Config().AccessListType == "whitelist" {
|
||||
return "i2cp.enableAccessList=true"
|
||||
} else if f.accessListType == "blacklist" {
|
||||
} else if f.Config().AccessListType == "blacklist" {
|
||||
return "i2cp.enableBlackList=true"
|
||||
} else if f.accessListType == "none" {
|
||||
} else if f.Config().AccessListType == "none" {
|
||||
return ""
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (f *SAMSSUForwarder) accesslist() string {
|
||||
if f.accessListType != "" && len(f.accessList) > 0 {
|
||||
if f.Config().AccessListType != "" && len(f.Config().AccessList) > 0 {
|
||||
r := ""
|
||||
for _, s := range f.accessList {
|
||||
for _, s := range f.Config().AccessList {
|
||||
r += s + ","
|
||||
}
|
||||
return "i2cp.accessList=" + strings.TrimSuffix(r, ",")
|
||||
@ -198,25 +155,25 @@ func (f *SAMSSUForwarder) accesslist() string {
|
||||
|
||||
func (f *SAMSSUForwarder) leasesetsettings() (string, string, string) {
|
||||
var r, s, t string
|
||||
if f.leaseSetKey != "" {
|
||||
r = "i2cp.leaseSetKey=" + f.leaseSetKey
|
||||
if f.Config().LeaseSetKey != "" {
|
||||
r = "i2cp.leaseSetKey=" + f.Config().LeaseSetKey
|
||||
}
|
||||
if f.leaseSetPrivateKey != "" {
|
||||
s = "i2cp.leaseSetPrivateKey=" + f.leaseSetPrivateKey
|
||||
if f.Config().LeaseSetPrivateKey != "" {
|
||||
s = "i2cp.leaseSetPrivateKey=" + f.Config().LeaseSetPrivateKey
|
||||
}
|
||||
if f.leaseSetPrivateSigningKey != "" {
|
||||
t = "i2cp.leaseSetPrivateSigningKey=" + f.leaseSetPrivateSigningKey
|
||||
if f.Config().LeaseSetPrivateSigningKey != "" {
|
||||
t = "i2cp.leaseSetPrivateSigningKey=" + f.Config().LeaseSetPrivateSigningKey
|
||||
}
|
||||
return r, s, t
|
||||
}
|
||||
|
||||
// Target returns the host:port of the local service you want to forward to i2p
|
||||
func (f *SAMSSUForwarder) Target() string {
|
||||
return f.TargetHost + ":" + f.TargetPort
|
||||
return f.Config().TargetHost + ":" + f.Config().TargetPort
|
||||
}
|
||||
|
||||
func (f *SAMSSUForwarder) sam() string {
|
||||
return f.SamHost + ":" + f.SamPort
|
||||
return f.Config().SamHost + ":" + f.Config().SamPort
|
||||
}
|
||||
|
||||
//func (f *SAMSSUForwarder) forward(conn net.Conn) {
|
||||
@ -224,10 +181,10 @@ func (f *SAMSSUForwarder) forward() {
|
||||
Loop := false
|
||||
if f.clientConnection == nil {
|
||||
for !Loop {
|
||||
log.Println("Attempting to resolve local UDP Service to forward to I2P", f.Target())
|
||||
addr, err := net.ResolveUDPAddr("udp", f.Target())
|
||||
log.Println("Attempting to resolve local UDP Service to forward to I2P", f.Config().Target())
|
||||
addr, err := net.ResolveUDPAddr("udp", f.Config().Target())
|
||||
Loop = f.errSleep(err)
|
||||
log.Println("Attempting to dial resolved UDP Address", f.Target())
|
||||
log.Println("Attempting to dial resolved UDP Address", f.Config().Target())
|
||||
f.clientConnection, err = net.DialUDP("udp", nil, addr)
|
||||
Loop = f.errSleep(err)
|
||||
log.Printf("Connected %v to localhost %v\n", f.publishConnection, f.clientConnection)
|
||||
@ -287,9 +244,9 @@ func (f *SAMSSUForwarder) errSleep(err error) bool {
|
||||
func (f *SAMSSUForwarder) Serve() error {
|
||||
var err error
|
||||
|
||||
sp, _ := strconv.Atoi(f.SamPort)
|
||||
sp, _ := strconv.Atoi(f.Config().SamPort)
|
||||
f.publishConnection, err = f.samConn.NewDatagramSession(
|
||||
f.TunName,
|
||||
f.Config().TunName,
|
||||
f.SamKeys,
|
||||
f.print(),
|
||||
sp-1,
|
||||
@ -314,18 +271,18 @@ func (s *SAMSSUForwarder) Load() (samtunnel.SAMTunnel, error) {
|
||||
return nil, err
|
||||
}
|
||||
log.Println("SAM Bridge connection established.")
|
||||
if s.save {
|
||||
if s.Config().SaveFile {
|
||||
log.Println("Saving i2p keys")
|
||||
}
|
||||
if s.SamKeys, err = sfi2pkeys.Load(s.FilePath, s.TunName, s.passfile, s.samConn, s.save); err != nil {
|
||||
if s.SamKeys, err = sfi2pkeys.Load(s.Config().FilePath, s.Config().TunName, s.Config().KeyFilePath, s.samConn, s.Config().SaveFile); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
log.Println("Destination keys generated, tunnel name:", s.TunName)
|
||||
if s.save {
|
||||
if err := sfi2pkeys.Save(s.FilePath, s.TunName, s.passfile, s.SamKeys); err != nil {
|
||||
log.Println("Destination keys generated, tunnel name:", s.Config().TunName)
|
||||
if s.Config().SaveFile {
|
||||
if err := sfi2pkeys.Save(s.Config().FilePath, s.Config().TunName, s.Config().KeyFilePath, s.SamKeys); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
log.Println("Saved tunnel keys for", s.TunName)
|
||||
log.Println("Saved tunnel keys for", s.Config().TunName)
|
||||
}
|
||||
s.Hasher, err = hashhash.NewHasher(len(strings.Replace(s.Base32(), ".b32.i2p", "", 1)))
|
||||
if err != nil {
|
||||
@ -347,37 +304,8 @@ func NewSAMSSUForwarder(host, port string) (*SAMSSUForwarder, error) {
|
||||
//NewSAMSSUForwarderFromOptions makes a new SAM forwarder with default options, accepts host:port arguments
|
||||
func NewSAMSSUForwarderFromOptions(opts ...func(*SAMSSUForwarder) error) (*SAMSSUForwarder, error) {
|
||||
var s SAMSSUForwarder
|
||||
s.SamHost = "127.0.0.1"
|
||||
s.SamPort = "7656"
|
||||
s.FilePath = ""
|
||||
s.save = false
|
||||
s.TargetHost = "127.0.0.1"
|
||||
s.TargetPort = "8081"
|
||||
s.TunName = "samSSUForwarder"
|
||||
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.fastRecieve = "false"
|
||||
s.useCompression = "true"
|
||||
s.encryptLeaseSet = "false"
|
||||
s.leaseSetKey = ""
|
||||
s.leaseSetPrivateKey = ""
|
||||
s.leaseSetPrivateSigningKey = ""
|
||||
s.reduceIdle = "false"
|
||||
s.reduceIdleTime = "300000"
|
||||
s.closeIdle = "false"
|
||||
s.closeIdleTime = "300000"
|
||||
s.reduceIdleQuantity = "4"
|
||||
s.Type = "udpserver"
|
||||
s.messageReliability = "none"
|
||||
s.passfile = ""
|
||||
s.Conf = i2ptunconf.NewI2PBlankTunConf()
|
||||
s.Conf.Type = "udpserver"
|
||||
for _, o := range opts {
|
||||
if err := o(&s); err != nil {
|
||||
return nil, err
|
||||
|
Reference in New Issue
Block a user