mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-15 23:06:38 +00:00
The health check endpoint listens on a dedicated HTTP server. By default, it is available at 0.0.0.0:9000/health. This can be configured using the --health-listen-address flag. The results are cached for 3 seconds to avoid excessive calls. The health check performs the following: Checks the number of active listeners. Validates each listener via WebSocket and QUIC dials, including TLS certificate verification.
32 lines
693 B
Go
32 lines
693 B
Go
package healthcheck
|
|
|
|
import (
|
|
"context"
|
|
"crypto/tls"
|
|
"fmt"
|
|
"time"
|
|
|
|
"github.com/quic-go/quic-go"
|
|
|
|
tlsnb "github.com/netbirdio/netbird/shared/relay/tls"
|
|
)
|
|
|
|
func dialQUIC(ctx context.Context, address string) error {
|
|
tlsConfig := &tls.Config{
|
|
InsecureSkipVerify: false, // Keep certificate validation enabled
|
|
NextProtos: []string{tlsnb.NBalpn},
|
|
}
|
|
|
|
conn, err := quic.DialAddr(ctx, address, tlsConfig, &quic.Config{
|
|
MaxIdleTimeout: 30 * time.Second,
|
|
KeepAlivePeriod: 10 * time.Second,
|
|
EnableDatagrams: true,
|
|
})
|
|
if err != nil {
|
|
return fmt.Errorf("failed to connect to QUIC server: %w", err)
|
|
}
|
|
|
|
_ = conn.CloseWithError(0, "availability check complete")
|
|
return nil
|
|
}
|