Skip to content

Commit

Permalink
update work on hidden service name setting
Browse files Browse the repository at this point in the history
  • Loading branch information
n8fr8 committed Oct 29, 2019
1 parent 84c3c3e commit 56e4726
Showing 1 changed file with 48 additions and 36 deletions.
Expand Up @@ -862,7 +862,11 @@ private void startTor() {

if (success)
{
updateOnionNames ();
try { updateOnionNames (); }
catch (SecurityException se)
{
logNotice("unable to upload onion names");
}
}

} catch (Exception e) {
Expand All @@ -875,7 +879,7 @@ private void startTor() {
}
}

private void updateOnionNames ()
private void updateOnionNames () throws SecurityException
{
// Tor is running, update new .onion names at db
ContentResolver mCR = getApplicationContext().getContentResolver();
Expand Down Expand Up @@ -1726,49 +1730,57 @@ else if (proxyPass != null)

ContentResolver mCR = getApplicationContext().getContentResolver();

/* ---- Hidden Services ---- */
Cursor hidden_services = mCR.query(HS_CONTENT_URI, hsProjection, HiddenService.ENABLED + "=1", null, null);
if(hidden_services != null) {
try {
while (hidden_services.moveToNext()) {
String HSname = hidden_services.getString(hidden_services.getColumnIndex(HiddenService.NAME));
Integer HSLocalPort = hidden_services.getInt(hidden_services.getColumnIndex(HiddenService.PORT));
Integer HSOnionPort = hidden_services.getInt(hidden_services.getColumnIndex(HiddenService.ONION_PORT));
Integer HSAuthCookie = hidden_services.getInt(hidden_services.getColumnIndex(HiddenService.AUTH_COOKIE));
String hsDirPath = new File(mHSBasePath.getAbsolutePath(),"hs" + HSLocalPort).getCanonicalPath();
try {
/* ---- Hidden Services ---- */
Cursor hidden_services = mCR.query(HS_CONTENT_URI, hsProjection, HiddenService.ENABLED + "=1", null, null);
if (hidden_services != null) {
try {
while (hidden_services.moveToNext()) {
String HSname = hidden_services.getString(hidden_services.getColumnIndex(HiddenService.NAME));
Integer HSLocalPort = hidden_services.getInt(hidden_services.getColumnIndex(HiddenService.PORT));
Integer HSOnionPort = hidden_services.getInt(hidden_services.getColumnIndex(HiddenService.ONION_PORT));
Integer HSAuthCookie = hidden_services.getInt(hidden_services.getColumnIndex(HiddenService.AUTH_COOKIE));
String hsDirPath = new File(mHSBasePath.getAbsolutePath(), "hs" + HSLocalPort).getCanonicalPath();

debug("Adding hidden service on port: " + HSLocalPort);
debug("Adding hidden service on port: " + HSLocalPort);

extraLines.append("HiddenServiceDir" + ' ' + hsDirPath).append('\n');
extraLines.append("HiddenServicePort" + ' ' + HSOnionPort + " 127.0.0.1:" + HSLocalPort).append('\n');
extraLines.append("HiddenServiceDir" + ' ' + hsDirPath).append('\n');
extraLines.append("HiddenServicePort" + ' ' + HSOnionPort + " 127.0.0.1:" + HSLocalPort).append('\n');

if(HSAuthCookie == 1)
extraLines.append("HiddenServiceAuthorizeClient stealth " + HSname).append('\n');
if (HSAuthCookie == 1)
extraLines.append("HiddenServiceAuthorizeClient stealth " + HSname).append('\n');
}
} catch (NumberFormatException e) {
Log.e(OrbotConstants.TAG, "error parsing hsport", e);
} catch (Exception e) {
Log.e(OrbotConstants.TAG, "error starting share server", e);
}
} catch (NumberFormatException e) {
Log.e(OrbotConstants.TAG,"error parsing hsport",e);
} catch (Exception e) {
Log.e(OrbotConstants.TAG,"error starting share server",e);

hidden_services.close();
}
}
catch (SecurityException se) {}

hidden_services.close();
}
try
{

/* ---- Client Cookies ---- */
Cursor client_cookies = mCR.query(COOKIE_CONTENT_URI, cookieProjection, ClientCookie.ENABLED + "=1", null, null);
if(client_cookies != null) {
try {
while (client_cookies.moveToNext()) {
String domain = client_cookies.getString(client_cookies.getColumnIndex(ClientCookie.DOMAIN));
String cookie = client_cookies.getString(client_cookies.getColumnIndex(ClientCookie.AUTH_COOKIE_VALUE));
extraLines.append("HidServAuth" + ' ' + domain + ' ' + cookie).append('\n');
/* ---- Client Cookies ---- */
Cursor client_cookies = mCR.query(COOKIE_CONTENT_URI, cookieProjection, ClientCookie.ENABLED + "=1", null, null);
if(client_cookies != null) {
try {
while (client_cookies.moveToNext()) {
String domain = client_cookies.getString(client_cookies.getColumnIndex(ClientCookie.DOMAIN));
String cookie = client_cookies.getString(client_cookies.getColumnIndex(ClientCookie.AUTH_COOKIE_VALUE));
extraLines.append("HidServAuth" + ' ' + domain + ' ' + cookie).append('\n');
}
} catch (Exception e) {
Log.e(OrbotConstants.TAG,"error starting share server",e);
}
} catch (Exception e) {
Log.e(OrbotConstants.TAG,"error starting share server",e);
}

client_cookies.close();
}
client_cookies.close();
}
}
catch (SecurityException se) {}

return extraLines;
}
Expand Down

0 comments on commit 56e4726

Please sign in to comment.