feat(config): 新增 HTTPS 代理类型, 增加 Maven 对 HTTPS 代理的支持.

为 ProxyType 增加 HTTPS 类型, 同时为 Aether 增加 Https 代理支持, 方便用户使用现有的公开代理下载依赖包.
This commit is contained in:
LamGC 2022-06-25 23:00:51 +08:00
parent df484d6bd7
commit 581eeba20b
Signed by: LamGC
GPG Key ID: 6C5AE2A913941E1D
2 changed files with 7 additions and 4 deletions

View File

@ -26,17 +26,19 @@ internal fun ProxyType.toTelegramBotsType(): DefaultBotOptions.ProxyType {
return when (this) { return when (this) {
ProxyType.NO_PROXY -> DefaultBotOptions.ProxyType.NO_PROXY ProxyType.NO_PROXY -> DefaultBotOptions.ProxyType.NO_PROXY
ProxyType.HTTP -> DefaultBotOptions.ProxyType.HTTP ProxyType.HTTP -> DefaultBotOptions.ProxyType.HTTP
ProxyType.HTTPS -> DefaultBotOptions.ProxyType.HTTP
ProxyType.SOCKS4 -> DefaultBotOptions.ProxyType.SOCKS4 ProxyType.SOCKS4 -> DefaultBotOptions.ProxyType.SOCKS4
ProxyType.SOCKS5 -> DefaultBotOptions.ProxyType.SOCKS5 ProxyType.SOCKS5 -> DefaultBotOptions.ProxyType.SOCKS5
} }
} }
internal fun ProxyConfig.toAetherProxy(): Proxy? { internal fun ProxyConfig.toAetherProxy(): Proxy? {
return if (type == ProxyType.HTTP) { val typeStr = when (type) {
Proxy(Proxy.TYPE_HTTP, host, port) ProxyType.HTTP -> Proxy.TYPE_HTTP
} else { ProxyType.HTTPS -> Proxy.TYPE_HTTPS
null else -> return null
} }
return Proxy(typeStr, host, port)
} }
internal fun MavenRepositoryConfig.toRemoteRepository(proxyConfig: ProxyConfig): RemoteRepository { internal fun MavenRepositoryConfig.toRemoteRepository(proxyConfig: ProxyConfig): RemoteRepository {

View File

@ -51,6 +51,7 @@ data class BotConfig(
enum class ProxyType { enum class ProxyType {
NO_PROXY, NO_PROXY,
HTTP, HTTP,
HTTPS,
SOCKS4, SOCKS4,
SOCKS5 SOCKS5
} }