1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package com.vauth.foxyvpn.vpn.upstream
import java.io.Closeable
import java.io.IOException
import java.io.InputStream
import java.io.OutputStream
interface UpstreamSession : Closeable {
suspend fun connect()
suspend fun openStream(targetHost: String, targetPort: Int): TunneledStream
fun disableNewStreamsAndCloseWhenIdle()
fun updateBearerToken(token: String)
val isConnected: Boolean
}
data class TunneledStream(
val input: InputStream,
val output: OutputStream,
val close: () -> Unit,
)
class UpstreamConnectRejectedException(
val statusCode: Int?,
val authority: String,
message: String,
) : IOException(message)
class UpstreamConnectTimeoutException(
val authority: String,
message: String,
cause: Throwable? = null,
) : IOException(message, cause)