Upgrade dependencies
- Use of context for custom http client - Remove unused nodeid for logger - Upgrade shadowsocks dependency
This commit is contained in:
@@ -13,7 +13,7 @@ import (
|
||||
|
||||
func (u *updater) updatePIAOld(ctx context.Context) (err error) {
|
||||
const zipURL = "https://www.privateinternetaccess.com/openvpn/openvpn.zip"
|
||||
contents, err := fetchAndExtractFiles(zipURL)
|
||||
contents, err := fetchAndExtractFiles(ctx, zipURL)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ func findSurfsharkServersFromAPI(ctx context.Context, lookupIP lookupIPFunc, htt
|
||||
|
||||
func findSurfsharkServersFromZip(ctx context.Context, lookupIP lookupIPFunc) (servers []models.SurfsharkServer, warnings []string, err error) {
|
||||
const zipURL = "https://my.surfshark.com/vpn/api/v1/server/configurations"
|
||||
contents, err := fetchAndExtractFiles(zipURL)
|
||||
contents, err := fetchAndExtractFiles(ctx, zipURL)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ func (u *updater) updateVyprvpn(ctx context.Context) (err error) {
|
||||
|
||||
func findVyprvpnServers(ctx context.Context, lookupIP lookupIPFunc) (servers []models.VyprvpnServer, err error) {
|
||||
const zipURL = "https://support.vyprvpn.com/hc/article_attachments/360052617332/Vypr_OpenVPN_20200320.zip"
|
||||
contents, err := fetchAndExtractFiles(zipURL)
|
||||
contents, err := fetchAndExtractFiles(ctx, zipURL)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package updater
|
||||
import (
|
||||
"archive/zip"
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
@@ -13,11 +14,11 @@ import (
|
||||
"github.com/qdm12/golibs/network"
|
||||
)
|
||||
|
||||
func fetchAndExtractFiles(urls ...string) (contents map[string][]byte, err error) {
|
||||
func fetchAndExtractFiles(ctx context.Context, urls ...string) (contents map[string][]byte, err error) {
|
||||
client := network.NewClient(10 * time.Second)
|
||||
contents = make(map[string][]byte)
|
||||
for _, url := range urls {
|
||||
zipBytes, status, err := client.GetContent(url)
|
||||
zipBytes, status, err := client.Get(ctx, url)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if status != http.StatusOK {
|
||||
|
||||
Reference in New Issue
Block a user