Remove x/net Go dependency
This commit is contained in:
@@ -17,7 +17,6 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/updater"
|
||||
"github.com/qdm12/golibs/files"
|
||||
"github.com/qdm12/golibs/logging"
|
||||
"golang.org/x/net/context/ctxhttp"
|
||||
)
|
||||
|
||||
func ClientKey(args []string) error {
|
||||
@@ -42,7 +41,11 @@ func ClientKey(args []string) error {
|
||||
|
||||
func HealthCheck(ctx context.Context, client *http.Client) error {
|
||||
const url = "http://localhost:8000/health"
|
||||
response, err := ctxhttp.Get(ctx, client, url)
|
||||
request, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
response, err := client.Do(request)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
"github.com/qdm12/golibs/files"
|
||||
"github.com/qdm12/golibs/logging"
|
||||
"golang.org/x/net/context/ctxhttp"
|
||||
)
|
||||
|
||||
type piaV3 struct {
|
||||
@@ -94,7 +93,12 @@ func (p *piaV3) PortForward(ctx context.Context, client *http.Client,
|
||||
}
|
||||
clientID := hex.EncodeToString(b)
|
||||
url := fmt.Sprintf("%s/?client_id=%s", constants.PIAPortForwardURL, clientID)
|
||||
response, err := ctxhttp.Get(ctx, client, url)
|
||||
request, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
|
||||
if err != nil {
|
||||
pfLogger.Error(err)
|
||||
return
|
||||
}
|
||||
response, err := client.Do(request)
|
||||
if err != nil {
|
||||
pfLogger.Error(err)
|
||||
return
|
||||
|
||||
@@ -21,7 +21,6 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
"github.com/qdm12/golibs/files"
|
||||
"github.com/qdm12/golibs/logging"
|
||||
"golang.org/x/net/context/ctxhttp"
|
||||
)
|
||||
|
||||
type piaV4 struct {
|
||||
@@ -447,7 +446,11 @@ func fetchPIAPortForwardData(ctx context.Context, client *http.Client, gateway n
|
||||
Path: "/getSignature",
|
||||
RawQuery: queryParams.Encode(),
|
||||
}
|
||||
response, err := ctxhttp.Get(ctx, client, url.String())
|
||||
request, err := http.NewRequestWithContext(ctx, http.MethodGet, url.String(), nil)
|
||||
if err != nil {
|
||||
return 0, "", expiration, fmt.Errorf("cannot obtain signature: %w", err)
|
||||
}
|
||||
response, err := client.Do(request)
|
||||
if err != nil {
|
||||
return 0, "", expiration, fmt.Errorf("cannot obtain signature: %w", err)
|
||||
}
|
||||
@@ -489,7 +492,11 @@ func bindPIAPort(ctx context.Context, client *http.Client, gateway net.IP, data
|
||||
RawQuery: queryParams.Encode(),
|
||||
}
|
||||
|
||||
response, err := ctxhttp.Get(ctx, client, url.String())
|
||||
request, err := http.NewRequestWithContext(ctx, http.MethodGet, url.String(), nil)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot bind port: %w", err)
|
||||
}
|
||||
response, err := client.Do(request)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot bind port: %w", err)
|
||||
}
|
||||
|
||||
@@ -6,8 +6,6 @@ import (
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"golang.org/x/net/context/ctxhttp"
|
||||
)
|
||||
|
||||
type githubRelease struct {
|
||||
@@ -28,7 +26,11 @@ type githubCommit struct {
|
||||
|
||||
func getGithubReleases(ctx context.Context, client *http.Client) (releases []githubRelease, err error) {
|
||||
const url = "https://api.github.com/repos/qdm12/gluetun/releases"
|
||||
response, err := ctxhttp.Get(ctx, client, url)
|
||||
request, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response, err := client.Do(request)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -45,7 +47,11 @@ func getGithubReleases(ctx context.Context, client *http.Client) (releases []git
|
||||
|
||||
func getGithubCommits(ctx context.Context, client *http.Client) (commits []githubCommit, err error) {
|
||||
const url = "https://api.github.com/repos/qdm12/gluetun/commits"
|
||||
response, err := ctxhttp.Get(ctx, client, url)
|
||||
request, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response, err := client.Do(request)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user