forked from guardianproject/orbot-android
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue guardianproject#1193: Added support for mixing bridge types wit…
…h custom bridges Meek, Obfs4 and Webtunnel can now be used all in parallel.
- Loading branch information
1 parent
1fb0350
commit e5b8b83
Showing
8 changed files
with
147 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
// Top-level build file where you can add configuration options common to all sub-projects/modules. | ||
plugins { | ||
id "com.android.application" version "8.8.0" apply false | ||
id "org.jetbrains.kotlin.android" version "2.0.0" apply false | ||
id "org.jetbrains.kotlin.android" version "2.1.0" apply false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
orbotservice/src/main/java/org/torproject/android/service/util/Bridge.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package org.torproject.android.service.util | ||
|
||
/** | ||
* Parser for bridge lines. | ||
*/ | ||
@Suppress("MemberVisibilityCanBePrivate", "unused") | ||
class Bridge(var raw: String) { | ||
|
||
val rawPieces | ||
get() = raw.split(" ") | ||
|
||
val transport | ||
get() = rawPieces.firstOrNull() | ||
|
||
val address | ||
get() = rawPieces.getOrNull(1) | ||
|
||
val ip | ||
get() = address?.split(":")?.firstOrNull() | ||
|
||
val port | ||
get() = address?.split(":")?.lastOrNull()?.toInt() | ||
|
||
val fingerprint1 | ||
get() = rawPieces.getOrNull(2) | ||
|
||
val fingerprint2 | ||
get() = rawPieces.firstOrNull { it.startsWith("fingerprint=") } | ||
?.split("=")?.lastOrNull() | ||
|
||
val url | ||
get() = rawPieces.firstOrNull { it.startsWith("url=") } | ||
?.split("=")?.lastOrNull() | ||
|
||
val front | ||
get() = rawPieces.firstOrNull { it.startsWith("front=") } | ||
?.split("=")?.lastOrNull() | ||
|
||
val fronts | ||
get() = rawPieces.firstOrNull { it.startsWith("fronts=") } | ||
?.split("=")?.lastOrNull()?.split(",")?.filter { it.isNotEmpty() } | ||
|
||
val cert | ||
get() = rawPieces.firstOrNull { it.startsWith("cert=") } | ||
?.split("=")?.lastOrNull() | ||
|
||
val iatMode | ||
get() = rawPieces.firstOrNull { it.startsWith("iat-mode=") } | ||
?.split("=")?.lastOrNull() | ||
|
||
val ice | ||
get() = rawPieces.firstOrNull { it.startsWith("ice=") } | ||
?.split("=")?.lastOrNull() | ||
|
||
val utlsImitate | ||
get() = rawPieces.firstOrNull { it.startsWith("utls-imitate=") } | ||
?.split("=")?.lastOrNull() | ||
|
||
val ver | ||
get() = rawPieces.firstOrNull { it.startsWith("ver=") } | ||
?.split("=")?.lastOrNull() | ||
|
||
|
||
override fun toString(): String { | ||
return raw | ||
} | ||
|
||
companion object { | ||
|
||
@JvmStatic | ||
fun parseBridges(bridges: String): List<Bridge> { | ||
return bridges | ||
.split("\n") | ||
.mapNotNull { | ||
val b = it.trim() | ||
if (b.isNotEmpty()) Bridge(b) else null | ||
} | ||
} | ||
|
||
@JvmStatic | ||
fun getTransports(bridges: List<Bridge>): Set<String> { | ||
return bridges.mapNotNull { it.transport }.toSet() | ||
} | ||
} | ||
} |