WIP: remove tor binaries; add macos tor dependencies from tmp Maven repo

This commit is contained in:
Sebastian Kürten
2023-03-18 08:39:40 +01:00
parent b5283146b1
commit d963e75bd1
11 changed files with 29 additions and 150740 deletions

View File

@@ -55,8 +55,6 @@ 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;
@@ -210,6 +208,10 @@ abstract class TorPlugin implements DuplexPlugin, EventHandler, EventListener {
return new File(torDirectory, "tor");
}
private File getLibEventFile() {
return new File(torDirectory, "libevent-2.1.7.dylib");
}
protected File getObfs4ExecutableFile() {
return new File(torDirectory, "obfs4proxy");
}
@@ -336,7 +338,7 @@ abstract class TorPlugin implements DuplexPlugin, EventHandler, EventListener {
doneFile.delete();
installTorExecutable();
installObfs4Executable();
// installSnowflakeExecutable();
installSnowflakeExecutable();
if (!doneFile.createNewFile())
LOG.warning("Failed to create done file");
}
@@ -350,9 +352,9 @@ abstract class TorPlugin implements DuplexPlugin, EventHandler, EventListener {
if (LOG.isLoggable(INFO))
LOG.info("Installing Tor binary for " + architecture);
File torFile = getTorExecutableFile();
extract(getTorInputStream(), torFile);
extract(getLibEventInputStream(),
new File(torFile.getParentFile(), "libevent-2.1.7.dylib"));
File libEventFile = getLibEventFile();
extract(getExecutableInputStream("tor"), torFile);
extract(getExecutableInputStream("libevent-2.1.7.dylib"), libEventFile);
if (!torFile.setExecutable(true, true)) throw new IOException();
}
@@ -382,46 +384,6 @@ 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(" ");