mirror of
https://github.com/go-i2p/go-sam-go.git
synced 2025-06-15 21:28:46 -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
|
||||
func (f *I2PConfig) formatConfigPair(direction, property string, value int) string {
|
||||
return fmt.Sprintf("%s.%s=%d", direction, property, value)
|
||||
func (f *I2PConfig) formatConfigPair(direction, property string, value interface{}) string {
|
||||
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 {
|
||||
@ -355,6 +365,10 @@ func (f *I2PConfig) OutboundQuantity() string {
|
||||
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
|
||||
func (f *I2PConfig) Print() []string {
|
||||
// Get lease set settings
|
||||
|
@ -69,7 +69,7 @@ func ExtractDest(input string) string {
|
||||
log.WithField("input", input).Debug("ExtractDest called")
|
||||
dest := strings.Split(input, " ")[0]
|
||||
log.WithField("dest", dest).Debug("Destination extracted")
|
||||
return strings.Split(input, " ")[0]
|
||||
return dest
|
||||
}
|
||||
|
||||
var (
|
||||
|
Reference in New Issue
Block a user