Skip to content

Commit

Permalink
closes getlantern/lantern#2288 Added headless mode for lantern
Browse files Browse the repository at this point in the history
  • Loading branch information
oxtoacart committed Mar 9, 2015
1 parent f1b5e7b commit 274b707
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 11 deletions.
2 changes: 1 addition & 1 deletion run.bash
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

source setenv.bash
pushd src/github.com/getlantern/flashlight
go build && ./flashlight
go build && ./flashlight "$@"
popd
10 changes: 6 additions & 4 deletions src/github.com/getlantern/flashlight/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,20 @@ Usage of flashlight:
-configdir="": directory in which to store configuration, including flashlight.yaml (defaults to current directory)
-country="xx": 2 digit country code under which to report stats. Defaults to xx.
-cpuprofile="": write cpu profile to given file
-headless=false: if true, lantern will run with no ui
-help=false: Get usage help
-httptest.serve="": if non-empty, httptest.NewServer serves on this address and blocks
-instanceid="": instanceId under which to report stats to statshub. If not specified, no stats are reported.
-memprofile="": write heap profile to given file
-parentpid=0: the parent process's PID, used on Windows for killing flashlight when the parent disappears
-portmap=0: try to map this port on the firewall to the port on which flashlight is listening, using UPnP or NAT-PMP. If mapping this port fails, flashlight will exit with status code 50
-registerat="": base URL for peer DNS registry at which to register (e.g. https://peerscanner.getiantem.org)
-role="": either 'client' or 'server' (required)
-server="": FQDN of flashlight server when running in server mode (required)
-statsaddr="": host:port at which to make detailed stats available using server-sent events (optional)
-statshub="pure-journey-3547.herokuapp.com": address of statshub server
-statsperiod=0: time in seconds to wait between reporting stats. If not specified, stats are not reported. If specified, statshub, instanceid and statsaddr must also be specified.
-waddelladdr="": if specified, connect to this waddell server and process NAT traversal requests inbound from waddell
-waddellcert="": if specified, use this cert (PEM-encoded) to authenticate connections to waddell. Otherwise, a default certificate is used.
-statsperiod=0: time in seconds to wait between reporting stats. If not specified, stats are not reported. If specified, statshub, instanceid and statshubAddr must also be specified.
-uiaddr="": if specified, indicates host:port the UI HTTP server should be started on
-unencrypted=false: set to true to run server in unencrypted mode (no TLS)
```
Example Client:
Expand Down
26 changes: 20 additions & 6 deletions src/github.com/getlantern/flashlight/flashlight.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,12 @@ var (
// Command-line Flags
help = flag.Bool("help", false, "Get usage help")
parentPID = flag.Int("parentpid", 0, "the parent process's PID, used on Windows for killing flashlight when the parent disappears")
headless = flag.Bool("headless", false, "if true, lantern will run with no ui")

configUpdates = make(chan *config.Config)
exitCh = make(chan error, 1)

showui = true
)

func init() {
Expand All @@ -52,7 +55,15 @@ func init() {
}

func main() {
systray.Run(_main)
flag.Parse()
showui = !*headless

if showui {
systray.Run(_main)
} else {
log.Debug("Running headless")
_main()
}
}

func _main() {
Expand All @@ -76,13 +87,14 @@ func doMain() error {
defer systray.Quit()

i18nInit()
err = configureSystemTray()
if err != nil {
return err
if showui {
err = configureSystemTray()
if err != nil {
return err
}
}
displayVersion()

flag.Parse()
configUpdates = make(chan *config.Config)
cfg, err := config.Init()
if err != nil {
Expand Down Expand Up @@ -154,7 +166,9 @@ func runClientProxy(cfg *config.Config) {
exit(fmt.Errorf("Unable to start UI: %v", err))
return
}
ui.Show()
if showui {
ui.Show()
}
}

logging.Configure(cfg, version, buildDate)
Expand Down

0 comments on commit 274b707

Please sign in to comment.