Skip to content

Commit

Permalink
Readme and help
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahmed Bashir committed Oct 15, 2017
1 parent c2eebfa commit cf88c7c
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 3 deletions.
37 changes: 36 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,36 @@
# muxd
# muxd

Multi-purpose utility for converting network traffic

Usage:
```
./muxd --input-protocol tcp --input-host 127.0.0.1 --input-port 8080 --output-protocol udp --output-host myserver.example.com --output-port 12345 --debug
```

Help:
```
NAME:
muxd - Network multiplexer
USAGE:
muxd [global options] command [command options] [arguments...]
VERSION:
0.0.1
COMMANDS:
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS:
--input-protocol value Input protocol [tcp, udp, redis]
--input-host value Input host (IP)
--input-port value Input port (default: 0)
--input-channel value Input channel [redis]
--output-protocol value Output protocol [tcp, udp, redis]
--output-host value Output host (IP)
--output-port value Output port (default: 0)
--output-channel value Output channel [redis]
--debug Set debug log level
--help, -h show help
--version, -v print the version
```
15 changes: 14 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"os"

"github.com/ahmbas/muxd/mux"

log "github.com/sirupsen/logrus"
"github.com/urfave/cli"
prefixed "github.com/x-cray/logrus-prefixed-formatter"
Expand All @@ -14,7 +15,7 @@ func init() {
formatter.FullTimestamp = true
log.SetFormatter(formatter)
log.SetOutput(os.Stdout)
log.SetLevel(log.DebugLevel)
log.SetLevel(log.WarnLevel)
}

func main() {
Expand All @@ -27,8 +28,11 @@ func main() {
var outputHost string
var outputPort int
var outputChannel string
var debugLevel bool

app := cli.NewApp()
app.Version = "0.0.1"
app.Usage = "Network multiplexer"

app.Flags = []cli.Flag{
cli.StringFlag{
Expand Down Expand Up @@ -79,9 +83,18 @@ func main() {
Usage: "Output channel [redis]",
Destination: &outputChannel,
},
cli.BoolFlag{
Name: "debug",
Usage: "Set debug log level",
Destination: &debugLevel,
},
}
app.Action = func(c *cli.Context) error {

if debugLevel {
log.SetLevel(log.DebugLevel)
}

inputOpts := mux.Opts{
Protocol: inputProtocol,
Host: inputHost,
Expand Down
2 changes: 1 addition & 1 deletion mux/mux.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func GetConnection(o Opts) protocols.BaseConnection {
Port: o.Port,
}
default:
fmt.Printf("%v protocol not supported. Yet\n", o.Protocol)
fmt.Printf("Invalid args. Run with --help")
os.Exit(1)
}
return nil
Expand Down

0 comments on commit cf88c7c

Please sign in to comment.