Skip to content

Commit

Permalink
Merge branch 'valencia-mobile-socks' into valencia-mobile-full
Browse files Browse the repository at this point in the history
  • Loading branch information
oxtoacart committed Feb 7, 2016
2 parents d3862ba + 3bbdce0 commit e8d60d1
Show file tree
Hide file tree
Showing 1,549 changed files with 123 additions and 133,664 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,5 @@ LanternMobileTestbed/app/libs/
*.apk
*.aar
*/.idea/workspace.xml */.idea/tasks.xml
*/app/build
*/sdk/build
29 changes: 15 additions & 14 deletions MobileSDK/sdk/src/main/java/org/lantern/mobilesdk/Lantern.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
* Created by ox.to.a.cart on 1/28/16.
*/
public class Lantern {
private static boolean enabled = false;

private static final Map<String, Tracker> trackersById = new HashMap<>();
private static boolean enabled = false;

static {
// Track extra info about Android for logging to Loggly.
Expand All @@ -31,22 +30,22 @@ public class Lantern {
* <p>Starts Lantern at a random port, storing configuration information in the indicated
* configDir and waiting up to timeoutMillis for the proxy to come online. If the proxy fails to
* come online within the timeout, this throws an exception.</p>
*
* <p/>
* <p>If a Lantern proxy is already running within this process, that proxy is reused.</p>
*
* <p/>
* <p>Note - this does not wait for the entire initialization sequence to finish, just for the
* proxy to be listening. Once the proxy is listening, one can start to use it, even as it
* finishes its initialization sequence. However, initial activity may be slow, so clients with
* low read timeouts may time out.</p>
*
* @param context
* @param timeoutMillis how long to wait for proxy to start listening (should be fairly quick)
* @param timeoutMillis how long to wait for proxy to start listening (should be fairly quick)
* @param analyticsTrackingId (optional tracking ID for tracking Google analytics)
*
* @return the {@link go.lantern.Lantern.StartResult} with port information about the started
* lantern
*/
public synchronized static go.lantern.Lantern.StartResult enable(Context context, int timeoutMillis, String analyticsTrackingId) {
public synchronized static go.lantern.Lantern.StartResult enable(Context context, int timeoutMillis, String analyticsTrackingId)
throws LanternNotRunningException {
String configDir = new File(context.getFilesDir().getAbsolutePath(), ".lantern").getAbsolutePath();
go.lantern.Lantern.StartResult result = enable(configDir, timeoutMillis);
if (analyticsTrackingId != null && !enabled) {
Expand All @@ -55,19 +54,21 @@ public synchronized static go.lantern.Lantern.StartResult enable(Context context
return result;
}

private static go.lantern.Lantern.StartResult enable(String configDir, int timeoutMillis) {
private static go.lantern.Lantern.StartResult enable(String configDir, int timeoutMillis)
throws LanternNotRunningException {
try {
go.lantern.Lantern.StartResult result = go.lantern.Lantern.Start(configDir, timeoutMillis);
String addr = result.getHTTPAddr();
String host = addr.split(":")[0];
String port = addr.split(":")[1];
int lastIndexOfColon = addr.lastIndexOf(':');
String host = addr.substring(0, lastIndexOfColon);
String port = addr.substring(lastIndexOfColon + 1);
System.setProperty("http.proxyHost", host);
System.setProperty("http.proxyPort", port);
System.setProperty("https.proxyHost", host);
System.setProperty("https.proxyPort", port);
return result;
} catch (Exception e) {
throw new RuntimeException("Unable to start Lantern: " + e.getMessage(), e);
throw new LanternNotRunningException("Unable to start Lantern: " + e.getMessage(), e);
}
}

Expand Down Expand Up @@ -100,9 +101,9 @@ private static void trackStartSession(Context context, String trackingId) {

private static void sendSessionEvent(Context context, String trackingId, String action) {
trackerFor(context, trackingId).send(new HitBuilders.EventBuilder()
.setCategory("Session")
.setLabel("android")
.setAction(action)
.setCategory("Session")
.setLabel("android")
.setAction(action)
.build());
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.lantern.mobilesdk;

/**
* Thrown to indicate that Lantern is not running.
*
* @author ox
*/
public class LanternNotRunningException extends Exception {
public LanternNotRunningException(String msg, Throwable cause) {
super(msg, cause);
}
}
22 changes: 22 additions & 0 deletions src/github.com/getlantern/lantern-mobile/.idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions src/github.com/getlantern/lantern-mobile/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/github.com/getlantern/lantern-mobile/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/github.com/getlantern/lantern-mobile/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e8d60d1

Please sign in to comment.