updated exception handling when getting lan ip address

master
Robinson 2023-05-18 17:29:02 +02:00
parent 4b656c4bcc
commit 592b22351b
No known key found for this signature in database
GPG Key ID: 8E7DB78588BD6F5C
4 changed files with 15 additions and 7 deletions

View File

@ -21,7 +21,7 @@ Maven Info
<dependency>
<groupId>com.dorkbox</groupId>
<artifactId>NetworkUtils</artifactId>
<version>2.20</version>
<version>2.21</version>
</dependency>
</dependencies>
```
@ -30,7 +30,7 @@ Gradle Info
```
dependencies {
...
implementation("com.dorkbox:NetworkUtils:2.20")
implementation("com.dorkbox:NetworkUtils:2.21")
}
```

View File

@ -39,7 +39,7 @@ object Extras {
// set for the project
const val description = "Utilities for managing network configurations, IP/MAC address conversion, and ping (via OS native commands)"
const val group = "com.dorkbox"
const val version = "2.20"
const val version = "2.21"
// set as project.ext
const val name = "NetworkUtils"

View File

@ -30,7 +30,7 @@ internal object Common {
/**
* Gets the version number.
*/
const val version = "2.20"
const val version = "2.21"
val OS_LINUX: Boolean
val OS_WINDOWS: Boolean

View File

@ -19,8 +19,16 @@ package dorkbox.netUtil
import dorkbox.netUtil.Common.logger
import java.io.BufferedReader
import java.io.InputStreamReader
import java.net.*
import java.util.regex.Pattern
import java.net.Inet4Address
import java.net.Inet6Address
import java.net.InetAddress
import java.net.InetSocketAddress
import java.net.NetworkInterface
import java.net.Socket
import java.net.SocketException
import java.net.URL
import java.net.UnknownHostException
import java.util.regex.*
/**
* A class that holds a number of network-related constants, also from:
@ -213,7 +221,7 @@ object IP {
return it.localAddress
}
}.onFailure {
logger.error("Unable to determine outbound traffic local address (${it.javaClass.simpleName}. Using alternate logic instead.")
logger.error("Unable to determine outbound traffic local address (${it.javaClass.simpleName}). Using alternate logic instead.")
}
// there was an error doing this! (it's possible that outbound traffic is not allowed