Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Relax the health checks for STUN #2077

Merged
merged 2 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import org.jitsi.health.HealthChecker
import org.jitsi.health.Result
import org.jitsi.videobridge.health.config.HealthConfig.Companion.config
import org.jitsi.videobridge.ice.Harvesters
import java.net.InetAddress

class JvbHealthChecker : HealthCheckService {
private val healthChecker = HealthChecker(
Expand All @@ -36,7 +37,10 @@ class JvbHealthChecker : HealthCheckService {
fun stop() = healthChecker.stop()

private fun check(): Result {
if (MappingCandidateHarvesters.stunDiscoveryFailed) {
if (config.requireValidAddress && !hasValidAddress()) {
return Result(success = false, message = "No valid IP addresses available for harvesting.")
}
if (config.requireStun && MappingCandidateHarvesters.stunDiscoveryFailed) {
return Result(success = false, message = "Address discovery through STUN failed")
}
if (!Harvesters.isHealthy()) {
Expand All @@ -48,6 +52,20 @@ class JvbHealthChecker : HealthCheckService {
return Result(success = true)
}

private fun InetAddress.isValid(): Boolean {
return !this.isSiteLocalAddress && !this.isLinkLocalAddress && !this.isLoopbackAddress
}

private fun hasValidAddress(): Boolean {
if (Harvesters.singlePortHarvesters.any { it.localAddress.address.isValid() }) {
return true
}
if (MappingCandidateHarvesters.getHarvesters().any { it.mask?.address?.isValid() == true }) {
return true
}
return false
}

override val result: Result
get() = healthChecker.result
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ class HealthConfig private constructor() {
"videobridge.health.sticky-failures".from(JitsiConfig.newConfig)
}

val requireStun: Boolean by config {
"videobridge.health.require-stun".from(JitsiConfig.newConfig)
}

val requireValidAddress: Boolean by config {
"videobridge.health.require-valid-address".from(JitsiConfig.newConfig)
}

companion object {
@JvmField
val config = HealthConfig()
Expand Down
8 changes: 8 additions & 0 deletions jvb/src/main/resources/reference.conf
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ videobridge {
# (i.e. once the bridge becomes unhealthy, it will never
# go back to a healthy state)
sticky-failures = false

# If enabled, health checks fail when there are no valid addresses available for ICE. Here "valid" means not
# site local, link local or loopback.
require-valid-address = true

# If enabled, health checks will fail when a STUN mapping harvester is configured, but fails to get a mapping (even
# if there is a valid address available through other mappings or locally).
require-stun = false
}
ep-connection-status {
# How long we'll wait for an endpoint to *start* sending
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>ice4j</artifactId>
<version>3.0-66-g1c60acc</version>
<version>3.0-68-gd289f12</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
Expand Down
Loading