mirror of
https://github.com/go-i2p/go-sam-go.git
synced 2025-06-07 09:03:18 -04:00
Simplify, add readme
This commit is contained in:
20
common/README.md
Normal file
20
common/README.md
Normal file
@ -0,0 +1,20 @@
|
||||
# go-sam-go/common
|
||||
|
||||
Core library for SAMv3 protocol implementation in Go, providing connection management and session configuration for I2P applications.
|
||||
|
||||
## Installation
|
||||
|
||||
Install using Go modules with the package path `github.com/go-i2p/go-sam-go/common`.
|
||||
|
||||
## Usage
|
||||
|
||||
The package handles SAM bridge connections, handshakes, and base session management. It provides configuration options for tunnel parameters, encryption settings, and I2P-specific features. The BaseSession implementation must be wrapped in specific session types (stream, datagram, or raw) for actual use.
|
||||
|
||||
Key components include SAM connection establishment, I2P address resolution, destination key management, and comprehensive tunnel configuration through the I2PConfig struct.
|
||||
|
||||
## Dependencies
|
||||
|
||||
- github.com/go-i2p/i2pkeys - I2P cryptographic key handling
|
||||
- github.com/go-i2p/logger - Logging functionality
|
||||
- github.com/sirupsen/logrus - Structured logging
|
||||
- github.com/samber/oops - Enhanced error handling
|
@ -261,49 +261,32 @@ func (f *I2PConfig) Reliability() string {
|
||||
|
||||
// Reduce returns I2CP reduce-on-idle configuration settings as a string if enabled
|
||||
func (f *I2PConfig) Reduce() string {
|
||||
// If reduce idle is enabled, return formatted configuration string
|
||||
if f.ReduceIdle {
|
||||
// Log the reduce idle settings being applied
|
||||
log.WithFields(logrus.Fields{
|
||||
"reduceIdle": f.ReduceIdle,
|
||||
"reduceIdleTime": f.ReduceIdleTime,
|
||||
"reduceIdleQuantity": f.ReduceIdleQuantity,
|
||||
}).Debug("Reduce idle settings applied")
|
||||
|
||||
// Return formatted configuration string using Sprintf
|
||||
return fmt.Sprintf("i2cp.reduceOnIdle=%t"+
|
||||
"i2cp.reduceIdleTime=%d"+
|
||||
"i2cp.reduceQuantity=%d",
|
||||
f.ReduceIdle,
|
||||
f.ReduceIdleTime,
|
||||
f.ReduceIdleQuantity)
|
||||
// Return early if reduce idle is not enabled
|
||||
if !f.ReduceIdle {
|
||||
log.Debug("Reduce idle settings not applied")
|
||||
return ""
|
||||
}
|
||||
|
||||
// Log when reduce idle is not enabled
|
||||
log.Debug("Reduce idle settings not applied")
|
||||
return ""
|
||||
// Log and return the reduce idle configuration
|
||||
result := fmt.Sprintf("i2cp.reduceOnIdle=%t i2cp.reduceIdleTime=%d i2cp.reduceQuantity=%d",
|
||||
f.ReduceIdle, f.ReduceIdleTime, f.ReduceIdleQuantity)
|
||||
log.WithField("config", result).Debug("Reduce idle settings applied")
|
||||
return result
|
||||
}
|
||||
|
||||
// Close returns I2CP close-on-idle configuration settings as a string if enabled
|
||||
func (f *I2PConfig) Close() string {
|
||||
// If close idle is enabled, return formatted configuration string
|
||||
if f.CloseIdle {
|
||||
// Log the close idle settings being applied
|
||||
log.WithFields(logrus.Fields{
|
||||
"closeIdle": f.CloseIdle,
|
||||
"closeIdleTime": f.CloseIdleTime,
|
||||
}).Debug("Close idle settings applied")
|
||||
|
||||
// Return formatted configuration string using Sprintf
|
||||
return fmt.Sprintf("i2cp.closeOnIdle=%t"+
|
||||
"i2cp.closeIdleTime=%d",
|
||||
f.CloseIdle,
|
||||
f.CloseIdleTime)
|
||||
// Return early if close idle is not enabled
|
||||
if !f.CloseIdle {
|
||||
log.Debug("Close idle settings not applied")
|
||||
return ""
|
||||
}
|
||||
|
||||
// Log when close idle is not enabled
|
||||
log.Debug("Close idle settings not applied")
|
||||
return ""
|
||||
// Log and return the close idle configuration
|
||||
result := fmt.Sprintf("i2cp.closeOnIdle=%t i2cp.closeIdleTime=%d",
|
||||
f.CloseIdle, f.CloseIdleTime)
|
||||
log.WithField("config", result).Debug("Close idle settings applied")
|
||||
return result
|
||||
}
|
||||
|
||||
// DoZero returns the zero hop and fast receive configuration string settings
|
||||
|
Reference in New Issue
Block a user