54 lines
1.1 KiB
Go
54 lines
1.1 KiB
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"derohe-proxy/proxy"
|
||
|
"fmt"
|
||
|
"net"
|
||
|
"time"
|
||
|
|
||
|
"github.com/docopt/docopt-go"
|
||
|
)
|
||
|
|
||
|
func main() {
|
||
|
var err error
|
||
|
|
||
|
Arguments, err = docopt.Parse(command_line, nil, true, "pre-alpha", false)
|
||
|
|
||
|
if err != nil {
|
||
|
fmt.Printf("Error while parsing options err: %s\n", err)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
if Arguments["--listen-address"] != nil {
|
||
|
addr, err := net.ResolveTCPAddr("tcp", Arguments["--listen-address"].(string))
|
||
|
if err != nil {
|
||
|
fmt.Printf("--listen-address: address is invalid\n")
|
||
|
return
|
||
|
} else {
|
||
|
if addr.Port == 0 {
|
||
|
fmt.Printf("--listen-address: no port specified\n")
|
||
|
return
|
||
|
} else {
|
||
|
listen_addr = addr.String()
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if Arguments["--daemon-address"] == nil {
|
||
|
fmt.Printf("--daemon-address: option is required\n")
|
||
|
return
|
||
|
} else {
|
||
|
fmt.Printf("--daemon-address: is set to %v\n", Arguments["--daemon-address"].(string))
|
||
|
daemon_address = Arguments["--daemon-address"].(string)
|
||
|
}
|
||
|
|
||
|
go proxy.Start_server(listen_addr)
|
||
|
|
||
|
// Wait for first miner connection to grad wallet address
|
||
|
for proxy.CountMiners() < 1 {
|
||
|
time.Sleep(time.Second * 1)
|
||
|
}
|
||
|
proxy.Start_client(daemon_address, proxy.Address)
|
||
|
|
||
|
}
|