mirror of
https://github.com/LamGC/ScalaBot.git
synced 2025-04-29 22:27:31 +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) {
|
||||
ProxyType.NO_PROXY -> DefaultBotOptions.ProxyType.NO_PROXY
|
||||
ProxyType.HTTP -> DefaultBotOptions.ProxyType.HTTP
|
||||
ProxyType.HTTPS -> DefaultBotOptions.ProxyType.HTTP
|
||||
ProxyType.SOCKS4 -> DefaultBotOptions.ProxyType.SOCKS4
|
||||
ProxyType.SOCKS5 -> DefaultBotOptions.ProxyType.SOCKS5
|
||||
}
|
||||
}
|
||||
|
||||
internal fun ProxyConfig.toAetherProxy(): Proxy? {
|
||||
return if (type == ProxyType.HTTP) {
|
||||
Proxy(Proxy.TYPE_HTTP, host, port)
|
||||
} else {
|
||||
null
|
||||
val typeStr = when (type) {
|
||||
ProxyType.HTTP -> Proxy.TYPE_HTTP
|
||||
ProxyType.HTTPS -> Proxy.TYPE_HTTPS
|
||||
else -> return null
|
||||
}
|
||||
return Proxy(typeStr, host, port)
|
||||
}
|
||||
|
||||
internal fun MavenRepositoryConfig.toRemoteRepository(proxyConfig: ProxyConfig): RemoteRepository {
|
||||
|
@ -51,6 +51,7 @@ data class BotConfig(
|
||||
enum class ProxyType {
|
||||
NO_PROXY,
|
||||
HTTP,
|
||||
HTTPS,
|
||||
SOCKS4,
|
||||
SOCKS5
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user