- Exported `Fetcher` interface - Inject `Fetcher` to publicip loop and updaters - Get public IP and information at the same time - Only query ipinfo.io - Make `MultiInfo` part of the `Fetch` object
36 lines
864 B
Go
36 lines
864 B
Go
package common
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"net"
|
|
|
|
"github.com/qdm12/gluetun/internal/models"
|
|
publicipmodels "github.com/qdm12/gluetun/internal/publicip/models"
|
|
"github.com/qdm12/gluetun/internal/updater/resolver"
|
|
)
|
|
|
|
var ErrNotEnoughServers = errors.New("not enough servers found")
|
|
|
|
type Fetcher interface {
|
|
FetchServers(ctx context.Context, minServers int) (servers []models.Server, err error)
|
|
}
|
|
|
|
type ParallelResolver interface {
|
|
Resolve(ctx context.Context, settings resolver.ParallelSettings) (
|
|
hostToIPs map[string][]net.IP, warnings []string, err error)
|
|
}
|
|
|
|
type Unzipper interface {
|
|
FetchAndExtract(ctx context.Context, url string) (
|
|
contents map[string][]byte, err error)
|
|
}
|
|
|
|
type Warner interface {
|
|
Warn(s string)
|
|
}
|
|
|
|
type IPFetcher interface {
|
|
FetchMultiInfo(ctx context.Context, ips []net.IP) (data []publicipmodels.IPInfoData, err error)
|
|
}
|