Added default router.config based on I2P Android
This commit is contained in:
@@ -2,10 +2,22 @@ package i2p.bote.android.service;
|
||||
|
||||
import net.i2p.android.router.service.IRouterState;
|
||||
import net.i2p.client.I2PClient;
|
||||
import net.i2p.data.DataHelper;
|
||||
import net.i2p.util.OrderedProperties;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Resources;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
import i2p.bote.android.R;
|
||||
|
||||
public class Init {
|
||||
private final Context ctx;
|
||||
private final String myDir;
|
||||
@@ -33,6 +45,8 @@ public class Init {
|
||||
System.setProperty("i2p.dir.config", myDir);
|
||||
System.setProperty("wrapper.logfile", myDir + "/wrapper.log");
|
||||
|
||||
mergeResourceToFile(R.raw.router_config, "router.config", null);
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx);
|
||||
RouterChoice routerChoice;
|
||||
String i2cpHost, i2cpPort;
|
||||
@@ -71,4 +85,47 @@ public class Init {
|
||||
|
||||
return routerChoice;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load defaults from resource,
|
||||
* then add props from settings,
|
||||
* and write back
|
||||
*
|
||||
* @param f relative to base dir
|
||||
* @param props local overrides or null
|
||||
*/
|
||||
public void mergeResourceToFile(int resID, String f, Properties overrides) {
|
||||
InputStream in = null;
|
||||
InputStream fin = null;
|
||||
|
||||
try {
|
||||
in = ctx.getResources().openRawResource(resID);
|
||||
Properties props = new OrderedProperties();
|
||||
try {
|
||||
fin = new FileInputStream(new File(myDir, f));
|
||||
DataHelper.loadProps(props, fin);
|
||||
} catch (IOException ioe) {
|
||||
}
|
||||
|
||||
// write in default settings
|
||||
DataHelper.loadProps(props, in);
|
||||
|
||||
// override with user settings
|
||||
if (overrides != null)
|
||||
props.putAll(overrides);
|
||||
File path = new File(myDir, f);
|
||||
DataHelper.storeProps(props, path);
|
||||
} catch (IOException ioe) {
|
||||
} catch (Resources.NotFoundException nfe) {
|
||||
} finally {
|
||||
if (in != null) try {
|
||||
in.close();
|
||||
} catch (IOException ioe) {
|
||||
}
|
||||
if (fin != null) try {
|
||||
fin.close();
|
||||
} catch (IOException ioe) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
78
app/src/main/res/raw/router_config
Normal file
78
app/src/main/res/raw/router_config
Normal file
@@ -0,0 +1,78 @@
|
||||
# initial router.config
|
||||
# duplicated from I2P Android
|
||||
# temp directory now set in Init.java
|
||||
#i2p.dir.temp=/data/data/net.i2p.android.router/files/tmp
|
||||
#i2p.dir.pid=/data/data/net.i2p.android.router/files/tmp
|
||||
#
|
||||
# save memory
|
||||
# I've done some testing, and the amount 'saved' is not all that much.
|
||||
# I will, however, leave this alone, for now.
|
||||
#
|
||||
prng.buffers=2
|
||||
prng.bufferSize=32768
|
||||
router.decayingBloomFilterM=20
|
||||
stat.full=false
|
||||
#
|
||||
# Don't run NTP client, the phone should have a valid time
|
||||
# Tablets are not phones, turn this on. I've seen the phone not have
|
||||
# accurate time too (yes, really) and the router had too much skew.
|
||||
# I've even seen current tablets that have NTP on lose or gain time.
|
||||
time.disabled=false
|
||||
#
|
||||
# no external I2CP (7654)
|
||||
#
|
||||
i2cp.disableInterface=true
|
||||
#
|
||||
# hosts.txt should be more crash-proof than blockfile
|
||||
# Todo: implement a NamingService using the android native SQLite
|
||||
#
|
||||
i2p.naming.impl=net.i2p.client.naming.HostsTxtNamingService
|
||||
i2p.hostsfilelist=privatehosts.txt,hosts.txt
|
||||
#
|
||||
##### Tunnels
|
||||
#
|
||||
router.inboundPool.backupQuantity=0
|
||||
router.inboundPool.length=2
|
||||
router.inboundPool.lengthVariance=0
|
||||
router.inboundPool.quantity=2
|
||||
router.outboundPool.backupQuantity=0
|
||||
router.outboundPool.length=2
|
||||
router.outboundPool.lengthVariance=0
|
||||
router.outboundPool.quantity=2
|
||||
router.maxParticipatingTunnels=0
|
||||
router.sharePercentage=10
|
||||
#
|
||||
##### Transport
|
||||
#
|
||||
i2np.bandwidth.inboundKBytesPerSecond=100
|
||||
i2np.bandwidth.outboundKBytesPerSecond=50
|
||||
#
|
||||
# NTCP
|
||||
#
|
||||
i2np.ntcp.enable=true
|
||||
i2np.ntcp.maxConnections=32
|
||||
#
|
||||
# UDP
|
||||
#
|
||||
i2np.udp.enable=true
|
||||
i2np.udp.maxConnections=32
|
||||
#
|
||||
#
|
||||
# not on android
|
||||
routerconsole.geoip.enable=false
|
||||
#
|
||||
# false is default but was true in 0.9.1-0_b1 release so have to set it back
|
||||
router.reseedSSLDisable=false
|
||||
#
|
||||
# Tablets are not phones. It does not hurt to have this on by default.
|
||||
#
|
||||
#i2np.upnp.enable=true
|
||||
|
||||
#
|
||||
# Hidden by default, this turns off sharing, etc.
|
||||
router.hiddenMode=true
|
||||
|
||||
#
|
||||
# Bad idea, disable it!
|
||||
#
|
||||
router.floodfillParticipant=false
|
||||
Reference in New Issue
Block a user