mirror of
https://github.com/go-i2p/go-i2p-testnet.git
synced 2025-06-15 13:24:25 -04:00
read router info from i2pd node
This commit is contained in:
9
go.mod
9
go.mod
@ -12,7 +12,7 @@ require (
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/AdaLogics/go-fuzz-headers v0.0.0-20240806141605-e8a1dd7889d6 // indirect
|
||||
filippo.io/edwards25519 v1.1.0 // indirect
|
||||
github.com/Microsoft/go-winio v0.4.14 // indirect
|
||||
github.com/containerd/log v0.1.0 // indirect
|
||||
github.com/distribution/reference v0.6.0 // indirect
|
||||
@ -22,12 +22,7 @@ require (
|
||||
github.com/go-logr/logr v1.4.2 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
github.com/gogo/protobuf v1.3.2 // indirect
|
||||
github.com/klauspost/compress v1.17.11 // indirect
|
||||
github.com/moby/docker-image-spec v1.3.1 // indirect
|
||||
github.com/moby/patternmatcher v0.6.0 // indirect
|
||||
github.com/moby/sys/sequential v0.6.0 // indirect
|
||||
github.com/moby/sys/user v0.3.0 // indirect
|
||||
github.com/moby/sys/userns v0.1.0 // indirect
|
||||
github.com/moby/term v0.5.0 // indirect
|
||||
github.com/morikuni/aec v1.0.0 // indirect
|
||||
github.com/opencontainers/go-digest v1.0.0 // indirect
|
||||
@ -39,6 +34,8 @@ require (
|
||||
go.opentelemetry.io/otel/metric v1.31.0 // indirect
|
||||
go.opentelemetry.io/otel/sdk v1.31.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.31.0 // indirect
|
||||
go.step.sm/crypto v0.51.2 // indirect
|
||||
golang.org/x/crypto v0.26.0 // indirect
|
||||
golang.org/x/sys v0.26.0 // indirect
|
||||
golang.org/x/time v0.7.0 // indirect
|
||||
gotest.tools/v3 v3.5.1 // indirect
|
||||
|
62
main.go
62
main.go
@ -8,6 +8,7 @@ import (
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/docker/api/types/volume"
|
||||
"github.com/docker/docker/client"
|
||||
"github.com/go-i2p/go-i2p/lib/common/router_info"
|
||||
"go-i2p-testnet/lib/docker_control"
|
||||
goi2pnode "go-i2p-testnet/lib/go-i2p"
|
||||
"go-i2p-testnet/lib/i2pd"
|
||||
@ -489,7 +490,7 @@ func main() {
|
||||
case "add":
|
||||
if len(parts) < 2 {
|
||||
fmt.Println("Specify the type of router to add. Usage: add [goi2p_router|i2pd_router]")
|
||||
return
|
||||
continue
|
||||
}
|
||||
switch parts[1] {
|
||||
case "goi2p_router":
|
||||
@ -522,6 +523,65 @@ func main() {
|
||||
return
|
||||
default:
|
||||
fmt.Println("Unknown command. Type 'help' for a list of commands")
|
||||
|
||||
case "hidden": // This is used for debugging and experimental reasons, not meant to be used for the end user but to force actions
|
||||
if len(parts) < 2 {
|
||||
fmt.Println("Specify hidden command")
|
||||
continue
|
||||
}
|
||||
switch parts[1] {
|
||||
case "extract":
|
||||
if len(parts) < 4 {
|
||||
fmt.Println("Usage: hidden extract <containerID> <filePath>")
|
||||
continue
|
||||
}
|
||||
|
||||
containerID := parts[2]
|
||||
filePath := parts[3]
|
||||
|
||||
content, err := docker_control.ReadFileFromContainer(cli, ctx, containerID, filePath)
|
||||
if err != nil {
|
||||
fmt.Printf("Error extracting file: %v\n", err)
|
||||
continue
|
||||
}
|
||||
|
||||
fmt.Println("File content:")
|
||||
fmt.Println(content)
|
||||
case "read_router_info":
|
||||
if len(parts) < 4 {
|
||||
fmt.Println("Usage: hidden read_router_info <containerID> <filePath>")
|
||||
continue
|
||||
}
|
||||
|
||||
containerID := parts[2]
|
||||
filePath := parts[3]
|
||||
|
||||
content, err := docker_control.ReadFileFromContainer(cli, ctx, containerID, filePath)
|
||||
if err != nil {
|
||||
fmt.Printf("Error extracting file: %v\n", err)
|
||||
continue
|
||||
}
|
||||
|
||||
ri, _, err := router_info.ReadRouterInfo([]byte(content))
|
||||
if err != nil {
|
||||
fmt.Printf("Error reading router info: %v\n", err)
|
||||
continue
|
||||
}
|
||||
fmt.Println("Successfully read router info")
|
||||
fmt.Printf("Options: %v\n", ri.Options())
|
||||
fmt.Printf("Signature: %s\n", ri.Signature())
|
||||
fmt.Printf("GoodVersion: %v\n", ri.GoodVersion())
|
||||
fmt.Printf("IdentHash: %v\n", ri.IdentHash())
|
||||
fmt.Printf("Network: %v\n", ri.Network())
|
||||
fmt.Printf("Peersize: %v\n", ri.PeerSize())
|
||||
fmt.Printf("Published: %v\n", ri.Published())
|
||||
fmt.Printf("Reachable: %v\n", ri.Reachable())
|
||||
fmt.Printf("RouterAddressCount: %v\n", ri.RouterAddressCount())
|
||||
fmt.Printf("RouterAddresses: %v\n", ri.RouterAddresses())
|
||||
fmt.Printf("RouterIdentity: %v\n", ri.RouterIdentity())
|
||||
fmt.Printf("RouterVersion: %v\n", ri.RouterVersion())
|
||||
fmt.Printf("UnCongested: %v\n", ri.UnCongested())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user