Skip to content

Commit

Permalink
Add explicit clear mtu
Browse files Browse the repository at this point in the history
  • Loading branch information
Pururun committed May 15, 2024
1 parent 197f501 commit 72dcfc8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class SettingsRepository(

suspend fun setWireguardMtu(mtu: Mtu) = managementService.setWireguardMtu(mtu.value)

suspend fun clearWireguardMtu() = managementService.setWireguardMtu(null)
suspend fun clearWireguardMtu() = managementService.clearWireguardMtu()

suspend fun setWireguardQuantumResistant(value: QuantumResistantState) =
managementService.setWireguardQuantumResistant(value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import arrow.optics.typeclasses.Index
import com.google.protobuf.BoolValue
import com.google.protobuf.Empty
import com.google.protobuf.StringValue
import com.google.protobuf.UInt32Value
import io.grpc.ConnectivityState
import io.grpc.Status
import io.grpc.StatusException
Expand Down Expand Up @@ -353,8 +354,13 @@ class ManagementService(
.mapLeft(SetDnsOptionsError::Unknown)
.mapEmpty()

suspend fun setWireguardMtu(value: Int?): Either<SetWireguardMtuError, Unit> =
Either.catch { grpc.setWireguardMtu(value.fromDomain()) }
suspend fun setWireguardMtu(value: Int): Either<SetWireguardMtuError, Unit> =
Either.catch { grpc.setWireguardMtu(UInt32Value.of(value)) }
.mapLeft(SetWireguardMtuError::Unknown)
.mapEmpty()

suspend fun clearWireguardMtu(): Either<SetWireguardMtuError, Unit> =
Either.catch { grpc.setWireguardMtu(UInt32Value.newBuilder().clearValue().build()) }
.mapLeft(SetWireguardMtuError::Unknown)
.mapEmpty()

Expand Down

0 comments on commit 72dcfc8

Please sign in to comment.