option for map a local port to different onion port number

This commit is contained in:
Juan Ezquerro LLanes 2016-11-17 09:48:27 +01:00
parent 94a3b0b107
commit ebc736be8d
3 changed files with 9 additions and 3 deletions

View File

@ -565,14 +565,15 @@ public class OrbotMainActivity extends AppCompatActivity
stopVpnService(); stopVpnService();
} }
private void enableHiddenServicePort (String hsName, int hsPort, boolean getGey) throws RemoteException, InterruptedException private void enableHiddenServicePort (String hsName, int hsPort, int hsRemotePort, boolean getGey) throws RemoteException, InterruptedException
{ {
String onionHostname=""; String onionHostname="";
String[] mProjection = new String[]{ String[] mProjection = new String[]{
HSContentProvider.HiddenService._ID, HSContentProvider.HiddenService._ID,
HSContentProvider.HiddenService.NAME, HSContentProvider.HiddenService.NAME,
HSContentProvider.HiddenService.DOMAIN, HSContentProvider.HiddenService.DOMAIN,
HSContentProvider.HiddenService.PORT}; HSContentProvider.HiddenService.PORT,
HSContentProvider.HiddenService.REMOTE_PORT};
if(hsName == null) if(hsName == null)
hsName = "hs"+hsPort; hsName = "hs"+hsPort;
@ -580,6 +581,7 @@ public class OrbotMainActivity extends AppCompatActivity
ContentValues fields = new ContentValues(); ContentValues fields = new ContentValues();
fields.put("name", hsName); fields.put("name", hsName);
fields.put("port", hsPort); fields.put("port", hsPort);
fields.put("remote_port", hsRemotePort);
ContentResolver cr = getContentResolver(); ContentResolver cr = getContentResolver();
Cursor row = cr.query(HSContentProvider.CONTENT_URI, mProjection, "port="+hsPort, null, null); Cursor row = cr.query(HSContentProvider.CONTENT_URI, mProjection, "port="+hsPort, null, null);
@ -621,6 +623,7 @@ public class OrbotMainActivity extends AppCompatActivity
if (action.equals(INTENT_ACTION_REQUEST_HIDDEN_SERVICE)) if (action.equals(INTENT_ACTION_REQUEST_HIDDEN_SERVICE))
{ {
final int hiddenServicePort = getIntent().getIntExtra("hs_port", -1); final int hiddenServicePort = getIntent().getIntExtra("hs_port", -1);
final int hiddenServiceRemotePort = getIntent().getIntExtra("hs_remote_port", -1);
final String hiddenServiceName = getIntent().getStringExtra("hs_name"); final String hiddenServiceName = getIntent().getStringExtra("hs_name");
final boolean getHiddenServiceKey = getIntent().getBooleanExtra("hs_key",false); final boolean getHiddenServiceKey = getIntent().getBooleanExtra("hs_key",false);
@ -632,7 +635,8 @@ public class OrbotMainActivity extends AppCompatActivity
try { try {
enableHiddenServicePort ( enableHiddenServicePort (
hiddenServiceName, hiddenServicePort, getHiddenServiceKey hiddenServiceName, hiddenServicePort,
hiddenServiceRemotePort, getHiddenServiceKey
); );
} catch (RemoteException e) { } catch (RemoteException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block

View File

@ -15,6 +15,7 @@ public class HSDatabase extends SQLiteOpenHelper {
"_id INTEGER PRIMARY KEY AUTOINCREMENT, " + "_id INTEGER PRIMARY KEY AUTOINCREMENT, " +
"name TEXT, " + "name TEXT, " +
"domain TEXT, " + "domain TEXT, " +
"remote_port INTEGER, " +
"port INTEGER);"; "port INTEGER);";
public HSDatabase(Context context) { public HSDatabase(Context context) {

View File

@ -113,6 +113,7 @@ public class HSContentProvider extends ContentProvider {
//Nombres de columnas //Nombres de columnas
public static final String NAME = "name"; public static final String NAME = "name";
public static final String PORT = "port"; public static final String PORT = "port";
public static final String REMOTE_PORT = "remote_port";
public static final String DOMAIN = "domain"; public static final String DOMAIN = "domain";
private HiddenService() { private HiddenService() {