mirror of
https://github.com/8lecramm/derohe-proxy.git
synced 2025-01-10 13:57:56 +00:00
Delete derohe-proxy directory
This commit is contained in:
parent
ad8020f895
commit
9f399ed393
@ -1,24 +0,0 @@
|
|||||||
# derohe-proxy
|
|
||||||
|
|
||||||
Proxy to combine miners and to reduce network load.
|
|
||||||
Long To-Do list, but this is a working release.
|
|
||||||
|
|
||||||
**Features**
|
|
||||||
- random nonces
|
|
||||||
- muliple wallets are supported
|
|
||||||
- notification of incoming and lost connections / submitted results / stats
|
|
||||||
- user-defined logging interval
|
|
||||||
- pool mining support (not stratum)
|
|
||||||
- worker support (wallet_address.worker_name)
|
|
||||||
|
|
||||||
**Usage**
|
|
||||||
|
|
||||||
```derohe-proxy [--listen-address=<127.0.0.1:11111>] [--log-interval=<60>] [--minimal] [--nonce] [--pool] --daemon-address=<1.2.3.4:10100>```
|
|
||||||
|
|
||||||
```--listen-address (optional): bind to address:port for incoming miner connections. By default, proxy listens on 0.0.0.0:10200
|
|
||||||
--daemon-address: address:port of daemon
|
|
||||||
--log-interval (optional): logging every X seconds, where X >= 60. Default is 60 seconds
|
|
||||||
--minimal (optional): forward only 2 jobs per block (1 for first 9 miniblocks, 1 for final miniblock)
|
|
||||||
--nonce (optional): enable random nonces, disabled by default```
|
|
||||||
--pool (optional): enable pool mining, disable keyhash replacement
|
|
||||||
--wallet-address=<dero1....> use this wallet address for all connections
|
|
@ -1,38 +0,0 @@
|
|||||||
package config
|
|
||||||
|
|
||||||
var Command_line string = `derohe-proxy
|
|
||||||
Proxy to combine all miners and to reduce network load
|
|
||||||
|
|
||||||
Usage:
|
|
||||||
derohe-proxy --daemon-address=<1.2.3.4:10100> [--listen-address=<127.0.0.1:10100>] [--log-interval=<60>] [--minimal] [--nonce] [--pool] [--wallet-address=<dero1...>]
|
|
||||||
|
|
||||||
Options:
|
|
||||||
--listen-address=<127.0.0.1:10100> bind to specific address:port, default is 0.0.0.0:10200
|
|
||||||
--daemon-address=<1.2.3.4:10100> connect to this daemon
|
|
||||||
--wallet-address=<dero1....> use this wallet address for all connections
|
|
||||||
--log-interval=<60> set logging interval in seconds (range 60 - 3600), default is 60 seconds
|
|
||||||
--minimal forward only 2 jobs per block (1 for miniblocks and 1 for final miniblock), by default all jobs are forwarded
|
|
||||||
--nonce enable nonce editing, default is off
|
|
||||||
--pool use this option for pool mining; this option avoids changing the keyhash
|
|
||||||
|
|
||||||
Example Mainnet: ./derohe-proxy --daemon-address=minernode1.dero.io:10100
|
|
||||||
`
|
|
||||||
|
|
||||||
// program arguments
|
|
||||||
var Arguments = map[string]interface{}{}
|
|
||||||
|
|
||||||
var Listen_addr string = "0.0.0.0:10200"
|
|
||||||
var Daemon_address string = "minernode1.dero.io:10100"
|
|
||||||
var WalletAddr string = ""
|
|
||||||
|
|
||||||
// logging interval in seconds
|
|
||||||
var Log_intervall int = 60
|
|
||||||
|
|
||||||
// send only 2 jobs per block
|
|
||||||
var Minimal bool = false
|
|
||||||
|
|
||||||
// edit nonce
|
|
||||||
var Nonce bool = false
|
|
||||||
|
|
||||||
// pool mining
|
|
||||||
var Pool_mode bool = false
|
|
@ -1,125 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"derohe-proxy/config"
|
|
||||||
"derohe-proxy/proxy"
|
|
||||||
"fmt"
|
|
||||||
"net"
|
|
||||||
"strconv"
|
|
||||||
"sync"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/deroproject/derohe/globals"
|
|
||||||
"github.com/docopt/docopt-go"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
var err error
|
|
||||||
var rwmutex sync.RWMutex
|
|
||||||
|
|
||||||
config.Arguments, err = docopt.Parse(config.Command_line, nil, true, "pre-alpha", false)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if config.Arguments["--listen-address"] != nil {
|
|
||||||
addr, err := net.ResolveTCPAddr("tcp", config.Arguments["--listen-address"].(string))
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
} else {
|
|
||||||
if addr.Port == 0 {
|
|
||||||
return
|
|
||||||
} else {
|
|
||||||
config.Listen_addr = addr.String()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if config.Arguments["--daemon-address"] == nil {
|
|
||||||
return
|
|
||||||
} else {
|
|
||||||
config.Daemon_address = config.Arguments["--daemon-address"].(string)
|
|
||||||
}
|
|
||||||
|
|
||||||
if config.Arguments["--wallet-address"] != nil {
|
|
||||||
addr, err := globals.ParseValidateAddress(config.Arguments["--wallet-address"].(string))
|
|
||||||
if err != nil {
|
|
||||||
fmt.Printf("%v Wallet address is invalid!\n", time.Now().Format(time.Stamp))
|
|
||||||
}
|
|
||||||
config.WalletAddr = addr.String()
|
|
||||||
fmt.Printf("%v Using wallet %s for all connections\n", time.Now().Format(time.Stamp), config.WalletAddr)
|
|
||||||
}
|
|
||||||
|
|
||||||
if config.Arguments["--log-interval"] != nil {
|
|
||||||
interval, err := strconv.ParseInt(config.Arguments["--log-interval"].(string), 10, 32)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
} else {
|
|
||||||
if interval < 60 || interval > 3600 {
|
|
||||||
config.Log_intervall = 60
|
|
||||||
} else {
|
|
||||||
config.Log_intervall = int(interval)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if config.Arguments["--minimal"].(bool) {
|
|
||||||
config.Minimal = true
|
|
||||||
fmt.Printf("%v Forward only 2 jobs per block\n", time.Now().Format(time.Stamp))
|
|
||||||
}
|
|
||||||
|
|
||||||
if config.Arguments["--nonce"].(bool) {
|
|
||||||
config.Nonce = true
|
|
||||||
fmt.Printf("%v Nonce editing is enabled\n", time.Now().Format(time.Stamp))
|
|
||||||
}
|
|
||||||
|
|
||||||
if config.Arguments["--pool"].(bool) {
|
|
||||||
config.Pool_mode = true
|
|
||||||
config.Minimal = false
|
|
||||||
fmt.Printf("%v Pool mode is enabled\n", time.Now().Format(time.Stamp))
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Printf("%v Logging every %d seconds\n", time.Now().Format(time.Stamp), config.Log_intervall)
|
|
||||||
|
|
||||||
go proxy.Start_server()
|
|
||||||
|
|
||||||
// Wait for first miner connection to grab wallet address
|
|
||||||
for proxy.CountMiners() < 1 {
|
|
||||||
time.Sleep(time.Second * 1)
|
|
||||||
}
|
|
||||||
go proxy.Start_client(proxy.Address)
|
|
||||||
//go proxy.SendUpdateToDaemon()
|
|
||||||
|
|
||||||
for {
|
|
||||||
time.Sleep(time.Second * time.Duration(config.Log_intervall))
|
|
||||||
|
|
||||||
hash_rate_string := ""
|
|
||||||
|
|
||||||
switch {
|
|
||||||
case proxy.Hashrate > 1000000000000:
|
|
||||||
hash_rate_string = fmt.Sprintf("%.3f TH/s", float64(proxy.Hashrate)/1000000000000.0)
|
|
||||||
case proxy.Hashrate > 1000000000:
|
|
||||||
hash_rate_string = fmt.Sprintf("%.3f GH/s", float64(proxy.Hashrate)/1000000000.0)
|
|
||||||
case proxy.Hashrate > 1000000:
|
|
||||||
hash_rate_string = fmt.Sprintf("%.3f MH/s", float64(proxy.Hashrate)/1000000.0)
|
|
||||||
case proxy.Hashrate > 1000:
|
|
||||||
hash_rate_string = fmt.Sprintf("%.3f KH/s", float64(proxy.Hashrate)/1000.0)
|
|
||||||
case proxy.Hashrate > 0:
|
|
||||||
hash_rate_string = fmt.Sprintf("%d H/s", int(proxy.Hashrate))
|
|
||||||
}
|
|
||||||
|
|
||||||
if !config.Pool_mode {
|
|
||||||
fmt.Printf("%v %d miners connected, IB:%d MB:%d MBR:%d MBO:%d - MINING @ %s\n", time.Now().Format(time.Stamp), proxy.CountMiners(), proxy.Blocks, proxy.Minis, proxy.Rejected, proxy.Orphans, hash_rate_string)
|
|
||||||
} else {
|
|
||||||
fmt.Printf("%v %d miners connected, Pool stats: IB:%d MB:%d MBR:%d MBO:%d - MINING @ %s\n", time.Now().Format(time.Stamp), proxy.CountMiners(), proxy.Blocks, proxy.Minis, proxy.Rejected, proxy.Orphans, hash_rate_string)
|
|
||||||
}
|
|
||||||
rwmutex.RLock()
|
|
||||||
for i := range proxy.Wallet_count {
|
|
||||||
if proxy.Wallet_count[i] > 1 {
|
|
||||||
fmt.Printf("%v Wallet %v, %d miners\n", time.Now().Format(time.Stamp), i, proxy.Wallet_count[i])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
rwmutex.RUnlock()
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
module derohe-proxy
|
|
||||||
|
|
||||||
go 1.18
|
|
||||||
|
|
||||||
require (
|
|
||||||
github.com/chzyer/readline v1.5.0
|
|
||||||
github.com/deroproject/derohe v0.0.0-20220502125456-607af6dfdc9a
|
|
||||||
github.com/deroproject/graviton v0.0.0-20220130070622-2c248a53b2e1
|
|
||||||
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815
|
|
||||||
github.com/gorilla/websocket v1.5.0
|
|
||||||
github.com/lesismal/llib v1.1.6
|
|
||||||
github.com/lesismal/nbio v1.2.18
|
|
||||||
)
|
|
||||||
|
|
||||||
require (
|
|
||||||
github.com/blang/semver/v4 v4.0.0 // indirect
|
|
||||||
github.com/caarlos0/env/v6 v6.9.1 // indirect
|
|
||||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
|
||||||
github.com/fxamacker/cbor/v2 v2.4.0 // indirect
|
|
||||||
github.com/go-logr/logr v1.2.3 // indirect
|
|
||||||
github.com/go-logr/zapr v1.2.3 // indirect
|
|
||||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
|
||||||
github.com/robfig/cron/v3 v3.0.1 // indirect
|
|
||||||
github.com/satori/go.uuid v1.2.0 // indirect
|
|
||||||
github.com/stretchr/testify v1.7.1 // indirect
|
|
||||||
github.com/x448/float16 v0.8.4 // indirect
|
|
||||||
go.uber.org/atomic v1.7.0 // indirect
|
|
||||||
go.uber.org/multierr v1.6.0 // indirect
|
|
||||||
go.uber.org/zap v1.21.0 // indirect
|
|
||||||
golang.org/x/crypto v0.0.0-20210513122933-cd7d49e622d5 // indirect
|
|
||||||
golang.org/x/net v0.0.0-20210510120150-4163338589ed // indirect
|
|
||||||
golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5 // indirect
|
|
||||||
golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f // indirect
|
|
||||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
|
|
||||||
)
|
|
@ -1,116 +0,0 @@
|
|||||||
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
|
|
||||||
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
|
|
||||||
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
|
|
||||||
github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM=
|
|
||||||
github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ=
|
|
||||||
github.com/caarlos0/env/v6 v6.9.1 h1:zOkkjM0F6ltnQ5eBX6IPI41UP/KDGEK7rRPwGCNos8k=
|
|
||||||
github.com/caarlos0/env/v6 v6.9.1/go.mod h1:hvp/ryKXKipEkcuYjs9mI4bBCg+UI0Yhgm5Zu0ddvwc=
|
|
||||||
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
|
|
||||||
github.com/chzyer/logex v1.2.0 h1:+eqR0HfOetur4tgnC8ftU5imRnhi4te+BadWS95c5AM=
|
|
||||||
github.com/chzyer/logex v1.2.0/go.mod h1:9+9sk7u7pGNWYMkh0hdiL++6OeibzJccyQU4p4MedaY=
|
|
||||||
github.com/chzyer/readline v1.5.0 h1:lSwwFrbNviGePhkewF1az4oLmcwqCZijQ2/Wi3BGHAI=
|
|
||||||
github.com/chzyer/readline v1.5.0/go.mod h1:x22KAscuvRqlLoK9CsoYsmxoXZMMFVyOl86cAH8qUic=
|
|
||||||
github.com/chzyer/test v0.0.0-20210722231415-061457976a23 h1:dZ0/VyGgQdVGAss6Ju0dt5P0QltE0SFY5Woh6hbIfiQ=
|
|
||||||
github.com/chzyer/test v0.0.0-20210722231415-061457976a23/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
|
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
|
||||||
github.com/deroproject/derohe v0.0.0-20220502125456-607af6dfdc9a h1:hl0OLefIqk4AlonnM/0IBbff+ZvkGEB4fFrmzAgXLk8=
|
|
||||||
github.com/deroproject/derohe v0.0.0-20220502125456-607af6dfdc9a/go.mod h1:EWHh1VkXRnCHvyGML98kXhngDFYebmOhk/9kZ1ATJ1c=
|
|
||||||
github.com/deroproject/graviton v0.0.0-20220130070622-2c248a53b2e1 h1:nsiNx83HYmRmYpYO37pUzSTmB7p9PFtGBl4FyD+a0jg=
|
|
||||||
github.com/deroproject/graviton v0.0.0-20220130070622-2c248a53b2e1/go.mod h1:a4u6QJtGGIADg1JwujD77UtaAyhIxg14+I0C7xjyQcc=
|
|
||||||
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815 h1:bWDMxwH3px2JBh6AyO7hdCn/PkvCZXii8TGj7sbtEbQ=
|
|
||||||
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE=
|
|
||||||
github.com/fxamacker/cbor/v2 v2.4.0 h1:ri0ArlOR+5XunOP8CRUowT0pSJOwhW098ZCUyskZD88=
|
|
||||||
github.com/fxamacker/cbor/v2 v2.4.0/go.mod h1:TA1xS00nchWmaBnEIxPSE5oHLuJBAVvqrtAnWBwBCVo=
|
|
||||||
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
|
||||||
github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0=
|
|
||||||
github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
|
||||||
github.com/go-logr/zapr v1.2.3 h1:a9vnzlIBPQBBkeaR9IuMUfmVOrQlkoC4YfPoFkX3T7A=
|
|
||||||
github.com/go-logr/zapr v1.2.3/go.mod h1:eIauM6P8qSvTw5o2ez6UEAfGjQKrxQTl5EoK+Qa2oG4=
|
|
||||||
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
|
|
||||||
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
|
||||||
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
|
||||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
|
||||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
|
||||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
|
||||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
|
||||||
github.com/lesismal/llib v1.1.6 h1:/mtiOFShydKSEsO/cajK8benGD1OHgP51GrBni7rGEY=
|
|
||||||
github.com/lesismal/llib v1.1.6/go.mod h1:3vmCrIMrpkaoA3bDu/sI+J7EyEUMPbOvmAxb7PlzilM=
|
|
||||||
github.com/lesismal/nbio v1.2.18 h1:0xo501NqzQLqYuvOBm4hgYoi6tX+qPI6f/fO8koXXbQ=
|
|
||||||
github.com/lesismal/nbio v1.2.18/go.mod h1:11bIzMFWwJJ5WurkTKIJejOw5JPCfPP+siptchxeSr8=
|
|
||||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
|
||||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
|
||||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
|
||||||
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
|
|
||||||
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
|
|
||||||
github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww=
|
|
||||||
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
|
|
||||||
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
|
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
|
||||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
|
||||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
|
||||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
|
||||||
github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
|
|
||||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
|
||||||
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
|
|
||||||
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
|
|
||||||
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
|
||||||
go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw=
|
|
||||||
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
|
|
||||||
go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A=
|
|
||||||
go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI=
|
|
||||||
go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ=
|
|
||||||
go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4=
|
|
||||||
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
|
|
||||||
go.uber.org/zap v1.19.0/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI=
|
|
||||||
go.uber.org/zap v1.21.0 h1:WefMeulhovoZ2sYXz7st6K0sLj7bBhpiFaud4r4zST8=
|
|
||||||
go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw=
|
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
|
||||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
|
||||||
golang.org/x/crypto v0.0.0-20210513122933-cd7d49e622d5 h1:N6Jp/LCiEoIBX56BZSR2bepK5GtbSC2DDOYT742mMfE=
|
|
||||||
golang.org/x/crypto v0.0.0-20210513122933-cd7d49e622d5/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8=
|
|
||||||
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
|
||||||
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
|
||||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
|
||||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
|
||||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
|
||||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
|
||||||
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
|
||||||
golang.org/x/net v0.0.0-20210510120150-4163338589ed h1:p9UgmWI9wKpfYmgaV/IZKGdXc5qEK45tDwwwDyjS26I=
|
|
||||||
golang.org/x/net v0.0.0-20210510120150-4163338589ed/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
|
||||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
|
||||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
|
||||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5 h1:y/woIyUBFbpQGKS0u1aHF/40WUDnek3fPOyD08H5Vng=
|
|
||||||
golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
|
||||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
|
||||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
|
||||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
|
||||||
golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
|
||||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
|
||||||
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
|
||||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
|
||||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
|
||||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
|
||||||
golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f h1:GGU+dLjvlC3qDwqYgL6UgRmHXhOOgns0bZu2Ty5mm6U=
|
|
||||||
golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
|
||||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
|
|
||||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
|
||||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|
||||||
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
|
||||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
|
||||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
|
|
||||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
|
@ -1,90 +0,0 @@
|
|||||||
RESEARCH LICENSE
|
|
||||||
|
|
||||||
|
|
||||||
Version 1.1.2
|
|
||||||
|
|
||||||
I. DEFINITIONS.
|
|
||||||
|
|
||||||
"Licensee " means You and any other party that has entered into and has in effect a version of this License.
|
|
||||||
|
|
||||||
“Licensor” means DERO PROJECT(GPG: 0F39 E425 8C65 3947 702A 8234 08B2 0360 A03A 9DE8) and its successors and assignees.
|
|
||||||
|
|
||||||
"Modifications" means any (a) change or addition to the Technology or (b) new source or object code implementing any portion of the Technology.
|
|
||||||
|
|
||||||
"Research Use" means research, evaluation, or development for the purpose of advancing knowledge, teaching, learning, or customizing the Technology for personal use. Research Use expressly excludes use or distribution for direct or indirect commercial (including strategic) gain or advantage.
|
|
||||||
|
|
||||||
"Technology" means the source code, object code and specifications of the technology made available by Licensor pursuant to this License.
|
|
||||||
|
|
||||||
"Technology Site" means the website designated by Licensor for accessing the Technology.
|
|
||||||
|
|
||||||
"You" means the individual executing this License or the legal entity or entities represented by the individual executing this License.
|
|
||||||
|
|
||||||
II. PURPOSE.
|
|
||||||
|
|
||||||
Licensor is licensing the Technology under this Research License (the "License") to promote research, education, innovation, and development using the Technology.
|
|
||||||
|
|
||||||
COMMERCIAL USE AND DISTRIBUTION OF TECHNOLOGY AND MODIFICATIONS IS PERMITTED ONLY UNDER AN APPROPRIATE COMMERCIAL USE LICENSE AVAILABLE FROM LICENSOR AT <url>.
|
|
||||||
|
|
||||||
III. RESEARCH USE RIGHTS.
|
|
||||||
|
|
||||||
A. Subject to the conditions contained herein, Licensor grants to You a non-exclusive, non-transferable, worldwide, and royalty-free license to do the following for Your Research Use only:
|
|
||||||
|
|
||||||
1. reproduce, create Modifications of, and use the Technology alone, or with Modifications;
|
|
||||||
2. share source code of the Technology alone, or with Modifications, with other Licensees;
|
|
||||||
|
|
||||||
3. distribute object code of the Technology, alone, or with Modifications, to any third parties for Research Use only, under a license of Your choice that is consistent with this License; and
|
|
||||||
|
|
||||||
4. publish papers and books discussing the Technology which may include relevant excerpts that do not in the aggregate constitute a significant portion of the Technology.
|
|
||||||
|
|
||||||
B. Residual Rights. You may use any information in intangible form that you remember after accessing the Technology, except when such use violates Licensor's copyrights or patent rights.
|
|
||||||
|
|
||||||
C. No Implied Licenses. Other than the rights granted herein, Licensor retains all rights, title, and interest in Technology , and You retain all rights, title, and interest in Your Modifications and associated specifications, subject to the terms of this License.
|
|
||||||
|
|
||||||
D. Open Source Licenses. Portions of the Technology may be provided with notices and open source licenses from open source communities and third parties that govern the use of those portions, and any licenses granted hereunder do not alter any rights and obligations you may have under such open source licenses, however, the disclaimer of warranty and limitation of liability provisions in this License will apply to all Technology in this distribution.
|
|
||||||
|
|
||||||
IV. INTELLECTUAL PROPERTY REQUIREMENTS
|
|
||||||
|
|
||||||
As a condition to Your License, You agree to comply with the following restrictions and responsibilities:
|
|
||||||
|
|
||||||
A. License and Copyright Notices. You must include a copy of this License in a Readme file for any Technology or Modifications you distribute. You must also include the following statement, "Use and distribution of this technology is subject to the Java Research License included herein", (a) once prominently in the source code tree and/or specifications for Your source code distributions, and (b) once in the same file as Your copyright or proprietary notices for Your binary code distributions. You must cause any files containing Your Modification to carry prominent notice stating that You changed the files. You must not remove or alter any copyright or other proprietary notices in the Technology.
|
|
||||||
|
|
||||||
B. Licensee Exchanges. Any Technology and Modifications You receive from any Licensee are governed by this License.
|
|
||||||
|
|
||||||
V. GENERAL TERMS.
|
|
||||||
|
|
||||||
A. Disclaimer Of Warranties.
|
|
||||||
|
|
||||||
TECHNOLOGY IS PROVIDED "AS IS", WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT ANY SUCH TECHNOLOGY IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING OF THIRD PARTY RIGHTS. YOU AGREE THAT YOU BEAR THE ENTIRE RISK IN CONNECTION WITH YOUR USE AND DISTRIBUTION OF ANY AND ALL TECHNOLOGY UNDER THIS LICENSE.
|
|
||||||
|
|
||||||
B. Infringement; Limitation Of Liability.
|
|
||||||
|
|
||||||
1. If any portion of, or functionality implemented by, the Technology becomes the subject of a claim or threatened claim of infringement ("Affected Materials"), Licensor may, in its unrestricted discretion, suspend Your rights to use and distribute the Affected Materials under this License. Such suspension of rights will be effective immediately upon Licensor's posting of notice of suspension on the Technology Site.
|
|
||||||
|
|
||||||
2. IN NO EVENT WILL LICENSOR BE LIABLE FOR ANY DIRECT, INDIRECT, PUNITIVE, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES IN CONNECTION WITH OR ARISING OUT OF THIS LICENSE (INCLUDING, WITHOUT LIMITATION, LOSS OF PROFITS, USE, DATA, OR ECONOMIC ADVANTAGE OF ANY SORT), HOWEVER IT ARISES AND ON ANY THEORY OF LIABILITY (including negligence), WHETHER OR NOT LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. LIABILITY UNDER THIS SECTION V.B.2 SHALL BE SO LIMITED AND EXCLUDED, NOTWITHSTANDING FAILURE OF THE ESSENTIAL PURPOSE OF ANY REMEDY.
|
|
||||||
|
|
||||||
C. Termination.
|
|
||||||
|
|
||||||
1. You may terminate this License at any time by notifying Licensor in writing.
|
|
||||||
|
|
||||||
2. All Your rights will terminate under this License if You fail to comply with any of its material terms or conditions and do not cure such failure within thirty (30) days after becoming aware of such noncompliance.
|
|
||||||
|
|
||||||
3. Upon termination, You must discontinue all uses and distribution of the Technology , and all provisions of this Section V shall survive termination.
|
|
||||||
|
|
||||||
D. Miscellaneous.
|
|
||||||
|
|
||||||
1. Trademark. You agree to comply with Licensor's Trademark & Logo Usage Requirements, if any and as modified from time to time, available at the Technology Site. Except as expressly provided in this License, You are granted no rights in or to any Licensor's trademarks now or hereafter used or licensed by Licensor.
|
|
||||||
|
|
||||||
2. Integration. This License represents the complete agreement of the parties concerning the subject matter hereof.
|
|
||||||
|
|
||||||
3. Severability. If any provision of this License is held unenforceable, such provision shall be reformed to the extent necessary to make it enforceable unless to do so would defeat the intent of the parties, in which case, this License shall terminate.
|
|
||||||
|
|
||||||
4. Governing Law. This License is governed by the laws of the United States and the State of California, as applied to contracts entered into and performed in California between California residents. In no event shall this License be construed against the drafter.
|
|
||||||
|
|
||||||
5. Export Control. You agree to comply with the U.S. export controlsand trade laws of other countries that apply to Technology and Modifications.
|
|
||||||
|
|
||||||
READ ALL THE TERMS OF THIS LICENSE CAREFULLY BEFORE ACCEPTING.
|
|
||||||
|
|
||||||
BY CLICKING ON THE YES BUTTON BELOW OR USING THE TECHNOLOGY, YOU ARE ACCEPTING AND AGREEING TO ABIDE BY THE TERMS AND CONDITIONS OF THIS LICENSE. YOU MUST BE AT LEAST 18 YEARS OF AGE AND OTHERWISE COMPETENT TO ENTER INTO CONTRACTS.
|
|
||||||
|
|
||||||
IF YOU DO NOT MEET THESE CRITERIA, OR YOU DO NOT AGREE TO ANY OF THE TERMS OF THIS LICENSE, DO NOT USE THIS SOFTWARE IN ANY FORM.
|
|
||||||
|
|
@ -1,151 +0,0 @@
|
|||||||
package proxy
|
|
||||||
|
|
||||||
import (
|
|
||||||
"crypto/tls"
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
"math/rand"
|
|
||||||
"net/url"
|
|
||||||
"sync"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"derohe-proxy/config"
|
|
||||||
|
|
||||||
"github.com/gorilla/websocket"
|
|
||||||
)
|
|
||||||
|
|
||||||
type (
|
|
||||||
GetBlockTemplate_Params struct {
|
|
||||||
Wallet_Address string `json:"wallet_address"`
|
|
||||||
Block bool `json:"block"`
|
|
||||||
Miner string `json:"miner"`
|
|
||||||
}
|
|
||||||
GetBlockTemplate_Result struct {
|
|
||||||
JobID string `json:"jobid"`
|
|
||||||
Blocktemplate_blob string `json:"blocktemplate_blob,omitempty"`
|
|
||||||
Blockhashing_blob string `json:"blockhashing_blob,omitempty"`
|
|
||||||
Difficulty string `json:"difficulty"`
|
|
||||||
Difficultyuint64 uint64 `json:"difficultyuint64"`
|
|
||||||
Height uint64 `json:"height"`
|
|
||||||
Prev_Hash string `json:"prev_hash"`
|
|
||||||
EpochMilli uint64 `json:"epochmilli"`
|
|
||||||
Blocks uint64 `json:"blocks"` // number of blocks found
|
|
||||||
MiniBlocks uint64 `json:"miniblocks"` // number of miniblocks found
|
|
||||||
Rejected uint64 `json:"rejected"` // reject count
|
|
||||||
LastError string `json:"lasterror"` // last error
|
|
||||||
Status string `json:"status"`
|
|
||||||
Orphans uint64 `json:"orphans"`
|
|
||||||
Hansen33Mod bool `json:"hansen33_mod"`
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
type clientConn struct {
|
|
||||||
conn *websocket.Conn
|
|
||||||
sync.Mutex
|
|
||||||
}
|
|
||||||
|
|
||||||
var connection clientConn
|
|
||||||
var Blocks uint64
|
|
||||||
var Minis uint64
|
|
||||||
var Rejected uint64
|
|
||||||
var Orphans uint64
|
|
||||||
var ModdedNode bool = false
|
|
||||||
var Hashrate float64
|
|
||||||
|
|
||||||
// proxy-client
|
|
||||||
func Start_client(w string) {
|
|
||||||
var err error
|
|
||||||
var last_diff uint64
|
|
||||||
var last_height uint64
|
|
||||||
|
|
||||||
rand.Seed(time.Now().UnixMilli())
|
|
||||||
|
|
||||||
for {
|
|
||||||
|
|
||||||
u := url.URL{Scheme: "wss", Host: config.Daemon_address, Path: "/ws/" + w}
|
|
||||||
|
|
||||||
dialer := websocket.DefaultDialer
|
|
||||||
dialer.TLSClientConfig = &tls.Config{
|
|
||||||
InsecureSkipVerify: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
if !config.Pool_mode {
|
|
||||||
fmt.Printf("%v Connected to node %v\n", time.Now().Format(time.Stamp), config.Daemon_address)
|
|
||||||
} else {
|
|
||||||
fmt.Printf("%v Connected to node %v using wallet %v\n", time.Now().Format(time.Stamp), config.Daemon_address, w)
|
|
||||||
}
|
|
||||||
connection.conn, _, err = websocket.DefaultDialer.Dial(u.String(), nil)
|
|
||||||
if err != nil {
|
|
||||||
time.Sleep(5 * time.Second)
|
|
||||||
fmt.Println(err)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
var params GetBlockTemplate_Result
|
|
||||||
|
|
||||||
for {
|
|
||||||
msg_type, recv_data, err := connection.conn.ReadMessage()
|
|
||||||
if err != nil {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if msg_type != websocket.TextMessage {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if err = json.Unmarshal(recv_data, ¶ms); err != nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
Blocks = params.Blocks
|
|
||||||
Minis = params.MiniBlocks
|
|
||||||
Rejected = params.Rejected
|
|
||||||
Orphans = params.Orphans
|
|
||||||
|
|
||||||
if ModdedNode != params.Hansen33Mod {
|
|
||||||
if params.Hansen33Mod {
|
|
||||||
fmt.Printf("%v Hansen33 Mod Mining Node Detected - Happy Mining\n", time.Now().Format(time.Stamp))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ModdedNode = params.Hansen33Mod
|
|
||||||
|
|
||||||
if !ModdedNode {
|
|
||||||
fmt.Printf("%v Official Mining Node Detected - Happy Mining\n", time.Now().Format(time.Stamp))
|
|
||||||
}
|
|
||||||
if config.Minimal {
|
|
||||||
if params.Height != last_height || params.Difficultyuint64 != last_diff {
|
|
||||||
last_height = params.Height
|
|
||||||
last_diff = params.Difficultyuint64
|
|
||||||
go SendTemplateToNodes(recv_data)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
go SendTemplateToNodes(recv_data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func SendUpdateToDaemon() {
|
|
||||||
|
|
||||||
var count = 0
|
|
||||||
for {
|
|
||||||
if ModdedNode {
|
|
||||||
if count == 0 {
|
|
||||||
time.Sleep(60 * time.Second)
|
|
||||||
}
|
|
||||||
|
|
||||||
connection.conn.WriteJSON(MinerInfo_Params{Wallet_Address: Address, Miner_Tag: "", Miner_Hashrate: Hashrate})
|
|
||||||
|
|
||||||
count++
|
|
||||||
}
|
|
||||||
time.Sleep(10 * time.Second)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func SendToDaemon(buffer []byte) {
|
|
||||||
connection.Lock()
|
|
||||||
defer connection.Unlock()
|
|
||||||
|
|
||||||
connection.conn.WriteMessage(websocket.TextMessage, buffer)
|
|
||||||
|
|
||||||
}
|
|
@ -1,56 +0,0 @@
|
|||||||
package proxy
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"encoding/hex"
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
"math/rand"
|
|
||||||
|
|
||||||
"github.com/deroproject/derohe/block"
|
|
||||||
)
|
|
||||||
|
|
||||||
func edit_blob(input []byte, miner [32]byte, nonce bool) (output []byte) {
|
|
||||||
var err error
|
|
||||||
var params GetBlockTemplate_Result
|
|
||||||
var mbl block.MiniBlock
|
|
||||||
var raw_hex []byte
|
|
||||||
var out bytes.Buffer
|
|
||||||
|
|
||||||
if err = json.Unmarshal(input, ¶ms); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if raw_hex, err = hex.DecodeString(params.Blockhashing_blob); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if mbl.Deserialize(raw_hex); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Insert miner address
|
|
||||||
if !mbl.Final {
|
|
||||||
copy(mbl.KeyHash[:], miner[:])
|
|
||||||
}
|
|
||||||
|
|
||||||
// Insert random nonce
|
|
||||||
if nonce {
|
|
||||||
for i := range mbl.Nonce {
|
|
||||||
mbl.Nonce[i] = rand.Uint32()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mbl.Flags = 3735928559 // ;)
|
|
||||||
|
|
||||||
params.Blockhashing_blob = fmt.Sprintf("%x", mbl.Serialize())
|
|
||||||
encoder := json.NewEncoder(&out)
|
|
||||||
|
|
||||||
if err = encoder.Encode(params); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
output = out.Bytes()
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
@ -1,314 +0,0 @@
|
|||||||
package proxy
|
|
||||||
|
|
||||||
import (
|
|
||||||
"crypto/ecdsa"
|
|
||||||
"crypto/elliptic"
|
|
||||||
"crypto/rand"
|
|
||||||
"crypto/x509"
|
|
||||||
"encoding/pem"
|
|
||||||
"fmt"
|
|
||||||
"math/big"
|
|
||||||
"net/http"
|
|
||||||
"runtime"
|
|
||||||
"strings"
|
|
||||||
"sync"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"derohe-proxy/config"
|
|
||||||
|
|
||||||
"github.com/deroproject/derohe/globals"
|
|
||||||
"github.com/deroproject/derohe/rpc"
|
|
||||||
"github.com/deroproject/graviton"
|
|
||||||
"github.com/lesismal/llib/std/crypto/tls"
|
|
||||||
"github.com/lesismal/nbio"
|
|
||||||
"github.com/lesismal/nbio/nbhttp"
|
|
||||||
"github.com/lesismal/nbio/nbhttp/websocket"
|
|
||||||
)
|
|
||||||
|
|
||||||
var server *nbhttp.Server
|
|
||||||
|
|
||||||
var memPool = sync.Pool{
|
|
||||||
New: func() interface{} {
|
|
||||||
return make([]byte, 16*1024)
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
type user_session struct {
|
|
||||||
blocks uint64
|
|
||||||
miniblocks uint64
|
|
||||||
lasterr string
|
|
||||||
address rpc.Address
|
|
||||||
worker string
|
|
||||||
orphans uint64
|
|
||||||
hashrate float64
|
|
||||||
valid_address bool
|
|
||||||
address_sum [32]byte
|
|
||||||
}
|
|
||||||
|
|
||||||
type ( // array without name containing block template in hex
|
|
||||||
MinerInfo_Params struct {
|
|
||||||
Wallet_Address string `json:"wallet_address"`
|
|
||||||
Miner_Tag string `json:"miner_tag"`
|
|
||||||
Miner_Hashrate float64 `json:"miner_hashrate"`
|
|
||||||
}
|
|
||||||
MinerInfo_Result struct {
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
var client_list_mutex sync.Mutex
|
|
||||||
var client_list = map[*websocket.Conn]*user_session{}
|
|
||||||
|
|
||||||
var miners_count int
|
|
||||||
var shares uint64
|
|
||||||
var Wallet_count map[string]uint
|
|
||||||
var Address string
|
|
||||||
|
|
||||||
func Start_server() {
|
|
||||||
var err error
|
|
||||||
|
|
||||||
tlsConfig := &tls.Config{
|
|
||||||
Certificates: []tls.Certificate{generate_random_tls_cert()},
|
|
||||||
InsecureSkipVerify: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
mux := &http.ServeMux{}
|
|
||||||
mux.HandleFunc("/", onWebsocket) // handle everything
|
|
||||||
|
|
||||||
server = nbhttp.NewServer(nbhttp.Config{
|
|
||||||
Name: "GETWORK",
|
|
||||||
Network: "tcp",
|
|
||||||
AddrsTLS: []string{config.Listen_addr},
|
|
||||||
TLSConfig: tlsConfig,
|
|
||||||
Handler: mux,
|
|
||||||
MaxLoad: 10 * 1024,
|
|
||||||
MaxWriteBufferSize: 5 * 1024 * 1024,
|
|
||||||
ReleaseWebsocketPayload: true,
|
|
||||||
KeepaliveTime: 240 * time.Hour, // we expects all miners to find a block every 10 days,
|
|
||||||
NPoller: runtime.NumCPU(),
|
|
||||||
})
|
|
||||||
|
|
||||||
server.OnReadBufferAlloc(func(c *nbio.Conn) []byte {
|
|
||||||
return memPool.Get().([]byte)
|
|
||||||
})
|
|
||||||
server.OnReadBufferFree(func(c *nbio.Conn, b []byte) {
|
|
||||||
memPool.Put(b)
|
|
||||||
})
|
|
||||||
|
|
||||||
if err = server.Start(); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
Wallet_count = make(map[string]uint)
|
|
||||||
|
|
||||||
server.Wait()
|
|
||||||
defer server.Stop()
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func CountMiners() int {
|
|
||||||
client_list_mutex.Lock()
|
|
||||||
defer client_list_mutex.Unlock()
|
|
||||||
|
|
||||||
miners_count = len(client_list)
|
|
||||||
|
|
||||||
return miners_count
|
|
||||||
}
|
|
||||||
|
|
||||||
// forward all incoming templates from daemon to all miners
|
|
||||||
func SendTemplateToNodes(data []byte) {
|
|
||||||
|
|
||||||
client_list_mutex.Lock()
|
|
||||||
defer client_list_mutex.Unlock()
|
|
||||||
|
|
||||||
for rk, rv := range client_list {
|
|
||||||
|
|
||||||
if client_list == nil {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if !config.Pool_mode {
|
|
||||||
miner_address := rv.address_sum
|
|
||||||
|
|
||||||
if result := edit_blob(data, miner_address, config.Nonce); result != nil {
|
|
||||||
data = result
|
|
||||||
} else {
|
|
||||||
fmt.Println(time.Now().Format(time.Stamp), "Failed to change nonce / miner keyhash")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
go func(k *websocket.Conn, v *user_session) {
|
|
||||||
defer globals.Recover(2)
|
|
||||||
k.SetWriteDeadline(time.Now().Add(100 * time.Millisecond))
|
|
||||||
k.WriteMessage(websocket.TextMessage, data)
|
|
||||||
|
|
||||||
}(rk, rv)
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// handling for incoming miner connections
|
|
||||||
func onWebsocket(w http.ResponseWriter, r *http.Request) {
|
|
||||||
if !strings.HasPrefix(r.URL.Path, "/ws/") {
|
|
||||||
http.NotFound(w, r)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
address := strings.TrimPrefix(r.URL.Path, "/ws/")
|
|
||||||
|
|
||||||
// check for worker suffix
|
|
||||||
var parseWorker []string
|
|
||||||
var worker string
|
|
||||||
if strings.Contains(address, ".") {
|
|
||||||
parseWorker = strings.Split(address, ".")
|
|
||||||
worker = parseWorker[1]
|
|
||||||
address = parseWorker[0]
|
|
||||||
}
|
|
||||||
|
|
||||||
addr, err := globals.ParseValidateAddress(address)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Fprintf(w, "err: %s\n", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
upgrader := newUpgrader()
|
|
||||||
conn, err := upgrader.Upgrade(w, r, nil)
|
|
||||||
if err != nil {
|
|
||||||
//panic(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
addr_raw := addr.PublicKey.EncodeCompressed()
|
|
||||||
wsConn := conn.(*websocket.Conn)
|
|
||||||
|
|
||||||
session := user_session{address: *addr, address_sum: graviton.Sum(addr_raw), worker: worker}
|
|
||||||
wsConn.SetSession(&session)
|
|
||||||
|
|
||||||
client_list_mutex.Lock()
|
|
||||||
defer client_list_mutex.Unlock()
|
|
||||||
|
|
||||||
client_list[wsConn] = &session
|
|
||||||
Wallet_count[client_list[wsConn].address.String()]++
|
|
||||||
|
|
||||||
if config.WalletAddr != "" {
|
|
||||||
Address = config.WalletAddr
|
|
||||||
} else {
|
|
||||||
Address = address
|
|
||||||
}
|
|
||||||
|
|
||||||
if !config.Pool_mode {
|
|
||||||
fmt.Printf("%v Incoming connection: %v (%v), Wallet: %v\n", time.Now().Format(time.Stamp), wsConn.RemoteAddr().String(), worker, address)
|
|
||||||
} else {
|
|
||||||
fmt.Printf("%v Incoming connection: %v (%v)\n", time.Now().Format(time.Stamp), wsConn.RemoteAddr().String(), worker)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// forward results to daemon
|
|
||||||
func newUpgrader() *websocket.Upgrader {
|
|
||||||
u := websocket.NewUpgrader()
|
|
||||||
|
|
||||||
u.OnMessage(func(c *websocket.Conn, messageType websocket.MessageType, data []byte) {
|
|
||||||
|
|
||||||
if messageType != websocket.TextMessage {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
client_list_mutex.Lock()
|
|
||||||
defer client_list_mutex.Unlock()
|
|
||||||
|
|
||||||
/*
|
|
||||||
var x MinerInfo_Params
|
|
||||||
if json.Unmarshal(data, &x); len(x.Wallet_Address) > 0 {
|
|
||||||
|
|
||||||
if x.Miner_Hashrate > 0 {
|
|
||||||
sess := client_list[c]
|
|
||||||
sess.hashrate = x.Miner_Hashrate
|
|
||||||
client_list[c] = sess
|
|
||||||
}
|
|
||||||
|
|
||||||
var NewHashRate float64
|
|
||||||
for _, s := range client_list {
|
|
||||||
NewHashRate += s.hashrate
|
|
||||||
}
|
|
||||||
Hashrate = NewHashRate
|
|
||||||
|
|
||||||
// Update miners information
|
|
||||||
return
|
|
||||||
} else {
|
|
||||||
*/
|
|
||||||
SendToDaemon(data)
|
|
||||||
if !config.Pool_mode {
|
|
||||||
fmt.Printf("%v Submitting result from miner: %v (%v), Wallet: %v\n", time.Now().Format(time.Stamp), c.RemoteAddr().String(), client_list[c].worker, client_list[c].address.String())
|
|
||||||
} else {
|
|
||||||
shares++
|
|
||||||
fmt.Printf("%v Shares submitted: %d\n", time.Now().Format(time.Stamp), shares)
|
|
||||||
}
|
|
||||||
//}
|
|
||||||
})
|
|
||||||
|
|
||||||
u.OnClose(func(c *websocket.Conn, err error) {
|
|
||||||
client_list_mutex.Lock()
|
|
||||||
defer client_list_mutex.Unlock()
|
|
||||||
Wallet_count[client_list[c].address.String()]--
|
|
||||||
fmt.Printf("%v Lost connection: %v (%v)\n", time.Now().Format(time.Stamp), c.RemoteAddr().String(), client_list[c].worker)
|
|
||||||
delete(client_list, c)
|
|
||||||
})
|
|
||||||
|
|
||||||
return u
|
|
||||||
}
|
|
||||||
|
|
||||||
// taken unmodified from derohe repo
|
|
||||||
// cert handling
|
|
||||||
func generate_random_tls_cert() tls.Certificate {
|
|
||||||
|
|
||||||
/* RSA can do only 500 exchange per second, we need to be faster
|
|
||||||
* reference https://github.com/golang/go/issues/20058
|
|
||||||
key, err := rsa.GenerateKey(rand.Reader, 512) // current using minimum size
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal("Private key cannot be created.", err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
// Generate a pem block with the private key
|
|
||||||
keyPem := pem.EncodeToMemory(&pem.Block{
|
|
||||||
Type: "RSA PRIVATE KEY",
|
|
||||||
Bytes: x509.MarshalPKCS1PrivateKey(key),
|
|
||||||
})
|
|
||||||
*/
|
|
||||||
// EC256 does roughly 20000 exchanges per second
|
|
||||||
key, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
|
|
||||||
b, err := x509.MarshalECPrivateKey(key)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
// Generate a pem block with the private key
|
|
||||||
keyPem := pem.EncodeToMemory(&pem.Block{Type: "EC PRIVATE KEY", Bytes: b})
|
|
||||||
|
|
||||||
tml := x509.Certificate{
|
|
||||||
SerialNumber: big.NewInt(int64(time.Now().UnixNano())),
|
|
||||||
|
|
||||||
// TODO do we need to add more parameters to make our certificate more authentic
|
|
||||||
// and thwart traffic identification as a mass scale
|
|
||||||
|
|
||||||
// you can add any attr that you need
|
|
||||||
NotBefore: time.Now().AddDate(0, -1, 0),
|
|
||||||
NotAfter: time.Now().AddDate(1, 0, 0),
|
|
||||||
// you have to generate a different serial number each execution
|
|
||||||
/*
|
|
||||||
Subject: pkix.Name{
|
|
||||||
CommonName: "New Name",
|
|
||||||
Organization: []string{"New Org."},
|
|
||||||
},
|
|
||||||
BasicConstraintsValid: true, // even basic constraints are not required
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
cert, err := x509.CreateCertificate(rand.Reader, &tml, &tml, &key.PublicKey, key)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Generate a pem block with the certificate
|
|
||||||
certPem := pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: cert})
|
|
||||||
tlsCert, err := tls.X509KeyPair(certPem, keyPem)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return tlsCert
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user