Add an optional HTTP proxy for downloads (#1474)

* Add an optional HTTP proxy for downloads

Downloads only reached GitHub directly or through URL-rewrite
mirrors, which does not help where a local proxy is the workable
route. Setup now takes a host:port HTTP proxy that every Downloader
connection uses, independently of the download source mode.

* Reference the Kotlin object instance from Java

Java cannot call a Kotlin object member on the class name without
@JvmStatic; the surrounding code already uses INSTANCE.

* Assert the proxy host literal without a reverse lookup

InetSocketAddress.getHostName reverse-resolves on some JVMs
(127.0.0.1 became localhost on CI); hostString is the literal.

* Pass the app proxy into the guest environment

The Steam client installer and the guest package tools fetch with
plain curl against their own CDNs, outside Downloader. Export the
usual proxy variables for them when the app proxy is set; proot
shares the host network, so a localhost proxy is reachable as-is.

---------

Co-authored-by: VIIII4 <VIIII4@users.noreply.github.com>
This commit is contained in:
VIIII4andVIIII4 authored and GitHub committed 2026-10-25 12:07:26 -04:00
1 parent 2be08bc67d
commit c6bc8aef04
9 files changed
+100 -1

No files matched your search

@@ -0,0 +1,36 @@
package com.droiddeck.launcher.core
import java.net.InetSocketAddress
import java.net.Proxy
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
import org.junit.Test
class DownloadSourceProxyTest {
@Test fun hostAndPortBecomeAnHttpProxy() {
val proxy = DownloadSource.proxyOf("127.0.0.1:9910")
assertEquals(Proxy.Type.HTTP, proxy?.type())
val address = proxy?.address() as InetSocketAddress
assertEquals("127.0.0.1", address.hostString)
assertEquals(9910, address.port)
}
@Test fun missingOrInvalidPortIsIgnored() {
assertNull(DownloadSource.proxyOf(""))
assertNull(DownloadSource.proxyOf("127.0.0.1"))
assertNull(DownloadSource.proxyOf("127.0.0.1:"))
assertNull(DownloadSource.proxyOf("127.0.0.1:notaport"))
}
@Test fun normalizationAcceptsSchemeAndTrailingSlash() {
assertEquals("127.0.0.1:9910", DownloadSource.normalizeProxy(" http://127.0.0.1:9910/ "))
assertEquals("192.168.1.2:8080", DownloadSource.normalizeProxy("192.168.1.2:8080"))
}
@Test fun invalidInputDisablesTheProxy() {
assertEquals("", DownloadSource.normalizeProxy(""))
assertEquals("", DownloadSource.normalizeProxy("127.0.0.1"))
assertEquals("", DownloadSource.normalizeProxy("127.0.0.1:70000"))
assertEquals("", DownloadSource.normalizeProxy("http://127.0.0.1:notaport"))
}
}