Compare commits

..

13 Commits

Author SHA1 Message Date
739fe36513 test: Add ConvertToHashTest fall through case
Nothing can be resolved at all.
2021-01-18 18:40:54 +01:00
f80be27579 test: Add ConvertToHashTest base 32 tests 2021-01-18 18:40:53 +01:00
a1183d6ac4 test: Add ConvertToHashTest destination tests 2021-01-18 18:40:53 +01:00
eacb09e118 test: Add ConvertToHashTest::getHashB64&getHashB64DotI2P 2021-01-18 18:40:53 +01:00
9cca5de29a test: Add ConvertToHashTest::getHashNullPeer 2021-01-18 18:40:53 +01:00
9e4eb5de0c gitlab-ci: Run tests on merge requests and tags 2021-01-18 18:40:53 +01:00
baaf1b363f gitlab-ci: Replace check job with test
I can't see what other things `check` is running besides tests.
2021-01-18 18:40:53 +01:00
f721571181 gitlab-ci: Install grep instead of using busybox version 2021-01-18 18:40:53 +01:00
7dd7d2c974 gitlab-ci: Try adding code coverage 2021-01-18 18:40:53 +01:00
fd03049cbf gitlab-ci: Gradle command typo
Step 1: Learn how to type
2021-01-18 18:40:53 +01:00
d88cb57b78 gitlab-ci: Keep cache only on branch and tag
Sharing caches across branches surely isn't a good idea.
2021-01-18 18:40:53 +01:00
73e777d731 gitlab-ci: first attempt 2021-01-18 18:40:53 +01:00
f18915c708 test: fix I2PSocketExceptionTest::testUnknownStatus
In non-English environments, the message is translated.
2021-01-18 18:40:53 +01:00
7 changed files with 18 additions and 214 deletions

View File

@@ -46,7 +46,7 @@
</td>
</tr>
<tr>
<th id="upnpconfig"><%=intl._t("UPnP Configuration")%>&nbsp;<a href="peers?tx=upnp">[<%=intl._t("UPnP Status")%>]</a></th>
<th id="upnpconfig"><%=intl._t("UPnP Configuration")%>&nbsp;<a href="peers#upnp">[<%=intl._t("UPnP Status")%>]</a></th>
</tr>
<tr>
<td>

View File

