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
6 changed files with 9 additions and 258 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

@@ -1,195 +0,0 @@
package net.i2p.socks;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
import sun.net.util.IPAddressUtil;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.Socket;
import java.nio.charset.StandardCharsets;
import static net.i2p.socks.SOCKS4Constants.SOCKS_VERSION_4;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertThrows;
/**
* @since 0.9.49
*/
public class SOCKS4ClientTest {
ByteArrayInputStream inputStream;
ByteArrayOutputStream outputStream;
@Before
public void openStreams(){
outputStream = new ByteArrayOutputStream();
}
@After
public void closeStreams() throws IOException {
if (inputStream != null) {
inputStream.close();
}
if (outputStream != null) {
outputStream.close();
}
}
/**
* A successful connection to an IPv4 host
*/
@Test
public void connect() throws IOException {
_testConnect(false);
}
/**
* A successful connection to an IPv4 host using a socket
*/
@Test
public void connect__withSocket() throws IOException {
_testConnect(true);
}
private void _testConnect(boolean useSocket) throws IOException {
String hostIPv4 = "11.22.33.44";
int connectionPort = 8080;
byte[] hostIPv4Bin = IPAddressUtil.textToNumericFormatV4(hostIPv4);
// Build sequence of bytes to be expected
ByteArrayOutputStream expectedByteStream = new ByteArrayOutputStream();
DataOutputStream writerStream = new DataOutputStream(expectedByteStream);
writerStream.writeByte(SOCKS_VERSION_4);
writerStream.writeByte(SOCKS4Constants.Command.CONNECT);
writerStream.writeShort(connectionPort);
writerStream.write(hostIPv4Bin);
writerStream.write((byte) 0);
inputStream = new ByteArrayInputStream(new byte[]{
0, // dummy
SOCKS4Constants.Reply.SUCCEEDED, // Connection succeeded
0, 0, 0, 0, 0, 0 // filler
});
outputStream = new ByteArrayOutputStream();
// Test overloaded function
try {
if (useSocket) {
Socket socket = Mockito.mock(Socket.class);
Mockito.when(socket.getInputStream()).thenReturn(inputStream);
Mockito.when(socket.getOutputStream()).thenReturn(outputStream);
SOCKS4Client.connect(socket, hostIPv4, connectionPort);
} else {
SOCKS4Client.connect(inputStream, outputStream, hostIPv4, connectionPort);
}
} finally {
writerStream.close();
}
assertArrayEquals(expectedByteStream.toByteArray(), outputStream.toByteArray());
}
/**
* Connect proxy with a domain name
*/
@Test
public void connect__host() throws IOException {
String host = "stats.i2p";
int connectionPort = 80;
// Build sequence of bytes to be expected
ByteArrayOutputStream expectedByteStream = new ByteArrayOutputStream();
DataOutputStream writerStream = new DataOutputStream(expectedByteStream);
writerStream.writeByte(SOCKS_VERSION_4);
writerStream.writeByte(SOCKS4Constants.Command.CONNECT);
writerStream.writeShort(connectionPort);
writerStream.write(new byte[]{0,0,0,1}); // 0.0.0.1
writerStream.write((byte) 0); // empty userID
writerStream.write(host.getBytes(StandardCharsets.ISO_8859_1));
writerStream.write((byte) 0);
inputStream = new ByteArrayInputStream(new byte[]{
0, // dummy
SOCKS4Constants.Reply.SUCCEEDED, // Connection succeeded
0, 0, 0, 0, 0, 0 // filler
});
try {
SOCKS4Client.connect(SOCKS4ClientTest.this.inputStream, outputStream, host, connectionPort);
} finally {
expectedByteStream.close();
}
assertArrayEquals(expectedByteStream.toByteArray(), outputStream.toByteArray());
}
/**
* Run into IOException while trying to connect due to no input/response
*/
@Test
public void connect__ioException() {
inputStream = new ByteArrayInputStream(new byte[]{});
assertThrows(IOException.class, () -> {
SOCKS4Client.connect(
inputStream,
outputStream,
"127.0.0.1",
80);
});
}
/**
* Run into IOException while trying to connect due to closed input stream
*/
@Test
public void connect__ioExceptionWithSocket() {
inputStream = new ByteArrayInputStream(new byte[]{});
assertThrows(IOException.class, () -> {
Socket socket = Mockito.mock(Socket.class);
Mockito.when(socket.getInputStream()).thenReturn(inputStream);
Mockito.when(socket.getOutputStream()).thenReturn(outputStream);
SOCKS4Client.connect(
socket,
"127.0.0.1",
80
);
});
}
/**
* Check that CONNECTION_REFUSED throws exception
*/
@Test
public void connect__responseCONNECTION_REFUSED() throws IOException {
inputStream = new ByteArrayInputStream(new byte[]{
0, // dummy
SOCKS4Constants.Reply.CONNECTION_REFUSED, // Connection succeeded
});
assertThrows(SOCKSException.class, () -> {
SOCKS4Client.connect(inputStream,
outputStream,
"1.1.1.1",
80
);
});
}
/**
* IPv6 is not supported by this SOCKS client so it just throws an exception
*/
@Test
public void connect__IPv6() {
inputStream = new ByteArrayInputStream(new byte[]{});
assertThrows(SOCKSException.class, () -> {
SOCKS4Client.connect(
inputStream,
outputStream,
"::1",
80);
});
}
}

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