WIP: macos support

This commit is contained in:
Sebastian Kürten
2022-01-05 00:32:57 +01:00
parent 3dbf327937
commit b5283146b1
10 changed files with 150743 additions and 10 deletions

View File

@@ -55,6 +55,8 @@ import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.logging.Logger;
import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import javax.annotation.Nullable;
import javax.annotation.concurrent.GuardedBy;
@@ -334,7 +336,7 @@ abstract class TorPlugin implements DuplexPlugin, EventHandler, EventListener {
doneFile.delete();
installTorExecutable();
installObfs4Executable();
installSnowflakeExecutable();
// installSnowflakeExecutable();
if (!doneFile.createNewFile())
LOG.warning("Failed to create done file");
}
@@ -348,7 +350,9 @@ abstract class TorPlugin implements DuplexPlugin, EventHandler, EventListener {
if (LOG.isLoggable(INFO))
LOG.info("Installing Tor binary for " + architecture);
File torFile = getTorExecutableFile();
extract(getExecutableInputStream("tor"), torFile);
extract(getTorInputStream(), torFile);
extract(getLibEventInputStream(),
new File(torFile.getParentFile(), "libevent-2.1.7.dylib"));
if (!torFile.setExecutable(true, true)) throw new IOException();
}
@@ -378,6 +382,46 @@ abstract class TorPlugin implements DuplexPlugin, EventHandler, EventListener {
return "";
}
private InputStream getTorInputStream() throws IOException {
System.out.println("tor_macos-" + architecture + ".zip");
InputStream in = resourceProvider
.getResourceInputStream("tor_macos-" + architecture, ".zip");
ZipInputStream zin = new ZipInputStream(in);
while (true) {
ZipEntry entry = zin.getNextEntry();
if (entry == null) {
break;
}
String name = entry.getName();
System.out.println(name);
if (name.equals("tor")) {
return zin;
}
}
throw new IOException();
}
private InputStream getLibEventInputStream() throws IOException {
System.out.println("tor_macos-" + architecture + ".zip");
InputStream in = resourceProvider
.getResourceInputStream("tor_macos-" + architecture, ".zip");
ZipInputStream zin = new ZipInputStream(in);
while (true) {
ZipEntry entry = zin.getNextEntry();
if (entry == null) {
break;
}
String name = entry.getName();
System.out.println(name);
if (name.startsWith("libevent")) {
return zin;
}
}
throw new IOException();
}
private static void append(StringBuilder strb, String name, Object value) {
strb.append(name);
strb.append(" ");

View File

@@ -11,7 +11,7 @@ dependencies {
implementation project(':bramble-core')
implementation fileTree(dir: 'libs', include: '*.jar')
def jna_version = '4.5.2'
def jna_version = '5.10.0'
implementation "net.java.dev.jna:jna:$jna_version"
implementation "net.java.dev.jna:jna-platform:$jna_version"

View File

@@ -53,7 +53,7 @@ class UnixTorPlugin extends JavaTorPlugin {
private interface CLibrary extends Library {
CLibrary INSTANCE = Native.loadLibrary("c", CLibrary.class);
CLibrary INSTANCE = Native.load("c", CLibrary.class);
int getpid();
}

View File

@@ -27,6 +27,7 @@ import javax.net.SocketFactory;
import static java.util.logging.Level.INFO;
import static org.briarproject.bramble.util.OsUtils.isLinux;
import static org.briarproject.bramble.util.OsUtils.isMac;
@Immutable
@NotNullByDefault
@@ -57,14 +58,18 @@ public class UnixTorPluginFactory extends TorPluginFactory {
@Nullable
@Override
String getArchitectureForTorBinary() {
if (!isLinux()) return null;
if (!isLinux() && !isMac()) return null;
String arch = System.getProperty("os.arch");
if (LOG.isLoggable(INFO)) {
LOG.info("System's os.arch is " + arch);
}
if (arch.equals("amd64")) return "x86_64";
else if (arch.equals("aarch64")) return "aarch64";
else if (arch.equals("arm")) return "armhf";
if (isLinux()) {
if (arch.equals("amd64")) return "x86_64";
else if (arch.equals("aarch64")) return "aarch64";
else if (arch.equals("arm")) return "armhf";
} else if (isMac()) {
if (arch.equals("aarch64")) return "aarch64";
}
return null;
}

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -21,8 +21,8 @@ dependencyVerification {
'javax.inject:javax.inject:1:javax.inject-1.jar:91c77044a50c481636c32d916fd89c9118a72195390452c81065080f957de7ff',
'junit:junit:4.13.2:junit-4.13.2.jar:8e495b634469d64fb8acfa3495a065cbacc8a0fff55ce1e31007be4c16dc57d3',
'net.bytebuddy:byte-buddy:1.9.12:byte-buddy-1.9.12.jar:3688c3d434bebc3edc5516296a2ed0f47b65e451071b4afecad84f902f0efc11',
'net.java.dev.jna:jna-platform:4.5.2:jna-platform-4.5.2.jar:f1d00c167d8921c6e23c626ef9f1c3ae0be473c95c68ffa012bc7ae55a87e2d6',
'net.java.dev.jna:jna:4.5.2:jna-4.5.2.jar:0c8eb7acf67261656d79005191debaba3b6bf5dd60a43735a245429381dbecff',
'net.java.dev.jna:jna-platform:5.10.0:jna-platform-5.10.0.jar:1f71afd977051bf0109ef5e3767d4e2afd777be894d89788cc0f38ad68f6a16f',
'net.java.dev.jna:jna:5.10.0:jna-5.10.0.jar:e335c10679f743207d822c5f7948e930319835492575a9dba6b94f8a3b96fcc8',
'net.jcip:jcip-annotations:1.0:jcip-annotations-1.0.jar:be5805392060c71474bf6c9a67a099471274d30b83eef84bfc4e0889a4f1dcc0',
'net.ltgt.gradle.incap:incap:0.2:incap-0.2.jar:b625b9806b0f1e4bc7a2e3457119488de3cd57ea20feedd513db070a573a4ffd',
'org.apache-extras.beanshell:bsh:2.0b6:bsh-2.0b6.jar:a17955976070c0573235ee662f2794a78082758b61accffce8d3f8aedcd91047',