mirror of
https://github.com/qdm12/gluetun.git
synced 2026-06-24 04:47:46 +02:00
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:
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user