28 lines
701 B
Kotlin
28 lines
701 B
Kotlin
package com.rainy.token.data.proxy
|
||
|
||
import kotlinx.coroutines.flow.MutableStateFlow
|
||
import kotlinx.coroutines.flow.StateFlow
|
||
|
||
/**
|
||
* 本地 HTTP 反代服务配置。
|
||
*/
|
||
data class ProxyServerConfig(
|
||
val port: Int = 8787,
|
||
/** 客户端必须携带的 Bearer Key;null = 关闭鉴权(仅本机建议)。 */
|
||
val apiKey: String? = null,
|
||
)
|
||
|
||
/**
|
||
* 本地 HTTP 反代服务。
|
||
*
|
||
* 具体实现建议用 Ktor CIO(协程友好,方便 SSE 流式转发);
|
||
* 若 APK 体积敏感,可换 NanoHTTPD,但流式转发需要额外桥接。
|
||
*/
|
||
interface LocalProxyServer {
|
||
val isRunning: StateFlow<Boolean>
|
||
|
||
fun start(config: ProxyServerConfig): Result<Unit>
|
||
|
||
fun stop()
|
||
}
|