diff --git a/cmd/dmsgweb/README.md b/cmd/dmsgweb/README.md index ac418b38..c5fe77fa 100644 --- a/cmd/dmsgweb/README.md +++ b/cmd/dmsgweb/README.md @@ -2,31 +2,79 @@ ``` +$ go run cmd/dmsgweb/dmsgweb.go --help -┌┬┐┌┬┐┌─┐┌─┐┬ ┬┌─┐┌┐ - │││││└─┐│ ┬│││├┤ ├┴┐ -─┴┘┴ ┴└─┘└─┘└┴┘└─┘└─┘ -DMSG resolving proxy & browser client - access websites over dmsg + ┌┬┐┌┬┐┌─┐┌─┐┬ ┬┌─┐┌┐ + │││││└─┐│ ┬│││├┤ ├┴┐ + ─┴┘┴ ┴└─┘└─┘└┴┘└─┘└─┘ +DMSG resolving proxy & browser client - access websites and http interfaces over dmsg +.conf file may also be specified with +DMSGWEB=/path/to/dmsgweb.conf skywire dmsg web Usage: -web + dmsgweb Available Commands: -completion Generate the autocompletion script for the specified shell -gen-keys generate public / secret keypair + completion Generate the autocompletion script for the specified shell + srv Serve HTTP or raw TCP from local port over DMSG Flags: --d, --dmsg-disc string dmsg discovery url default: - http://dmsgd.skywire.skycoin.com --f, --filter string domain suffix to filter (default ".dmsg") --l, --loglvl string [ debug | warn | error | fatal | panic | trace | info ] --p, --port string port to serve the web application (default "8080") --r, --proxy string configure additional socks5 proxy for dmsgweb (i.e. 127.0.0.1:1080) --t, --resolve string resolve the specified dmsg address:port on the local port & disable proxy --e, --sess int number of dmsg servers to connect to (default 1) --s, --sk cipher.SecKey a random key is generated if unspecified -(default 0000000000000000000000000000000000000000000000000000000000000000) --q, --socks string port to serve the socks5 proxy (default "4445") --v, --version version for web + -r, --addproxy string configure additional socks5 proxy for dmsgweb (i.e. 127.0.0.1:1080) + + -D, --dmsg-disc string dmsg discovery url + (default "http://dmsgd.skywire.skycoin.com") + -z, --envs show example .conf file + + -f, --filter string domain suffix to filter + (default ".dmsg") + -l, --loglvl string [ debug | warn | error | fatal | panic | trace | info ] + + -p, --port uints port(s) to serve the web application + (default [8080]) + -x, --proxy string connect to dmsg via proxy (i.e. '127.0.0.1:1080') + + -t, --resolve strings resolve the specified dmsg address:port on the local port & disable proxy + + -c, --rt bools proxy local port as raw TCP + (default [false]) + -e, --sess int number of dmsg servers to connect to + (default 1) + -s, --sk cipher.SecKey a random key is generated if unspecified + (default 0000000000000000000000000000000000000000000000000000000000000000) + -q, --socks uint port to serve the socks5 proxy + (default 4445) + -v, --version version for dmsgweb + +``` + +``` +$ go run cmd/dmsgweb/dmsgweb.go srv --help +DMSG web server - serve HTTP or raw TCP interface from local port over DMSG + .conf file may also be specified with DMSGWEBSRV=/path/to/dmsgwebsrv.conf skywire dmsg web srv + +Usage: + dmsgweb srv [flags] + +Flags: + -D, --dmsg-disc string DMSG discovery URL + (default "http://dmsgd.skywire.skycoin.com") + -d, --dport uints DMSG port(s) to serve + (default [80]) + -e, --dsess int DMSG sessions + (default 1) + -z, --envs show example .conf file + + -l, --loglvl string [ debug | warn | error | fatal | panic | trace | info ] + + -p, --lport uints local application interface port(s) + (default [8086]) + -x, --proxy string connect to DMSG via proxy (e.g., '127.0.0.1:1080') + + -c, --rt bools proxy local port as raw TCP, comma separated + (default [false]) + -s, --sk cipher.SecKey a random key is generated if unspecified + (default 0000000000000000000000000000000000000000000000000000000000000000) + -w, --wl strings whitelisted keys for DMSG authenticated routes + ``` diff --git a/cmd/dmsgweb/commands/dmsgweb.go b/cmd/dmsgweb/commands/dmsgweb.go index f1c5c7c4..7db2a4c1 100644 --- a/cmd/dmsgweb/commands/dmsgweb.go +++ b/cmd/dmsgweb/commands/dmsgweb.go @@ -67,18 +67,18 @@ func init() { } pk, _ = sk.PubKey() //nolint - RootCmd.Flags().StringVarP(&filterDomainSuffix, "filter", "f", ".dmsg", "domain suffix to filter") - RootCmd.Flags().UintVarP(&proxyPort, "socks", "q", proxyPort, "port to serve the socks5 proxy") - RootCmd.Flags().StringVarP(&addProxy, "addproxy", "r", addProxy, "configure additional socks5 proxy for dmsgweb (i.e. 127.0.0.1:1080)") - RootCmd.Flags().UintSliceVarP(&webPort, "port", "p", webPort, "port(s) to serve the web application") - RootCmd.Flags().StringSliceVarP(&resolveDmsgAddr, "resolve", "t", resolveDmsgAddr, "resolve the specified dmsg address:port on the local port & disable proxy") - RootCmd.Flags().StringVarP(&dmsgDisc, "dmsg-disc", "D", dmsgDisc, "dmsg discovery url") - RootCmd.Flags().StringVarP(&proxyAddr, "proxy", "x", "", "connect to dmsg via proxy (i.e. '127.0.0.1:1080')") - RootCmd.Flags().IntVarP(&dmsgSessions, "sess", "e", dmsgSess, "number of dmsg servers to connect to") - RootCmd.Flags().BoolSliceVarP(&rawTCP, "rt", "c", rawTCP, "proxy local port as raw TCP") - RootCmd.Flags().StringVarP(&logLvl, "loglvl", "l", "", "[ debug | warn | error | fatal | panic | trace | info ]\033[0m") + RootCmd.Flags().StringVarP(&filterDomainSuffix, "filter", "f", ".dmsg", "domain suffix to filter\033[0m\n\r") + RootCmd.Flags().UintVarP(&proxyPort, "socks", "q", proxyPort, "port to serve the socks5 proxy\033[0m\n\r") + RootCmd.Flags().StringVarP(&addProxy, "addproxy", "r", addProxy, "configure additional socks5 proxy for dmsgweb (i.e. 127.0.0.1:1080)\033[0m\n\r") + RootCmd.Flags().UintSliceVarP(&webPort, "port", "p", webPort, "port(s) to serve the web application\033[0m\n\r") + RootCmd.Flags().StringSliceVarP(&resolveDmsgAddr, "resolve", "t", resolveDmsgAddr, "resolve the specified dmsg address:port on the local port & disable proxy\033[0m\n\r") + RootCmd.Flags().StringVarP(&dmsgDisc, "dmsg-disc", "D", dmsgDisc, "dmsg discovery url\033[0m\n\r") + RootCmd.Flags().StringVarP(&proxyAddr, "proxy", "x", "", "connect to dmsg via proxy (i.e. '127.0.0.1:1080')\033[0m\n\r") + RootCmd.Flags().IntVarP(&dmsgSessions, "sess", "e", dmsgSess, "number of dmsg servers to connect to\033[0m\n\r") + RootCmd.Flags().BoolSliceVarP(&rawTCP, "rt", "c", rawTCP, "proxy local port as raw TCP\033[0m\n\r") + RootCmd.Flags().StringVarP(&logLvl, "loglvl", "l", "debug", "[ debug | warn | error | fatal | panic | trace | info ]\033[0m\n\r") RootCmd.Flags().VarP(&sk, "sk", "s", "a random key is generated if unspecified\n\r") - RootCmd.Flags().BoolVarP(&isEnvs, "envs", "z", false, "show example .conf file") + RootCmd.Flags().BoolVarP(&isEnvs, "envs", "z", false, "show example .conf file\033[0m\n\r") } diff --git a/cmd/dmsgweb/commands/dmsgwebsrv.go b/cmd/dmsgweb/commands/dmsgwebsrv.go index 5d869d5e..a1253e17 100644 --- a/cmd/dmsgweb/commands/dmsgwebsrv.go +++ b/cmd/dmsgweb/commands/dmsgwebsrv.go @@ -43,16 +43,16 @@ func init() { pk, _ = sk.PubKey() //nolint RootCmd.AddCommand(srvCmd) - srvCmd.Flags().UintSliceVarP(&localPort, "lport", "p", localPort, "local application interface port(s)") - srvCmd.Flags().UintSliceVarP(&dmsgPort, "dport", "d", dmsgPort, "DMSG port(s) to serve") - srvCmd.Flags().StringSliceVarP(&wl, "wl", "w", wl, "whitelisted keys for DMSG authenticated routes") - srvCmd.Flags().StringVarP(&dmsgDisc, "dmsg-disc", "D", dmsgDisc, "DMSG discovery URL") - srvCmd.Flags().StringVarP(&proxyAddr, "proxy", "x", proxyAddr, "connect to DMSG via proxy (e.g., '127.0.0.1:1080')") - srvCmd.Flags().IntVarP(&dmsgSess, "dsess", "e", dmsgSess, "DMSG sessions") - srvCmd.Flags().BoolSliceVarP(&rawTCP, "rt", "c", rawTCP, "proxy local port as raw TCP, comma separated") - srvCmd.Flags().StringVarP(&logLvl, "loglvl", "l", "", "[ debug | warn | error | fatal | panic | trace | info ]\033[0m") - srvCmd.Flags().BoolVarP(&isEnvs, "envs", "z", false, "show example .conf file") - srvCmd.Flags().VarP(&sk, "sk", "s", "a random key is generated if unspecified") + srvCmd.Flags().UintSliceVarP(&localPort, "lport", "p", localPort, "local application interface port(s)\033[0m\n\r") + srvCmd.Flags().UintSliceVarP(&dmsgPort, "dport", "d", dmsgPort, "DMSG port(s) to serve\033[0m\n\r") + srvCmd.Flags().StringSliceVarP(&wl, "wl", "w", wl, "whitelisted keys for DMSG authenticated routes\033[0m\n\r") + srvCmd.Flags().StringVarP(&dmsgDisc, "dmsg-disc", "D", dmsgDisc, "DMSG discovery URL\033[0m\n\r") + srvCmd.Flags().StringVarP(&proxyAddr, "proxy", "x", proxyAddr, "connect to DMSG via proxy (e.g., '127.0.0.1:1080')\033[0m\n\r") + srvCmd.Flags().IntVarP(&dmsgSess, "dsess", "e", dmsgSess, "DMSG sessions\033[0m\n\r") + srvCmd.Flags().BoolSliceVarP(&rawTCP, "rt", "c", rawTCP, "proxy local port as raw TCP, comma separated\033[0m\n\r") + srvCmd.Flags().StringVarP(&logLvl, "loglvl", "l", "debug", "[ debug | warn | error | fatal | panic | trace | info ]\033[0m\n\r") + srvCmd.Flags().BoolVarP(&isEnvs, "envs", "z", false, "show example .conf file\033[0m\n\r") + srvCmd.Flags().VarP(&sk, "sk", "s", "a random key is generated if unspecified\033[0m\n\r") srvCmd.CompletionOptions.DisableDefaultCmd = true } @@ -257,13 +257,13 @@ func proxyTCPConnections(ctx context.Context, localPort uint, listener net.Liste defer localConn.Close() //nolint go func() { - _, err := io.Copy(dmsgConn, localConn) - if err != nil { + _, err1 := io.Copy(dmsgConn, localConn) + if err1 != nil { dLog.WithError(err).Warn("Error on io.Copy(dmsgConn, localConn)") } }() - _, err := io.Copy(localConn, dmsgConn) - if err != nil { + _, err2 := io.Copy(localConn, dmsgConn) + if err2 != nil { dLog.WithError(err).Warn("Error on io.Copy(localConn, dmsgConn)") }