mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI-bot_template.git
synced 2024-11-17 13:53:52 +00:00
small fix for password setting up in authenticator
This commit is contained in:
parent
22562426e7
commit
c4f214758d
@ -7,10 +7,7 @@ import io.ktor.client.plugins.*
|
|||||||
import io.ktor.client.request.*
|
import io.ktor.client.request.*
|
||||||
import io.ktor.http.*
|
import io.ktor.http.*
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import java.net.Authenticator
|
import java.net.*
|
||||||
import java.net.InetSocketAddress
|
|
||||||
import java.net.PasswordAuthentication
|
|
||||||
import java.net.Proxy
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
@ -68,8 +65,12 @@ data class HttpClientConfig(
|
|||||||
proxyConfig.password ?.toCharArray() ?: error("For Socks proxy you should use both username and password or do not use authentication at all")
|
proxyConfig.password ?.toCharArray() ?: error("For Socks proxy you should use both username and password or do not use authentication at all")
|
||||||
)
|
)
|
||||||
Authenticator.setDefault(object : Authenticator() {
|
Authenticator.setDefault(object : Authenticator() {
|
||||||
override fun getPasswordAuthentication(): PasswordAuthentication {
|
override fun getPasswordAuthentication(): PasswordAuthentication? {
|
||||||
return passwordAuthentication
|
return if (requestingHost.lowercase() == proxyConfig.hostname.lowercase()) {
|
||||||
|
passwordAuthentication
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user