Compare commits
11 Commits
10k
...
routerinfo
Author | SHA1 | Date | |
---|---|---|---|
![]() |
627e131a58 | ||
![]() |
f729bda62d | ||
![]() |
4ad0f97bfe | ||
![]() |
20032e0f55 | ||
![]() |
700391788f | ||
![]() |
e296441f29 | ||
![]() |
62086c7d04 | ||
![]() |
df45c19272 | ||
![]() |
f6894e9064 | ||
![]() |
b36ef65a10 | ||
![]() |
8c2b952616 |
20
.github/workflows/auto-assign.yml
vendored
Normal file
20
.github/workflows/auto-assign.yml
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
name: Auto Assign
|
||||
on:
|
||||
issues:
|
||||
types: [opened]
|
||||
pull_request:
|
||||
types: [opened]
|
||||
jobs:
|
||||
run:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
issues: write
|
||||
pull-requests: write
|
||||
steps:
|
||||
- name: 'Auto-assign issue'
|
||||
uses: pozil/auto-assign-issue@v1
|
||||
with:
|
||||
repo-token:${{ secrets.GITHUB_TOKEN }}
|
||||
assignees: eyedeekay
|
||||
numOfAssignee: 1
|
||||
|
13
README.md
13
README.md
@@ -94,7 +94,7 @@ please keep up with these changes, as they will not be backward compatible and r
|
||||
- [X] Session Tag
|
||||
|
||||
## Verbosity ##
|
||||
Logging can be enabled and configured using the DEBUG_I2P environment variable. By default, logging is disabled.
|
||||
Logging can be enabled and configured using the `DEBUG_I2P` environment variable. By default, logging is disabled.
|
||||
|
||||
There are three available log levels:
|
||||
|
||||
@@ -113,6 +113,17 @@ export DEBUG_I2P=error
|
||||
|
||||
If DEBUG_I2P is set to an unrecognized variable, it will fall back to "debug".
|
||||
|
||||
## Fast-Fail mode ##
|
||||
|
||||
Fast-Fail mode can be activated by setting `WARNFAIL_I2P` to any non-empty value. When set, every warning or error is Fatal.
|
||||
It is unsafe for production use, and intended only for debugging and testing purposes.
|
||||
|
||||
```shell
|
||||
export WARNFAIL_I2P=true
|
||||
```
|
||||
|
||||
If `WARNFAIL_I2P` is set and `DEBUG_I2P` is unset, `DEBUG_I2P` will be set to `debug`.
|
||||
|
||||
## Contributing
|
||||
|
||||
See CONTRIBUTING.md for more information.
|
||||
|
@@ -155,7 +155,7 @@ func ReadMappingValues(remainder []byte, map_length Integer) (values *MappingVal
|
||||
"reason": "duplicate key in mapping",
|
||||
"key": string(key_str),
|
||||
}).Error("mapping format violation")
|
||||
log.Printf("DUPE: %s", key_str)
|
||||
log.Warnf("DUPE: %s", key_str)
|
||||
errs = append(errs, errors.New("mapping format violation, duplicate key in mapping"))
|
||||
// Based on other implementations this does not seem to happen often?
|
||||
// Java throws an exception in this case, the base object is a Hashmap so the value is overwritten and an exception is thrown.
|
||||
@@ -170,7 +170,7 @@ func ReadMappingValues(remainder []byte, map_length Integer) (values *MappingVal
|
||||
"value:": string(remainder),
|
||||
}).Warn("mapping format violation")
|
||||
errs = append(errs, errors.New("mapping format violation, expected ="))
|
||||
log.Printf("ERRVAL: %s", remainder)
|
||||
log.Warnf("ERRVAL: %s", remainder)
|
||||
break
|
||||
} else {
|
||||
remainder = remainder[1:]
|
||||
|
@@ -5,7 +5,7 @@ import common "github.com/go-i2p/go-i2p/lib/common/router_identity"
|
||||
func Fuzz(data []byte) int {
|
||||
router_identity, _, _ := common.ReadRouterIdentity(data)
|
||||
router_identity.Certificate()
|
||||
//router_identity.publicKey()
|
||||
//router_identity.signingPublicKey()
|
||||
// router_identity.publicKey()
|
||||
// router_identity.signingPublicKey()
|
||||
return 0
|
||||
}
|
||||
|
@@ -123,7 +123,7 @@ func TestConstructSigningPublicKeyWithP521(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
key_cert, _, err := NewKeyCertificate([]byte{0x05, 0x00, 0x08, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00})
|
||||
data := make([]byte, 128)
|
||||
data := make([]byte, 132)
|
||||
spk, err := key_cert.ConstructSigningPublicKey(data)
|
||||
|
||||
assert.Nil(err, "ConstructSigningPublicKey() with P521 returned err on valid data")
|
||||
|
@@ -12,7 +12,7 @@ import (
|
||||
|
||||
func consolidateNetDb(sourcePath string, destPath string) error {
|
||||
// Create destination directory if it doesn't exist
|
||||
if err := os.MkdirAll(destPath, 0755); err != nil {
|
||||
if err := os.MkdirAll(destPath, 0o755); err != nil {
|
||||
return fmt.Errorf("failed to create destination directory: %v", err)
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ func consolidateAllNetDbs(tempDir string) error {
|
||||
i2pdPath := filepath.Join(os.Getenv("HOME"), ".i2pd/netDb")
|
||||
|
||||
// Create the temp directory
|
||||
if err := os.MkdirAll(tempDir, 0755); err != nil {
|
||||
if err := os.MkdirAll(tempDir, 0o755); err != nil {
|
||||
return fmt.Errorf("failed to create temp directory: %v", err)
|
||||
}
|
||||
|
||||
@@ -88,12 +88,14 @@ func consolidateAllNetDbs(tempDir string) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func cleanupTempDir(path string) error {
|
||||
if err := os.RemoveAll(path); err != nil {
|
||||
return fmt.Errorf("failed to cleanup temporary directory %s: %v", path, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func createTempNetDbDir() (string, error) {
|
||||
// Get system's temp directory in a platform-independent way
|
||||
baseDir := os.TempDir()
|
||||
@@ -106,13 +108,14 @@ func createTempNetDbDir() (string, error) {
|
||||
tempDir := filepath.Join(baseDir, dirName)
|
||||
|
||||
// Create the directory with appropriate permissions
|
||||
err := os.MkdirAll(tempDir, 0755)
|
||||
err := os.MkdirAll(tempDir, 0o755)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to create temporary directory: %v", err)
|
||||
}
|
||||
|
||||
return tempDir, nil
|
||||
}
|
||||
|
||||
func Test10K(t *testing.T) {
|
||||
i2pPath := filepath.Join(os.Getenv("HOME"), ".i2p/netDb")
|
||||
i2pdPath := filepath.Join(os.Getenv("HOME"), ".i2pd/netDb")
|
||||
@@ -128,7 +131,7 @@ func Test10K(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to create temp directory: %v", err)
|
||||
}
|
||||
//defer cleanupTempDir(tempDir)
|
||||
// defer cleanupTempDir(tempDir)
|
||||
|
||||
if err := consolidateAllNetDbs(tempDir); err != nil {
|
||||
t.Fatalf("Failed to consolidate netDbs: %v", err)
|
||||
@@ -156,7 +159,7 @@ func Test10K(t *testing.T) {
|
||||
}
|
||||
|
||||
// Parse the router info
|
||||
//fmt.Printf("data: %s\n", string(data))
|
||||
// fmt.Printf("data: %s\n", string(data))
|
||||
routerInfo, _, err := ReadRouterInfo(data)
|
||||
if err != nil {
|
||||
t.Logf("Failed to parse router info from %s: %v", file.Name(), err)
|
||||
@@ -170,7 +173,7 @@ func Test10K(t *testing.T) {
|
||||
continue
|
||||
}
|
||||
|
||||
err = os.WriteFile(filepath.Join(targetDir, file.Name()), routerBytes, 0644)
|
||||
err = os.WriteFile(filepath.Join(targetDir, file.Name()), routerBytes, 0o644)
|
||||
if err != nil {
|
||||
t.Logf("Failed to write router info %s: %v", file.Name(), err)
|
||||
continue
|
||||
|
@@ -4,11 +4,12 @@ package router_info
|
||||
import (
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"github.com/go-i2p/go-i2p/lib/common/certificate"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/go-i2p/go-i2p/lib/common/certificate"
|
||||
|
||||
"github.com/go-i2p/go-i2p/lib/crypto"
|
||||
|
||||
"github.com/go-i2p/go-i2p/lib/util/logger"
|
||||
@@ -174,7 +175,7 @@ func (router_info *RouterInfo) RouterIdentity() *RouterIdentity {
|
||||
// IndentHash returns the identity hash (sha256 sum) for this RouterInfo.
|
||||
func (router_info *RouterInfo) IdentHash() Hash {
|
||||
log.Debug("Calculating IdentHash for RouterInfo")
|
||||
//data, _ := router_info.RouterIdentity().keyCertificate.Data()
|
||||
// data, _ := router_info.RouterIdentity().keyCertificate.Data()
|
||||
cert := router_info.RouterIdentity().KeysAndCert.Certificate()
|
||||
data := cert.Data()
|
||||
hash := HashData(data)
|
||||
|
@@ -4,10 +4,11 @@ import (
|
||||
"bytes"
|
||||
"crypto/rand"
|
||||
"encoding/binary"
|
||||
"github.com/go-i2p/go-i2p/lib/common/signature"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/go-i2p/go-i2p/lib/common/signature"
|
||||
|
||||
"github.com/go-i2p/go-i2p/lib/common/certificate"
|
||||
"github.com/go-i2p/go-i2p/lib/common/data"
|
||||
"github.com/go-i2p/go-i2p/lib/common/router_address"
|
||||
|
@@ -3,6 +3,7 @@ package signature
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/go-i2p/go-i2p/lib/util/logger"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
@@ -185,7 +185,7 @@ func (v *Ed25519Verifier) Verify(data, sig []byte) (err error) {
|
||||
type Ed25519PrivateKey ed25519.PrivateKey
|
||||
|
||||
func (k Ed25519PrivateKey) NewDecrypter() (Decrypter, error) {
|
||||
//TODO implement me
|
||||
// TODO implement me
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
|
@@ -30,7 +30,7 @@ type SigningPublicKey interface {
|
||||
}
|
||||
type PublicKey interface {
|
||||
Len() int
|
||||
Bytes() []byte
|
||||
Bytes() []byte
|
||||
NewEncrypter() (Encrypter, error)
|
||||
}
|
||||
|
||||
|
@@ -76,7 +76,7 @@ func (r Reseed) SingleReseed(uri string) ([]router_info.RouterInfo, error) {
|
||||
log.WithError(err).Error("Failed to read SU3 file signature")
|
||||
return nil, err
|
||||
}
|
||||
log.Println("warning: this doesn't validate the signature yet", signature)
|
||||
log.Debug("warning: this doesn't validate the signature yet", signature)
|
||||
log.Warn("Doesn't validate the signature yet", logrus.Fields{"signature": signature})
|
||||
}
|
||||
zip := filepath.Join(config.RouterConfigProperties.NetDb.Path, "reseed.zip")
|
||||
|
@@ -152,7 +152,7 @@ func (db *StdNetDB) RecalculateSize() (err error) {
|
||||
}
|
||||
if db.CheckFilePathValid(fname) {
|
||||
log.WithField("file_name", fname).Debug("Reading RouterInfo file")
|
||||
log.Println("Reading in file:", fname)
|
||||
log.Debug("Reading in file:", fname)
|
||||
b, err := os.ReadFile(fname)
|
||||
if err != nil {
|
||||
log.WithError(err).Error("Failed to read RouterInfo file")
|
||||
@@ -165,9 +165,9 @@ func (db *StdNetDB) RecalculateSize() (err error) {
|
||||
}
|
||||
ih := ri.IdentHash().Bytes()
|
||||
log.WithError(err).Error("Failed to parse RouterInfo")
|
||||
log.Printf("Read in IdentHash: %s", base32.EncodeToString(ih[:]))
|
||||
log.Debugf("Read in IdentHash: %s", base32.EncodeToString(ih[:]))
|
||||
for _, addr := range ri.RouterAddresses() {
|
||||
log.Println(string(addr.Bytes()))
|
||||
log.Debug(string(addr.Bytes()))
|
||||
log.WithField("address", string(addr.Bytes())).Debug("RouterInfo address")
|
||||
}
|
||||
if ent, ok := db.RouterInfos[ih]; !ok {
|
||||
@@ -177,13 +177,13 @@ func (db *StdNetDB) RecalculateSize() (err error) {
|
||||
}
|
||||
} else {
|
||||
log.Debug("RouterInfo already in memory cache")
|
||||
log.Println("entry previously found in table", ent, fname)
|
||||
log.Debug("entry previously found in table", ent, fname)
|
||||
}
|
||||
ri = router_info.RouterInfo{}
|
||||
count++
|
||||
} else {
|
||||
log.WithField("file_path", fname).Warn("Invalid file path")
|
||||
log.Println("Invalid path error")
|
||||
log.Debug("Invalid path error")
|
||||
}
|
||||
return err
|
||||
})
|
||||
|
@@ -36,7 +36,7 @@ func (c *NoiseSession) RunIncomingHandshake() error {
|
||||
}
|
||||
log.Debug("Handshake message written successfully")
|
||||
log.WithField("state", state).Debug("Handshake state after message write")
|
||||
log.Println(state)
|
||||
log.Debug(state)
|
||||
c.handshakeComplete = true
|
||||
log.Debug("Incoming handshake completed successfully")
|
||||
return nil
|
||||
|
@@ -39,7 +39,7 @@ func (c *NoiseSession) RunOutgoingHandshake() error {
|
||||
}
|
||||
log.Debug("Handshake message written successfully")
|
||||
log.WithField("state", state).Debug("Handshake state after message write")
|
||||
log.Println(state)
|
||||
log.Debug(state)
|
||||
c.handshakeComplete = true
|
||||
log.Debug("Outgoing handshake completed successfully")
|
||||
return nil
|
||||
|
@@ -21,11 +21,11 @@ type NoiseSession struct {
|
||||
*sync.Cond
|
||||
*NoiseTransport // The parent transport, which "Dialed" the connection to the peer whith whom we established the session
|
||||
*HandshakeState
|
||||
RecvQueue *cb.Queue
|
||||
SendQueue *cb.Queue
|
||||
VerifyCallback VerifyCallbackFunc
|
||||
activeCall int32
|
||||
Conn net.Conn
|
||||
RecvQueue *cb.Queue
|
||||
SendQueue *cb.Queue
|
||||
VerifyCallback VerifyCallbackFunc
|
||||
activeCall int32
|
||||
Conn net.Conn
|
||||
}
|
||||
|
||||
// RemoteAddr implements net.Conn
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package logger
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
@@ -10,18 +10,96 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
log *logrus.Logger
|
||||
once sync.Once
|
||||
log *Logger
|
||||
once sync.Once
|
||||
failFast string
|
||||
)
|
||||
|
||||
// Logger wraps logrus.Logger and adds the ability to make all warnings fatal
|
||||
type Logger struct {
|
||||
*logrus.Logger
|
||||
}
|
||||
|
||||
// Entry wraps logrus.Entry and enables it to use our Logger
|
||||
type Entry struct {
|
||||
Logger
|
||||
entry *logrus.Entry
|
||||
}
|
||||
|
||||
// Warn wraps logrus.Warn and logs a fatal error if failFast is set
|
||||
func (l *Logger) Warn(args ...interface{}) {
|
||||
warnFatal(args)
|
||||
l.Logger.Warn(args...)
|
||||
}
|
||||
|
||||
// Warnf wraps logrus.Warnf and logs a fatal error if failFast is set
|
||||
func (l *Logger) Warnf(format string, args ...interface{}) {
|
||||
warnFatalf(format, args...)
|
||||
l.Logger.Warnf(format, args...)
|
||||
}
|
||||
|
||||
// Error wraps logrus.Error and logs a fatal error if failFast is set
|
||||
func (l *Logger) Error(args ...interface{}) {
|
||||
warnFatal(args)
|
||||
l.Logger.Error(args...)
|
||||
}
|
||||
|
||||
// Errorf wraps logrus.Errorf and logs a fatal error if failFast is set
|
||||
func (l *Logger) Errorf(format string, args ...interface{}) {
|
||||
warnFatalf(format, args...)
|
||||
l.Logger.Errorf(format, args...)
|
||||
}
|
||||
|
||||
// WithField wraps logrus.WithField and returns an Entry
|
||||
func (l *Logger) WithField(key string, value interface{}) *Entry {
|
||||
entry := l.Logger.WithField(key, value)
|
||||
return &Entry{*l, entry}
|
||||
}
|
||||
|
||||
// WithFields wraps logrus.WithFields and returns an Entry
|
||||
func (l *Logger) WithFields(fields logrus.Fields) *Entry {
|
||||
entry := l.Logger.WithFields(fields)
|
||||
return &Entry{*l, entry}
|
||||
}
|
||||
|
||||
// WithError wraps logrus.WithError and returns an Entry
|
||||
func (l *Logger) WithError(err error) *Entry {
|
||||
entry := l.Logger.WithError(err)
|
||||
return &Entry{*l, entry}
|
||||
}
|
||||
|
||||
func warnFatal(args ...interface{}) {
|
||||
if failFast != "" {
|
||||
log.Fatal(args)
|
||||
}
|
||||
}
|
||||
|
||||
func warnFatalf(format string, args ...interface{}) {
|
||||
if failFast != "" {
|
||||
log.Fatalf(format, args...)
|
||||
}
|
||||
}
|
||||
|
||||
func warnFail() {
|
||||
if failFast != "" {
|
||||
log.Error("FATAL ERROR")
|
||||
}
|
||||
}
|
||||
|
||||
// InitializeGoI2PLogger sets up all the necessary logging
|
||||
func InitializeGoI2PLogger() {
|
||||
once.Do(func() {
|
||||
log = logrus.New()
|
||||
log = &Logger{}
|
||||
log.Logger = logrus.New()
|
||||
// We do not want to log by default
|
||||
log.SetOutput(ioutil.Discard)
|
||||
log.SetOutput(io.Discard)
|
||||
log.SetLevel(logrus.PanicLevel)
|
||||
// Check if DEBUG_I2P is set
|
||||
if logLevel := os.Getenv("DEBUG_I2P"); logLevel != "" {
|
||||
failFast = os.Getenv("WARNFAIL_I2P")
|
||||
if failFast != "" && logLevel == "" {
|
||||
logLevel = "debug"
|
||||
}
|
||||
log.SetOutput(os.Stdout)
|
||||
switch strings.ToLower(logLevel) {
|
||||
case "debug":
|
||||
@@ -38,8 +116,8 @@ func InitializeGoI2PLogger() {
|
||||
})
|
||||
}
|
||||
|
||||
// GetGoI2PLogger returns the initialized logger
|
||||
func GetGoI2PLogger() *logrus.Logger {
|
||||
// GetGoI2PLogger returns the initialized Logger
|
||||
func GetGoI2PLogger() *Logger {
|
||||
if log == nil {
|
||||
InitializeGoI2PLogger()
|
||||
}
|
||||
|
Reference in New Issue
Block a user