Skip to content

Commit 05720e6

Browse files
authored
onion stuff (#796)
1 parent cdc2b23 commit 05720e6

File tree

94 files changed

+2210
-860
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+2210
-860
lines changed

app/build.gradle

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ android {
88
applicationId "com.m2049r.xmrwallet"
99
minSdkVersion 21
1010
targetSdkVersion 30
11-
versionCode 1102
12-
versionName "2.1.2 'Vertant'"
11+
versionCode 1201
12+
versionName "2.2.1 'René'"
1313
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1414
externalNativeBuild {
1515
cmake {
@@ -113,34 +113,38 @@ android {
113113
}
114114
}
115115

116-
def getId(name) {
117-
def Properties props = new Properties()
116+
static def getId(name) {
117+
Properties props = new Properties()
118118
props.load(new FileInputStream(new File('monerujo.id')))
119119
return props[name]
120120
}
121121

122122
dependencies {
123-
implementation 'androidx.core:core:1.3.2'
124-
implementation 'androidx.appcompat:appcompat:1.2.0'
125-
implementation 'com.google.android.material:material:1.3.0'
123+
implementation 'androidx.core:core:1.6.0'
124+
implementation 'androidx.appcompat:appcompat:1.3.1'
125+
implementation 'com.google.android.material:material:1.4.0'
126126
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
127-
implementation 'androidx.recyclerview:recyclerview:1.2.0'
127+
implementation 'androidx.recyclerview:recyclerview:1.2.1'
128128
implementation 'androidx.cardview:cardview:1.0.0'
129129
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.2.0-alpha01'
130-
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
130+
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
131131

132132
implementation 'me.dm7.barcodescanner:zxing:1.9.8'
133133
implementation "com.squareup.okhttp3:okhttp:4.9.0"
134134
implementation "io.github.rburgst:okhttp-digest:2.5"
135135
implementation "com.jakewharton.timber:timber:4.7.1"
136136

137+
implementation 'info.guardianproject.netcipher:netcipher:2.1.0'
138+
//implementation 'info.guardianproject.netcipher:netcipher-okhttp3:2.1.0'
139+
implementation fileTree(dir: 'libs/classes', include: ['*.jar'])
137140
implementation 'com.nulab-inc:zxcvbn:1.3.0'
138141

139142
implementation 'dnsjava:dnsjava:2.1.9'
140143
implementation 'org.jitsi:dnssecjava:1.2.0'
141144
implementation 'org.slf4j:slf4j-nop:1.7.30'
142145
implementation 'com.github.brnunes:swipeablerecyclerview:1.0.2'
143146

147+
//noinspection GradleDependency
144148
testImplementation "junit:junit:$rootProject.ext.junitVersion"
145149
testImplementation "org.mockito:mockito-all:$rootProject.ext.mockitoVersion"
146150
testImplementation "com.squareup.okhttp3:mockwebserver:4.9.0"
@@ -150,3 +154,4 @@ dependencies {
150154
compileOnly 'org.projectlombok:lombok:1.18.16'
151155
annotationProcessor 'org.projectlombok:lombok:1.18.16'
152156
}
157+

app/src/main/AndroidManifest.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,24 @@
1111
<uses-permission android:name="android.permission.NFC" />
1212
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
1313

14+
<queries>
15+
<intent>
16+
<action android:name="org.torproject.android.intent.action.START" />
17+
</intent>
18+
<intent>
19+
<action android:name="org.torproject.android.intent.action.STATUS" />
20+
</intent>
21+
22+
<intent>
23+
<action android:name="org.torproject.android.REQUEST_HS_PORT" />
24+
</intent>
25+
<intent>
26+
<action android:name="org.torproject.android.REQUEST_V3_ONION_SERVICE" />
27+
</intent>
28+
29+
<package android:name="org.torproject.android" />
30+
</queries>
31+
1432
<application
1533
android:name=".XmrWalletApplication"
1634
android:allowBackup="false"

app/src/main/cpp/monerujo.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,17 @@ Java_com_m2049r_xmrwallet_model_WalletManager_resolveOpenAlias(JNIEnv *env, jobj
531531
return env->NewStringUTF(resolvedAlias.c_str());
532532
}
533533

534+
JNIEXPORT jboolean JNICALL
535+
Java_com_m2049r_xmrwallet_model_WalletManager_setProxy(JNIEnv *env, jobject instance,
536+
jstring address) {
537+
const char *_address = env->GetStringUTFChars(address, nullptr);
538+
bool rc =
539+
Bitmonero::WalletManagerFactory::getWalletManager()->setProxy(std::string(_address));
540+
env->ReleaseStringUTFChars(address, _address);
541+
return rc;
542+
}
543+
544+
534545
//TODO static std::tuple<bool, std::string, std::string, std::string, std::string> checkUpdates(const std::string &software, const std::string &subdir);
535546

536547
JNIEXPORT jboolean JNICALL
@@ -727,6 +738,16 @@ Java_com_m2049r_xmrwallet_model_Wallet_getConnectionStatusJ(JNIEnv *env, jobject
727738
//TODO virtual void setTrustedDaemon(bool arg) = 0;
728739
//TODO virtual bool trustedDaemon() const = 0;
729740

741+
JNIEXPORT jboolean JNICALL
742+
Java_com_m2049r_xmrwallet_model_Wallet_setProxy(JNIEnv *env, jobject instance,
743+
jstring address) {
744+
const char *_address = env->GetStringUTFChars(address, nullptr);
745+
Bitmonero::Wallet *wallet = getHandle<Bitmonero::Wallet>(env, instance);
746+
bool rc = wallet->setProxy(std::string(_address));
747+
env->ReleaseStringUTFChars(address, _address);
748+
return rc;
749+
}
750+
730751
JNIEXPORT jlong JNICALL
731752
Java_com_m2049r_xmrwallet_model_Wallet_getBalance(JNIEnv *env, jobject instance,
732753
jint accountIndex) {

app/src/main/java/com/m2049r/levin/scanner/Dispatcher.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public void awaitTermination(int nodesToFind) {
7777
final NodeInfo nodeInfo = retrievedPeer.getNodeInfo();
7878
Timber.d("Retrieved %s", nodeInfo);
7979
if ((nodeInfo.isValid() || nodeInfo.isFavourite())) {
80-
nodeInfo.setName();
80+
nodeInfo.setDefaultName();
8181
rpcNodes.add(nodeInfo);
8282
Timber.d("RPC: %s", nodeInfo);
8383
// the following is not totally correct but it works (otherwise we need to

app/src/main/java/com/m2049r/xmrwallet/LoginActivity.java

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
import com.m2049r.xmrwallet.util.LegacyStorageHelper;
6666
import com.m2049r.xmrwallet.util.LocaleHelper;
6767
import com.m2049r.xmrwallet.util.MoneroThreadPoolExecutor;
68+
import com.m2049r.xmrwallet.util.NetCipherHelper;
6869
import com.m2049r.xmrwallet.util.NightmodeHelper;
6970
import com.m2049r.xmrwallet.util.ThemeHelper;
7071
import com.m2049r.xmrwallet.util.ZipBackup;
@@ -701,6 +702,7 @@ protected void onResume() {
701702
new AsyncWaitForService().execute();
702703
}
703704
if (!Ledger.isConnected()) attachLedger();
705+
registerTor();
704706
}
705707

706708
private class AsyncWaitForService extends AsyncTask<Void, Void, Void> {
@@ -1469,4 +1471,69 @@ private UsbManager getUsbManager() {
14691471
}
14701472
return usbManager;
14711473
}
1474+
1475+
//
1476+
// Tor (Orbot) stuff
1477+
//
1478+
1479+
void torNotify() {
1480+
final Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.fragment_container);
1481+
if (fragment == null) return;
1482+
1483+
if (fragment instanceof LoginFragment) {
1484+
runOnUiThread(((LoginFragment) fragment)::showNetwork);
1485+
}
1486+
}
1487+
1488+
private void deregisterTor() {
1489+
NetCipherHelper.deregister();
1490+
}
1491+
1492+
private void registerTor() {
1493+
NetCipherHelper.register(new NetCipherHelper.OnStatusChangedListener() {
1494+
@Override
1495+
public void connected() {
1496+
Timber.d("CONNECTED");
1497+
WalletManager.getInstance().setProxy(NetCipherHelper.getProxy());
1498+
torNotify();
1499+
if (waitingUiTask != null) {
1500+
Timber.d("RUN");
1501+
runOnUiThread(waitingUiTask);
1502+
waitingUiTask = null;
1503+
}
1504+
}
1505+
1506+
@Override
1507+
public void disconnected() {
1508+
Timber.d("DISCONNECTED");
1509+
WalletManager.getInstance().setProxy("");
1510+
torNotify();
1511+
}
1512+
1513+
@Override
1514+
public void notInstalled() {
1515+
Timber.d("NOT INSTALLED");
1516+
WalletManager.getInstance().setProxy("");
1517+
torNotify();
1518+
}
1519+
1520+
@Override
1521+
public void notEnabled() {
1522+
Timber.d("NOT ENABLED");
1523+
notInstalled();
1524+
}
1525+
});
1526+
}
1527+
1528+
private Runnable waitingUiTask;
1529+
1530+
@Override
1531+
public void runOnNetCipher(Runnable uiTask) {
1532+
if (waitingUiTask != null) throw new IllegalStateException("only one tor task at a time");
1533+
if (NetCipherHelper.hasClient()) {
1534+
runOnUiThread(uiTask);
1535+
} else {
1536+
waitingUiTask = uiTask;
1537+
}
1538+
}
14721539
}

0 commit comments

Comments
 (0)