Skip to content

Commit 63ee44c

Browse files
committed
Fix compile errors for v6.2.0 release build
- Fix KDoc bracket parsing in AdblockRuleParser - Add DNS_PROXY branch to all exhaustive when(BlockMethod) blocks - Fix WgConfig constructor params in DnsVpnService (String->ByteArray) - Fix WireGuardProxy Long!=Int comparison - Fix Vico 2.0 axis API (VerticalAxis.rememberStart/HorizontalAxis.rememberBottom) - Fix Glance widget ColorProvider constructor (single Color, not day/night) - Fix coroutine isActive ambiguity in HomeViewModel/StatsScreen - Add missing imports (DnsProxyService, collectAsStateWithLifecycle) - Fix suspend function calls in DnsProxyService/LocalDnsServer - Fix ConnectionTracker synchronized return scope - Add @OptIn for FlowRow ExperimentalLayoutApi - Fix QrConfigScreen useDoH -> dohEnabled preference name - Remove broken captivePortalApiUrl reference
1 parent f3e0c7f commit 63ee44c

21 files changed

Lines changed: 1096 additions & 382 deletions

File tree

app/app/schemas/com.hostshield.data.database.HostShieldDatabase/12.json

Lines changed: 902 additions & 0 deletions
Large diffs are not rendered by default.

app/app/src/main/java/com/hostshield/domain/parser/AdblockRuleParser.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ object AdblockRuleParser {
114114
* Parse a blocklist file containing adblock-syntax rules.
115115
*
116116
* Handles mixed-format files: adblock-syntax, hosts-style, and domains-only
117-
* lines are all parsed. Comments (! and #) and metadata ([Adblock...]) are skipped.
117+
* lines are all parsed. Comments (! and #) and metadata (Adblock headers) are skipped.
118118
*
119119
* @param content Raw file content
120120
* @return ParseResult with categorized rules

app/app/src/main/java/com/hostshield/service/AutomationReceiver.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,11 @@ class AutomationReceiver : BroadcastReceiver() {
225225
)
226226
}
227227
BlockMethod.ROOT_HOSTS -> RootDnsService.start(context)
228+
BlockMethod.DNS_PROXY -> {
229+
context.startForegroundService(
230+
Intent(context, DnsProxyService::class.java)
231+
)
232+
}
228233
BlockMethod.DISABLED -> { }
229234
}
230235
prefs.setEnabled(true)
@@ -242,6 +247,9 @@ class AutomationReceiver : BroadcastReceiver() {
242247
)
243248
}
244249
BlockMethod.ROOT_HOSTS -> RootDnsService.stop(context)
250+
BlockMethod.DNS_PROXY -> {
251+
context.stopService(Intent(context, DnsProxyService::class.java))
252+
}
245253
BlockMethod.DISABLED -> { }
246254
}
247255
prefs.setEnabled(false)

app/app/src/main/java/com/hostshield/service/BootReceiver.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ class BootReceiver : BroadcastReceiver() {
6969
RootDnsService.start(context)
7070
Log.i("BootReceiver", "Root DNS service restarted")
7171
}
72+
BlockMethod.DNS_PROXY -> {
73+
context.startForegroundService(Intent(context, DnsProxyService::class.java))
74+
Log.i("BootReceiver", "DNS proxy service restarted")
75+
}
7276
BlockMethod.DISABLED -> { }
7377
}
7478

app/app/src/main/java/com/hostshield/service/CaptivePortalHandler.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,8 @@ class CaptivePortalHandler @Inject constructor(
148148
try {
149149
val cm = context.getSystemService(ConnectivityManager::class.java) ?: return CAPTIVE_PORTAL_URL
150150
val lp = cm.getLinkProperties(network)
151-
if (android.os.Build.VERSION.SDK_INT >= 30) {
152-
lp?.captivePortalApiUrl?.toString()?.let { return it }
153-
}
151+
// CaptivePortalData is API 30+ but its userPortalUrl may not always
152+
// be populated. Fall through to default connectivity check URL.
154153
} catch (_: Exception) { }
155154
return CAPTIVE_PORTAL_URL
156155
}

