Health server runs on 127.0.0.1:9999, fix #272
This commit is contained in:
21
internal/healthcheck/health.go
Normal file
21
internal/healthcheck/health.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package healthcheck
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net"
|
||||
)
|
||||
|
||||
func healthCheck(ctx context.Context, resolver *net.Resolver) (err error) {
|
||||
// TODO use mullvad API if current provider is Mullvad
|
||||
const domainToResolve = "github.com"
|
||||
ips, err := resolver.LookupIP(ctx, "ip", domainToResolve)
|
||||
switch {
|
||||
case err != nil:
|
||||
return fmt.Errorf("cannot resolve github.com: %s", err)
|
||||
case len(ips) == 0:
|
||||
return fmt.Errorf("resolved no IP addresses for %s", domainToResolve)
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user