2022-05-28 22:02:18 +00:00
|
|
|
package common
|
|
|
|
|
|
2022-06-09 03:10:56 +00:00
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"errors"
|
|
|
|
|
"net"
|
2022-06-09 23:47:12 +00:00
|
|
|
|
|
|
|
|
"github.com/qdm12/gluetun/internal/models"
|
2022-06-09 03:10:56 +00:00
|
|
|
)
|
2022-05-28 22:02:18 +00:00
|
|
|
|
|
|
|
|
var ErrNotEnoughServers = errors.New("not enough servers found")
|
2022-06-09 03:10:56 +00:00
|
|
|
|
2022-06-09 23:47:12 +00:00
|
|
|
type Fetcher interface {
|
|
|
|
|
FetchServers(ctx context.Context, minServers int) (servers []models.Server, err error)
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-09 03:10:56 +00:00
|
|
|
type ParallelResolver interface {
|
|
|
|
|
Resolve(ctx context.Context, hosts []string, minToFind int) (
|
|
|
|
|
hostToIPs map[string][]net.IP, warnings []string, err error)
|
|
|
|
|
}
|
2022-06-09 23:47:12 +00:00
|
|
|
|
|
|
|
|
type Unzipper interface {
|
|
|
|
|
FetchAndExtract(ctx context.Context, url string) (contents map[string][]byte, err error)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Warner interface {
|
|
|
|
|
Warn(s string)
|
|
|
|
|
}
|