mirror of
https://github.com/DeBrosOfficial/network.git
synced 2025-10-06 06:19:08 +00:00

- Added encryption module identity.go for reusable identity create, save etc funtions - Updated make file to support identity/main.go - Updated node/node.go on loadOrCreateIdentity to use encryption.identity - Updated cli/main.go to remove fallbacks for identity - Updated install-debros-network.sh script to use new ./cmd/identity and fixed port order on print - Updated makefile and changelog
46 lines
1.0 KiB
Go
46 lines
1.0 KiB
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/DeBrosOfficial/network/pkg/encryption"
|
|
)
|
|
|
|
func main() {
|
|
var outputPath string
|
|
var displayOnly bool
|
|
|
|
flag.StringVar(&outputPath, "output", "", "Output path for identity key")
|
|
flag.BoolVar(&displayOnly, "display-only", false, "Only display identity info, don't save")
|
|
flag.Parse()
|
|
|
|
// Generate identity using shared package
|
|
info, err := encryption.GenerateIdentity()
|
|
if err != nil {
|
|
fmt.Fprintf(os.Stderr, "Failed to generate identity: %v\n", err)
|
|
os.Exit(1)
|
|
}
|
|
|
|
// If display only, just show the info
|
|
if displayOnly {
|
|
fmt.Printf("Node Identity: %s\n", info.PeerID.String())
|
|
return
|
|
}
|
|
|
|
// Save to file using shared package
|
|
if outputPath == "" {
|
|
fmt.Fprintln(os.Stderr, "Output path is required")
|
|
os.Exit(1)
|
|
}
|
|
|
|
if err := encryption.SaveIdentity(info, outputPath); err != nil {
|
|
fmt.Fprintf(os.Stderr, "Failed to save identity: %v\n", err)
|
|
os.Exit(1)
|
|
}
|
|
|
|
fmt.Printf("Generated Node Identity: %s\n", info.PeerID.String())
|
|
fmt.Printf("Identity saved to: %s\n", outputPath)
|
|
}
|