Skip to content
This repository has been archived by the owner on Mar 21, 2022. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Release v0.1.4
This release adds support for status output redirection to stderr to aid
people who prefer to only preserve the useful bits of miner output.
  • Loading branch information
tdemin committed Oct 13, 2020
2 parents 101b0b4 + 56bd4a7 commit 80db005
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 32 deletions.
52 changes: 33 additions & 19 deletions README.md
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions debug.go
Expand Up @@ -3,7 +3,6 @@
package main

import (
"log"
"net/http"
_ "net/http/pprof"
"os"
Expand All @@ -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)
}
}()
}
30 changes: 20 additions & 10 deletions main.go
Expand Up @@ -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")
Expand All @@ -31,31 +40,32 @@ 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)
}

newKeys := make(chan keySet, *threads)
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)
Expand All @@ -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 {
Expand All @@ -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)
}
}
}
Expand All @@ -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[:]),
Expand Down

0 comments on commit 80db005

Please sign in to comment.