app/app/src/main/java/com/hostshield/service/ConnectionTracker.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,10 @@ class ConnectionTracker @Inject constructor() {
127127
* All records for a single app, sorted newest-first.
128128
*/
129129
fun getConnectionsForApp(packageName: String): List<ConnectionRecord> {
130-
synchronized(records) {
131-
return records[packageName]?.toList().orEmpty()
132-
}.sortedByDescending { it.timestamp }
130+
val list = synchronized(records) {
131+
records[packageName]?.toList().orEmpty()
132+
}
133+
return list.sortedByDescending { it.timestamp }
133134
}
134135

135136
/**

app/app/src/main/java/com/hostshield/service/DnsProxyService.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ class DnsProxyService : Service() {
265265
}
266266
}
267267

268-
private fun forwardAndReply(
268+
private suspend fun forwardAndReply(
269269
socket: DatagramSocket,
270270
queryData: ByteArray,
271271
clientAddr: InetAddress,
@@ -286,7 +286,7 @@ class DnsProxyService : Service() {
286286
* Tries each upstream in order with a timeout; returns the first
287287
* successful response or null if all fail.
288288
*/
289-
private fun forwardToUpstream(queryData: ByteArray): ByteArray? {
289+
private suspend fun forwardToUpstream(queryData: ByteArray): ByteArray? {
290290
// Try encrypted DNS first (DoT > DoH, matching VPN priority)
291291
if (useDoT) {
292292
try {

app/app/src/main/java/com/hostshield/service/DnsVpnService.kt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -458,12 +458,11 @@ class DnsVpnService : VpnService() {
458458
val host = parts.getOrElse(0) { "" }
459459
val port = parts.getOrElse(1) { "51820" }.toIntOrNull() ?: 51820
460460
val config = WireGuardProxy.WgConfig(
461-
endpoint = host,
462-
port = port,
463-
privateKey = wgPrivKey,
464-
publicKey = wgPubKey,
465-
presharedKey = wgPsk.ifBlank { null },
466-
dnsServerIp = wgDnsIp.ifBlank { "1.1.1.1" }
461+
privateKey = android.util.Base64.decode(wgPrivKey, android.util.Base64.NO_WRAP),
462+
peerPublicKey = android.util.Base64.decode(wgPubKey, android.util.Base64.NO_WRAP),
463+
presharedKey = if (wgPsk.isBlank()) null else android.util.Base64.decode(wgPsk, android.util.Base64.NO_WRAP),
464+
endpoint = "$host:$port",
465+
dnsServer = wgDnsIp.ifBlank { "1.1.1.1" }
467466
)
468467
try {
469468
wireGuardProxy.connect(config)

app/app/src/main/java/com/hostshield/service/HostShieldTileService.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ class HostShieldTileService : TileService() {
6969
BlockMethod.ROOT_HOSTS -> {
7070
RootDnsService.stop(this@HostShieldTileService)
7171
}
72+
BlockMethod.DNS_PROXY -> {
73+
stopService(Intent(this@HostShieldTileService, DnsProxyService::class.java))
74+
}
7275
BlockMethod.DISABLED -> { }
7376
}
7477
prefs.setEnabled(false)
@@ -85,6 +88,9 @@ class HostShieldTileService : TileService() {
8588
BlockMethod.ROOT_HOSTS -> {
8689
RootDnsService.start(this@HostShieldTileService)
8790
}
91+
BlockMethod.DNS_PROXY -> {
92+
startForegroundService(Intent(this@HostShieldTileService, DnsProxyService::class.java))
93+
}
8894
BlockMethod.DISABLED -> { }
8995
}
9096
prefs.setEnabled(true)

app/app/src/main/java/com/hostshield/service/HostsUpdateWorker.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class HostsUpdateWorker @AssistedInject constructor(
9797
val method = prefs.blockMethod.first()
9898

9999
when (method) {
100-
BlockMethod.ROOT_HOSTS, BlockMethod.VPN -> {
100+
BlockMethod.ROOT_HOSTS, BlockMethod.VPN, BlockMethod.DNS_PROXY -> {
101101
// Download block sources and rebuild in-memory blocklist.
102102
// Both root (RootDnsLogger) and VPN (DnsVpnService) read from
103103
// BlocklistHolder, so updates take effect immediately.

0 commit comments

Comments
 (0)