chore: use gofumpt for code formatting
This commit is contained in:
@@ -11,7 +11,8 @@ import (
|
||||
)
|
||||
|
||||
func addServersFromAPI(ctx context.Context, client *http.Client,
|
||||
hts hostToServers) (err error) {
|
||||
hts hostToServers,
|
||||
) (err error) {
|
||||
data, err := fetchAPI(ctx, client)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -37,9 +38,7 @@ func addServersFromAPI(ctx context.Context, client *http.Client,
|
||||
return nil
|
||||
}
|
||||
|
||||
var (
|
||||
ErrHTTPStatusCodeNotOK = errors.New("HTTP status code not OK")
|
||||
)
|
||||
var ErrHTTPStatusCodeNotOK = errors.New("HTTP status code not OK")
|
||||
|
||||
type serverData struct {
|
||||
Host string `json:"connectionName"`
|
||||
@@ -50,7 +49,8 @@ type serverData struct {
|
||||
}
|
||||
|
||||
func fetchAPI(ctx context.Context, client *http.Client) (
|
||||
servers []serverData, err error) {
|
||||
servers []serverData, err error,
|
||||
) {
|
||||
const url = "https://api.surfshark.com/v4/server/clusters"
|
||||
|
||||
for _, clustersType := range [...]string{"generic", "double", "static", "obfuscated"} {
|
||||
|
||||
@@ -10,7 +10,8 @@ import (
|
||||
type hostToServers map[string][]models.Server
|
||||
|
||||
func (hts hostToServers) addOpenVPN(host, region, country, city,
|
||||
retroLoc string, tcp, udp bool) {
|
||||
retroLoc string, tcp, udp bool,
|
||||
) {
|
||||
// Check for existing server for this host and OpenVPN.
|
||||
servers := hts[host]
|
||||
for i, existingServer := range servers {
|
||||
@@ -43,7 +44,8 @@ func (hts hostToServers) addOpenVPN(host, region, country, city,
|
||||
}
|
||||
|
||||
func (hts hostToServers) addWireguard(host, region, country, city, retroLoc,
|
||||
wgPubKey string) {
|
||||
wgPubKey string,
|
||||
) {
|
||||
// Check for existing server for this host and Wireguard.
|
||||
servers := hts[host]
|
||||
for _, existingServer := range servers {
|
||||
|
||||
@@ -7,12 +7,11 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/provider/surfshark/servers"
|
||||
)
|
||||
|
||||
var (
|
||||
errHostnameNotFound = errors.New("hostname not found in hostname to location mapping")
|
||||
)
|
||||
var errHostnameNotFound = errors.New("hostname not found in hostname to location mapping")
|
||||
|
||||
func getHostInformation(host string, hostnameToLocation map[string]servers.ServerLocation) (
|
||||
data servers.ServerLocation, err error) {
|
||||
data servers.ServerLocation, err error,
|
||||
) {
|
||||
locationData, ok := hostnameToLocation[host]
|
||||
if !ok {
|
||||
return locationData, fmt.Errorf("%w: %s", errHostnameNotFound, host)
|
||||
@@ -22,7 +21,8 @@ func getHostInformation(host string, hostnameToLocation map[string]servers.Serve
|
||||
}
|
||||
|
||||
func hostToLocation(locationData []servers.ServerLocation) (
|
||||
hostToLocation map[string]servers.ServerLocation) {
|
||||
hostToLocation map[string]servers.ServerLocation,
|
||||
) {
|
||||
hostToLocation = make(map[string]servers.ServerLocation, len(locationData))
|
||||
for _, data := range locationData {
|
||||
hostToLocation[data.Hostname] = data
|
||||
|
||||
@@ -10,7 +10,8 @@ import (
|
||||
)
|
||||
|
||||
func (u *Updater) FetchServers(ctx context.Context, minServers int) (
|
||||
servers []models.Server, err error) {
|
||||
servers []models.Server, err error,
|
||||
) {
|
||||
hts := make(hostToServers)
|
||||
|
||||
err = addServersFromAPI(ctx, u.client, hts)
|
||||
|
||||
@@ -14,7 +14,8 @@ type Updater struct {
|
||||
}
|
||||
|
||||
func New(client *http.Client, unzipper common.Unzipper,
|
||||
warner common.Warner, parallelResolver common.ParallelResolver) *Updater {
|
||||
warner common.Warner, parallelResolver common.ParallelResolver,
|
||||
) *Updater {
|
||||
return &Updater{
|
||||
client: client,
|
||||
unzipper: unzipper,
|
||||
|
||||
@@ -11,7 +11,8 @@ import (
|
||||
|
||||
func addOpenVPNServersFromZip(ctx context.Context,
|
||||
unzipper common.Unzipper, hts hostToServers) (
|
||||
warnings []string, err error) {
|
||||
warnings []string, err error,
|
||||
) {
|
||||
const url = "https://my.surfshark.com/vpn/api/v1/server/configurations"
|
||||
contents, err := unzipper.FetchAndExtract(ctx, url)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user