Maint: hardcoded data in JSON embedded file

- Server information, versions and timestamps together in internal/constants/servers.json
- breaking change: updater cli uses -enduser instead of -file
- breaking change: updater cli uses -maintainer instead of -stdout
- Fix: replace special last a character with 'a' from Bogota for PrivateVPN
- Feat: do not write out servers and timestamp if no change was detected
This commit is contained in:
Quentin McGaw (desktop)
2021-07-20 03:01:26 +00:00
parent 394abbbe35
commit da4d528463
49 changed files with 109965 additions and 12159 deletions

View File

@@ -1,14 +0,0 @@
package ivpn
import "github.com/qdm12/gluetun/internal/models"
func Stringify(servers []models.IvpnServer) (s string) {
s = "func IvpnServers() []models.IvpnServer {\n"
s += " return []models.IvpnServer{\n"
for _, server := range servers {
s += " " + server.String() + ",\n"
}
s += " }\n"
s += "}"
return s
}

View File

@@ -1,43 +0,0 @@
package ivpn
import (
"testing"
"github.com/qdm12/gluetun/internal/models"
"github.com/stretchr/testify/assert"
)
func Test_Stringify(t *testing.T) {
t.Parallel()
testCases := map[string]struct {
servers []models.IvpnServer
s string
}{
"no server": {
s: `func IvpnServers() []models.IvpnServer {
return []models.IvpnServer{
}
}`,
},
"multiple servers": {
servers: []models.IvpnServer{
{Country: "A"},
{Country: "B"},
},
s: `func IvpnServers() []models.IvpnServer {
return []models.IvpnServer{
{Country: "A", City: "", Hostname: "", TCP: false, UDP: false, IPs: []net.IP{}},
{Country: "B", City: "", Hostname: "", TCP: false, UDP: false, IPs: []net.IP{}},
}
}`,
},
}
for name, testCase := range testCases {
testCase := testCase
t.Run(name, func(t *testing.T) {
t.Parallel()
s := Stringify(testCase.servers)
assert.Equal(t, testCase.s, s)
})
}
}