mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-15 20:29:52 +01:00
Added public key and placeholder onion address.
This commit is contained in:
@@ -24,6 +24,8 @@ import dagger.Module;
|
|||||||
import dagger.Provides;
|
import dagger.Provides;
|
||||||
|
|
||||||
import static android.content.Context.MODE_PRIVATE;
|
import static android.content.Context.MODE_PRIVATE;
|
||||||
|
import static org.briarproject.api.reporting.ReportingConstants.DEV_ONION_ADDRESS;
|
||||||
|
import static org.briarproject.api.reporting.ReportingConstants.DEV_PUBLIC_KEY_HEX;
|
||||||
|
|
||||||
@Module
|
@Module
|
||||||
public class AppModule {
|
public class AppModule {
|
||||||
@@ -97,36 +99,22 @@ public class AppModule {
|
|||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
public DevConfig provideDevConfig(CryptoComponent crypto) {
|
public DevConfig provideDevConfig(final CryptoComponent crypto) {
|
||||||
final PublicKey pub;
|
|
||||||
try {
|
|
||||||
// TODO fill in
|
|
||||||
pub = crypto.getMessageKeyParser()
|
|
||||||
.parsePublicKey(StringUtils.fromHexString(""));
|
|
||||||
} catch (GeneralSecurityException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new DevConfig() {
|
return new DevConfig() {
|
||||||
|
|
||||||
private final PublicKey DEV_PUB_KEY = pub;
|
|
||||||
// TODO fill in
|
|
||||||
private final String DEV_ONION = "";
|
|
||||||
private final int DEV_REPORT_PORT = 8080;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PublicKey getDevPublicKey() {
|
public PublicKey getDevPublicKey() {
|
||||||
return DEV_PUB_KEY;
|
try {
|
||||||
|
return crypto.getMessageKeyParser().parsePublicKey(
|
||||||
|
StringUtils.fromHexString(DEV_PUBLIC_KEY_HEX));
|
||||||
|
} catch (GeneralSecurityException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDevOnionAddress() {
|
public String getDevOnionAddress() {
|
||||||
return DEV_ONION;
|
return DEV_ONION_ADDRESS;
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getDevReportPort() {
|
|
||||||
return DEV_REPORT_PORT;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,4 @@ public interface DevConfig {
|
|||||||
PublicKey getDevPublicKey();
|
PublicKey getDevPublicKey();
|
||||||
|
|
||||||
String getDevOnionAddress();
|
String getDevOnionAddress();
|
||||||
|
|
||||||
int getDevReportPort();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package org.briarproject.api.reporting;
|
||||||
|
|
||||||
|
public interface ReportingConstants {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Public key for reporting crashes and feedback to the developers. This
|
||||||
|
* is an ECIES key on the brainpoolp512r1 curve, encoded in SEC 1 format
|
||||||
|
* without point compression.
|
||||||
|
*/
|
||||||
|
String DEV_PUBLIC_KEY_HEX =
|
||||||
|
"0457AD1619FBD433D5E13D5560697054"
|
||||||
|
+ "6E8FC5F4EF83A8C18718E8BF59BB601F"
|
||||||
|
+ "E20CCB233F06714A1BED370141A04C81"
|
||||||
|
+ "808CF2EE95C7323CDEE5999670BD1174"
|
||||||
|
+ "1F65ED691F355518E1A7E5E54BDDCA4C"
|
||||||
|
+ "B86BD8DB8842BBFD706EBD9708DB8C04"
|
||||||
|
+ "4FF006F215D83A66B3AEBAD674C4C1C4"
|
||||||
|
+ "218121A38FA1FDD4A51E77588D90BD9652";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hidden service address for reporting crashes and feedback to the
|
||||||
|
* developers. TODO: Replace this with a real address.
|
||||||
|
*/
|
||||||
|
String DEV_ONION_ADDRESS = "aaaaaaaaaaaaaaaa.onion";
|
||||||
|
}
|
||||||
@@ -22,7 +22,6 @@ import java.net.Socket;
|
|||||||
import java.net.SocketException;
|
import java.net.SocketException;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -33,7 +32,7 @@ class DevReporterImpl implements DevReporter {
|
|||||||
private static final Logger LOG =
|
private static final Logger LOG =
|
||||||
Logger.getLogger(DevReporterImpl.class.getName());
|
Logger.getLogger(DevReporterImpl.class.getName());
|
||||||
|
|
||||||
private static final int TIMEOUT = 30 * 1000; // 30 seconds
|
private static final int SOCKET_TIMEOUT = 30 * 1000; // 30 seconds
|
||||||
private static final String PREFIX = "briar-";
|
private static final String PREFIX = "briar-";
|
||||||
private static final String REPORT_EXT = ".report";
|
private static final String REPORT_EXT = ".report";
|
||||||
private static final String CRLF = "\r\n";
|
private static final String CRLF = "\r\n";
|
||||||
@@ -46,13 +45,12 @@ class DevReporterImpl implements DevReporter {
|
|||||||
this.devConfig = devConfig;
|
this.devConfig = devConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Socket connectToDevelopers(int socksPort, int devPort)
|
private Socket connectToDevelopers(int socksPort)
|
||||||
throws UnknownHostException, SocksException, SocketException {
|
throws UnknownHostException, SocksException, SocketException {
|
||||||
Socks5Proxy proxy = new Socks5Proxy("127.0.0.1", socksPort);
|
Socks5Proxy proxy = new Socks5Proxy("127.0.0.1", socksPort);
|
||||||
proxy.resolveAddrLocally(false);
|
proxy.resolveAddrLocally(false);
|
||||||
Socket s =
|
Socket s = new SocksSocket(proxy, devConfig.getDevOnionAddress(), 80);
|
||||||
new SocksSocket(proxy, devConfig.getDevOnionAddress(), devPort);
|
s.setSoTimeout(SOCKET_TIMEOUT);
|
||||||
s.setSoTimeout(TIMEOUT);
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,7 +61,7 @@ class DevReporterImpl implements DevReporter {
|
|||||||
crypto.encryptToKey(devConfig.getDevPublicKey(),
|
crypto.encryptToKey(devConfig.getDevPublicKey(),
|
||||||
StringUtils.toUtf8(crashReport));
|
StringUtils.toUtf8(crashReport));
|
||||||
|
|
||||||
String filename = PREFIX + new Date().getTime() + REPORT_EXT;
|
String filename = PREFIX + System.currentTimeMillis() + REPORT_EXT;
|
||||||
File report = new File(crashReportDir, filename);
|
File report = new File(crashReportDir, filename);
|
||||||
PrintWriter writer = null;
|
PrintWriter writer = null;
|
||||||
try {
|
try {
|
||||||
@@ -83,14 +81,13 @@ class DevReporterImpl implements DevReporter {
|
|||||||
if (reports == null || reports.length == 0)
|
if (reports == null || reports.length == 0)
|
||||||
return; // No crash reports to send
|
return; // No crash reports to send
|
||||||
|
|
||||||
LOG.info("Connecting to developers' Hidden Service");
|
LOG.info("Connecting to developers");
|
||||||
Socket s;
|
Socket s;
|
||||||
try {
|
try {
|
||||||
s = connectToDevelopers(socksPort,
|
s = connectToDevelopers(socksPort);
|
||||||
devConfig.getDevReportPort());
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
if (LOG.isLoggable(WARNING))
|
if (LOG.isLoggable(WARNING))
|
||||||
LOG.log(WARNING, "Tor SOCKS proxy failed", e);
|
LOG.log(WARNING, "Could not connect to developers", e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,9 +106,9 @@ class DevReporterImpl implements DevReporter {
|
|||||||
writer.append(line).append(CRLF);
|
writer.append(line).append(CRLF);
|
||||||
}
|
}
|
||||||
writer.append(CRLF);
|
writer.append(CRLF);
|
||||||
|
writer.flush();
|
||||||
f.delete();
|
f.delete();
|
||||||
}
|
}
|
||||||
writer.flush();
|
|
||||||
LOG.info("Crash reports sent");
|
LOG.info("Crash reports sent");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
if (LOG.isLoggable(WARNING))
|
if (LOG.isLoggable(WARNING))
|
||||||
|
|||||||
Reference in New Issue
Block a user