enabled setting client destinations from ini file.
This commit is contained in:
@ -81,12 +81,12 @@ I'm eventually going to make the manager implement net.Conn. This won't be
|
||||
exposed in the default application probably though, but rather as a library.
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
|
||||
iQEzBAEBCAAdFiEEcNIGBzi++AUjrK/311wDs5teFOEFAluiarYACgkQ11wDs5te
|
||||
FOFb/wgAi8jrj66r8vaEnkABlOSpNems7X5jJbh3FcUVjo8tQPVANzaHf0nBo3yl
|
||||
zi0ccERToNyDKqwo9J4z+OxXv5vv3A90uJaKUASMn34a84WQ4SD0jQ4RCsrkQqaa
|
||||
du8HIUclfXr67qoYJx4OiE6biBJ2f9r8I243ll8RN/8eI1O55kWEhLn/k2hAqPHV
|
||||
fI5OarJdaaM3ltKwsMXAPzNjm4tAyFaBLQbDcPUf3557zUFOwBA+qy17oeBmwklR
|
||||
ALBhPnpEWVpVdV64zcVPQTkoLx9NXY8HwwMQQ/ROmA0tHs39NktHgkFPpuJhx1fs
|
||||
sy0o9xWgzFHu7tmXTRMrS/ToX3GAEw==
|
||||
=cOx/
|
||||
iQEzBAEBCAAdFiEEcNIGBzi++AUjrK/311wDs5teFOEFAluidHEACgkQ11wDs5te
|
||||
FOFRDQgAigrVlLTqIXoExr2pa9UMsW2l+9586Ma+mIkUpUkQMxhi3Tp+mZa5JJRZ
|
||||
bbBO8Fum+kmLcZBR2R9xLP7v+Td72+mVOff3lJ0MvoiBfrZ9Yyrv+0j9HJ+alctd
|
||||
4wZt3zc7860togquQ99OXMVfY8Q/Xse/RwgGlPNl3iq9gQK+xoFUBVT0YuJLs4n0
|
||||
K0ayVYJdKrSpfyStAxD2TegGrJWCh3r8uxfSqhcO6VjdC7Nd/1s63Oq8EK9lMGro
|
||||
eoiTKdOocMmEMm6B5ZDn4l9oFuHTMAnIPrFNmMtR7qY+FmLfxiGrsPrGxFBpbrN3
|
||||
R1hayLzsaK+i5WYnGl5W0tuzsMEtdA==
|
||||
=Du9h
|
||||
-----END PGP SIGNATURE-----
|
||||
|
27
config/dest.go
Normal file
27
config/dest.go
Normal file
@ -0,0 +1,27 @@
|
||||
package i2ptunconf
|
||||
|
||||
// GetClientDest takes an argument and a default. If the argument differs from the
|
||||
// default, the argument is always returned. If the argument and default are
|
||||
// the same and the key exists, the key is returned. If the key is absent, the
|
||||
// default is returned.
|
||||
func (c *Conf) GetClientDest(arg, def string, label ...string) string {
|
||||
if arg != def {
|
||||
return arg
|
||||
}
|
||||
if c.config == nil {
|
||||
return arg
|
||||
}
|
||||
if x, o := c.Get("destination", label...); o {
|
||||
return x
|
||||
}
|
||||
return arg
|
||||
}
|
||||
|
||||
// SetClientDest sets the key name from the config file
|
||||
func (c *Conf) SetClientDest(label ...string) {
|
||||
if v, ok := c.Get("destination", label...); ok {
|
||||
c.ClientDest = v
|
||||
} else {
|
||||
c.ClientDest = v
|
||||
}
|
||||
}
|
@ -21,6 +21,7 @@ type Conf struct {
|
||||
KeyFilePath string
|
||||
Labels []string
|
||||
Client bool
|
||||
ClientDest string
|
||||
Type string
|
||||
SaveDirectory string
|
||||
SaveFile bool
|
||||
@ -212,6 +213,7 @@ func (c *Conf) I2PINILoad(iniFile string, label ...string) error {
|
||||
c.SetAccessListType(label...)
|
||||
c.SetTargetPort443(label...)
|
||||
c.SetMessageReliability(label...)
|
||||
c.SetClientDest(label...)
|
||||
c.SetKeyFile(label...)
|
||||
if v, ok := c.Get("i2cp.accessList", label...); ok {
|
||||
csv := strings.Split(v, ",")
|
||||
@ -337,6 +339,7 @@ func NewSAMClientForwarderFromConf(config *Conf) (*samforwarder.SAMClientForward
|
||||
samforwarder.SetClientAccessList(config.AccessList),
|
||||
samforwarder.SetClientMessageReliability(config.MessageReliability),
|
||||
samforwarder.SetClientPassword(config.KeyFilePath),
|
||||
samforwarder.SetClientDestination(config.ClientDest),
|
||||
)
|
||||
}
|
||||
return nil, nil
|
||||
@ -455,6 +458,7 @@ func NewSAMSSUClientForwarderFromConf(config *Conf) (*samforwarderudp.SAMSSUClie
|
||||
samforwarderudp.SetClientAccessList(config.AccessList),
|
||||
samforwarderudp.SetClientMessageReliability(config.MessageReliability),
|
||||
samforwarderudp.SetClientPassword(config.KeyFilePath),
|
||||
samforwarderudp.SetClientDestination(config.ClientDest),
|
||||
)
|
||||
}
|
||||
return nil, nil
|
||||
|
@ -1,6 +1,5 @@
|
||||
|
||||
## Defaults, these are only invoked with the -start option or if labeled tunnels
|
||||
## are not present(samcatd instructions)
|
||||
## DO NOT USE THESE AS DEFAULTS. THEY ARE FOR TESTING.
|
||||
|
||||
[ephsite]
|
||||
type = server
|
||||
|
@ -1,9 +1,11 @@
|
||||
|
||||
## Defaults, these are only invoked with the -start option or if labeled tunnels
|
||||
## are not present(samcatd instructions)
|
||||
## are not present(samcatd instructions). **THESE** are the correct config files
|
||||
## to use as defaults, and not the ones in ../sam-forwarder/tunnels.ini, which
|
||||
## are used for testing settings availability only.
|
||||
|
||||
inbound.length = 3
|
||||
outbound.length = 6
|
||||
outbound.length = 3
|
||||
inbound.lengthVariance = 0
|
||||
outbound.lengthVariance = 0
|
||||
inbound.backupQuantity = 3
|
||||
@ -26,37 +28,39 @@ type = server
|
||||
host = 127.0.0.1
|
||||
port = 8081
|
||||
inbound.length = 3
|
||||
outbound.length = 6
|
||||
outbound.length = 3
|
||||
keys = forwarder
|
||||
|
||||
[sam-forwarder-two]
|
||||
type = client
|
||||
host = 127.0.0.1
|
||||
port = 8082
|
||||
inbound.length = 6
|
||||
outbound.length = 3
|
||||
keys = forwarder-two
|
||||
#[sam-forwarder-two]
|
||||
#type = client
|
||||
#host = 127.0.0.1
|
||||
#port = 8082
|
||||
#inbound.length = 6
|
||||
#outbound.length = 3
|
||||
#destination = i2p-projekt.i2p
|
||||
#keys = forwarder-two
|
||||
|
||||
[sam-forwarder-three]
|
||||
type = udpclient
|
||||
host = 127.0.0.1
|
||||
port = 8083
|
||||
inbound.length = 3
|
||||
outbound.length = 6
|
||||
keys = forwarder-three
|
||||
#[sam-forwarder-three]
|
||||
#type = udpclient
|
||||
#host = 127.0.0.1
|
||||
#port = 8083
|
||||
#inbound.length = 3
|
||||
#outbound.length = 3
|
||||
#keys = forwarder-three
|
||||
|
||||
[sam-forwarder-four]
|
||||
type = udpserver
|
||||
host = 127.0.0.1
|
||||
port = 8084
|
||||
inbound.length = 6
|
||||
outbound.length = 3
|
||||
keys = forwarder-four
|
||||
#[sam-forwarder-four]
|
||||
#type = udpserver
|
||||
#host = 127.0.0.1
|
||||
#port = 8084
|
||||
#inbound.length = 6
|
||||
#outbound.length = 3
|
||||
#destination = example-udp-stream.i2p
|
||||
#keys = forwarder-four
|
||||
|
||||
[sam-forwarder-five]
|
||||
type = http
|
||||
host = 127.0.0.1
|
||||
port = 8085
|
||||
inbound.length = 3
|
||||
outbound.length = 6
|
||||
keys = forwarder-five
|
||||
#[sam-forwarder-five]
|
||||
#type = http
|
||||
#host = 127.0.0.1
|
||||
#port = 8085
|
||||
#inbound.length = 3
|
||||
#outbound.length = 3
|
||||
#keys = forwarder-five
|
||||
|
@ -70,6 +70,14 @@ 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
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
//SetClientName sets the host of the SAMSSUForwarder's SAM bridge
|
||||
func SetClientName(s string) func(*SAMSSUClientForwarder) error {
|
||||
return func(c *SAMSSUClientForwarder) error {
|
||||
|
Reference in New Issue
Block a user