@@ -40,7 +40,7 @@ import net.i2p.data.DataHelper;
* @author zzz
*/
public abstract class Addresses {
private static final File IF_INET6_FILE = new File("/proc/net/if_inet6");
private static final long INET6_CACHE_EXPIRE = 10*60*1000;
private static final boolean INET6_CACHE_ENABLED = !SystemVersion.isMac() && !SystemVersion.isWindows() &&
@@ -122,9 +122,10 @@ public abstract class Addresses {
*
* Warning, very slow on Windows, appx. 200ms + 50ms/interface
*
* @return a sorted set of all addresses including wildcard
* @param includeLocal whether to include local
* @param includeIPv6 whether to include IPV6
* @return a sorted set of all addresses including wildcard
* @return a Set of all addresses
* @since 0.8.3
*/
public static SortedSet<String> getAddresses(boolean includeLocal, boolean includeIPv6) {
@@ -140,10 +141,11 @@ public abstract class Addresses {
*
* Warning, very slow on Windows, appx. 200ms + 50ms/interface
*
* @return a sorted set of all addresses
* @param includeSiteLocal whether to include private like 192.168.x.x
* @param includeLoopbackAndWildcard whether to include 127.x.x.x and 0.0.0.0
* @param includeIPv6 whether to include IPV6
* @return a sorted set of all addresses
* @return a Set of all addresses
* @since 0.9.4
*/
public static SortedSet<String> getAddresses(boolean includeSiteLocal,
@@ -161,11 +163,12 @@ public abstract class Addresses {
*
* Warning, very slow on Windows, appx. 200ms + 50ms/interface
*
* @return a sorted set of all addresses
* @param includeSiteLocal whether to include private like 192.168.x.x
* @param includeLoopbackAndWildcard whether to include 127.x.x.x and 0.0.0.0
* @param includeIPv6 whether to include IPV6
* @param includeIPv6Temporary whether to include IPV6 temporary addresses
* @return a sorted set of all addresses
* @return a Set of all addresses
* @since 0.9.46
*/
public static SortedSet<String> getAddresses(boolean includeSiteLocal,
@@ -340,7 +343,7 @@ public abstract class Addresses {
return "(bad IP length " + addr.length + "):" + port;
}
}
/**
* Convenience method to convert and validate a port String
* without throwing an exception.
@@ -399,7 +402,7 @@ public abstract class Addresses {
* @since 0.9.3
*/
public static byte[] getIP(String host) {
if (host == null || host.isEmpty())
if (host == null)
return null;
byte[] rv;
synchronized (_IPAddress) {

View File

@@ -1,145 +0,0 @@
package net.i2p.util;
import org.junit.Test;
import java.net.Inet6Address;
import java.net.UnknownHostException;
import static org.junit.Assert.*;
/**
* @since 0.9.49
*/
public class AddressesTest {
@Test
public void getIPNull() {
assertNull(Addresses.getIP(null));
}
@Test
public void getIPEmptyString() {
assertNull(Addresses.getIP(""));
}
@Test
public void getIPWithIPString() {
byte[] address = {
1, 2, 3, 4
};
assertArrayEquals(address, Addresses.getIP("1.2.3.4"));
}
@Test
public void getPort() {
assertEquals(80, Addresses.getPort("80"));
}
@Test
public void getPort__invalidPort() {
String[] strings = {
"",
" 80",
"-100",
"a",
"99999",
null
};
for (String string : strings) {
assertEquals(0, Addresses.getPort(string));
}
}
@Test
public void isIPAddress() {
assertTrue(Addresses.isIPAddress("127.0.0.1"));
assertTrue(Addresses.isIPAddress("::1"));
}
@Test
public void isIPv6Address() {
assertTrue(Addresses.isIPv6Address("::1"));
assertFalse(Addresses.isIPv6Address(""));
}
@Test
public void isIPv4Address() {
assertTrue(Addresses.isIPv4Address("127.0.0.1"));
assertFalse(Addresses.isIPv4Address(""));
}
/**
* Should always return false when the address isn't in the cache
*/
@Test
public void isDynamic() throws UnknownHostException {
String host = "localhost";
byte[] address = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
assertFalse(Addresses.isDynamic((Inet6Address) Inet6Address.getByAddress(host, address)));
}
/**
* Should always return false when the address isn't in the cache
*/
@Test
public void isDeprecated() throws UnknownHostException {
String host = "localhost";
byte[] address = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
assertFalse(Addresses.isDeprecated((Inet6Address) Inet6Address.getByAddress(host, address)));
}
@Test
public void testToString() {
byte[] address = {127, 0, 0, 1};
assertEquals("127.0.0.1", Addresses.toString(address));
}
@Test
public void testToString__ipv4withPort() {
byte[] address = {127, 0, 0, 1};
assertEquals("127.0.0.1:80", Addresses.toString(address, 80));
}
@Test
public void testToString__ipv6withPort() {
byte[] address = {
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 1,
};
assertEquals("[0:0:0:0:0:0:0:1]:80", Addresses.toString(address, 80));
}
@Test
public void testToString__null() {
assertEquals("null", Addresses.toString(null));
}
@Test
public void testToString__nullWithPort() {
assertEquals("null:80", Addresses.toString(null, 80));
}
@Test
public void testToString__badLength() {
byte[] address = {1};
assertTrue(Addresses.toString(address).startsWith("bad IP length"));
}
@Test
public void testToString__badLengthWithPort() {
byte[] address = {1};
String string = Addresses.toString(address, 80);
String expectedStartString = "(bad IP length";
assertTrue(
String.format("%s doesn't start with: %s", string, expectedStartString),
string.startsWith(expectedStartString)
);
String expectedEndString = "80";
assertTrue(
String.format("%s doesn't end with: %s", string, expectedEndString),
string.endsWith(expectedEndString)
);
}
}

View File

@@ -1,22 +1,3 @@
2021-01-20 zzz
* Console: Fix link to UPnP status
* SSU: Fix deadlock with router restart
2021-01-14 zzz
* Router:
- Change default encryption type to ECIES-X25519 (proposal 156)
- Move Sybil subsystem from console to router
- Limit max addresses in RI
2021-01-13 zzz
* Jetty: Fix URI in request logs
2021-01-12 zzz
* i2psnark: Don't decrement downloaded counter after receiving bad piece
2021-01-11 zzz
* Console: Delete rrd files for no-longer-configured stats at startup
2021-01-08 zzz
* i2ptunnel: Disable shared clients (DSA) (part 2)
* SSU: Fix bandwidth estimator deadlock (ticket #2798)

View File

@@ -18,7 +18,7 @@ public class RouterVersion {
/** deprecated */
public final static String ID = "Monotone";
public final static String VERSION = CoreVersion.VERSION;
public final static long BUILD = 14;
public final static long BUILD = 13;
/** for example "-test" */
public final static String EXTRA = "";

View File

@@ -81,33 +81,22 @@ public class WorkingDir {
String home = System.getProperty("user.home");
if (isWindows) {
String appdata = System.getenv("LOCALAPPDATA");
if (appdata != null) {
if (appdata != null)
home = appdata;
}
// Don't mess with existing Roaming Application Data installs,
// in case somebody is using roaming appdata for a reason
// already. In new installs, use local appdata by default. -idk
appdata = System.getenv("APPDATA");
if (appdata != null) {
File checkOld = new File(appdata, WORKING_DIR_DEFAULT_WINDOWS);
if (checkOld.exists() && checkOld.isDirectory()){
File routerConfig = new File(checkOld.getAbsolutePath(), "router.config");
// The Firefox profile installer was mistakenly using the Roaming application data
// which is synced between devices on some Windows machines using MS cloud services,
// instead of the local application data which is used by default.
// It would create the router.config file in an empty directory, which the router would
// then attempt to use, resulting in a router with no client applications. Checking
// for clients.config.d determines if the directory is "Real" or not.
File clientAppsConfig = new File(checkOld.getAbsolutePath(), "clients.config.d");
if (routerConfig.exists() && clientAppsConfig.exists() && clientAppsConfig.isDirectory())
home = appdata;
}
if (checkOld.exists() && checkOld.isDirectory())
home = appdata;
}
dirf = new SecureDirectory(home, WORKING_DIR_DEFAULT_WINDOWS);
} else if (SystemVersion.isMac()) {
String appdata = "/Library/Application Support/";
File old = new File(home,WORKING_DIR_DEFAULT);
if (old.exists() && old.isDirectory())
File old = new File(home,WORKING_DIR_DEFAULT);
if (old.exists() && old.isDirectory())
dirf = new SecureDirectory(home, WORKING_DIR_DEFAULT);
else {
home = home+appdata;

View File

@@ -2455,7 +2455,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
// warning, this calls back into us with allowRebuildRouterInfo = false,
// via CSFI.createAddresses->TM.getAddresses()->updateAddress()->REA
if (allowRebuildRouterInfo)
rebuildRouterInfo();
_context.router().rebuildRouterInfo();
} else {
addr = null;
}
@@ -2510,35 +2510,11 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
// warning, this calls back into us with allowRebuildRouterInfo = false,
// via CSFI.createAddresses->TM.getAddresses()->updateAddress()->REA
if (allowRebuildRouterInfo)
rebuildRouterInfo();
_context.router().rebuildRouterInfo();
}
}
}
/**
* Avoid deadlocks part 999
* @since 0.9.49
*/
private void rebuildRouterInfo() {
(new RebuildEvent()).schedule(0);
}
/**
* @since 0.9.49
*/
private class RebuildEvent extends SimpleTimer2.TimedEvent {
/**
* Caller must schedule
*/
public RebuildEvent() {
super(_context.simpleTimer2());
}
public void timeReached() {
_context.router().rebuildRouterInfo(true);
}
}
/**
* Simple fetch of stored IP and port, since
* we don't put them in the real, published RouterAddress anymore