Maint: pass only single strings to logger methods
- Do not assume formatting from logger's interface - Allow to change golibs in the future to accept only strings for logger methods
This commit is contained in:
@@ -84,7 +84,7 @@ func main() {
|
|||||||
if err == nil { // expected exit such as healthcheck
|
if err == nil { // expected exit such as healthcheck
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
logger.Error(err)
|
logger.Error(err.Error())
|
||||||
cancel()
|
cancel()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,7 +207,7 @@ func _main(ctx context.Context, buildInfo models.BuildInformation,
|
|||||||
return fmt.Errorf("%w: %s", errCreateUser, err)
|
return fmt.Errorf("%w: %s", errCreateUser, err)
|
||||||
}
|
}
|
||||||
if nonRootUsername != defaultUsername {
|
if nonRootUsername != defaultUsername {
|
||||||
logger.Info("using existing username %s corresponding to user id %d", nonRootUsername, puid)
|
logger.Info("using existing username " + nonRootUsername + " corresponding to user id " + fmt.Sprint(puid))
|
||||||
}
|
}
|
||||||
// set it for Unbound
|
// set it for Unbound
|
||||||
// TODO remove this when migrating to qdm12/dns v2
|
// TODO remove this when migrating to qdm12/dns v2
|
||||||
@@ -260,7 +260,7 @@ func _main(ctx context.Context, buildInfo models.BuildInformation,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := ovpnConf.CheckTUN(); err != nil {
|
if err := ovpnConf.CheckTUN(); err != nil {
|
||||||
logger.Warn(err)
|
logger.Warn(err.Error())
|
||||||
err = ovpnConf.CreateTUN()
|
err = ovpnConf.CreateTUN()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -403,9 +403,9 @@ func _main(ctx context.Context, buildInfo models.BuildInformation,
|
|||||||
<-ctx.Done()
|
<-ctx.Done()
|
||||||
|
|
||||||
if allSettings.OpenVPN.Provider.PortForwarding.Enabled {
|
if allSettings.OpenVPN.Provider.PortForwarding.Enabled {
|
||||||
logger.Info("Clearing forwarded port status file %s", allSettings.OpenVPN.Provider.PortForwarding.Filepath)
|
logger.Info("Clearing forwarded port status file " + allSettings.OpenVPN.Provider.PortForwarding.Filepath)
|
||||||
if err := os.Remove(allSettings.OpenVPN.Provider.PortForwarding.Filepath); err != nil {
|
if err := os.Remove(allSettings.OpenVPN.Provider.PortForwarding.Filepath); err != nil {
|
||||||
logger.Error(err)
|
logger.Error(err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -461,9 +461,9 @@ func routeReadyEvents(ctx context.Context, done chan<- struct{}, buildInfo model
|
|||||||
case <-tunnelReadyCh: // blocks until openvpn is connected
|
case <-tunnelReadyCh: // blocks until openvpn is connected
|
||||||
vpnDestination, err := routing.VPNDestinationIP()
|
vpnDestination, err := routing.VPNDestinationIP()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Warn(err)
|
logger.Warn(err.Error())
|
||||||
} else {
|
} else {
|
||||||
logger.Info("VPN routing IP address: %s", vpnDestination)
|
logger.Info("VPN routing IP address: " + vpnDestination.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
if unboundLooper.GetSettings().Enabled {
|
if unboundLooper.GetSettings().Enabled {
|
||||||
@@ -495,9 +495,9 @@ func routeReadyEvents(ctx context.Context, done chan<- struct{}, buildInfo model
|
|||||||
// vpnGateway required only for PIA
|
// vpnGateway required only for PIA
|
||||||
vpnGateway, err := routing.VPNLocalGatewayIP()
|
vpnGateway, err := routing.VPNLocalGatewayIP()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error(err)
|
logger.Error("cannot get VPN local gateway IP: " + err.Error())
|
||||||
}
|
}
|
||||||
logger.Info("VPN gateway IP address: %s", vpnGateway)
|
logger.Info("VPN gateway IP address: " + vpnGateway.String())
|
||||||
startPortForward(vpnGateway)
|
startPortForward(vpnGateway)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ func NewLooper(conf unbound.Configurator, settings configuration.DNS, client *ht
|
|||||||
|
|
||||||
func (l *looper) logAndWait(ctx context.Context, err error) {
|
func (l *looper) logAndWait(ctx context.Context, err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.logger.Warn(err)
|
l.logger.Warn(err.Error())
|
||||||
}
|
}
|
||||||
l.logger.Info("attempting restart in " + l.backoffTime.String())
|
l.logger.Info("attempting restart in " + l.backoffTime.String())
|
||||||
timer := time.NewTimer(l.backoffTime)
|
timer := time.NewTimer(l.backoffTime)
|
||||||
@@ -229,7 +229,7 @@ func (l *looper) setupUnbound(ctx context.Context) (
|
|||||||
err = nameserver.UseDNSSystemWide(l.resolvConf, net.IP{127, 0, 0, 1},
|
err = nameserver.UseDNSSystemWide(l.resolvConf, net.IP{127, 0, 0, 1},
|
||||||
settings.KeepNameserver)
|
settings.KeepNameserver)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.logger.Error(err)
|
l.logger.Error(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := check.WaitForDNS(ctx, net.DefaultResolver); err != nil {
|
if err := check.WaitForDNS(ctx, net.DefaultResolver); err != nil {
|
||||||
@@ -250,14 +250,14 @@ func (l *looper) useUnencryptedDNS(fallback bool) {
|
|||||||
targetIP := settings.PlaintextAddress
|
targetIP := settings.PlaintextAddress
|
||||||
if targetIP != nil {
|
if targetIP != nil {
|
||||||
if fallback {
|
if fallback {
|
||||||
l.logger.Info("falling back on plaintext DNS at address %s", targetIP)
|
l.logger.Info("falling back on plaintext DNS at address " + targetIP.String())
|
||||||
} else {
|
} else {
|
||||||
l.logger.Info("using plaintext DNS at address %s", targetIP)
|
l.logger.Info("using plaintext DNS at address " + targetIP.String())
|
||||||
}
|
}
|
||||||
nameserver.UseDNSInternally(targetIP)
|
nameserver.UseDNSInternally(targetIP)
|
||||||
err := nameserver.UseDNSSystemWide(l.resolvConf, targetIP, settings.KeepNameserver)
|
err := nameserver.UseDNSSystemWide(l.resolvConf, targetIP, settings.KeepNameserver)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.logger.Error(err)
|
l.logger.Error(err.Error())
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -272,7 +272,7 @@ func (l *looper) useUnencryptedDNS(fallback bool) {
|
|||||||
nameserver.UseDNSInternally(targetIP)
|
nameserver.UseDNSInternally(targetIP)
|
||||||
err := nameserver.UseDNSSystemWide(l.resolvConf, targetIP, settings.KeepNameserver)
|
err := nameserver.UseDNSSystemWide(l.resolvConf, targetIP, settings.KeepNameserver)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.logger.Error(err)
|
l.logger.Error(err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -302,7 +302,7 @@ func (l *looper) RunRestartTicker(ctx context.Context, done chan<- struct{}) {
|
|||||||
if status == constants.Running {
|
if status == constants.Running {
|
||||||
if err := l.updateFiles(ctx); err != nil {
|
if err := l.updateFiles(ctx); err != nil {
|
||||||
l.state.SetStatus(constants.Crashed)
|
l.state.SetStatus(constants.Crashed)
|
||||||
l.logger.Error(err)
|
l.logger.Error(err.Error())
|
||||||
l.logger.Warn("skipping Unbound restart due to failed files update")
|
l.logger.Warn("skipping Unbound restart due to failed files update")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -345,7 +345,7 @@ func (l *looper) updateFiles(ctx context.Context) (err error) {
|
|||||||
blockedHostnames, blockedIPs, blockedIPPrefixes, errs := l.blockBuilder.All(
|
blockedHostnames, blockedIPs, blockedIPPrefixes, errs := l.blockBuilder.All(
|
||||||
ctx, settings.BlacklistBuild)
|
ctx, settings.BlacklistBuild)
|
||||||
for _, err := range errs {
|
for _, err := range errs {
|
||||||
l.logger.Warn(err)
|
l.logger.Warn(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO change to BlockHostnames() when migrating to qdm12/dns v2
|
// TODO change to BlockHostnames() when migrating to qdm12/dns v2
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ func (c *configurator) removeOutboundSubnets(ctx context.Context, subnets []net.
|
|||||||
const remove = true
|
const remove = true
|
||||||
for _, subnet := range subnets {
|
for _, subnet := range subnets {
|
||||||
if err := c.acceptOutputFromIPToSubnet(ctx, c.defaultInterface, c.localIP, subnet, remove); err != nil {
|
if err := c.acceptOutputFromIPToSubnet(ctx, c.defaultInterface, c.localIP, subnet, remove); err != nil {
|
||||||
c.logger.Error("cannot remove outdated outbound subnet through firewall: %s", err)
|
c.logger.Error("cannot remove outdated outbound subnet through firewall: " + err.Error())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
c.outboundSubnets = removeSubnetFromSubnets(c.outboundSubnets, subnet)
|
c.outboundSubnets = removeSubnetFromSubnets(c.outboundSubnets, subnet)
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package firewall
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *configurator) SetAllowedPort(ctx context.Context, port uint16, intf string) (err error) {
|
func (c *configurator) SetAllowedPort(ctx context.Context, port uint16, intf string) (err error) {
|
||||||
@@ -19,7 +20,7 @@ func (c *configurator) SetAllowedPort(ctx context.Context, port uint16, intf str
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
c.logger.Info("setting allowed input port %d through interface %s...", port, intf)
|
c.logger.Info("setting allowed input port " + fmt.Sprint(port) + " through interface " + intf + "...")
|
||||||
|
|
||||||
if existingIntf, ok := c.allowedInputPorts[port]; ok {
|
if existingIntf, ok := c.allowedInputPorts[port]; ok {
|
||||||
if intf == existingIntf {
|
if intf == existingIntf {
|
||||||
@@ -54,7 +55,7 @@ func (c *configurator) RemoveAllowedPort(ctx context.Context, port uint16) (err
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
c.logger.Info("removing allowed port %d through firewall...", port)
|
c.logger.Info("removing allowed port "+strconv.Itoa(int(port))+" through firewall...", port)
|
||||||
|
|
||||||
intf, ok := c.allowedInputPorts[port]
|
intf, ok := c.allowedInputPorts[port]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ func (c *configurator) SetVPNConnection(ctx context.Context, connection models.O
|
|||||||
remove := true
|
remove := true
|
||||||
if c.vpnConnection.IP != nil {
|
if c.vpnConnection.IP != nil {
|
||||||
if err := c.acceptOutputTrafficToVPN(ctx, c.defaultInterface, c.vpnConnection, remove); err != nil {
|
if err := c.acceptOutputTrafficToVPN(ctx, c.defaultInterface, c.vpnConnection, remove); err != nil {
|
||||||
c.logger.Error("cannot remove outdated VPN connection through firewall: %s", err)
|
c.logger.Error("cannot remove outdated VPN connection through firewall: " + err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
c.vpnConnection = models.OpenVPNConnection{}
|
c.vpnConnection = models.OpenVPNConnection{}
|
||||||
|
|||||||
@@ -62,14 +62,14 @@ func (s *server) Run(ctx context.Context, done chan<- struct{}) {
|
|||||||
shutdownCtx, cancel := context.WithTimeout(context.Background(), shutdownGraceDuration)
|
shutdownCtx, cancel := context.WithTimeout(context.Background(), shutdownGraceDuration)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
if err := server.Shutdown(shutdownCtx); err != nil {
|
if err := server.Shutdown(shutdownCtx); err != nil {
|
||||||
s.logger.Error("failed shutting down: %s", err)
|
s.logger.Error("failed shutting down: " + err.Error())
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
s.logger.Info("listening on " + s.config.ServerAddress)
|
s.logger.Info("listening on " + s.config.ServerAddress)
|
||||||
err := server.ListenAndServe()
|
err := server.ListenAndServe()
|
||||||
if err != nil && !errors.Is(ctx.Err(), context.Canceled) {
|
if err != nil && !errors.Is(ctx.Err(), context.Canceled) {
|
||||||
s.logger.Error(err)
|
s.logger.Error(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
<-loopDone
|
<-loopDone
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ func (h *handler) isAccepted(responseWriter http.ResponseWriter, request *http.R
|
|||||||
if !request.ProtoAtLeast(minimalMajorVersion, minimalMinorVersion) ||
|
if !request.ProtoAtLeast(minimalMajorVersion, minimalMinorVersion) ||
|
||||||
request.ProtoAtLeast(maximumMajorVersion, maximumMinorVersion) {
|
request.ProtoAtLeast(maximumMajorVersion, maximumMinorVersion) {
|
||||||
message := fmt.Sprintf("http version not supported: %s", request.Proto)
|
message := fmt.Sprintf("http version not supported: %s", request.Proto)
|
||||||
h.logger.Info("%s, from %s", message, request.RemoteAddr)
|
h.logger.Info(message + ", from " + request.RemoteAddr)
|
||||||
http.Error(responseWriter, message, http.StatusBadRequest)
|
http.Error(responseWriter, message, http.StatusBadRequest)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ func (h *handler) isAuthorized(responseWriter http.ResponseWriter, request *http
|
|||||||
}
|
}
|
||||||
basicAuth := request.Header.Get("Proxy-Authorization")
|
basicAuth := request.Header.Get("Proxy-Authorization")
|
||||||
if len(basicAuth) == 0 {
|
if len(basicAuth) == 0 {
|
||||||
h.logger.Info("Proxy-Authorization header not found from %s", request.RemoteAddr)
|
h.logger.Info("Proxy-Authorization header not found from " + request.RemoteAddr)
|
||||||
responseWriter.Header().Set("Proxy-Authenticate", `Basic realm="Access to Gluetun over HTTP"`)
|
responseWriter.Header().Set("Proxy-Authenticate", `Basic realm="Access to Gluetun over HTTP"`)
|
||||||
responseWriter.WriteHeader(http.StatusProxyAuthRequired)
|
responseWriter.WriteHeader(http.StatusProxyAuthRequired)
|
||||||
return false
|
return false
|
||||||
@@ -20,8 +20,8 @@ func (h *handler) isAuthorized(responseWriter http.ResponseWriter, request *http
|
|||||||
b64UsernamePassword := strings.TrimPrefix(basicAuth, "Basic ")
|
b64UsernamePassword := strings.TrimPrefix(basicAuth, "Basic ")
|
||||||
b, err := base64.StdEncoding.DecodeString(b64UsernamePassword)
|
b, err := base64.StdEncoding.DecodeString(b64UsernamePassword)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
h.logger.Info("Cannot decode Proxy-Authorization header value from %s: %s",
|
h.logger.Info("Cannot decode Proxy-Authorization header value from " +
|
||||||
request.RemoteAddr, err.Error())
|
request.RemoteAddr + ": " + err.Error())
|
||||||
responseWriter.WriteHeader(http.StatusUnauthorized)
|
responseWriter.WriteHeader(http.StatusUnauthorized)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@@ -32,8 +32,9 @@ func (h *handler) isAuthorized(responseWriter http.ResponseWriter, request *http
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if h.username != usernamePassword[0] || h.password != usernamePassword[1] {
|
if h.username != usernamePassword[0] || h.password != usernamePassword[1] {
|
||||||
h.logger.Info("Username or password mismatch from %s", request.RemoteAddr)
|
h.logger.Info("Username or password mismatch from " + request.RemoteAddr)
|
||||||
h.logger.Debug("username provided %q and password provided %q", usernamePassword[0], usernamePassword[1])
|
h.logger.Debug("username provided \"" + usernamePassword[0] +
|
||||||
|
"\" and password provided \"" + usernamePassword[1] + "\"")
|
||||||
responseWriter.WriteHeader(http.StatusUnauthorized)
|
responseWriter.WriteHeader(http.StatusUnauthorized)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ func (h *handler) handleHTTP(responseWriter http.ResponseWriter, request *http.R
|
|||||||
switch request.URL.Scheme {
|
switch request.URL.Scheme {
|
||||||
case "http", "https":
|
case "http", "https":
|
||||||
default:
|
default:
|
||||||
h.logger.Warn("Unsupported scheme %q", request.URL.Scheme)
|
h.logger.Warn("Unsupported scheme " + request.URL.Scheme)
|
||||||
http.Error(responseWriter, "unsupported scheme", http.StatusBadRequest)
|
http.Error(responseWriter, "unsupported scheme", http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -32,13 +32,14 @@ func (h *handler) handleHTTP(responseWriter http.ResponseWriter, request *http.R
|
|||||||
response, err := h.client.Do(request)
|
response, err := h.client.Do(request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(responseWriter, "server error", http.StatusInternalServerError)
|
http.Error(responseWriter, "server error", http.StatusInternalServerError)
|
||||||
h.logger.Warn("cannot request %s for client %q: %s",
|
h.logger.Warn("cannot request " + request.URL.String() +
|
||||||
request.URL, request.RemoteAddr, err)
|
" for client " + request.RemoteAddr + ": " + err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer response.Body.Close()
|
defer response.Body.Close()
|
||||||
if h.verbose {
|
if h.verbose {
|
||||||
h.logger.Info("%s %s %s %s", request.RemoteAddr, response.Status, request.Method, request.URL)
|
h.logger.Info(request.RemoteAddr + " " + response.Status + " " +
|
||||||
|
request.Method + " " + request.URL.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, key := range hopHeaders {
|
for _, key := range hopHeaders {
|
||||||
@@ -54,7 +55,8 @@ func (h *handler) handleHTTP(responseWriter http.ResponseWriter, request *http.R
|
|||||||
|
|
||||||
responseWriter.WriteHeader(response.StatusCode)
|
responseWriter.WriteHeader(response.StatusCode)
|
||||||
if _, err := io.Copy(responseWriter, response.Body); err != nil {
|
if _, err := io.Copy(responseWriter, response.Body); err != nil {
|
||||||
h.logger.Error("%s %s: body copy error: %s", request.RemoteAddr, request.URL, err)
|
h.logger.Error(request.RemoteAddr + " " + request.URL.String() +
|
||||||
|
": body copy error: " + err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,16 +25,16 @@ func (h *handler) handleHTTPS(responseWriter http.ResponseWriter, request *http.
|
|||||||
}
|
}
|
||||||
clientConnection, _, err := hijacker.Hijack()
|
clientConnection, _, err := hijacker.Hijack()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
h.logger.Warn(err)
|
h.logger.Warn(err.Error())
|
||||||
http.Error(responseWriter, err.Error(), http.StatusServiceUnavailable)
|
http.Error(responseWriter, err.Error(), http.StatusServiceUnavailable)
|
||||||
if err := destinationConn.Close(); err != nil {
|
if err := destinationConn.Close(); err != nil {
|
||||||
h.logger.Error("closing destination connection: %s", err)
|
h.logger.Error("closing destination connection: " + err.Error())
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if h.verbose {
|
if h.verbose {
|
||||||
h.logger.Info("%s <-> %s", request.RemoteAddr, request.Host)
|
h.logger.Info(request.RemoteAddr + " <-> " + request.Host)
|
||||||
}
|
}
|
||||||
|
|
||||||
h.wg.Add(1)
|
h.wg.Add(1)
|
||||||
|
|||||||
@@ -117,8 +117,8 @@ func (l *looper) Run(ctx context.Context, done chan<- struct{}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (l *looper) logAndWait(ctx context.Context, err error) {
|
func (l *looper) logAndWait(ctx context.Context, err error) {
|
||||||
l.logger.Error(err)
|
l.logger.Error(err.Error())
|
||||||
l.logger.Info("retrying in %s", l.backoffTime)
|
l.logger.Info("retrying in " + l.backoffTime.String())
|
||||||
timer := time.NewTimer(l.backoffTime)
|
timer := time.NewTimer(l.backoffTime)
|
||||||
l.backoffTime *= 2
|
l.backoffTime *= 2
|
||||||
select {
|
select {
|
||||||
|
|||||||
@@ -39,10 +39,10 @@ func (s *server) Run(ctx context.Context, errorCh chan<- error) {
|
|||||||
shutdownCtx, cancel := context.WithTimeout(context.Background(), shutdownGraceDuration)
|
shutdownCtx, cancel := context.WithTimeout(context.Background(), shutdownGraceDuration)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
if err := server.Shutdown(shutdownCtx); err != nil {
|
if err := server.Shutdown(shutdownCtx); err != nil {
|
||||||
s.logger.Error("failed shutting down: %s", err)
|
s.logger.Error("failed shutting down: " + err.Error())
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
s.logger.Info("listening on %s", s.address)
|
s.logger.Info("listening on " + s.address)
|
||||||
err := server.ListenAndServe()
|
err := server.ListenAndServe()
|
||||||
s.internalWG.Wait()
|
s.internalWG.Wait()
|
||||||
if err != nil && ctx.Err() == nil {
|
if err != nil && ctx.Err() == nil {
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/qdm12/gluetun/internal/constants"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// WriteAuthFile writes the OpenVPN auth file to disk with the right permissions.
|
// WriteAuthFile writes the OpenVPN auth file to disk with the right permissions.
|
||||||
@@ -48,7 +46,7 @@ func (c *configurator) WriteAuthFile(user, password string, puid, pgid int) erro
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
c.logger.Info("username and password changed in %s", constants.OpenVPNAuthConf)
|
c.logger.Info("username and password changed in " + c.authFilePath)
|
||||||
file, err = os.OpenFile(c.authFilePath, os.O_TRUNC|os.O_WRONLY, 0400)
|
file, err = os.OpenFile(c.authFilePath, os.O_TRUNC|os.O_WRONLY, 0400)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -247,7 +247,7 @@ func (l *looper) Run(ctx context.Context, done chan<- struct{}) {
|
|||||||
|
|
||||||
func (l *looper) logAndWait(ctx context.Context, err error) {
|
func (l *looper) logAndWait(ctx context.Context, err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.logger.Error(err)
|
l.logger.Error(err.Error())
|
||||||
}
|
}
|
||||||
l.logger.Info("retrying in " + l.backoffTime.String())
|
l.logger.Info("retrying in " + l.backoffTime.String())
|
||||||
timer := time.NewTimer(l.backoffTime)
|
timer := time.NewTimer(l.backoffTime)
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ func (c *configurator) CheckTUN() error {
|
|||||||
return fmt.Errorf("TUN device is not available: %w", err)
|
return fmt.Errorf("TUN device is not available: %w", err)
|
||||||
}
|
}
|
||||||
if err := f.Close(); err != nil {
|
if err := f.Close(); err != nil {
|
||||||
c.logger.Warn("Could not close TUN device file: %s", err)
|
c.logger.Warn("Could not close TUN device file: " + err.Error())
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ func (p *PIA) PortForward(ctx context.Context, client *http.Client,
|
|||||||
|
|
||||||
data, err := readPIAPortForwardData(p.portForwardPath)
|
data, err := readPIAPortForwardData(p.portForwardPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error(err)
|
logger.Error(err.Error())
|
||||||
}
|
}
|
||||||
dataFound := data.Port > 0
|
dataFound := data.Port > 0
|
||||||
durationToExpiration := data.Expiration.Sub(p.timeNow())
|
durationToExpiration := data.Expiration.Sub(p.timeNow())
|
||||||
@@ -93,11 +93,11 @@ func (p *PIA) PortForward(ctx context.Context, client *http.Client,
|
|||||||
filepath := syncState(data.Port)
|
filepath := syncState(data.Port)
|
||||||
logger.Info("Writing port to " + filepath)
|
logger.Info("Writing port to " + filepath)
|
||||||
if err := writePortForwardedToFile(filepath, data.Port); err != nil {
|
if err := writePortForwardedToFile(filepath, data.Port); err != nil {
|
||||||
logger.Error(err)
|
logger.Error(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := fw.SetAllowedPort(ctx, data.Port, string(constants.TUN)); err != nil {
|
if err := fw.SetAllowedPort(ctx, data.Port, string(constants.TUN)); err != nil {
|
||||||
logger.Error(err)
|
logger.Error(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
expiryTimer := time.NewTimer(durationToExpiration)
|
expiryTimer := time.NewTimer(durationToExpiration)
|
||||||
@@ -110,7 +110,7 @@ func (p *PIA) PortForward(ctx context.Context, client *http.Client,
|
|||||||
removeCtx, cancel := context.WithTimeout(context.Background(), time.Second)
|
removeCtx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
if err := fw.RemoveAllowedPort(removeCtx, data.Port); err != nil {
|
if err := fw.RemoveAllowedPort(removeCtx, data.Port); err != nil {
|
||||||
logger.Error(err)
|
logger.Error(err.Error())
|
||||||
}
|
}
|
||||||
if !keepAliveTimer.Stop() {
|
if !keepAliveTimer.Stop() {
|
||||||
<-keepAliveTimer.C
|
<-keepAliveTimer.C
|
||||||
@@ -132,7 +132,7 @@ func (p *PIA) PortForward(ctx context.Context, client *http.Client,
|
|||||||
data, err = refreshPIAPortForwardData(ctx, client, privateIPClient, gateway,
|
data, err = refreshPIAPortForwardData(ctx, client, privateIPClient, gateway,
|
||||||
p.portForwardPath, p.authFilePath)
|
p.portForwardPath, p.authFilePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error(err)
|
logger.Error(err.Error())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
@@ -141,10 +141,10 @@ func (p *PIA) PortForward(ctx context.Context, client *http.Client,
|
|||||||
logger.Info("Port forwarded is " + strconv.Itoa(int(data.Port)) +
|
logger.Info("Port forwarded is " + strconv.Itoa(int(data.Port)) +
|
||||||
" expiring in " + format.Duration(durationToExpiration))
|
" expiring in " + format.Duration(durationToExpiration))
|
||||||
if err := fw.RemoveAllowedPort(ctx, oldPort); err != nil {
|
if err := fw.RemoveAllowedPort(ctx, oldPort); err != nil {
|
||||||
logger.Error(err)
|
logger.Error(err.Error())
|
||||||
}
|
}
|
||||||
if err := fw.SetAllowedPort(ctx, data.Port, string(constants.TUN)); err != nil {
|
if err := fw.SetAllowedPort(ctx, data.Port, string(constants.TUN)); err != nil {
|
||||||
logger.Error(err)
|
logger.Error(err.Error())
|
||||||
}
|
}
|
||||||
filepath := syncState(data.Port)
|
filepath := syncState(data.Port)
|
||||||
logger.Info("Writing port to " + filepath)
|
logger.Info("Writing port to " + filepath)
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ func tryUntilSuccessful(ctx context.Context, logger logging.Logger, fn func() er
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
logger.Error(err)
|
logger.Error(err.Error())
|
||||||
logger.Info("Trying again in " + retryPeriod.String())
|
logger.Info("Trying again in " + retryPeriod.String())
|
||||||
timer := time.NewTimer(retryPeriod)
|
timer := time.NewTimer(retryPeriod)
|
||||||
select {
|
select {
|
||||||
|
|||||||
@@ -75,9 +75,9 @@ func NewLooper(client *http.Client, logger logging.Logger,
|
|||||||
|
|
||||||
func (l *looper) logAndWait(ctx context.Context, err error) {
|
func (l *looper) logAndWait(ctx context.Context, err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.logger.Error(err)
|
l.logger.Error(err.Error())
|
||||||
}
|
}
|
||||||
l.logger.Info("retrying in %s", l.backoffTime)
|
l.logger.Info("retrying in " + l.backoffTime.String())
|
||||||
timer := time.NewTimer(l.backoffTime)
|
timer := time.NewTimer(l.backoffTime)
|
||||||
l.backoffTime *= 2
|
l.backoffTime *= 2
|
||||||
select {
|
select {
|
||||||
@@ -134,7 +134,7 @@ func (l *looper) Run(ctx context.Context, done chan<- struct{}) {
|
|||||||
filepath := l.GetSettings().IPFilepath
|
filepath := l.GetSettings().IPFilepath
|
||||||
l.logger.Info("Removing ip file " + filepath)
|
l.logger.Info("Removing ip file " + filepath)
|
||||||
if err := os.Remove(filepath); err != nil {
|
if err := os.Remove(filepath); err != nil {
|
||||||
l.logger.Error(err)
|
l.logger.Error(err.Error())
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
case <-l.start:
|
case <-l.start:
|
||||||
@@ -152,7 +152,7 @@ func (l *looper) Run(ctx context.Context, done chan<- struct{}) {
|
|||||||
message := "Public IP address is " + ip.String()
|
message := "Public IP address is " + ip.String()
|
||||||
result, err := Info(ctx, l.client, ip)
|
result, err := Info(ctx, l.client, ip)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.logger.Warn(err)
|
l.logger.Warn(err.Error())
|
||||||
} else {
|
} else {
|
||||||
message += " (" + result.Country + ", " + result.Region + ", " + result.City + ")"
|
message += " (" + result.Country + ", " + result.Region + ", " + result.City + ")"
|
||||||
}
|
}
|
||||||
@@ -161,7 +161,7 @@ func (l *looper) Run(ctx context.Context, done chan<- struct{}) {
|
|||||||
err = persistPublicIP(l.state.settings.IPFilepath,
|
err = persistPublicIP(l.state.settings.IPFilepath,
|
||||||
ip.String(), l.puid, l.pgid)
|
ip.String(), l.puid, l.pgid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.logger.Error(err)
|
l.logger.Error(err.Error())
|
||||||
}
|
}
|
||||||
l.state.setStatusWithLock(constants.Completed)
|
l.state.setStatusWithLock(constants.Completed)
|
||||||
case err := <-errorCh:
|
case err := <-errorCh:
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ var (
|
|||||||
func (r *routing) addRouteVia(destination net.IPNet, gateway net.IP, iface string, table int) error {
|
func (r *routing) addRouteVia(destination net.IPNet, gateway net.IP, iface string, table int) error {
|
||||||
destinationStr := destination.String()
|
destinationStr := destination.String()
|
||||||
if r.verbose {
|
if r.verbose {
|
||||||
r.logger.Info("adding route for %s", destinationStr)
|
r.logger.Info("adding route for " + destinationStr)
|
||||||
}
|
}
|
||||||
if r.debug {
|
if r.debug {
|
||||||
fmt.Printf("ip route replace %s via %s dev %s table %d\n", destinationStr, gateway, iface, table)
|
fmt.Printf("ip route replace %s via %s dev %s table %d\n", destinationStr, gateway, iface, table)
|
||||||
@@ -45,7 +45,7 @@ func (r *routing) addRouteVia(destination net.IPNet, gateway net.IP, iface strin
|
|||||||
func (r *routing) deleteRouteVia(destination net.IPNet, gateway net.IP, iface string, table int) (err error) {
|
func (r *routing) deleteRouteVia(destination net.IPNet, gateway net.IP, iface string, table int) (err error) {
|
||||||
destinationStr := destination.String()
|
destinationStr := destination.String()
|
||||||
if r.verbose {
|
if r.verbose {
|
||||||
r.logger.Info("deleting route for %s", destinationStr)
|
r.logger.Info("deleting route for " + destinationStr)
|
||||||
}
|
}
|
||||||
if r.debug {
|
if r.debug {
|
||||||
fmt.Printf("ip route delete %s via %s dev %s table %d\n", destinationStr, gateway, iface, table)
|
fmt.Printf("ip route delete %s via %s dev %s table %d\n", destinationStr, gateway, iface, table)
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ func (r *routing) removeOutboundSubnets(subnets []net.IPNet,
|
|||||||
for _, subnet := range subnets {
|
for _, subnet := range subnets {
|
||||||
const table = 0
|
const table = 0
|
||||||
if err := r.deleteRouteVia(subnet, defaultGateway, defaultInterfaceName, table); err != nil {
|
if err := r.deleteRouteVia(subnet, defaultGateway, defaultInterfaceName, table); err != nil {
|
||||||
r.logger.Error("cannot remove outdated outbound subnet from routing: %s", err)
|
r.logger.Error("cannot remove outdated outbound subnet from routing: " + err.Error())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
r.outboundSubnets = removeSubnetFromSubnets(r.outboundSubnets, subnet)
|
r.outboundSubnets = removeSubnetFromSubnets(r.outboundSubnets, subnet)
|
||||||
|
|||||||
@@ -50,7 +50,8 @@ func (r *routing) DefaultRoute() (defaultInterface string, defaultGateway net.IP
|
|||||||
attributes := link.Attrs()
|
attributes := link.Attrs()
|
||||||
defaultInterface = attributes.Name
|
defaultInterface = attributes.Name
|
||||||
if r.verbose {
|
if r.verbose {
|
||||||
r.logger.Info("default route found: interface %s, gateway %s", defaultInterface, defaultGateway.String())
|
r.logger.Info("default route found: interface " + defaultInterface +
|
||||||
|
", gateway " + defaultGateway.String())
|
||||||
}
|
}
|
||||||
return defaultInterface, defaultGateway, nil
|
return defaultInterface, defaultGateway, nil
|
||||||
}
|
}
|
||||||
@@ -105,7 +106,7 @@ func (r *routing) LocalSubnet() (defaultSubnet net.IPNet, err error) {
|
|||||||
}
|
}
|
||||||
defaultSubnet = *route.Dst
|
defaultSubnet = *route.Dst
|
||||||
if r.verbose {
|
if r.verbose {
|
||||||
r.logger.Info("local subnet found: %s", defaultSubnet.String())
|
r.logger.Info("local subnet found: " + defaultSubnet.String())
|
||||||
}
|
}
|
||||||
return defaultSubnet, nil
|
return defaultSubnet, nil
|
||||||
}
|
}
|
||||||
@@ -128,7 +129,7 @@ func (r *routing) LocalNetworks() (localNetworks []LocalNetwork, err error) {
|
|||||||
|
|
||||||
localLinks[link.Attrs().Index] = struct{}{}
|
localLinks[link.Attrs().Index] = struct{}{}
|
||||||
if r.verbose {
|
if r.verbose {
|
||||||
r.logger.Info("local ethernet link found: %s", link.Attrs().Name)
|
r.logger.Info("local ethernet link found: " + link.Attrs().Name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,7 +153,7 @@ func (r *routing) LocalNetworks() (localNetworks []LocalNetwork, err error) {
|
|||||||
|
|
||||||
localNet.IPNet = route.Dst
|
localNet.IPNet = route.Dst
|
||||||
if r.verbose {
|
if r.verbose {
|
||||||
r.logger.Info("local ipnet found: %s", localNet.IPNet.String())
|
r.logger.Info("local ipnet found: " + localNet.IPNet.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
link, err := netlink.LinkByIndex(route.LinkIndex)
|
link, err := netlink.LinkByIndex(route.LinkIndex)
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ func (h *dnsHandler) getStatus(w http.ResponseWriter) {
|
|||||||
encoder := json.NewEncoder(w)
|
encoder := json.NewEncoder(w)
|
||||||
data := statusWrapper{Status: string(status)}
|
data := statusWrapper{Status: string(status)}
|
||||||
if err := encoder.Encode(data); err != nil {
|
if err := encoder.Encode(data); err != nil {
|
||||||
h.logger.Warn(err)
|
h.logger.Warn(err.Error())
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -72,7 +72,7 @@ func (h *dnsHandler) setStatus(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
encoder := json.NewEncoder(w)
|
encoder := json.NewEncoder(w)
|
||||||
if err := encoder.Encode(outcomeWrapper{Outcome: outcome}); err != nil {
|
if err := encoder.Encode(outcomeWrapper{Outcome: outcome}); err != nil {
|
||||||
h.logger.Warn(err)
|
h.logger.Warn(err.Error())
|
||||||
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
|
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,19 +40,19 @@ func (h *handlerV0) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
http.Redirect(w, r, "/v1/version", http.StatusPermanentRedirect)
|
http.Redirect(w, r, "/v1/version", http.StatusPermanentRedirect)
|
||||||
case "/openvpn/actions/restart":
|
case "/openvpn/actions/restart":
|
||||||
outcome, _ := h.openvpn.ApplyStatus(h.ctx, constants.Stopped)
|
outcome, _ := h.openvpn.ApplyStatus(h.ctx, constants.Stopped)
|
||||||
h.logger.Info("openvpn: %s", outcome)
|
h.logger.Info("openvpn: " + outcome)
|
||||||
outcome, _ = h.openvpn.ApplyStatus(h.ctx, constants.Running)
|
outcome, _ = h.openvpn.ApplyStatus(h.ctx, constants.Running)
|
||||||
h.logger.Info("openvpn: %s", outcome)
|
h.logger.Info("openvpn: " + outcome)
|
||||||
if _, err := w.Write([]byte("openvpn restarted, please consider using the /v1/ API in the future.")); err != nil {
|
if _, err := w.Write([]byte("openvpn restarted, please consider using the /v1/ API in the future.")); err != nil {
|
||||||
h.logger.Warn(err)
|
h.logger.Warn(err.Error())
|
||||||
}
|
}
|
||||||
case "/unbound/actions/restart":
|
case "/unbound/actions/restart":
|
||||||
outcome, _ := h.dns.ApplyStatus(h.ctx, constants.Stopped)
|
outcome, _ := h.dns.ApplyStatus(h.ctx, constants.Stopped)
|
||||||
h.logger.Info("dns: %s", outcome)
|
h.logger.Info("dns: " + outcome)
|
||||||
outcome, _ = h.dns.ApplyStatus(h.ctx, constants.Running)
|
outcome, _ = h.dns.ApplyStatus(h.ctx, constants.Running)
|
||||||
h.logger.Info("dns: %s", outcome)
|
h.logger.Info("dns: " + outcome)
|
||||||
if _, err := w.Write([]byte("dns restarted, please consider using the /v1/ API in the future.")); err != nil {
|
if _, err := w.Write([]byte("dns restarted, please consider using the /v1/ API in the future.")); err != nil {
|
||||||
h.logger.Warn(err)
|
h.logger.Warn(err.Error())
|
||||||
}
|
}
|
||||||
case "/openvpn/portforwarded":
|
case "/openvpn/portforwarded":
|
||||||
http.Redirect(w, r, "/v1/openvpn/portforwarded", http.StatusPermanentRedirect)
|
http.Redirect(w, r, "/v1/openvpn/portforwarded", http.StatusPermanentRedirect)
|
||||||
@@ -60,11 +60,11 @@ func (h *handlerV0) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
http.Redirect(w, r, "/v1/openvpn/settings", http.StatusPermanentRedirect)
|
http.Redirect(w, r, "/v1/openvpn/settings", http.StatusPermanentRedirect)
|
||||||
case "/updater/restart":
|
case "/updater/restart":
|
||||||
outcome, _ := h.updater.SetStatus(h.ctx, constants.Stopped)
|
outcome, _ := h.updater.SetStatus(h.ctx, constants.Stopped)
|
||||||
h.logger.Info("updater: %s", outcome)
|
h.logger.Info("updater: " + outcome)
|
||||||
outcome, _ = h.updater.SetStatus(h.ctx, constants.Running)
|
outcome, _ = h.updater.SetStatus(h.ctx, constants.Running)
|
||||||
h.logger.Info("updater: %s", outcome)
|
h.logger.Info("updater: " + outcome)
|
||||||
if _, err := w.Write([]byte("updater restarted, please consider using the /v1/ API in the future.")); err != nil {
|
if _, err := w.Write([]byte("updater restarted, please consider using the /v1/ API in the future.")); err != nil {
|
||||||
h.logger.Warn(err)
|
h.logger.Warn(err.Error())
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
http.Error(w, "unversioned API: requested URI not found", http.StatusNotFound)
|
http.Error(w, "unversioned API: requested URI not found", http.StatusNotFound)
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ func (h *handlerV1) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
func (h *handlerV1) getVersion(w http.ResponseWriter) {
|
func (h *handlerV1) getVersion(w http.ResponseWriter) {
|
||||||
encoder := json.NewEncoder(w)
|
encoder := json.NewEncoder(w)
|
||||||
if err := encoder.Encode(h.buildInfo); err != nil {
|
if err := encoder.Encode(h.buildInfo); err != nil {
|
||||||
h.logger.Warn(err)
|
h.logger.Warn(err.Error())
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package server
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -34,8 +35,10 @@ func (m *logMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
statefulWriter := &statefulResponseWriter{httpWriter: w}
|
statefulWriter := &statefulResponseWriter{httpWriter: w}
|
||||||
m.childHandler.ServeHTTP(statefulWriter, r)
|
m.childHandler.ServeHTTP(statefulWriter, r)
|
||||||
duration := m.timeNow().Sub(tStart)
|
duration := m.timeNow().Sub(tStart)
|
||||||
m.logger.Info("%d %s %s wrote %dB to %s in %s",
|
m.logger.Info(strconv.Itoa(statefulWriter.statusCode) + " " +
|
||||||
statefulWriter.statusCode, r.Method, r.RequestURI, statefulWriter.length, r.RemoteAddr, duration)
|
r.Method + " " + r.RequestURI +
|
||||||
|
" wrote " + strconv.Itoa(statefulWriter.length) + "B to " +
|
||||||
|
r.RemoteAddr + " in " + duration.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *logMiddleware) setEnabled(enabled bool) {
|
func (m *logMiddleware) setEnabled(enabled bool) {
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ func (h *openvpnHandler) getStatus(w http.ResponseWriter) {
|
|||||||
encoder := json.NewEncoder(w)
|
encoder := json.NewEncoder(w)
|
||||||
data := statusWrapper{Status: string(status)}
|
data := statusWrapper{Status: string(status)}
|
||||||
if err := encoder.Encode(data); err != nil {
|
if err := encoder.Encode(data); err != nil {
|
||||||
h.logger.Warn(err)
|
h.logger.Warn(err.Error())
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -86,7 +86,7 @@ func (h *openvpnHandler) setStatus(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
encoder := json.NewEncoder(w)
|
encoder := json.NewEncoder(w)
|
||||||
if err := encoder.Encode(outcomeWrapper{Outcome: outcome}); err != nil {
|
if err := encoder.Encode(outcomeWrapper{Outcome: outcome}); err != nil {
|
||||||
h.logger.Warn(err)
|
h.logger.Warn(err.Error())
|
||||||
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
|
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -98,7 +98,7 @@ func (h *openvpnHandler) getSettings(w http.ResponseWriter) {
|
|||||||
settings.Password = "redacted"
|
settings.Password = "redacted"
|
||||||
encoder := json.NewEncoder(w)
|
encoder := json.NewEncoder(w)
|
||||||
if err := encoder.Encode(settings); err != nil {
|
if err := encoder.Encode(settings); err != nil {
|
||||||
h.logger.Warn(err)
|
h.logger.Warn(err.Error())
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -109,7 +109,7 @@ func (h *openvpnHandler) getPortForwarded(w http.ResponseWriter) {
|
|||||||
encoder := json.NewEncoder(w)
|
encoder := json.NewEncoder(w)
|
||||||
data := portWrapper{Port: port}
|
data := portWrapper{Port: port}
|
||||||
if err := encoder.Encode(data); err != nil {
|
if err := encoder.Encode(data); err != nil {
|
||||||
h.logger.Warn(err)
|
h.logger.Warn(err.Error())
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ func (h *publicIPHandler) getPublicIP(w http.ResponseWriter) {
|
|||||||
encoder := json.NewEncoder(w)
|
encoder := json.NewEncoder(w)
|
||||||
data := publicIPWrapper{PublicIP: publicIP.String()}
|
data := publicIPWrapper{PublicIP: publicIP.String()}
|
||||||
if err := encoder.Encode(data); err != nil {
|
if err := encoder.Encode(data); err != nil {
|
||||||
h.logger.Warn(err)
|
h.logger.Warn(err.Error())
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,12 +47,12 @@ func (s *server) Run(ctx context.Context, done chan<- struct{}) {
|
|||||||
shutdownCtx, cancel := context.WithTimeout(context.Background(), shutdownGraceDuration)
|
shutdownCtx, cancel := context.WithTimeout(context.Background(), shutdownGraceDuration)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
if err := server.Shutdown(shutdownCtx); err != nil {
|
if err := server.Shutdown(shutdownCtx); err != nil {
|
||||||
s.logger.Error("failed shutting down: %s", err)
|
s.logger.Error("failed shutting down: " + err.Error())
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
s.logger.Info("listening on %s", s.address)
|
s.logger.Info("listening on " + s.address)
|
||||||
err := server.ListenAndServe()
|
err := server.ListenAndServe()
|
||||||
if err != nil && errors.Is(ctx.Err(), context.Canceled) {
|
if err != nil && errors.Is(ctx.Err(), context.Canceled) {
|
||||||
s.logger.Error(err)
|
s.logger.Error(err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ func (h *updaterHandler) getStatus(w http.ResponseWriter) {
|
|||||||
encoder := json.NewEncoder(w)
|
encoder := json.NewEncoder(w)
|
||||||
data := statusWrapper{Status: string(status)}
|
data := statusWrapper{Status: string(status)}
|
||||||
if err := encoder.Encode(data); err != nil {
|
if err := encoder.Encode(data); err != nil {
|
||||||
h.logger.Warn(err)
|
h.logger.Warn(err.Error())
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -74,7 +74,7 @@ func (h *updaterHandler) setStatus(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
encoder := json.NewEncoder(w)
|
encoder := json.NewEncoder(w)
|
||||||
if err := encoder.Encode(outcomeWrapper{Outcome: outcome}); err != nil {
|
if err := encoder.Encode(outcomeWrapper{Outcome: outcome}); err != nil {
|
||||||
h.logger.Warn(err)
|
h.logger.Warn(err.Error())
|
||||||
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
|
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,9 +38,9 @@ type looper struct {
|
|||||||
|
|
||||||
func (l *looper) logAndWait(ctx context.Context, err error) {
|
func (l *looper) logAndWait(ctx context.Context, err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.logger.Error(err)
|
l.logger.Error(err.Error())
|
||||||
}
|
}
|
||||||
l.logger.Info("retrying in %s", l.backoffTime)
|
l.logger.Info("retrying in " + l.backoffTime.String())
|
||||||
timer := time.NewTimer(l.backoffTime)
|
timer := time.NewTimer(l.backoffTime)
|
||||||
l.backoffTime *= 2
|
l.backoffTime *= 2
|
||||||
select {
|
select {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/qdm12/gluetun/internal/models"
|
"github.com/qdm12/gluetun/internal/models"
|
||||||
)
|
)
|
||||||
@@ -48,12 +49,12 @@ func (s *storage) SyncServers(hardcodedServers models.AllServers) (
|
|||||||
countOnFile := countServers(serversOnFile)
|
countOnFile := countServers(serversOnFile)
|
||||||
|
|
||||||
if countOnFile == 0 {
|
if countOnFile == 0 {
|
||||||
s.logger.Info("creating %s with %d hardcoded servers", s.filepath, hardcodedCount)
|
s.logger.Info("creating " + s.filepath + " with " + strconv.Itoa(hardcodedCount) + " hardcoded servers")
|
||||||
allServers = hardcodedServers
|
allServers = hardcodedServers
|
||||||
} else {
|
} else {
|
||||||
s.logger.Info(
|
s.logger.Info("merging by most recent " +
|
||||||
"merging by most recent %d hardcoded servers and %d servers read from %s",
|
strconv.Itoa(hardcodedCount) + " hardcoded servers and " +
|
||||||
hardcodedCount, countOnFile, s.filepath)
|
strconv.Itoa(countOnFile) + " servers read from " + s.filepath)
|
||||||
allServers = s.mergeServers(hardcodedServers, serversOnFile)
|
allServers = s.mergeServers(hardcodedServers, serversOnFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -70,9 +70,9 @@ func NewLooper(settings configuration.Updater, currentServers models.AllServers,
|
|||||||
|
|
||||||
func (l *looper) logAndWait(ctx context.Context, err error) {
|
func (l *looper) logAndWait(ctx context.Context, err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.logger.Error(err)
|
l.logger.Error(err.Error())
|
||||||
}
|
}
|
||||||
l.logger.Info("retrying in %s", l.backoffTime)
|
l.logger.Info("retrying in " + l.backoffTime.String())
|
||||||
timer := time.NewTimer(l.backoffTime)
|
timer := time.NewTimer(l.backoffTime)
|
||||||
l.backoffTime *= 2
|
l.backoffTime *= 2
|
||||||
select {
|
select {
|
||||||
@@ -141,7 +141,7 @@ func (l *looper) Run(ctx context.Context, done chan<- struct{}) {
|
|||||||
case servers := <-serversCh:
|
case servers := <-serversCh:
|
||||||
l.setAllServers(servers)
|
l.setAllServers(servers)
|
||||||
if err := l.storage.FlushToFile(servers); err != nil {
|
if err := l.storage.FlushToFile(servers); err != nil {
|
||||||
l.logger.Error(err)
|
l.logger.Error(err.Error())
|
||||||
}
|
}
|
||||||
runWg.Wait()
|
runWg.Wait()
|
||||||
l.state.setStatusWithLock(constants.Completed)
|
l.state.setStatusWithLock(constants.Completed)
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ func (u *updater) updateHideMyAss(ctx context.Context) (err error) {
|
|||||||
ctx, u.client, u.presolver, minServers)
|
ctx, u.client, u.presolver, minServers)
|
||||||
if u.options.CLI {
|
if u.options.CLI {
|
||||||
for _, warning := range warnings {
|
for _, warning := range warnings {
|
||||||
u.logger.Warn("HideMyAss: %s", warning)
|
u.logger.Warn("HideMyAss: " + warning)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -91,7 +91,7 @@ func (u *updater) updateIpvanish(ctx context.Context) (err error) {
|
|||||||
ctx, u.unzipper, u.presolver, minServers)
|
ctx, u.unzipper, u.presolver, minServers)
|
||||||
if u.options.CLI {
|
if u.options.CLI {
|
||||||
for _, warning := range warnings {
|
for _, warning := range warnings {
|
||||||
u.logger.Warn("Ipvanish: %s", warning)
|
u.logger.Warn("Ipvanish: " + warning)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -113,7 +113,7 @@ func (u *updater) updateIvpn(ctx context.Context) (err error) {
|
|||||||
ctx, u.unzipper, u.presolver, minServers)
|
ctx, u.unzipper, u.presolver, minServers)
|
||||||
if u.options.CLI {
|
if u.options.CLI {
|
||||||
for _, warning := range warnings {
|
for _, warning := range warnings {
|
||||||
u.logger.Warn("Ivpn: %s", warning)
|
u.logger.Warn("Ivpn: " + warning)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -150,7 +150,7 @@ func (u *updater) updateNordvpn(ctx context.Context) (err error) {
|
|||||||
servers, warnings, err := nordvpn.GetServers(ctx, u.client, minServers)
|
servers, warnings, err := nordvpn.GetServers(ctx, u.client, minServers)
|
||||||
if u.options.CLI {
|
if u.options.CLI {
|
||||||
for _, warning := range warnings {
|
for _, warning := range warnings {
|
||||||
u.logger.Warn("NordVPN: %s", warning)
|
u.logger.Warn("NordVPN: " + warning)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -188,7 +188,7 @@ func (u *updater) updatePrivado(ctx context.Context) (err error) {
|
|||||||
ctx, u.unzipper, u.client, u.presolver, minServers)
|
ctx, u.unzipper, u.client, u.presolver, minServers)
|
||||||
if u.options.CLI {
|
if u.options.CLI {
|
||||||
for _, warning := range warnings {
|
for _, warning := range warnings {
|
||||||
u.logger.Warn("Privado: %s", warning)
|
u.logger.Warn("Privado: " + warning)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -210,7 +210,7 @@ func (u *updater) updatePrivatevpn(ctx context.Context) (err error) {
|
|||||||
ctx, u.unzipper, u.presolver, minServers)
|
ctx, u.unzipper, u.presolver, minServers)
|
||||||
if u.options.CLI {
|
if u.options.CLI {
|
||||||
for _, warning := range warnings {
|
for _, warning := range warnings {
|
||||||
u.logger.Warn("PrivateVPN: %s", warning)
|
u.logger.Warn("PrivateVPN: " + warning)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -231,7 +231,7 @@ func (u *updater) updateProtonvpn(ctx context.Context) (err error) {
|
|||||||
servers, warnings, err := protonvpn.GetServers(ctx, u.client, minServers)
|
servers, warnings, err := protonvpn.GetServers(ctx, u.client, minServers)
|
||||||
if u.options.CLI {
|
if u.options.CLI {
|
||||||
for _, warning := range warnings {
|
for _, warning := range warnings {
|
||||||
u.logger.Warn("ProtonVPN: %s", warning)
|
u.logger.Warn("ProtonVPN: " + warning)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -253,7 +253,7 @@ func (u *updater) updatePurevpn(ctx context.Context) (err error) {
|
|||||||
ctx, u.client, u.unzipper, u.presolver, minServers)
|
ctx, u.client, u.unzipper, u.presolver, minServers)
|
||||||
if u.options.CLI {
|
if u.options.CLI {
|
||||||
for _, warning := range warnings {
|
for _, warning := range warnings {
|
||||||
u.logger.Warn("PureVPN: %s", warning)
|
u.logger.Warn("PureVPN: " + warning)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -275,7 +275,7 @@ func (u *updater) updateSurfshark(ctx context.Context) (err error) {
|
|||||||
ctx, u.unzipper, u.presolver, minServers)
|
ctx, u.unzipper, u.presolver, minServers)
|
||||||
if u.options.CLI {
|
if u.options.CLI {
|
||||||
for _, warning := range warnings {
|
for _, warning := range warnings {
|
||||||
u.logger.Warn("Surfshark: %s", warning)
|
u.logger.Warn("Surfshark: " + warning)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -297,7 +297,7 @@ func (u *updater) updateTorguard(ctx context.Context) (err error) {
|
|||||||
ctx, u.unzipper, u.presolver, minServers)
|
ctx, u.unzipper, u.presolver, minServers)
|
||||||
if u.options.CLI {
|
if u.options.CLI {
|
||||||
for _, warning := range warnings {
|
for _, warning := range warnings {
|
||||||
u.logger.Warn("Torguard: %s", warning)
|
u.logger.Warn("Torguard: " + warning)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -341,7 +341,7 @@ func (u *updater) updateVyprvpn(ctx context.Context) (err error) {
|
|||||||
ctx, u.unzipper, u.presolver, minServers)
|
ctx, u.unzipper, u.presolver, minServers)
|
||||||
if u.options.CLI {
|
if u.options.CLI {
|
||||||
for _, warning := range warnings {
|
for _, warning := range warnings {
|
||||||
u.logger.Warn("VyprVPN: %s", warning)
|
u.logger.Warn("VyprVPN: " + warning)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -58,14 +58,14 @@ func (u *updater) UpdateServers(ctx context.Context) (allServers models.AllServe
|
|||||||
if ctxErr := ctx.Err(); ctxErr != nil {
|
if ctxErr := ctx.Err(); ctxErr != nil {
|
||||||
return allServers, ctxErr
|
return allServers, ctxErr
|
||||||
}
|
}
|
||||||
u.logger.Error(err)
|
u.logger.Error(err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if u.options.Fastestvpn {
|
if u.options.Fastestvpn {
|
||||||
u.logger.Info("updating Fastestvpn servers...")
|
u.logger.Info("updating Fastestvpn servers...")
|
||||||
if err := u.updateFastestvpn(ctx); err != nil {
|
if err := u.updateFastestvpn(ctx); err != nil {
|
||||||
u.logger.Error(err)
|
u.logger.Error(err.Error())
|
||||||
}
|
}
|
||||||
if err := ctx.Err(); err != nil {
|
if err := ctx.Err(); err != nil {
|
||||||
return allServers, err
|
return allServers, err
|
||||||
@@ -75,7 +75,7 @@ func (u *updater) UpdateServers(ctx context.Context) (allServers models.AllServe
|
|||||||
if u.options.HideMyAss {
|
if u.options.HideMyAss {
|
||||||
u.logger.Info("updating HideMyAss servers...")
|
u.logger.Info("updating HideMyAss servers...")
|
||||||
if err := u.updateHideMyAss(ctx); err != nil {
|
if err := u.updateHideMyAss(ctx); err != nil {
|
||||||
u.logger.Error(err)
|
u.logger.Error(err.Error())
|
||||||
}
|
}
|
||||||
if err := ctx.Err(); err != nil {
|
if err := ctx.Err(); err != nil {
|
||||||
return allServers, err
|
return allServers, err
|
||||||
@@ -85,7 +85,7 @@ func (u *updater) UpdateServers(ctx context.Context) (allServers models.AllServe
|
|||||||
if u.options.Ipvanish {
|
if u.options.Ipvanish {
|
||||||
u.logger.Info("updating Ipvanish servers...")
|
u.logger.Info("updating Ipvanish servers...")
|
||||||
if err := u.updateIpvanish(ctx); err != nil {
|
if err := u.updateIpvanish(ctx); err != nil {
|
||||||
u.logger.Error(err)
|
u.logger.Error(err.Error())
|
||||||
}
|
}
|
||||||
if err := ctx.Err(); err != nil {
|
if err := ctx.Err(); err != nil {
|
||||||
return allServers, err
|
return allServers, err
|
||||||
@@ -95,7 +95,7 @@ func (u *updater) UpdateServers(ctx context.Context) (allServers models.AllServe
|
|||||||
if u.options.Ivpn {
|
if u.options.Ivpn {
|
||||||
u.logger.Info("updating Ivpn servers...")
|
u.logger.Info("updating Ivpn servers...")
|
||||||
if err := u.updateIvpn(ctx); err != nil {
|
if err := u.updateIvpn(ctx); err != nil {
|
||||||
u.logger.Error(err)
|
u.logger.Error(err.Error())
|
||||||
}
|
}
|
||||||
if err := ctx.Err(); err != nil {
|
if err := ctx.Err(); err != nil {
|
||||||
return allServers, err
|
return allServers, err
|
||||||
@@ -105,7 +105,7 @@ func (u *updater) UpdateServers(ctx context.Context) (allServers models.AllServe
|
|||||||
if u.options.Mullvad {
|
if u.options.Mullvad {
|
||||||
u.logger.Info("updating Mullvad servers...")
|
u.logger.Info("updating Mullvad servers...")
|
||||||
if err := u.updateMullvad(ctx); err != nil {
|
if err := u.updateMullvad(ctx); err != nil {
|
||||||
u.logger.Error(err)
|
u.logger.Error(err.Error())
|
||||||
}
|
}
|
||||||
if err := ctx.Err(); err != nil {
|
if err := ctx.Err(); err != nil {
|
||||||
return allServers, err
|
return allServers, err
|
||||||
@@ -116,7 +116,7 @@ func (u *updater) UpdateServers(ctx context.Context) (allServers models.AllServe
|
|||||||
// TODO support servers offering only TCP or only UDP
|
// TODO support servers offering only TCP or only UDP
|
||||||
u.logger.Info("updating NordVPN servers...")
|
u.logger.Info("updating NordVPN servers...")
|
||||||
if err := u.updateNordvpn(ctx); err != nil {
|
if err := u.updateNordvpn(ctx); err != nil {
|
||||||
u.logger.Error(err)
|
u.logger.Error(err.Error())
|
||||||
}
|
}
|
||||||
if err := ctx.Err(); err != nil {
|
if err := ctx.Err(); err != nil {
|
||||||
return allServers, err
|
return allServers, err
|
||||||
@@ -126,7 +126,7 @@ func (u *updater) UpdateServers(ctx context.Context) (allServers models.AllServe
|
|||||||
if u.options.Privado {
|
if u.options.Privado {
|
||||||
u.logger.Info("updating Privado servers...")
|
u.logger.Info("updating Privado servers...")
|
||||||
if err := u.updatePrivado(ctx); err != nil {
|
if err := u.updatePrivado(ctx); err != nil {
|
||||||
u.logger.Error(err)
|
u.logger.Error(err.Error())
|
||||||
}
|
}
|
||||||
if ctx.Err() != nil {
|
if ctx.Err() != nil {
|
||||||
return allServers, ctx.Err()
|
return allServers, ctx.Err()
|
||||||
@@ -136,7 +136,7 @@ func (u *updater) UpdateServers(ctx context.Context) (allServers models.AllServe
|
|||||||
if u.options.PIA {
|
if u.options.PIA {
|
||||||
u.logger.Info("updating Private Internet Access servers...")
|
u.logger.Info("updating Private Internet Access servers...")
|
||||||
if err := u.updatePIA(ctx); err != nil {
|
if err := u.updatePIA(ctx); err != nil {
|
||||||
u.logger.Error(err)
|
u.logger.Error(err.Error())
|
||||||
}
|
}
|
||||||
if ctx.Err() != nil {
|
if ctx.Err() != nil {
|
||||||
return allServers, ctx.Err()
|
return allServers, ctx.Err()
|
||||||
@@ -149,7 +149,7 @@ func (u *updater) UpdateServers(ctx context.Context) (allServers models.AllServe
|
|||||||
if ctxErr := ctx.Err(); ctxErr != nil {
|
if ctxErr := ctx.Err(); ctxErr != nil {
|
||||||
return allServers, ctxErr
|
return allServers, ctxErr
|
||||||
}
|
}
|
||||||
u.logger.Error(err)
|
u.logger.Error(err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,7 +159,7 @@ func (u *updater) UpdateServers(ctx context.Context) (allServers models.AllServe
|
|||||||
if ctxErr := ctx.Err(); ctxErr != nil {
|
if ctxErr := ctx.Err(); ctxErr != nil {
|
||||||
return allServers, ctxErr
|
return allServers, ctxErr
|
||||||
}
|
}
|
||||||
u.logger.Error(err)
|
u.logger.Error(err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,7 +170,7 @@ func (u *updater) UpdateServers(ctx context.Context) (allServers models.AllServe
|
|||||||
if ctxErr := ctx.Err(); ctxErr != nil {
|
if ctxErr := ctx.Err(); ctxErr != nil {
|
||||||
return allServers, ctxErr
|
return allServers, ctxErr
|
||||||
}
|
}
|
||||||
u.logger.Error(err)
|
u.logger.Error(err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,7 +180,7 @@ func (u *updater) UpdateServers(ctx context.Context) (allServers models.AllServe
|
|||||||
if ctxErr := ctx.Err(); ctxErr != nil {
|
if ctxErr := ctx.Err(); ctxErr != nil {
|
||||||
return allServers, ctxErr
|
return allServers, ctxErr
|
||||||
}
|
}
|
||||||
u.logger.Error(err)
|
u.logger.Error(err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,7 +190,7 @@ func (u *updater) UpdateServers(ctx context.Context) (allServers models.AllServe
|
|||||||
if ctxErr := ctx.Err(); ctxErr != nil {
|
if ctxErr := ctx.Err(); ctxErr != nil {
|
||||||
return allServers, ctxErr
|
return allServers, ctxErr
|
||||||
}
|
}
|
||||||
u.logger.Error(err)
|
u.logger.Error(err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,7 +200,7 @@ func (u *updater) UpdateServers(ctx context.Context) (allServers models.AllServe
|
|||||||
if ctxErr := ctx.Err(); ctxErr != nil {
|
if ctxErr := ctx.Err(); ctxErr != nil {
|
||||||
return allServers, ctxErr
|
return allServers, ctxErr
|
||||||
}
|
}
|
||||||
u.logger.Error(err)
|
u.logger.Error(err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -210,7 +210,7 @@ func (u *updater) UpdateServers(ctx context.Context) (allServers models.AllServe
|
|||||||
if ctxErr := ctx.Err(); ctxErr != nil {
|
if ctxErr := ctx.Err(); ctxErr != nil {
|
||||||
return allServers, ctxErr
|
return allServers, ctxErr
|
||||||
}
|
}
|
||||||
u.logger.Error(err)
|
u.logger.Error(err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,7 +220,7 @@ func (u *updater) UpdateServers(ctx context.Context) (allServers models.AllServe
|
|||||||
if ctxErr := ctx.Err(); ctxErr != nil {
|
if ctxErr := ctx.Err(); ctxErr != nil {
|
||||||
return allServers, ctxErr
|
return allServers, ctxErr
|
||||||
}
|
}
|
||||||
u.logger.Error(err)
|
u.logger.Error(err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user