mirror of
https://github.com/qdm12/gluetun.git
synced 2026-05-08 04:50:11 +02:00
25f67cd170
- new directory structure containing manifest.json and one json file per provider, by default. - the manifest.json file can specify a filepath for each vpn provider - each vpn provider json data file can contain the `"preferred": true` field to enforce it is used even if outdated, unless there is a version mismatch - `STORAGE_SERVERS_DIRECTORY_PATH` replaces `STORAGE_FILEPATH` (which is now a migration source only). It sets the directory where server manifest and per-provider JSON files are stored (default: `/gluetun/servers/`). - First-run migration: On startup, gluetun checks for the old /gluetun/servers.json file; if found and no new manifest exists, it automatically migrates all data to /gluetun/servers/ directory structure - Silent fallback: If legacy file isn't found, uses the new directory path normally - Legacy cleanup: After successful migration, attempts to remove the old fat JSON file (logs warning only if removal fails, e.g., read-only bind mounts) Co-authored-by: Copilot <copilot@github.com>
119 lines
3.5 KiB
Go
119 lines
3.5 KiB
Go
package settings
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func Test_Settings_String(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
withDefaults := func(s Settings) Settings {
|
|
s.SetDefaults()
|
|
return s
|
|
}
|
|
|
|
testCases := map[string]struct {
|
|
settings Settings
|
|
s string
|
|
}{
|
|
"default settings": {
|
|
settings: withDefaults(Settings{}),
|
|
s: `Settings summary:
|
|
├── VPN settings:
|
|
| ├── VPN provider settings:
|
|
| | ├── Name: private internet access
|
|
| | └── Server selection settings:
|
|
| | ├── VPN type: openvpn
|
|
| | └── OpenVPN server selection settings:
|
|
| | ├── Protocol: UDP
|
|
| | └── Private Internet Access encryption preset: strong
|
|
| ├── OpenVPN settings:
|
|
| | ├── OpenVPN version: 2.6
|
|
| | ├── User: [not set]
|
|
| | ├── Password: [not set]
|
|
| | ├── Private Internet Access encryption preset: strong
|
|
| | ├── Network interface: tun0
|
|
| | ├── Run OpenVPN as: root
|
|
| | └── Verbosity level: 1
|
|
| └── Path MTU discovery:
|
|
| ├── ICMP addresses:
|
|
| | ├── 1.1.1.1
|
|
| | └── 8.8.8.8
|
|
| └── TCP addresses:
|
|
| ├── 1.1.1.1:53
|
|
| ├── 8.8.8.8:53
|
|
| ├── 1.1.1.1:443
|
|
| ├── 8.8.8.8:443
|
|
| ├── [2606:4700:4700::1111]:53
|
|
| ├── [2001:4860:4860::8888]:53
|
|
| ├── [2606:4700:4700::1111]:443
|
|
| └── [2001:4860:4860::8888]:443
|
|
├── DNS settings:
|
|
| ├── Upstream resolver type: dot
|
|
| ├── Upstream resolvers:
|
|
| | └── Cloudflare
|
|
| ├── Caching: yes
|
|
| ├── IPv6: no
|
|
| ├── Update period: every 24h0m0s
|
|
| └── DNS filtering settings:
|
|
| ├── Block malicious: yes
|
|
| ├── Block ads: no
|
|
| └── Block surveillance: yes
|
|
├── Firewall settings:
|
|
| ├── Enabled: yes
|
|
| └── Iptables settings:
|
|
| └── Log level: INFO
|
|
├── Log settings:
|
|
| └── Log level: INFO
|
|
├── IPv6 settings:
|
|
| └── Check addresses:
|
|
| ├── [2001:4860:4860::8888]:53
|
|
| └── [2606:4700:4700::1111]:53
|
|
├── Health settings:
|
|
| ├── Server listening address: 127.0.0.1:9999
|
|
| ├── Target addresses:
|
|
| | ├── cloudflare.com:443
|
|
| | └── github.com:443
|
|
| ├── Small health check type: ICMP echo request
|
|
| | └── ICMP target IPs:
|
|
| | ├── 1.1.1.1
|
|
| | └── 8.8.8.8
|
|
| └── Restart VPN on healthcheck failure: yes
|
|
├── Shadowsocks server settings:
|
|
| └── Enabled: no
|
|
├── HTTP proxy settings:
|
|
| └── Enabled: no
|
|
├── Control server settings:
|
|
| ├── Listening address: :8000
|
|
| ├── Logging: yes
|
|
| └── Authentication file path: /gluetun/auth/config.toml
|
|
├── Storage settings:
|
|
| └── Servers directory path: /gluetun/servers/
|
|
├── OS Alpine settings:
|
|
| ├── Process UID: 1000
|
|
| └── Process GID: 1000
|
|
├── Public IP settings:
|
|
| ├── IP file path: /tmp/gluetun/ip
|
|
| ├── Public IP data base API: ipinfo
|
|
| └── Public IP data backup APIs:
|
|
| ├── cloudflare
|
|
| ├── ifconfigco
|
|
| └── ip2location
|
|
└── Version settings:
|
|
└── Enabled: yes`,
|
|
},
|
|
}
|
|
|
|
for name, testCase := range testCases {
|
|
t.Run(name, func(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
s := testCase.settings.String()
|
|
|
|
assert.Equal(t, testCase.s, s)
|
|
})
|
|
}
|
|
}
|