+ fun getAddresses(domainName: String, ipAddressesLabel: String, blueColorSpan: ForegroundColorSpan, ipAddressesTextView: TextView) {
+ // Get the IP addresses using a coroutine.
+ CoroutineScope(Dispatchers.Main).launch {
+ // Get the IP addresses on the IO thread.
+ withContext(Dispatchers.IO) {
+ // Get an array with the IP addresses for the host.
+ try {
+ // Initialize an IP address string builder.
+ val ipAddressesStringBuilder = StringBuilder()
+
+ // Get an array with all the IP addresses for the domain.
+ val inetAddressesArray = InetAddress.getAllByName(domainName)
+
+ // Add each IP address to the string builder.
+ for (inetAddress in inetAddressesArray) {
+ // Add a line break to the string builder if this is not the first IP address.
+ if (ipAddressesStringBuilder.isNotEmpty()) {
+ ipAddressesStringBuilder.append("\n")
+ }
+
+ // Add the IP address to the string builder.
+ ipAddressesStringBuilder.append(inetAddress.hostAddress)
+ }
+
+ // Create a spannable string builder.
+ val addressesStringBuilder = SpannableStringBuilder(ipAddressesLabel + ipAddressesStringBuilder)
+
+ // Set the string builder to display the certificate information in blue. `SPAN_INCLUSIVE_INCLUSIVE` allows the span to grow in either direction.
+ addressesStringBuilder.setSpan(blueColorSpan, ipAddressesLabel.length, addressesStringBuilder.length, Spanned.SPAN_INCLUSIVE_INCLUSIVE)
+
+ // Populate the IP addresses text view on the UI thread.
+ withContext(Dispatchers.Main) {
+ // Populate the IP addresses text view.
+ ipAddressesTextView.text = addressesStringBuilder
+ }
+ } catch (exception: UnknownHostException) {
+ // Do nothing.
+ }
+ }
+ }
+ }
+
+ fun checkPinnedMismatch(domainName: String, nestedScrollWebView: NestedScrollWebView, supportFragmentManager: FragmentManager, pinnedMismatchString: String) {