mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-24 02:25:19 +00:00
Merge branch 'dev' of https://github.com/oxen-io/session-android into client-side-nickname
This commit is contained in:
commit
c82a76b912
@ -158,8 +158,8 @@ dependencies {
|
|||||||
testImplementation 'org.robolectric:shadows-multidex:4.2'
|
testImplementation 'org.robolectric:shadows-multidex:4.2'
|
||||||
}
|
}
|
||||||
|
|
||||||
def canonicalVersionCode = 161
|
def canonicalVersionCode = 162
|
||||||
def canonicalVersionName = "1.10.2"
|
def canonicalVersionName = "1.10.3"
|
||||||
|
|
||||||
def postFixSize = 10
|
def postFixSize = 10
|
||||||
def abiPostFix = ['armeabi-v7a' : 1,
|
def abiPostFix = ['armeabi-v7a' : 1,
|
||||||
|
@ -39,6 +39,25 @@ object HTTP {
|
|||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getDefaultConnection(timeout: Long): OkHttpClient {
|
||||||
|
// Snode to snode communication uses self-signed certificates but clients can safely ignore this
|
||||||
|
val trustManager = object : X509TrustManager {
|
||||||
|
|
||||||
|
override fun checkClientTrusted(chain: Array<out X509Certificate>?, authorizationType: String?) { }
|
||||||
|
override fun checkServerTrusted(chain: Array<out X509Certificate>?, authorizationType: String?) { }
|
||||||
|
override fun getAcceptedIssuers(): Array<X509Certificate> { return arrayOf() }
|
||||||
|
}
|
||||||
|
val sslContext = SSLContext.getInstance("SSL")
|
||||||
|
sslContext.init(null, arrayOf( trustManager ), SecureRandom())
|
||||||
|
return OkHttpClient().newBuilder()
|
||||||
|
.sslSocketFactory(sslContext.socketFactory, trustManager)
|
||||||
|
.hostnameVerifier { _, _ -> true }
|
||||||
|
.connectTimeout(timeout, TimeUnit.SECONDS)
|
||||||
|
.readTimeout(timeout, TimeUnit.SECONDS)
|
||||||
|
.writeTimeout(timeout, TimeUnit.SECONDS)
|
||||||
|
.build()
|
||||||
|
}
|
||||||
|
|
||||||
private const val timeout: Long = 10
|
private const val timeout: Long = 10
|
||||||
|
|
||||||
class HTTPRequestFailedException(val statusCode: Int, val json: Map<*, *>?)
|
class HTTPRequestFailedException(val statusCode: Int, val json: Map<*, *>?)
|
||||||
@ -89,12 +108,7 @@ object HTTP {
|
|||||||
if (useSeedNodeConnection) {
|
if (useSeedNodeConnection) {
|
||||||
throw IllegalStateException("Setting a custom timeout is only allowed for requests to snodes.")
|
throw IllegalStateException("Setting a custom timeout is only allowed for requests to snodes.")
|
||||||
}
|
}
|
||||||
connection = OkHttpClient()
|
connection = getDefaultConnection(timeout)
|
||||||
.newBuilder()
|
|
||||||
.connectTimeout(timeout, TimeUnit.SECONDS)
|
|
||||||
.readTimeout(timeout, TimeUnit.SECONDS)
|
|
||||||
.writeTimeout(timeout, TimeUnit.SECONDS)
|
|
||||||
.build()
|
|
||||||
} else {
|
} else {
|
||||||
connection = if (useSeedNodeConnection) seedNodeConnection else defaultConnection
|
connection = if (useSeedNodeConnection) seedNodeConnection else defaultConnection
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user