Simplify ExtractDest

This commit is contained in:
eyedeekay
2025-05-27 19:37:52 -04:00
parent 95ccf4c187
commit 3e89669fec
2 changed files with 17 additions and 3 deletions

View File

@ -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

View File

@ -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 (