mirror of
https://github.com/go-i2p/go-sam-go.git
synced 2025-06-30 20:53:03 -04:00
Simplify ExtractDest
This commit is contained in:
@ -319,8 +319,18 @@ func (f *I2PConfig) DoZero() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// formatConfigPair creates a configuration string for inbound/outbound pairs
|
// formatConfigPair creates a configuration string for inbound/outbound pairs
|
||||||
func (f *I2PConfig) formatConfigPair(direction, property string, value int) string {
|
func (f *I2PConfig) formatConfigPair(direction, property string, value interface{}) string {
|
||||||
return fmt.Sprintf("%s.%s=%d", direction, property, value)
|
switch v := value.(type) {
|
||||||
|
case int:
|
||||||
|
return fmt.Sprintf("%s.%s=%d", direction, property, value)
|
||||||
|
case string:
|
||||||
|
return fmt.Sprintf("%s.%s=%s", direction, property, value)
|
||||||
|
case bool:
|
||||||
|
return fmt.Sprintf("%s.%s=%t", direction, property, value)
|
||||||
|
|
||||||
|
default:
|
||||||
|
return ""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *I2PConfig) InboundLength() string {
|
func (f *I2PConfig) InboundLength() string {
|
||||||
@ -355,6 +365,10 @@ func (f *I2PConfig) OutboundQuantity() string {
|
|||||||
return f.formatConfigPair("outbound", "quantity", f.OutQuantity)
|
return f.formatConfigPair("outbound", "quantity", f.OutQuantity)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f *I2PConfig) UsingCompression() string {
|
||||||
|
return f.formatConfigPair("i2cp", "useCompression", f.UseCompression)
|
||||||
|
}
|
||||||
|
|
||||||
// Print returns a slice of strings containing all the I2P configuration settings
|
// Print returns a slice of strings containing all the I2P configuration settings
|
||||||
func (f *I2PConfig) Print() []string {
|
func (f *I2PConfig) Print() []string {
|
||||||
// Get lease set settings
|
// Get lease set settings
|
||||||
|
@ -69,7 +69,7 @@ func ExtractDest(input string) string {
|
|||||||
log.WithField("input", input).Debug("ExtractDest called")
|
log.WithField("input", input).Debug("ExtractDest called")
|
||||||
dest := strings.Split(input, " ")[0]
|
dest := strings.Split(input, " ")[0]
|
||||||
log.WithField("dest", dest).Debug("Destination extracted")
|
log.WithField("dest", dest).Debug("Destination extracted")
|
||||||
return strings.Split(input, " ")[0]
|
return dest
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
Reference in New Issue
Block a user