Skip to content
This repository was archived by the owner on Aug 5, 2024. It is now read-only.

Commit 061e2dd

Browse files
committed
Support for armhf and arm64 architectures.
1 parent e1dc183 commit 061e2dd

7 files changed

Lines changed: 33 additions & 12 deletions

File tree

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>org.berndpruenster.netlayer</groupId>
77
<artifactId>parent</artifactId>
8-
<version>0.6.5</version>
8+
<version>0.6.6</version>
99
<packaging>pom</packaging>
1010

1111
<name>Netlayer</name>
@@ -17,7 +17,7 @@
1717
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1818
<!-- Maven plugins -->
1919
<maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>
20-
<tor-binary.version>8.0.8</tor-binary.version>
20+
<tor-binary.version>0.4.0.5</tor-binary.version>
2121
</properties>
2222

2323
<modules>

tor.external/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>org.berndpruenster.netlayer</groupId>
88
<artifactId>parent</artifactId>
9-
<version>0.6.5</version>
9+
<version>0.6.6</version>
1010
</parent>
1111

1212
<artifactId>tor.external</artifactId>

tor.native/pom.xml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>org.berndpruenster.netlayer</groupId>
88
<artifactId>parent</artifactId>
9-
<version>0.6.5</version>
9+
<version>0.6.6</version>
1010
</parent>
1111

1212
<artifactId>tor.native</artifactId>
@@ -34,6 +34,16 @@
3434
<artifactId>tor-binary-linux64</artifactId>
3535
<version>${tor-binary.version}</version>
3636
</dependency>
37+
<dependency>
38+
<groupId>com.github.JesusMcCloud.tor-binary</groupId>
39+
<artifactId>tor-binary-linux-armhf</artifactId>
40+
<version>${tor-binary.version}</version>
41+
</dependency>
42+
<dependency>
43+
<groupId>com.github.JesusMcCloud.tor-binary</groupId>
44+
<artifactId>tor-binary-linux-arm64</artifactId>
45+
<version>${tor-binary.version}</version>
46+
</dependency>
3747
<dependency>
3848
<groupId>com.github.JesusMcCloud.tor-binary</groupId>
3949
<artifactId>tor-binary-windows</artifactId>

tor.native/src/main/kotlin/org/berndpruenster/netlayer/tor/NativeTor.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ private const val BINARY_TOR_LNX = "tor"
4444
private const val PATH_LNX = "linux/"
4545
private const val PATH_LNX64 = "${PATH_LNX}x64/"
4646
private const val PATH_LNX32 = "${PATH_LNX}x86/"
47+
private const val PATH_LNXARMHF = "${PATH_LNX}armhf/"
48+
private const val PATH_LNXARM64 = "${PATH_LNX}arm64/"
4749
private const val PATH_MACOS = "osx/"
4850
private const val PATH_MACOS64 = "${PATH_MACOS}x64/"
4951
private const val PATH_WIN = "windows/"
@@ -53,7 +55,7 @@ private const val PATH_NATIVE = "native/"
5355
private const val OS_UNSUPPORTED = "We don't support Tor on this OS"
5456

5557
class NativeTor @JvmOverloads @Throws(TorCtlException::class) constructor(workingDirectory: File, bridgeLines: Collection<String>? = null, torrcOverrides: Torrc? = null, automaticShutdown : Boolean = true) : Tor() {
56-
58+
5759
private val context : NativeContext = NativeContext(workingDirectory, torrcOverrides)
5860

5961
private val bridgeConfig: List<String> = bridgeLines?.filter { it.length > 10 } ?: emptyList()
@@ -151,6 +153,8 @@ class NativeContext(workingDirectory: File, overrides: Torrc?) : TorContext(work
151153
OsType.MACOS -> PATH_NATIVE + PATH_MACOS64
152154
OsType.LNX32 -> PATH_NATIVE + PATH_LNX32
153155
OsType.LNX64 -> PATH_NATIVE + PATH_LNX64
156+
OsType.LNXARMHF -> PATH_NATIVE + PATH_LNXARMHF
157+
OsType.LNXARM64 -> PATH_NATIVE + PATH_LNXARM64
154158
else -> throw RuntimeException(OS_UNSUPPORTED)
155159
}
156160
}
@@ -159,15 +163,15 @@ class NativeContext(workingDirectory: File, overrides: Torrc?) : TorContext(work
159163
when (OsType.current) {
160164
OsType.WIN -> PATH_NATIVE + PATH_WIN
161165
OsType.MACOS -> PATH_NATIVE + PATH_MACOS
162-
OsType.LNX32, OsType.LNX64 -> PATH_NATIVE + PATH_LNX
166+
OsType.LNX32, OsType.LNX64, OsType.LNXARMHF, OsType.LNXARM64 -> PATH_NATIVE + PATH_LNX
163167
else -> throw RuntimeException(OS_UNSUPPORTED)
164168
}
165169
}
166170
override val pathToRC: String = "$rcPath$FILE_TORRC_NATIVE"
167171

