Skip to content

Conversation

@aanorbel
Copy link
Member

@aanorbel aanorbel commented Oct 6, 2025

No description provided.

@aanorbel aanorbel marked this pull request as draft October 6, 2025 10:41
it.assetsDir = assetsDir
// geoipDB may or may not exist in this binding; set via reflection when available
geoIpDB?.let { path ->
// it.geoipDB = path
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No desktop support from the start?

}
LaunchedEffect(Unit) {
// Check for GeoIP DB updates in the background
runCatching { dependencies.fetchGeoIpDbUpdates() }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need runCatching if we're already try/catching inside the method. I think we just need to log the failures, but that should be going inside the method.

* Perform a simple HTTP GET and return the raw response body bytes.
* Implemented per-platform to ensure binary-safe downloads.
*/
expect suspend fun httpGetBytes(url: String): ByteArray
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You didn't trust the engine httpDo to fetch a larger file? And you preferred not to use a library like ktor?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I think this should return a Result<ByteArray, ...>.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More like the httpDo method is configured to return strings which would be a headache especially when streaming large files


actual suspend fun httpGetBytes(url: String): ByteArray =
withContext(Dispatchers.IO) {
val connection = (URL(url).openConnection() as HttpURLConnection)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The openConnection() may also throw an IOException

import java.net.HttpURLConnection
import java.net.URL

actual suspend fun httpGetBytes(url: String): ByteArray =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the desktop implementation slightly different from the Android one? Shouldn't they match?

val ip: String?,
val asn: String?,
val countryCode: String?,
val geoIpdb: String?,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to get the geoIpDb from the engine?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To determine which version of geoIPDB the engine is currently working with.

val taskLogLevel: TaskLogLevel,
val uploadResults: Boolean,
val proxy: String?,
val geoipDbVersion: String?,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we also need to tell the engine what version of the Db?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is more to determine the path to themmdb file if it exists.

private fun session(sessionConfig: OonimkallBridge.SessionConfig): OonimkallBridge.Session = bridge.newSession(sessionConfig)

private fun buildTaskSettings(
private suspend fun buildTaskSettings(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suspend should not be needed.

null
},
proxy = getProxyOption().first().value,
geoipDbVersion = getValueForKey(SettingsKey.MMDB_VERSION) as String?,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should already be providing the DB path here, instead of having to construct it in multiple places.

private val downloader by lazy {
DownloadFile(
fileSystem = FileSystem.SYSTEM,
fetchBytes = { url -> httpGetBytes(url) },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as fetchBytes = ::httpGetBytes,.

@aanorbel aanorbel force-pushed the feat/dynamic-geoipdb branch from 2c846f4 to e779df5 Compare October 24, 2025 10:49
@aanorbel aanorbel force-pushed the feat/dynamic-geoipdb branch from af697b7 to eef3dbc Compare October 28, 2025 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants