Skip to content

Commit

Permalink
add single ip mode
Browse files Browse the repository at this point in the history
  • Loading branch information
froks committed Sep 25, 2024
1 parent 9bb6223 commit 8004759
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/publish_on_tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Build and publish with Gradle
uses: gradle/gradle-build-action@4137be6a8bf7d7133955359dbd952c0ca73b1021
with:
arguments: build test publish
arguments: -i --stacktrace build test publish
env:
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
Expand All @@ -36,7 +36,7 @@ jobs:
- name: release
uses: gradle/gradle-build-action@4137be6a8bf7d7133955359dbd952c0ca73b1021
with:
arguments: closeAndReleaseNexusArtifact
arguments: -i closeAndReleaseNexusArtifact
env:
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
Expand Down
19 changes: 11 additions & 8 deletions src/main/kotlin/NetworkManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public open class NetworkManager(
) {
private val log = LoggerFactory.getLogger(NetworkManager::class.java)

protected fun findInterfaceByName(): NetworkInterface? {
protected open fun findInterfaceByName(): NetworkInterface? {
var foundInterface: NetworkInterface? = null
NetworkInterface.getNetworkInterfaces()?.let { netIntf ->
while (netIntf.hasMoreElements()) {
Expand Down Expand Up @@ -41,27 +41,30 @@ public open class NetworkManager(
return foundInterface
}

protected fun getAvailableIPAddresses(): List<InetAddress> {
protected open fun getAvailableIPAddresses(): Set<InetAddress> {
if (config.networkInterface.isNullOrBlank() || config.networkInterface == "0.0.0.0") {
return listOf(InetAddress.getByName(config.networkInterface))
return setOf(InetAddress.getByName("0.0.0.0"))
}
val list = mutableListOf<InetAddress>()
val ipAddresses = mutableSetOf<InetAddress>()
findInterfaceByName()?.let { intf ->
intf.inetAddresses?.let { inetAddresses ->
while (inetAddresses.hasMoreElements()) {
val address = inetAddresses.nextElement()
if (address is Inet4Address) {
list.add(address)
ipAddresses.add(address)
}
if (config.networkMode == NetworkMode.SINGLE_IP && ipAddresses.isNotEmpty()) {
break
}
}
}
}
if (list.isEmpty()) {
if (ipAddresses.isEmpty()) {
InetAddress.getByName(config.networkInterface)?.let { addr ->
list.add(addr)
ipAddresses.add(addr)
}
}
return list
return ipAddresses
}

protected open fun buildStartupMap(): Map<String, List<DoipEntity<*>>> {
Expand Down

0 comments on commit 8004759

Please sign in to comment.