mirror of
https://github.com/LamGC/ScalaBot.git
synced 2025-04-30 06:37:29 +00:00
feat(config): 新增 HTTPS 代理类型, 增加 Maven 对 HTTPS 代理的支持.
为 ProxyType 增加 HTTPS 类型, 同时为 Aether 增加 Https 代理支持, 方便用户使用现有的公开代理下载依赖包.
This commit is contained in:
parent
df484d6bd7
commit
581eeba20b
@ -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 {
|
||||||
|
@ -51,6 +51,7 @@ data class BotConfig(
|
|||||||
enum class ProxyType {
|
enum class ProxyType {
|
||||||
NO_PROXY,
|
NO_PROXY,
|
||||||
HTTP,
|
HTTP,
|
||||||
|
HTTPS,
|
||||||
SOCKS4,
|
SOCKS4,
|
||||||
SOCKS5
|
SOCKS5
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user