Skip to content

Commit

Permalink
Add kingpin flag parsing (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
SapphicCode authored Aug 30, 2019
1 parent ef0fd43 commit f93f1f6
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 12 deletions.
23 changes: 12 additions & 11 deletions cmd/protoplex/protoplex.go
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
package main

import (
"flag"
"os"

"github.com/Pandentia/protoplex/protoplex"
"github.com/Pandentia/protoplex/protoplex/protocols"
"github.com/rs/zerolog"
"gopkg.in/alecthomas/kingpin.v2"
)

func main() {
app := kingpin.New("protoplex", "A fast and simple protocol multiplexer.")
logger := zerolog.New(os.Stdout).With().Timestamp().Logger()

bind := flag.String("bind", "0.0.0.0:8443", "The address to bind to")
verbose := flag.Bool("verbose", false, "Whether to be verbose")
pretty := flag.Bool("pretty", false, "Whether to enable pretty printing")
bind := app.Flag("bind", "The address to bind to").Short('b').Default("0.0.0.0:8443").String()
verbose := app.Flag("verbose", "Enables debug logging").Short('v').Bool()
pretty := app.Flag("pretty", "Enables pretty logging").Short('p').Bool()

ssh := flag.String("ssh", "", "The SSH server address")
tls := flag.String("tls", "", "The TLS/HTTPS server address")
openvpn := flag.String("ovpn", "", "The OpenVPN server address")
http := flag.String("http", "", "The HTTP server address")
socks5 := flag.String("socks5", "", "The SOCKS5 server address")
socks4 := flag.String("socks4", "", "The SOCKS4 server address")
ssh := app.Flag("ssh", "The SSH server address").String()
tls := app.Flag("tls", "The TLS/HTTPS server address").String()
openvpn := app.Flag("ovpn", "The OpenVPN server address").String()
http := app.Flag("http", "The HTTP server address").String()
socks5 := app.Flag("socks5", "The SOCKS5 server address").String()
socks4 := app.Flag("socks4", "The SOCKS4 server address").String()
// stRelay := flag.String("strelay", "", "The Syncthing Relay server address")

flag.Parse()
app.Parse(os.Args[1:])

if *pretty {
logger = logger.Output(zerolog.ConsoleWriter{Out: os.Stderr})
Expand Down
8 changes: 7 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@ module github.com/Pandentia/protoplex

go 1.12

require github.com/rs/zerolog v1.15.0
require (
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4 // indirect
github.com/rs/zerolog v1.15.0
github.com/stretchr/testify v1.4.0 // indirect
gopkg.in/alecthomas/kingpin.v2 v2.2.6
)
17 changes: 17 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafoB+tBA3gMyHYHrpOtNuDiK/uB5uXxq5wM=
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4 h1:Hs82Z41s6SdL1CELW+XaDYmOH4hkBN4/N9og/AsOv7E=
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pkg/errors v0.8.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/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ=
github.com/rs/zerolog v1.15.0 h1:uPRuwkWF4J6fGsJ2R0Gn2jB1EQiav9k3S6CSdygQJXY=
github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/tools v0.0.0-20190425163242-31fd60d6bfdc/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

0 comments on commit f93f1f6

Please sign in to comment.