mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-06-22 02:01:08 +07:00
Fix bugs in awg and wireguard protocols
This commit is contained in:
+1
-1
@@ -65,7 +65,7 @@ open class Wireguard : Protocol() {
|
||||
val config = GoBackend.wgGetConfig(tunnelHandle) ?: return Statistics.EMPTY_STATISTICS
|
||||
return Statistics.build {
|
||||
var optsCount = 0
|
||||
config.splitToSequence("\\n").forEach { line ->
|
||||
config.splitToSequence("\n").forEach { line ->
|
||||
with(line) {
|
||||
when {
|
||||
startsWith("rx_bytes=") -> setRxBytes(substring(9).toLong()).also { ++optsCount }
|
||||
|
||||
+11
-3
@@ -24,9 +24,18 @@ open class WireguardConfig protected constructor(
|
||||
builder.privateKeyHex
|
||||
)
|
||||
|
||||
open fun toWgUserspaceString(): String = with(StringBuilder()) {
|
||||
appendLine("private_key=$privateKeyHex")
|
||||
fun toWgUserspaceString(): String = with(StringBuilder()) {
|
||||
appendDeviceLine(this)
|
||||
appendLine("replace_peers=true")
|
||||
appendPeerLine(this)
|
||||
return this.toString()
|
||||
}
|
||||
|
||||
open fun appendDeviceLine(sb: StringBuilder) = with(sb) {
|
||||
appendLine("private_key=$privateKeyHex")
|
||||
}
|
||||
|
||||
open fun appendPeerLine(sb: StringBuilder) = with(sb) {
|
||||
appendLine("public_key=$publicKeyHex")
|
||||
routes.forEach { route ->
|
||||
appendLine("allowed_ip=$route")
|
||||
@@ -35,7 +44,6 @@ open class WireguardConfig protected constructor(
|
||||
if (persistentKeepalive != 0)
|
||||
appendLine("persistent_keepalive_interval=$persistentKeepalive")
|
||||
appendLine("preshared_key=$preSharedKeyHex")
|
||||
return this.toString()
|
||||
}
|
||||
|
||||
open class Builder : ProtocolConfig.Builder(true) {
|
||||
|
||||
Reference in New Issue
Block a user