[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r21823: {projects} Add an option for Relay support to Orbot! (projects/android/trunk/Orbot/src/org/torproject/android)



Author: ioerror
Date: 2010-03-06 01:23:36 +0000 (Sat, 06 Mar 2010)
New Revision: 21823

Modified:
   projects/android/trunk/Orbot/src/org/torproject/android/Orbot.java
Log:
Add an option for Relay support to Orbot!


Modified: projects/android/trunk/Orbot/src/org/torproject/android/Orbot.java
===================================================================
--- projects/android/trunk/Orbot/src/org/torproject/android/Orbot.java	2010-03-06 01:08:10 UTC (rev 21822)
+++ projects/android/trunk/Orbot/src/org/torproject/android/Orbot.java	2010-03-06 01:23:36 UTC (rev 21823)
@@ -457,7 +457,9 @@
 		boolean useBridges = prefs.getBoolean(PREF_BRIDGES_ENABLED, false);
 		
 		boolean autoUpdateBridges = prefs.getBoolean(PREF_BRIDGES_UPDATED, false);
-		
+
+        boolean becomeRelay = prefs.getBoolean(PREF_OR, false);
+
 		enableTransparentProxy = prefs.getBoolean(PREF_TRANSPARENT, false);
 		
 		if (hasRoot)
@@ -509,7 +511,31 @@
 		{
 			torrcText.append("UseBridges 0");
 		}
-		
+
+        try
+        {
+            if (becomeRelay && !useBridges)
+            {
+                int ORPort =  Integer.parseInt(prefs.getString(PREF_OR_PORT, "9001"));
+                String nickname = prefs.getString(PREF_OR_NICKNAME, "Orbot");
+
+                torrcText.append("ORPort ");
+                torrcText.append(ORPort);
+                torrcText.append('\n');
+
+                torrcText.append("Nickname ");
+                torrcText.append(nickname);
+                torrcText.append('\n');
+
+                torrcText.append("ExitPolicy reject *:*");
+                torrcText.append('\n');
+            }
+        }
+        catch (Exception e)
+        {
+            Toast.makeText(this,Â"Your relay settings caused an exception!", Toast.LENGTH_LONG).show();
+        }
+
 		Utils.saveTextFile(TorServiceConstants.TORRC_INSTALL_PATH, torrcText.toString());
 	}
 	
@@ -826,4 +852,4 @@
         }
     }
 	
-}
\ No newline at end of file
+}