This commit is contained in:
Haris Khan
2024-11-15 22:52:17 -05:00
parent ddba94d6ae
commit 62086c7d04
8 changed files with 24 additions and 18 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -3,6 +3,7 @@ package signature
import (
"fmt"
"github.com/go-i2p/go-i2p/lib/util/logger"
"github.com/sirupsen/logrus"
)

View File

@ -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")
}

View File

@ -30,7 +30,7 @@ type SigningPublicKey interface {
}
type PublicKey interface {
Len() int
Bytes() []byte
Bytes() []byte
NewEncrypter() (Encrypter, error)
}

View File

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