Fix some build issues(Stemming from resources moving to wars) and add a SAM API option

This commit is contained in:
idk
2021-01-10 09:20:45 -05:00
parent f016edec7a
commit 835667437b
10 changed files with 96 additions and 22 deletions

View File

@ -114,7 +114,7 @@ task copyI2PResources(type: Copy) {
outputs.upToDateWhen { false }
into 'src/main/res'
into('drawable') {
from file(i2pbase + '/installer/resources/themes/console/images/i2plogo.png')
from file(i2pbase + '/apps/routerconsole/jsp/themes/console/images/i2plogo.png')
}
into('raw') {
from(i2pbase + '/installer/resources/blocklist.txt') { rename { 'blocklist_txt' } }
@ -177,15 +177,15 @@ task copyI2PAssets(type: Copy) {
outputs.upToDateWhen { false }
into 'src/main/assets/themes/console'
into('images') {
from file(i2pbase + '/installer/resources/themes/console/images/i2plogo.png')
from file(i2pbase + '/installer/resources/themes/console/images/inbound.png')
from file(i2pbase + '/installer/resources/themes/console/images/outbound.png')
from file(i2pbase + '/apps/routerconsole/jsp/themes/console/images/i2plogo.png')
from file(i2pbase + '/apps/routerconsole/jsp/themes/console/images/inbound.png')
from file(i2pbase + '/apps/routerconsole/jsp/themes/console/images/outbound.png')
}
into('light') {
from file(i2pbase + '/installer/resources/themes/console/light/console.css')
from file(i2pbase + '/apps/routerconsole/jsp/themes/console/light/console.css')
}
into('light/images') {
from file(i2pbase + '/installer/resources/themes/console/light/images/header.png')
from file(i2pbase + '/apps/routerconsole/jsp/themes/console/light/images/header.png')
}
}

View File

@ -92,7 +92,7 @@ class InitActivities {
File docsDir = new File(myDir, "docs");
docsDir.mkdir();
copyResourceToFile(R.raw.ahelper_conflict_header_ht, "docs/ahelper-conflict-header.ht");
/*copyResourceToFile(R.raw.ahelper_conflict_header_ht, "docs/ahelper-conflict-header.ht");
copyResourceToFile(R.raw.ahelper_new_header_ht, "docs/ahelper-new-header.ht");
copyResourceToFile(R.raw.ahelper_notfound_header_ht, "docs/ahelper-notfound-header.ht");
copyResourceToFile(R.raw.auth_header_ht, "docs/auth-header.ht");
@ -110,7 +110,7 @@ class InitActivities {
copyResourceToFile(R.raw.noproxy_header_ht, "docs/noproxy-header.ht");
copyResourceToFile(R.raw.protocol_header_ht, "docs/protocol-header.ht");
copyResourceToFile(R.raw.reset_header_ht, "docs/reset-header.ht");
copyResourceToFile(R.raw.resetp_header_ht, "docs/resetp-header.ht");
copyResourceToFile(R.raw.resetp_header_ht, "docs/resetp-header.ht");*/
File cssDir = new File(docsDir, "themes/console/light");
cssDir.mkdirs();

View File

@ -14,8 +14,11 @@ import net.i2p.router.JobImpl;
import net.i2p.router.RouterContext;
import net.i2p.router.startup.RouterAppManager;
import net.i2p.util.I2PAppThread;
import net.i2p.sam.SAMBridge;
import java.io.File;
import java.io.IOException;
import java.util.Properties;
/**
* Load the clients we want.
@ -41,6 +44,7 @@ class LoadClientsJob extends JobImpl {
private final Context mCtx;
private final Notifications _notif;
private DaemonThread _addressbook;
public SAMBridge SAM_BRIDGE;
//private BOB _bob;
/** this is the delay to load (and start) the clients. */
@ -57,8 +61,9 @@ class LoadClientsJob extends JobImpl {
public String getName() { return "Start Clients"; }
public void runJob() {
Job j = new RunI2PTunnel(getContext());
getContext().jobQueue().addJob(j);
Job jtunnel = new RunI2PTunnel(getContext());
getContext().jobQueue().addJob(jtunnel);
Thread t = new I2PAppThread(new StatSummarizer(), "StatSummarizer", true);
t.setPriority(Thread.NORM_PRIORITY - 1);
@ -69,7 +74,16 @@ class LoadClientsJob extends JobImpl {
//try {
// _bob.startup();
//} catch (IOException ioe) {}
String useSAM = System.getProperty("i2pandroid.client.sam");
if (useSAM != null) {
Util.i("SAM API " + useSAM);
if (useSAM == "true") {
Job jsam = new RunI2PSAM(getContext());
getContext().jobQueue().addJob(jsam);
}else{
Util.i("SAM API disabled, not starting "+useSAM);
}
}
getContext().addShutdownTask(new ClientShutdownHook());
}
@ -112,6 +126,46 @@ class LoadClientsJob extends JobImpl {
}
}
private class RunI2PSAM extends JobImpl {
public RunI2PSAM(RouterContext ctx) {
super(ctx);
}
public String getName() { return "Start SAM API"; }
public void runJob() {
while (!getContext().router().isRunning()) {
try { Thread.sleep(1000); } catch (InterruptedException ie) { return; }
if (!getContext().router().isAlive()) {
Util.e("Router stopped before SAM API could start");
return;
}
}
Util.d("Starting SAM");
try {
Util.i("Starting the SAM API");
SAM_BRIDGE = new SAMBridge("127.0.0.1",
7656,
false,
SAM_PROPERTIES(),
"sam.keys",
new File("sam_config"));
SAM_BRIDGE.startup();
} catch (IOException e) {
Util.e( e.toString());
e.printStackTrace();
}
}
public Properties SAM_PROPERTIES() throws IOException {
Util.i("Getting the default properties");
Properties sam_properties = new Properties();
return sam_properties;
}
}
private class ClientShutdownHook implements Runnable {
public void run() {
Util.d("client shutdown hook");

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

@ -182,7 +182,9 @@
<string name="settings_label_transports">Transports</string>
<string name="settings_label_maxConns">Max connections</string>
<string name="settings_label_i2cp">I2CP interface</string>
<string name="settings_desc_i2cp">Allow third-party apps to create tunnels (requires router restart)</string>
<string name="settings_desc_i2cp">Allow third-party apps to create tunnels using I2CP (requires router restart)</string>
<string name="settings_label_sam">SAM interface</string>
<string name="settings_desc_sam">Allow third-party apps to create tunnels using SAM (requires router restart)</string>
<string name="settings_label_exploratory_pool">Exploratory pool</string>
<string name="settings_desc_exploratory_pool">Tunnel parameters</string>
<string name="settings_label_expl_inbound">Inbound tunnels</string>

View File

@ -23,6 +23,13 @@
android:summary="@string/settings_desc_i2cp"
/>
<CheckBoxPreference
android:key="i2pandroid.client.sam"
android:defaultValue="true"
android:title="@string/settings_label_sam"
android:summary="@string/settings_desc_sam"
/>
<Preference
android:key="preference_category_expl_tunnels"
android:summary="@string/settings_desc_exploratory_pool"

View File

@ -408,14 +408,14 @@
<target name="copy-i2p-resources" depends="-dirs" >
<copy file="LICENSE.txt" tofile="res/raw/license_app_txt" />
<copy file="licenses/LICENSE-Apache2.0.txt" tofile="res/raw/license_apache20_txt" />
<copy file="${i2pbase}/installer/resources/themes/console/images/i2plogo.png" todir="res/drawable/" />
<copy file="${i2pbase}/apps/routerconsole/jsp/themes/console/images/i2plogo.png" todir="res/drawable/" />
<!-- Static web sources should be in the assets directory. -->
<copy file="${i2pbase}/installer/resources/themes/console/images/i2plogo.png" todir="assets/themes/console/images/" />
<copy file="${i2pbase}/installer/resources/themes/console/images/outbound.png" todir="assets/themes/console/images/" />
<copy file="${i2pbase}/installer/resources/themes/console/images/inbound.png" todir="assets/themes/console/images/" />
<copy file="${i2pbase}/installer/resources/themes/console/light/images/header.png" todir="assets/themes/console/light/images/" />
<copy file="${i2pbase}/installer/resources/themes/console/light/console.css" todir="assets/themes/console/light/" />
<copy file="${i2pbase}/apps/routerconsole/jsp/themes/console/images/i2plogo.png" todir="assets/themes/console/images/" />
<copy file="${i2pbase}/apps/routerconsole/jsp/themes/console/images/outbound.png" todir="assets/themes/console/images/" />
<copy file="${i2pbase}/apps/routerconsole/jsp/themes/console/images/inbound.png" todir="assets/themes/console/images/" />
<copy file="${i2pbase}/apps/routerconsole/jsp/themes/console/light/images/header.png" todir="assets/themes/console/light/images/" />
<copy file="${i2pbase}/apps/routerconsole/jsp/themes/console/light/console.css" todir="assets/themes/console/light/" />
<copy file="${i2pbase}/installer/resources/blocklist.txt" tofile="res/raw/blocklist_txt" />
<copy file="${i2pbase}/installer/resources/hosts.txt" tofile="res/raw/hosts_txt" />

View File

@ -14,7 +14,7 @@ POM_DEVELOPER_ID=idk
POM_DEVELOPER_NAME=idk
POM_DEVELOPER_EMAIL=hankhill19580@gmail.com
I2P_VERSION=0.9.48
ANDROID_BUILD_TARGET_SDK_VERSION=28
I2P_VERSION=0.9.48-13
ANDROID_BUILD_TARGET_SDK_VERSION=29
ANDROID_BUILD_SDK_VERSION=28

View File

@ -13,6 +13,7 @@ artifacts {
routerjars file: file('libs/i2ptunnel.jar'), builtBy: buildRouter
routerjars file: file('libs/i2ptunnel-ui.jar'), builtBy: buildRouter
routerjars file: file('libs/addressbook.jar'), builtBy: buildRouter
routerjars file: file('libs/sam.jar'), builtBy: buildRouter
//routerjars file: file('libs/BOB.jar'), builtBy: buildRouter
}
clean.dependsOn cleanBuildRouter

View File

@ -20,6 +20,7 @@
<available property="have.bob" file="${i2plib}/BOB.jar" />
<available property="have.newsxml" file="${i2pbase}/apps/routerconsole/java/build/newsxml.jar" />
<available property="have.i2ptunnel" file="${i2plib}/i2ptunnel-ui.jar" />
<available property="have.sam" file="${i2plib}/sam.jar" />
<available property="have.addressbook" file="${i2plib}/addressbook.jar" />
<target name="buildNewsXMLJar" unless="have.newsxml">
@ -36,7 +37,11 @@
<ant dir="${i2pbase}" inheritall="false" useNativeBasedir="true" target="buildBOB" />
</target>
<target name="buildrouter" depends="buildNewsXMLJar, buildI2PTunnelJar, buildAddressbook">
<target name="buildSAM" unless="have.sam">
<ant dir="${i2pbase}" inheritall="false" useNativeBasedir="true" target="buildSAM" />
</target>
<target name="buildrouter" depends="buildNewsXMLJar, buildI2PTunnelJar, buildAddressbook, buildSAM">
<mkdir dir="${jar.libs.dir}" />
<!-- newsxml -->
@ -50,10 +55,15 @@
<copy file="${i2plib}/addressbook.jar" todir="${jar.libs.dir}" />
<!-- bob -->
<!--
<!--
<copy file="${i2plib}/BOB.jar" todir="${jar.libs.dir}" />
-->
<!-- sam -->
<copy file="${i2plib}/sam.jar" todir="${jar.libs.dir}" />
</target>
<target name="clean">