Upgrade dependencies

- Use of context for custom http client
- Remove unused nodeid for logger
- Upgrade shadowsocks dependency
This commit is contained in:
Quentin McGaw
2020-10-18 02:24:34 +00:00
parent b27e637894
commit 84c1f46ae4
16 changed files with 97 additions and 71 deletions

View File

@@ -104,7 +104,7 @@ func (l *looper) Run(ctx context.Context, wg *sync.WaitGroup) {
// Enabled and has a period set
ip, err := l.getter.Get()
ip, err := l.getter.Get(ctx)
if err != nil {
l.logAndWait(ctx, err)
continue

View File

@@ -1,6 +1,7 @@
package publicip
import (
"context"
"fmt"
"math/rand"
"net"
@@ -11,7 +12,7 @@ import (
)
type IPGetter interface {
Get() (ip net.IP, err error)
Get(ctx context.Context) (ip net.IP, err error)
}
type ipGetter struct {
@@ -26,7 +27,7 @@ func NewIPGetter(client network.Client) IPGetter {
}
}
func (i *ipGetter) Get() (ip net.IP, err error) {
func (i *ipGetter) Get(ctx context.Context) (ip net.IP, err error) {
urls := []string{
"https://ifconfig.me/ip",
"http://ip1.dynupdate.no-ip.com:8245",
@@ -38,7 +39,7 @@ func (i *ipGetter) Get() (ip net.IP, err error) {
"https://ipinfo.io/ip",
}
url := urls[i.randIntn(len(urls))]
content, status, err := i.client.GetContent(url, network.UseRandomUserAgent())
content, status, err := i.client.Get(ctx, url, network.UseRandomUserAgent())
if err != nil {
return nil, err
} else if status != http.StatusOK {