-
-
Notifications
You must be signed in to change notification settings - Fork 328
/
logs.go
80 lines (67 loc) · 2.35 KB
/
logs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package openvpn
import (
"strings"
"github.com/fatih/color"
"github.com/qdm12/gluetun/internal/constants"
)
type logLevel uint8
const (
levelInfo logLevel = iota
levelWarn
levelError
)
func processLogLine(s string) (filtered string, level logLevel) {
for _, ignored := range []string{
"WARNING: you are using user/group/chroot/setcon without persist-tun -- this may cause restarts to fail",
"NOTE: UID/GID downgrade will be delayed because of --client, --pull, or --up-delay",
} {
if s == ignored {
return "", levelInfo
}
}
switch {
case strings.HasPrefix(s, "NOTE: "):
filtered = strings.TrimPrefix(s, "NOTE: ")
level = levelInfo
case strings.HasPrefix(s, "WARNING: "):
filtered = strings.TrimPrefix(s, "WARNING: ")
level = levelWarn
case strings.HasPrefix(s, "ERROR: "):
filtered = strings.TrimPrefix(s, "ERROR: ")
level = levelError
case strings.HasPrefix(s, "Options error: "):
filtered = strings.TrimPrefix(s, "Options error: ")
level = levelError
case s == "Initialization Sequence Completed":
return color.HiGreenString(s), levelInfo
case s == "AUTH: Received control message: AUTH_FAILED":
filtered = s + `
Your credentials might be wrong 🤨
`
level = levelError
case strings.Contains(s, "TLS Error: TLS key negotiation failed to occur within 60 seconds (check your network connectivity)"): //nolint:lll
filtered = s + `
🚒🚒🚒🚒🚒🚨🚨🚨🚨🚨🚨🚒🚒🚒🚒🚒
That error usually happens because either:
1. The VPN server IP address you are trying to connect to is no longer valid 🔌
Check out https://github.com/qdm12/gluetun-wiki/blob/main/setup/servers.md#update-the-vpn-servers-list
2. The VPN server crashed 💥, try changing your VPN servers filtering options such as SERVER_REGIONS
3. Your Internet connection is not working 🤯, ensure it works
4. Something else ➡️ https://github.com/qdm12/gluetun/issues/new/choose
`
level = levelWarn
default:
filtered = s
level = levelInfo
}
switch {
case filtered == "RTNETLINK answers: File exists":
filtered = "OpenVPN tried to add an IP route which already exists (" + filtered + ")"
level = levelWarn
case strings.HasPrefix(filtered, "Linux route add command failed: "):
filtered = "Previous error details: " + filtered
level = levelWarn
}
filtered = constants.ColorOpenvpn().Sprintf(filtered)
return filtered, level
}