First PoC Ouinet integration

This commit is contained in:
ceno challenge 2022-11-29 14:03:01 +01:00
parent 219f0e9873
commit 9311f90fc9
3 changed files with 36 additions and 3 deletions

View File

@ -14,13 +14,16 @@ if (keyPropsFile.exists()) {
keyProps.load(new FileInputStream(keyPropsFile))
}
Properties localProperties = new Properties()
localProperties.load(rootProject.file('local.properties').newDataInputStream())
android {
compileSdk 32
compileSdk 33
defaultConfig {
applicationId "me.ash.reader"
minSdk 26
targetSdk 32
targetSdk 33
versionCode 15
versionName "0.9.1"
@ -37,6 +40,11 @@ android {
]
}
}
buildConfigField "String", "CACHE_PUB_KEY", localProperties['CACHE_PUB_KEY']
buildConfigField "String", "INJECTOR_CREDENTIALS", localProperties['INJECTOR_CREDENTIALS']
buildConfigField "String", "INJECTOR_TLS_CERT", localProperties['INJECTOR_TLS_CERT']
}
flavorDimensions "channel"
@ -186,4 +194,8 @@ dependencies {
testImplementation "junit:junit:4.13.2"
androidTestImplementation "androidx.test.ext:junit:1.1.3"
androidTestImplementation "androidx.test.espresso:espresso-core:3.4.0"
// OuiNet integration
implementation 'ie.equalit.ouinet:ouinet-x86_64:0.21.3'
implementation 'com.getkeepsafe.relinker:relinker:1.4.4'
}

View File

@ -10,6 +10,8 @@ import androidx.profileinstaller.ProfileInstallerInitializer
import coil.ImageLoader
import coil.compose.LocalImageLoader
import dagger.hilt.android.AndroidEntryPoint
import ie.equalit.ouinet.Ouinet
import ie.equalit.ouinet.Config
import me.ash.reader.data.dao.AccountDao
import me.ash.reader.data.model.preference.AccountSettingsProvider
import me.ash.reader.data.model.preference.LanguagesPreference
@ -23,6 +25,7 @@ import javax.inject.Inject
*/
@AndroidEntryPoint
class MainActivity : ComponentActivity() {
private lateinit var ouinet: Ouinet
@Inject
lateinit var imageLoader: ImageLoader
@ -41,6 +44,21 @@ class MainActivity : ComponentActivity() {
it.setLocale(this)
}
// Enable OuiNet client
val config = Config.ConfigBuilder(this)
.setCacheType("bep5-http")
.setCacheHttpPubKey(BuildConfig.CACHE_PUB_KEY)
.setInjectorCredentials(BuildConfig.INJECTOR_CREDENTIALS)
.setInjectorTlsCert(BuildConfig.INJECTOR_TLS_CERT)
.setTlsCaCertStorePath("file:///android_asset/cacert.pem")
.setDisableOriginAccess(true)
//.setDisableProxyAccess(true)
//.setDisableInjectorAccess(true)
.build()
ouinet = Ouinet(this, config)
ouinet.start()
setContent {
CompositionLocalProvider(
LocalImageLoader provides imageLoader,

View File

@ -31,6 +31,8 @@ import okhttp3.Cache
import okhttp3.Interceptor
import okhttp3.OkHttpClient
import okhttp3.Response
import java.net.Proxy
import java.net.InetSocketAddress
import java.io.File
import java.security.KeyManagementException
import java.security.NoSuchAlgorithmException
@ -67,7 +69,8 @@ fun cachingHttpClient(
connectTimeoutSecs: Long = 30L,
readTimeoutSecs: Long = 30L,
): OkHttpClient {
val builder: OkHttpClient.Builder = OkHttpClient.Builder()
val ouinetService = Proxy(Proxy.Type.HTTP, InetSocketAddress("127.0.0.1", 8077))
val builder: OkHttpClient.Builder = OkHttpClient.Builder().proxy(ouinetService)
if (cacheDirectory != null) {
builder.cache(Cache(cacheDirectory, cacheSize))