File tree Expand file tree Collapse file tree 2 files changed +12
-8
lines changed
Expand file tree Collapse file tree 2 files changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -2,10 +2,10 @@ package main
22
33import (
44 "context"
5+ "flag"
56 "fmt"
67 "os"
78 "strconv"
8- "strings"
99 "time"
1010
1111 "github.com/outcatcher/fwd2me/forwarder"
@@ -18,11 +18,11 @@ var (
1818
1919// keepForwarded makes sure ports are forwarded as long as possible without using a long lease.
2020func keepForwarded (ctx context.Context ) error {
21- if * portsStr == "" {
22- return fmt .Errorf ("no ports given" )
23- }
21+ portSlice := flag .Args ()
2422
25- portSlice := strings .Split (* portsStr , "," )
23+ if len (portSlice ) == 0 {
24+ return fmt .Errorf ("empty port list" )
25+ }
2626
2727 ports := make ([]uint16 , 0 , len (portSlice ))
2828
Original file line number Diff line number Diff line change @@ -10,12 +10,16 @@ import (
1010)
1111
1212var (
13- portsStr = flag .String ("ports" , "" , "Comma-separated list of ports to forward (REQUIRED)" )
14- proto = flag .String ("proto" , "TCP" , "Forwarded port protocol" )
15- label = flag .String ("label" , "fwd2me" , "Label for the forwarding" )
13+ proto = flag .String ("proto" , "TCP" , "Forwarded port protocol" )
14+ label = flag .String ("label" , "fwd2me" , "Label for the forwarding" )
1615)
1716
1817func main () {
18+ flag .Usage = func () {
19+ fmt .Fprintf (flag .CommandLine .Output (), "Usage of %s [options] [port1 port2 ...]:\n " , os .Args [0 ])
20+ flag .PrintDefaults ()
21+ }
22+
1923 flag .Parse ()
2024
2125 ctx , cancel := context .WithCancel (context .Background ())
You can’t perform that action at this time.
0 commit comments