-
Notifications
You must be signed in to change notification settings - Fork 351
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'slow-reconnection-on-grpc-droid-1223'
- Loading branch information
Showing
4 changed files
with
65 additions
and
3 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
35 changes: 35 additions & 0 deletions
35
...grpc/src/main/kotlin/net/mullvad/mullvadvpn/lib/daemon/grpc/resolver/DummyNameResolver.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,35 @@ | ||
package net.mullvad.mullvadvpn.lib.daemon.grpc.resolver | ||
|
||
import io.grpc.EquivalentAddressGroup | ||
import io.grpc.NameResolver | ||
import java.net.InetSocketAddress | ||
|
||
class DummyNameResolver : NameResolver() { | ||
|
||
override fun getServiceAuthority(): String = SERVICE_AUTHORITY | ||
|
||
override fun start(listener: Listener2) { | ||
val resolutionResult = | ||
ResolutionResult.newBuilder() | ||
.setAddresses( | ||
listOf( | ||
EquivalentAddressGroup( | ||
InetSocketAddress.createUnresolved(DUMMY_HOST, DUMMY_PORT) | ||
) | ||
) | ||
) | ||
.build() | ||
|
||
listener.onResult(resolutionResult) | ||
} | ||
|
||
override fun shutdown() { | ||
// Do nothing | ||
} | ||
|
||
companion object { | ||
const val SERVICE_AUTHORITY = "localhost" | ||
private const val DUMMY_HOST = "" | ||
private const val DUMMY_PORT = 80 | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...c/main/kotlin/net/mullvad/mullvadvpn/lib/daemon/grpc/resolver/DummyNameResolverFactory.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,18 @@ | ||
package net.mullvad.mullvadvpn.lib.daemon.grpc.resolver | ||
|
||
import io.grpc.NameResolver | ||
import java.net.URI | ||
|
||
class DummyNameResolverFactory : NameResolver.Factory() { | ||
override fun newNameResolver(targetUri: URI, args: NameResolver.Args): NameResolver { | ||
return DummyNameResolver() | ||
} | ||
|
||
override fun getDefaultScheme(): String { | ||
return DNS_SCHEME | ||
} | ||
|
||
companion object { | ||
private const val DNS_SCHEME = "dns" | ||
} | ||
} |
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