commit f7e684cc2f317ee8c2e8b0479c450d219b1afc24 Author: David Fifield david@bamsoftware.com Date: Thu Apr 10 08:55:20 2014 -0700
Use the flag package in meek-client-torbrowser.
I want to be able to give separate arguments to meek-client-torbrowser (like a log file). You can separate meek-client-torbrowser's options from meek-client's with a "--". --- meek-client-torbrowser/meek-client-torbrowser.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/meek-client-torbrowser/meek-client-torbrowser.go b/meek-client-torbrowser/meek-client-torbrowser.go index 1d55eff..1ac2f93 100644 --- a/meek-client-torbrowser/meek-client-torbrowser.go +++ b/meek-client-torbrowser/meek-client-torbrowser.go @@ -1,3 +1,6 @@ +// Usage: +// meek-client-torbrowser -- --url=https://meek-reflect.appspot.com/ --front=www.google.com --log meek-client.log +// // The meek-client-torbrowser program starts a copy of Tor Browser running // meek-http-helper in a special profile, and then starts meek-client set up to // use the browser helper. @@ -8,6 +11,7 @@ package main
import ( "bufio" + "flag" "io" "io/ioutil" "log" @@ -91,8 +95,7 @@ func grepHelperAddr(r io.Reader) (string, error) { }
// Run meek-client and return its exec.Cmd. -func runMeekClient(helperAddr string) (cmd *exec.Cmd, err error) { - args := os.Args[1:] +func runMeekClient(helperAddr string, args []string) (cmd *exec.Cmd, err error) { args = append(args, []string{"--helper", helperAddr}...) cmd = exec.Command(meekClientPath, args...) cmd.Stdout = os.Stdout @@ -109,6 +112,8 @@ func runMeekClient(helperAddr string) (cmd *exec.Cmd, err error) { func main() { var err error
+ flag.Parse() + f, err := os.OpenFile("meek-client-torbrowser.log", os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0600) if err != nil { log.Fatal(err) @@ -141,7 +146,7 @@ func main() { }
// Start meek-client with the helper address. - meekClientCmd, err := runMeekClient(helperAddr) + meekClientCmd, err := runMeekClient(helperAddr, flag.Args()) if err != nil { log.Print(err) return