Added simple healthcheck
This commit is contained in:
@@ -60,7 +60,7 @@ ENV USER= \
|
||||
TZ=
|
||||
ENTRYPOINT /entrypoint
|
||||
EXPOSE 8888/tcp 8388/tcp 8388/udp
|
||||
# HEALTHCHECK --interval=3m --timeout=3s --start-period=20s --retries=1 CMD /entrypoint -healthcheck
|
||||
HEALTHCHECK --interval=3m --timeout=3s --start-period=20s --retries=1 CMD /entrypoint healthcheck
|
||||
RUN apk add -q --progress --no-cache --update openvpn ca-certificates iptables unbound tinyproxy tzdata && \
|
||||
echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories && \
|
||||
apk add -q --progress --no-cache --update shadowsocks-libev && \
|
||||
|
||||
@@ -311,12 +311,13 @@ Note that not all regions support port forwarding.
|
||||
|
||||
## TODOs
|
||||
|
||||
- Healthcheck checking for IP address, DNS leaks etc.
|
||||
- Periodic update of malicious block lists with Unbound restart
|
||||
- HTTP proxy in Go to replace tinyproxy
|
||||
- Support other VPN providers
|
||||
- Mullvad
|
||||
- Windscribe
|
||||
- Periodic update of malicious block lists with Unbound restart
|
||||
- Improve healthcheck
|
||||
- Check IP address belongs to selected region
|
||||
- Check for DNS provider somehow if this is even possible
|
||||
- Support for other VPN protocols
|
||||
- Wireguard (wireguard-go)
|
||||
- Show new versions/commits at start
|
||||
|
||||
10
cmd/main.go
10
cmd/main.go
@@ -4,10 +4,12 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/qdm12/golibs/command"
|
||||
"github.com/qdm12/golibs/files"
|
||||
libhealthcheck "github.com/qdm12/golibs/healthcheck"
|
||||
"github.com/qdm12/golibs/logging"
|
||||
"github.com/qdm12/golibs/network"
|
||||
"github.com/qdm12/golibs/signals"
|
||||
@@ -15,6 +17,7 @@ import (
|
||||
"github.com/qdm12/private-internet-access-docker/internal/dns"
|
||||
"github.com/qdm12/private-internet-access-docker/internal/env"
|
||||
"github.com/qdm12/private-internet-access-docker/internal/firewall"
|
||||
"github.com/qdm12/private-internet-access-docker/internal/healthcheck"
|
||||
"github.com/qdm12/private-internet-access-docker/internal/openvpn"
|
||||
"github.com/qdm12/private-internet-access-docker/internal/params"
|
||||
"github.com/qdm12/private-internet-access-docker/internal/pia"
|
||||
@@ -33,6 +36,13 @@ func main() {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if libhealthcheck.Mode(os.Args) {
|
||||
if err := healthcheck.HealthCheck(); err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
os.Exit(0)
|
||||
}
|
||||
paramsReader := params.NewParamsReader(logger)
|
||||
fmt.Println(splash.Splash(paramsReader))
|
||||
e := env.New(logger)
|
||||
|
||||
24
internal/healthcheck/healthcheck.go
Normal file
24
internal/healthcheck/healthcheck.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package healthcheck
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/qdm12/golibs/network"
|
||||
)
|
||||
|
||||
func HealthCheck() error {
|
||||
// DNS, HTTP and HTTPs check on github.com
|
||||
connectivty := network.NewConnectivity(3 * time.Second)
|
||||
errs := connectivty.Checks("github.com")
|
||||
if len(errs) > 0 {
|
||||
var errsStr []string
|
||||
for _, err := range errs {
|
||||
errsStr = append(errsStr, err.Error())
|
||||
}
|
||||
return fmt.Errorf("Multiple errors: %s", strings.Join(errsStr, "; "))
|
||||
}
|
||||
// TODO check IP address is in the right region
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user