Skip to content

Commit

Permalink
Added ability to force use of flashlight from command-line
Browse files Browse the repository at this point in the history
  • Loading branch information
oxtoacart committed Dec 5, 2014
1 parent 7290977 commit 530fc06
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/main/java/org/lantern/Cli.java
Expand Up @@ -52,6 +52,7 @@ public class Cli {
public static final String OPTION_PLUGGABLE_TRANSPORT = "pt";
public static final String OPTION_CHECK_FALLBACKS = "check-fallbacks";
public static final String OPTION_CHROME = "chrome";
public static final String OPTION_FORCE_FLASHLIGHT = "force-flashlight";

private CommandLine cmd;

Expand Down Expand Up @@ -167,6 +168,7 @@ public static Options buildOptions() {
.withValueSeparator()
.withDescription("(Optional) Specify pluggable transport properties")
.create());
options.addOption(null, OPTION_FORCE_FLASHLIGHT, false, "Force all traffic through flashlight (useful for testing)");
return options;
}

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/lantern/LanternClientConstants.java
Expand Up @@ -79,6 +79,8 @@ public class LanternClientConstants {
public static final long START_TIME = System.currentTimeMillis();

public static final int SYNC_INTERVAL_SECONDS = 6;

public static volatile boolean FORCE_FLASHLIGHT = false;

/**
* Plist file for launchd on OSX.
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/org/lantern/S3Config.java
Expand Up @@ -74,7 +74,9 @@ public Map<String, String> getMasqueradeHostsToCerts() {
@JsonIgnore
public Collection<FallbackProxy> getAllFallbacks() {
final Collection<FallbackProxy> all = new HashSet<FallbackProxy>();
all.addAll(getFallbacks());
if (!LanternClientConstants.FORCE_FLASHLIGHT) {
all.addAll(getFallbacks());
}
all.add(FLASHLIGHT_PROXY);
return all;
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/lantern/state/ModelIo.java
Expand Up @@ -286,6 +286,10 @@ private void processCommandLine(final CommandLine cmd, final Model model) {
if (cmd.hasOption(Cli.OPTION_CHROME)) {
set.setChrome(true);
}

if (cmd.hasOption(Cli.OPTION_FORCE_FLASHLIGHT)) {
LanternClientConstants.FORCE_FLASHLIGHT = true;
}
}

private void loadServerAuthTokenFile(final String filename, final Settings set) {
Expand Down

0 comments on commit 530fc06

Please sign in to comment.