Pull reseed certs into Bote so the internal router can reseed
This commit is contained in:
@@ -16,3 +16,6 @@ signing.properties
|
|||||||
#Gradle
|
#Gradle
|
||||||
^.gradle
|
^.gradle
|
||||||
build
|
build
|
||||||
|
|
||||||
|
# I2P-specific ignores
|
||||||
|
^app/src/main/res/raw/certificates_zip
|
||||||
|
|||||||
@@ -53,14 +53,14 @@ dependencies {
|
|||||||
compile 'net.i2p.android.ext:floatingactionbutton:1.8.0'
|
compile 'net.i2p.android.ext:floatingactionbutton:1.8.0'
|
||||||
compile 'com.madgag.spongycastle:core:1.51.0.0'
|
compile 'com.madgag.spongycastle:core:1.51.0.0'
|
||||||
compile 'com.madgag.spongycastle:prov:1.51.0.0'
|
compile 'com.madgag.spongycastle:prov:1.51.0.0'
|
||||||
compile ('com.mcxiaoke.viewpagerindicator:library:2.4.1') {
|
compile('com.mcxiaoke.viewpagerindicator:library:2.4.1') {
|
||||||
exclude group: 'com.android.support', module: 'support-v4'
|
exclude group: 'com.android.support', module: 'support-v4'
|
||||||
}
|
}
|
||||||
compile 'com.google.zxing:core:3.2.0'
|
compile 'com.google.zxing:core:3.2.0'
|
||||||
compile 'com.google.zxing:android-integration:3.2.0'
|
compile 'com.google.zxing:android-integration:3.2.0'
|
||||||
compile 'com.androidplot:androidplot-core:0.6.1'
|
compile 'com.androidplot:androidplot-core:0.6.1'
|
||||||
compile 'com.pnikosis:materialish-progress:1.4'
|
compile 'com.pnikosis:materialish-progress:1.4'
|
||||||
compile ('com.android.support:support-v4-preferencefragment:1.0.0@aar'){
|
compile('com.android.support:support-v4-preferencefragment:1.0.0@aar') {
|
||||||
exclude module: 'support-v4'
|
exclude module: 'support-v4'
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,4 +88,42 @@ dependencyVerification {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
project.ext.i2pbase = '../i2p.i2p'
|
||||||
|
def Properties props = new Properties()
|
||||||
|
def propFile = new File(project(':botejars').projectDir, 'local.properties')
|
||||||
|
|
||||||
|
if (propFile.canRead()) {
|
||||||
|
props.load(new FileInputStream(propFile))
|
||||||
|
|
||||||
|
if (props != null &&
|
||||||
|
props.containsKey('i2psrc')) {
|
||||||
|
i2pbase = props['i2psrc']
|
||||||
|
} else {
|
||||||
|
println 'local.properties found but some entries are missing'
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
println 'local.properties not found'
|
||||||
|
}
|
||||||
|
|
||||||
|
task certificatesZip(type: Zip) {
|
||||||
|
archiveName = 'certificates_zip'
|
||||||
|
into('reseed') {
|
||||||
|
from files('' + i2pbase + '/installer/resources/certificates/reseed')
|
||||||
|
}
|
||||||
|
into('ssl') {
|
||||||
|
from files('' + i2pbase + '/installer/resources/certificates/ssl')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
task copyI2PResources(type: Copy) {
|
||||||
|
// Force this to always run: Copy only detects source changes, not if missing in destination
|
||||||
|
outputs.upToDateWhen { false }
|
||||||
|
into 'src/main/res/raw'
|
||||||
|
from certificatesZip
|
||||||
|
}
|
||||||
|
task cleanI2PResources(type: Delete) {
|
||||||
|
delete file('src/main/res/raw/certificates_zip')
|
||||||
|
}
|
||||||
|
preBuild.dependsOn copyI2PResources
|
||||||
|
clean.dependsOn cleanI2PResources
|
||||||
|
|
||||||
apply from: "${project.rootDir}/gradle/signing.gradle"
|
apply from: "${project.rootDir}/gradle/signing.gradle"
|
||||||
@@ -4,18 +4,25 @@ import android.content.Context;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import net.i2p.android.ui.I2PAndroidHelper;
|
import net.i2p.android.ui.I2PAndroidHelper;
|
||||||
import net.i2p.client.I2PClient;
|
import net.i2p.client.I2PClient;
|
||||||
import net.i2p.data.DataHelper;
|
import net.i2p.data.DataHelper;
|
||||||
|
import net.i2p.util.FileUtil;
|
||||||
import net.i2p.util.OrderedProperties;
|
import net.i2p.util.OrderedProperties;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
import java.util.zip.ZipEntry;
|
||||||
|
import java.util.zip.ZipInputStream;
|
||||||
|
|
||||||
|
import i2p.bote.android.Constants;
|
||||||
import i2p.bote.android.R;
|
import i2p.bote.android.R;
|
||||||
|
|
||||||
public class Init {
|
public class Init {
|
||||||
@@ -45,8 +52,6 @@ public class Init {
|
|||||||
System.setProperty("i2p.dir.config", myDir);
|
System.setProperty("i2p.dir.config", myDir);
|
||||||
System.setProperty("wrapper.logfile", myDir + "/wrapper.log");
|
System.setProperty("wrapper.logfile", myDir + "/wrapper.log");
|
||||||
|
|
||||||
mergeResourceToFile(R.raw.router_config, "router.config", null);
|
|
||||||
|
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx);
|
||||||
RouterChoice routerChoice;
|
RouterChoice routerChoice;
|
||||||
String i2cpHost, i2cpPort;
|
String i2cpHost, i2cpPort;
|
||||||
@@ -77,6 +82,22 @@ public class Init {
|
|||||||
System.setProperty(I2PClient.PROP_TCP_HOST, i2cpHost);
|
System.setProperty(I2PClient.PROP_TCP_HOST, i2cpHost);
|
||||||
System.setProperty(I2PClient.PROP_TCP_PORT, i2cpPort);
|
System.setProperty(I2PClient.PROP_TCP_PORT, i2cpPort);
|
||||||
|
|
||||||
|
if (routerChoice == RouterChoice.INTERNAL) {
|
||||||
|
mergeResourceToFile(R.raw.router_config, "router.config", null);
|
||||||
|
|
||||||
|
File certDir = new File(myDir, "certificates");
|
||||||
|
certDir.mkdir();
|
||||||
|
File certificates = new File(myDir, "certificates");
|
||||||
|
File[] allcertificates = certificates.listFiles();
|
||||||
|
if ( allcertificates != null) {
|
||||||
|
for (File f : allcertificates) {
|
||||||
|
Log.d(Constants.ANDROID_LOG_TAG, "Deleting old certificate file/dir " + f);
|
||||||
|
FileUtil.rmdir(f, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
unzipResourceToDir(R.raw.certificates_zip, "certificates");
|
||||||
|
}
|
||||||
|
|
||||||
return routerChoice;
|
return routerChoice;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,4 +143,52 @@ public class Init {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param folder relative to base dir
|
||||||
|
*/
|
||||||
|
private void unzipResourceToDir(int resID, String folder) {
|
||||||
|
InputStream in = null;
|
||||||
|
FileOutputStream out = null;
|
||||||
|
ZipInputStream zis = null;
|
||||||
|
|
||||||
|
Log.d(Constants.ANDROID_LOG_TAG, "Creating files in '" + myDir + "/" + folder + "/' from resource");
|
||||||
|
try {
|
||||||
|
// Context methods
|
||||||
|
in = ctx.getResources().openRawResource(resID);
|
||||||
|
zis = new ZipInputStream((in));
|
||||||
|
ZipEntry ze;
|
||||||
|
while ((ze = zis.getNextEntry()) != null) {
|
||||||
|
out = null;
|
||||||
|
try {
|
||||||
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
|
byte[] buffer = new byte[1024];
|
||||||
|
int count;
|
||||||
|
while ((count = zis.read(buffer)) != -1) {
|
||||||
|
baos.write(buffer, 0, count);
|
||||||
|
}
|
||||||
|
String name = ze.getName();
|
||||||
|
File f = new File(myDir + "/" + folder +"/" + name);
|
||||||
|
if (ze.isDirectory()) {
|
||||||
|
Log.d(Constants.ANDROID_LOG_TAG, "Creating directory " + myDir + "/" + folder +"/" + name + " from resource");
|
||||||
|
f.mkdir();
|
||||||
|
} else {
|
||||||
|
Log.d(Constants.ANDROID_LOG_TAG, "Creating file " + myDir + "/" + folder +"/" + name + " from resource");
|
||||||
|
byte[] bytes = baos.toByteArray();
|
||||||
|
out = new FileOutputStream(f);
|
||||||
|
out.write(bytes);
|
||||||
|
}
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
} finally {
|
||||||
|
if (out != null) { try { out.close(); } catch (IOException ioe) {} out = null; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
} catch (Resources.NotFoundException nfe) {
|
||||||
|
} finally {
|
||||||
|
if (in != null) try { in.close(); } catch (IOException ioe) {}
|
||||||
|
if (out != null) try { out.close(); } catch (IOException ioe) {}
|
||||||
|
if (zis != null) try { zis.close(); } catch (IOException ioe) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user