mirror of
https://github.com/go-i2p/go-sam-go.git
synced 2025-12-01 09:54:58 -05: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
|
// Reduce returns I2CP reduce-on-idle configuration settings as a string if enabled
|
||||||
func (f *I2PConfig) Reduce() string {
|
func (f *I2PConfig) Reduce() string {
|
||||||
// If reduce idle is enabled, return formatted configuration string
|
// Return early if reduce idle is not enabled
|
||||||
if f.ReduceIdle {
|
if !f.ReduceIdle {
|
||||||
// Log the reduce idle settings being applied
|
log.Debug("Reduce idle settings not applied")
|
||||||
log.WithFields(logrus.Fields{
|
return ""
|
||||||
"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)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log when reduce idle is not enabled
|
// Log and return the reduce idle configuration
|
||||||
log.Debug("Reduce idle settings not applied")
|
result := fmt.Sprintf("i2cp.reduceOnIdle=%t i2cp.reduceIdleTime=%d i2cp.reduceQuantity=%d",
|
||||||
return ""
|
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
|
// Close returns I2CP close-on-idle configuration settings as a string if enabled
|
||||||
func (f *I2PConfig) Close() string {
|
func (f *I2PConfig) Close() string {
|
||||||
// If close idle is enabled, return formatted configuration string
|
// Return early if close idle is not enabled
|
||||||
if f.CloseIdle {
|
if !f.CloseIdle {
|
||||||
// Log the close idle settings being applied
|
log.Debug("Close idle settings not applied")
|
||||||
log.WithFields(logrus.Fields{
|
return ""
|
||||||
"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)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log when close idle is not enabled
|
// Log and return the close idle configuration
|
||||||
log.Debug("Close idle settings not applied")
|
result := fmt.Sprintf("i2cp.closeOnIdle=%t i2cp.closeIdleTime=%d",
|
||||||
return ""
|
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
|
// DoZero returns the zero hop and fast receive configuration string settings
|
||||||
|
|||||||
Reference in New Issue
Block a user