diff --git a/README.md b/README.md index 14c10ec..ea0738a 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,39 @@ If you're an Arch Linux user, you can install it from `% yay -S syg_go` +### Features + +* regex-based key mining (see `-regex`) +* bruteforce-resistant keys mining mode (see `-highaddr`) +* multithreaded key mining (see `-threads`) + +### Usage + +``` +% syg_go -help +Usage of syg_go: + -highaddr + high address mining mode, excludes regex + -iter uint + per how many iterations to output status (default 100000) + -original + use original Yggdrasil code + -regex string + regex to match addresses against (default "::") + -threads int + how many threads to use for mining (default 16) + -version + display version +``` + +This program outputs keys found to stdout and iterations numbers reached +to stderr so that users can redirect the (possibly) irrelevant status +output to /dev/null. To redirect status output to /dev/null, run: + +``` +% syg_go ...flags... 2>/dev/null +``` + ### History [SimpleYggGen](https://notabug.org/acetone/SimpleYggGen-Bash) is originally a @@ -50,25 +83,6 @@ This program contains some modded code from Yggdrasil that aims to improve performance. If you prefer to use original Yggdrasil code, set `-original` flag. -### Usage - -``` -% syg_go -help -Usage of syg_go: - -highaddr - high address mining mode, excludes regex - -iter uint - per how many iterations to output status (default 100000) - -original - use original Yggdrasil code - -regex string - regex to match addresses against (default "::") - -threads int - how many threads to use for mining (default 16) - -version - display version -``` - ### Development `go tool pprof` support is available when building with `-tags debug`. The diff --git a/debug.go b/debug.go index f10ac30..7d2f07c 100644 --- a/debug.go +++ b/debug.go @@ -3,7 +3,6 @@ package main import ( - "log" "net/http" _ "net/http/pprof" "os" @@ -14,10 +13,10 @@ func init() { if listen == "" { listen = "[::]:8082" } - log.Printf("profiling is enabled, HTTP server is attached to %s\n", listen) + stdout.Printf("profiling is enabled, HTTP server is attached to %s\n", listen) go func() { if err := http.ListenAndServe(listen, nil); err != nil { - log.Fatalf("http failed: %v\n", err) + stderr.Fatalf("http failed: %v\n", err) } }() } diff --git a/main.go b/main.go index 8e2f929..24a6eda 100644 --- a/main.go +++ b/main.go @@ -20,7 +20,16 @@ import ( "github.com/yggdrasil-network/yggdrasil-go/src/crypto" ) -var version = "v0.1.3" +var ( + programName = "syg_go" + version = "v0.1.4" + copyright = "Copyright (c) 2020 Timur Demin" +) + +var ( + stdout = log.New(os.Stdout, "", log.Flags()) + stderr = log.New(os.Stderr, "", log.Flags()) +) func main() { rxflag := flag.String("regex", "::", "regex to match addresses against") @@ -31,21 +40,22 @@ func main() { highAddressMode := flag.Bool("highaddr", false, "high address mining mode, excludes regex") flag.Parse() if *displayVersion { - println("syg_go", version) + println(programName, version) + println(copyright) return } if *origCode { - log.Println("using unmodified Yggdrasil code") + stdout.Println("using unmodified Yggdrasil code") addrForNodeID = address.AddrForNodeID } else { - log.Println("using syg_go vendored code") + stdout.Println("using syg_go vendored code") addrForNodeID = AddrForNodeID } regex, err := regexp.Compile(*rxflag) if err != nil { - log.Printf("%v\n", err) + stderr.Printf("%v\n", err) os.Exit(1) } @@ -53,9 +63,9 @@ func main() { var currentBest []byte if !*highAddressMode { - log.Printf("starting mining for %v with %v threads\n", regex, *threads) + stdout.Printf("starting mining for %v with %v threads\n", regex, *threads) } else { - log.Printf("starting mining higher addresses with %v threads\n", *threads) + stdout.Printf("starting mining higher addresses with %v threads\n", *threads) } for i := 0; i < *threads; i++ { go doBoxKeys(newKeys) @@ -71,7 +81,7 @@ func main() { } counter++ if counter%i == 0 { - log.Printf("reached %v iterations\n", counter) + stderr.Printf("reached %v iterations\n", counter) } } } else { @@ -83,7 +93,7 @@ func main() { } counter++ if counter%i == 0 { - log.Printf("reached %v iterations\n", counter) + stderr.Printf("reached %v iterations\n", counter) } } } @@ -97,7 +107,7 @@ type keySet struct { } func (k *keySet) print() { - log.Printf("priv: %s | pub: %s | nodeid: %s | ip: %s\n", + stdout.Printf("priv: %s | pub: %s | nodeid: %s | ip: %s\n", hex.EncodeToString(k.priv[:]), hex.EncodeToString(k.pub[:]), hex.EncodeToString(k.id[:]),