Feat: rework Surfshark servers data (#575)

- Feat: `MULTIHOP_ONLY` variable
- Feat: `COUNTRY` variable
- Feat: `CITY` variable
- Feat: `REGION` variable, with retro-compatibility
- Feat: merge servers from API, zip and hardcoded hostnames
- Fix: remove outdated and duplicate servers
- Maint: faster update with fully parallel DNS resolutions
This commit is contained in:
Quentin McGaw
2021-08-23 10:25:00 -07:00
committed by GitHub
parent 8b52af0d03
commit f1a82d9d9c
21 changed files with 3023 additions and 1803 deletions
@@ -2,18 +2,20 @@ package surfshark
import (
"net"
"strings"
"github.com/qdm12/gluetun/internal/models"
)
type hostToServer map[string]models.SurfsharkServer
func (hts hostToServer) add(host, region string, tcp, udp bool) {
func (hts hostToServer) add(host, region, country, city, retroLoc string, tcp, udp bool) {
server, ok := hts[host]
if !ok {
server.Hostname = host
server.Region = region
server.Country = country
server.City = city
server.RetroLoc = retroLoc
}
if tcp {
server.TCP = tcp
@@ -32,16 +34,6 @@ func (hts hostToServer) toHostsSlice() (hosts []string) {
return hosts
}
func (hts hostToServer) toSubdomainsSlice() (subdomains []string) {
subdomains = make([]string, 0, len(hts))
const suffix = ".prod.surfshark.com"
for host := range hts {
subdomain := strings.TrimSuffix(host, suffix)
subdomains = append(subdomains, subdomain)
}
return subdomains
}
func (hts hostToServer) adaptWithIPs(hostToIPs map[string][]net.IP) {
for host, IPs := range hostToIPs {
server := hts[host]