Move SSD local host allowlist to typed Kotlin

ober

e39fafefc2b9920e2c57a424dbede00d86fe0faa

diff --git a/templates/ssd-review.ss b/templates/ssd-review.ss
index 2fd87ce..a605198 100644
--- a/templates/ssd-review.ss
+++ b/templates/ssd-review.ss
@@ -541,6 +541,22 @@
                       (and (not (equal? key ".."))
                            (string-matches-regex? key "[A-Za-z0-9][A-Za-z0-9._-]*"))))))))
 
+    (typed-kotlin-file "com/sfb/ssdreview/NetworkSafety.kt"
+      (typed-library (com sfb ssdreview)
+        (export localTruthHttpAllowed)
+        (def (localTruthHttpAllowed (host : String)) : Bool
+          (let ((lower (string-lowercase host)))
+            (if (or (or (equal? lower "localhost")
+                        (equal? lower "127.0.0.1"))
+                    (equal? lower "10.66.60.2"))
+              #t
+              (if (or (string-starts-with? lower "10.")
+                      (string-starts-with? lower "192.168."))
+                #t
+                (string-matches-regex?
+                  lower
+                  "^172\\.(1[6-9]|2[0-9]|3[0-1])\\..*"))))))
+
     (kotlin-file-lines "com/sfb/ssdreview/BoxTypes.kt"
       (
        "package com.sfb.ssdreview"
@@ -4166,13 +4182,6 @@
        "        return if (endpoint.trimEnd('/').endsWith(\"/api\")) endpoint else endpoint.trimEnd('/') + \"/api\""
        "    }"
        ""
-       "    private fun localTruthHttpAllowed(host: String): Boolean {"
-       "        val lower = host.lowercase()"
-       "        if (lower == \"localhost\" || lower == \"127.0.0.1\" || lower == \"10.66.60.2\") return true"
-       "        if (lower.startsWith(\"10.\") || lower.startsWith(\"192.168.\")) return true"
-       "        return Regex(\"^172\\\\.(1[6-9]|2[0-9]|3[0-1])\\\\.\").containsMatchIn(lower)"
-       "    }"
-       ""
        "    private fun remoteUrl(relative: String): URL {"
        "        require(relative.isNotBlank() && !relative.startsWith('/') && !relative.contains(\"..\"))"
        "        val config = remoteConfig ?: throw IllegalStateException(\"Remote SSD service is not locally configured\")"