168172
override val torExecutableFileName: String by lazy {
169173
when (OsType.current) {
170-
OsType.LNX32, OsType.LNX64 -> BINARY_TOR_LNX
174+
OsType.LNX32, OsType.LNX64, OsType.LNXARMHF, OsType.LNXARM64 -> BINARY_TOR_LNX
171175
OsType.WIN -> BINARY_TOR_WIN
172176
OsType.MACOS -> BINARY_TOR_MACOS
173177
else -> throw RuntimeException(OS_UNSUPPORTED)
@@ -182,7 +186,7 @@ class NativeContext(workingDirectory: File, overrides: Torrc?) : TorContext(work
182186
override fun installFiles() {
183187
super.installFiles()
184188
when (OsType.current) {
185-
OsType.WIN, OsType.LNX32, OsType.LNX64, OsType.MACOS -> extractContentFromArchive(workingDirectory,
189+
OsType.WIN, OsType.LNX32, OsType.LNX64, OsType.LNXARMHF, OsType.LNXARM64, OsType.MACOS -> extractContentFromArchive(workingDirectory,
186190
getByName(
187191
pathToTorExecutable + FILE_ARCHIVE))
188192
else -> throw RuntimeException(OS_UNSUPPORTED)

tor.native/src/main/kotlin/org/berndpruenster/netlayer/tor/TorContext.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ abstract class TorContext @Throws(IOException::class) protected constructor(val
238238
val environment = processBuilder.environment()
239239
environment.put("HOME", workingDirectory.absolutePath)
240240
when (OsType.current) {
241-
OsType.LNX32, OsType.LNX64 ->
241+
OsType.LNX32, OsType.LNX64, OsType.LNXARMHF, OsType.LNXARM64 ->
242242
// We have to provide the LD_LIBRARY_PATH because when looking
243243
// for dynamic libraries
244244
// Linux apparently will not look in the current directory by

tor/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>org.berndpruenster.netlayer</groupId>
88
<artifactId>parent</artifactId>
9-
<version>0.6.5</version>
9+
<version>0.6.6</version>
1010
</parent>
1111

1212
<artifactId>tor</artifactId>

tor/src/main/kotlin/org/berndpruenster/netlayer/tor/OsType.kt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ import java.util.*
4040
enum class OsType { WIN,
4141
LNX32,
4242
LNX64,
43+
LNXARMHF,
44+
LNXARM64,
4345
MACOS,
4446
ANDROID;
4547

@@ -86,6 +88,12 @@ enum class OsType { WIN,
8688
if (unameOutput.compareTo("x86_64") == 0) {
8789
return LNX64
8890
}
91+
if (unameOutput.matches(Regex("arm.+"))) {
92+
return LNXARMHF
93+
}
94+
if (unameOutput.compareTo("aarch64") == 0) {
95+
return LNXARM64
96+
}
8997
throw RuntimeException("Could not understand uname output, not sure what bitness")
9098
} catch (e: IOException) {
9199
throw RuntimeException("Uname failure", e)
@@ -99,7 +107,6 @@ enum class OsType { WIN,
99107
}
100108

101109
fun isUnixoid(): Boolean {
102-
return listOf(LNX32, LNX64, MACOS).contains(this)
110+
return listOf(LNX32, LNX64, LNXARMHF, LNXARM64, MACOS).contains(this)
103111
}
104112
}
105-

0 commit comments

Comments
 (0)