Skip to content
Diode client written in GO that run blockquick algorithm and socks server to transmit data through diodechain.
Go C C++ Assembly Java Python Other
Branch: master
Clone or download
Latest commit 2d922d2 Jan 21, 2020

README.MD

Diode go client

This is Go client for connecting device through diodechain. You can found more detail about how diodechain/client works in our previous presentations https://github.com/diodechain/presentations.

Build Status

Development

Prerequisite

Setup go environment

Mac

Before install golang, please ensure your device meets the requirements (https://golang.org/doc/install#requirements).

You can download the latest binary distribution https://golang.org/dl/ or install from the source code https://golang.org/doc/install/source. Here we are going to install golang with Homebrew.

Install Homebrew

$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Install Go

$ brew install golang

Then you can check go version meets the requirement (>1.10).

$ go version

Install dependencies

$ go mod download

Run test

$ go test `go list ./... | grep -v gowasm_test` // ignore gowasm_test folder

or

$ make test

Build

$ go build

or

$ make build

Examples

Command line options

Name
  diode - Diode network command line interfaces
SYNOPSIS
  diode [OPTIONS] COMMAND [ARG...]
OPTIONS
  -blacklists string
    	addresses are not allowed to connect to published resource (worked when whitelists is empty)
  -dbpath string
    	file path to db file (default "./db/private.db")
  -debug
    	turn on debug mode
  -diodeaddrs string
    	addresses of Diode node server (default "asia.testnet.diode.io:41043,europe.testnet.diode.io:41043,usa.testnet.diode.io:41043")
  -fleet string
    	fleet contract address (default "0x6000000000000000000000000000000000000000")
  -keepalive
    	enable tcp keepalive (default true)
  -metrics
    	enable metrics stats
  -registry string
    	registry contract address (default "0x5000000000000000000000000000000000000000")
  -retrytimes int
    	retry times to connect the remote rpc server (default 3)
  -retrywait int
    	wait seconds before next retry (default 1)
  -rlimit_nofile int
    	specify the file descriptor numbers that can be opened by this process
  -skiphostvalidation
    	skip host validation
  -timeout int
    	timeout seconds to connect to the remote rpc server (default 5)
  -whitelists string
    	addresses are allowed to connect to published resource (worked when whitelists is empty)
COMMANDS
  socksd
    This command enables a socks proxy on the local host for use with Browsers (Firefox), SSH, Java and other applications to communicate via the Diode Network.
    ARG
      -socksd_host string
    	host of socks server listening to (default "127.0.0.1")
      -socksd_port int
    	port of socks server listening to (default 1080)
    EXAMPLE
      diode socksd -socksd_port 8082 -socksd_host 127.0.0.1
  httpd
    This command enables a public http server as is used by the "diode.link" website
    ARG
      -allow_redirect
    	allow redirect all http transmission to httpsd
      -certpath string
    	Pem format of certificate file path of httpsd secure server (default "./priv/cert.pem")
      -httpd_host string
    	host of httpd server listening to (default "127.0.0.1")
      -httpd_port int
    	port of httpd server listening to (default 80)
      -httpsd_host string
    	host of httpsd server listening to (default "127.0.0.1")
      -httpsd_port int
    	port of httpsd server listening to (default 443)
      -privpath string
    	Pem format of private key file path of httpsd secure server (default "./priv/priv.pem")
      -proxy_host string
    	host of socksd proxy server (default "127.0.0.1")
      -proxy_port int
    	port of socksd proxy server (default 1080)
      -secure
    	enable httpsd server
      -socksd
    	enable socksd proxy server
    EXAMPLE
      diode httpd -httpd_port 8080 -httpsd_port 443 -secure -certpath ./cert.pem -privpath ./priv.pem
  publish
    This command publishes ports of the local device to the Diode Network.
    ARG
    EXAMPLE
      diode publish

Tunnel to ssh using your diode socks proxy

$ diode_go_client -runsocks=true
$ ssh pi@<ADDRESS>.diode -o 'ProxyCommand=nc -X 5 -x localhost:1080 %h %p'

Streaming video through websocket

  • Start socks with websocket server
$ go run main.go
  • Start raspivid or any other stream service
// profile must be baseline
$ raspivid -n -w 320 -h 180 -t 0 -l -o tcp://0.0.0.0:3030 -fps 12 -pf baseline

Then you can see streaming video through web/mplayer.

  • Through mplayer

    $ curl --socks5-hostname localhost:8080 <DIODE ADDRESS>.diode:9090 -o- | mplayer - -cache 1000
  • Through examples/web

    $ npm run dev
  • Enable proxy settings in browser

    Firefox

    1. Open Preferences in menu or type about:preferences in search bar.
    2. Goto Network Settings and click Settings button.
    3. Setup Automatic proxy configuration URL to the porxy.pac, eg: file:///Users/Guest/diode_go_client/proxy.pac
    4. Click reload then you can proxy request from *.diode *diode.ws to the go client.
  • Type the website URL and see <MODE>.<DIODE ADDRESS>.diode:8082.

    MODE:

    1. r: read
    2. w: write
    3. s: share
You can’t perform that action at this time.