chore(constants): internal/constants/providers
- New package to avoid package import cycles
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
|
||||
"github.com/qdm12/gluetun/internal/configuration/settings"
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
"github.com/qdm12/gluetun/internal/constants/providers"
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -25,7 +26,7 @@ func Test_Wevpn_GetConnection(t *testing.T) {
|
||||
"no server available": {
|
||||
selection: settings.ServerSelection{
|
||||
VPN: constants.OpenVPN,
|
||||
}.WithDefaults(constants.Wevpn),
|
||||
}.WithDefaults(providers.Wevpn),
|
||||
err: errors.New("no server found: for VPN openvpn; protocol udp"),
|
||||
},
|
||||
"no filter": {
|
||||
@@ -34,7 +35,7 @@ func Test_Wevpn_GetConnection(t *testing.T) {
|
||||
{UDP: true, IPs: []net.IP{net.IPv4(2, 2, 2, 2)}},
|
||||
{UDP: true, IPs: []net.IP{net.IPv4(3, 3, 3, 3)}},
|
||||
},
|
||||
selection: settings.ServerSelection{}.WithDefaults(constants.Wevpn),
|
||||
selection: settings.ServerSelection{}.WithDefaults(providers.Wevpn),
|
||||
connection: models.Connection{
|
||||
Type: constants.OpenVPN,
|
||||
IP: net.IPv4(1, 1, 1, 1),
|
||||
@@ -45,7 +46,7 @@ func Test_Wevpn_GetConnection(t *testing.T) {
|
||||
"target IP": {
|
||||
selection: settings.ServerSelection{
|
||||
TargetIP: net.IPv4(2, 2, 2, 2),
|
||||
}.WithDefaults(constants.Wevpn),
|
||||
}.WithDefaults(providers.Wevpn),
|
||||
servers: []models.WevpnServer{
|
||||
{UDP: true, IPs: []net.IP{net.IPv4(1, 1, 1, 1)}},
|
||||
{UDP: true, IPs: []net.IP{net.IPv4(2, 2, 2, 2)}},
|
||||
@@ -61,7 +62,7 @@ func Test_Wevpn_GetConnection(t *testing.T) {
|
||||
"with filter": {
|
||||
selection: settings.ServerSelection{
|
||||
Hostnames: []string{"b"},
|
||||
}.WithDefaults(constants.Wevpn),
|
||||
}.WithDefaults(providers.Wevpn),
|
||||
servers: []models.WevpnServer{
|
||||
{UDP: true, Hostname: "a", IPs: []net.IP{net.IPv4(1, 1, 1, 1)}},
|
||||
{UDP: true, Hostname: "b", IPs: []net.IP{net.IPv4(2, 2, 2, 2)}},
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/configuration/settings"
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
"github.com/qdm12/gluetun/internal/constants/providers"
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -24,7 +24,7 @@ func Test_Wevpn_filterServers(t *testing.T) {
|
||||
err error
|
||||
}{
|
||||
"no server available": {
|
||||
selection: settings.ServerSelection{}.WithDefaults(constants.Wevpn),
|
||||
selection: settings.ServerSelection{}.WithDefaults(providers.Wevpn),
|
||||
err: errors.New("no server found: for VPN openvpn; protocol udp"),
|
||||
},
|
||||
"no filter": {
|
||||
@@ -33,7 +33,7 @@ func Test_Wevpn_filterServers(t *testing.T) {
|
||||
{Hostname: "b", UDP: true},
|
||||
{Hostname: "c", UDP: true},
|
||||
},
|
||||
selection: settings.ServerSelection{}.WithDefaults(constants.Wevpn),
|
||||
selection: settings.ServerSelection{}.WithDefaults(providers.Wevpn),
|
||||
filtered: []models.WevpnServer{
|
||||
{Hostname: "a", UDP: true},
|
||||
{Hostname: "b", UDP: true},
|
||||
@@ -43,7 +43,7 @@ func Test_Wevpn_filterServers(t *testing.T) {
|
||||
"filter by protocol": {
|
||||
selection: settings.ServerSelection{
|
||||
OpenVPN: settings.OpenVPNSelection{TCP: boolPtr(true)},
|
||||
}.WithDefaults(constants.Wevpn),
|
||||
}.WithDefaults(providers.Wevpn),
|
||||
servers: []models.WevpnServer{
|
||||
{Hostname: "a", UDP: true},
|
||||
{Hostname: "b", TCP: true},
|
||||
@@ -56,7 +56,7 @@ func Test_Wevpn_filterServers(t *testing.T) {
|
||||
"filter by city": {
|
||||
selection: settings.ServerSelection{
|
||||
Cities: []string{"b"},
|
||||
}.WithDefaults(constants.Wevpn),
|
||||
}.WithDefaults(providers.Wevpn),
|
||||
servers: []models.WevpnServer{
|
||||
{City: "a", UDP: true},
|
||||
{City: "b", UDP: true},
|
||||
@@ -69,7 +69,7 @@ func Test_Wevpn_filterServers(t *testing.T) {
|
||||
"filter by hostname": {
|
||||
selection: settings.ServerSelection{
|
||||
Hostnames: []string{"b"},
|
||||
}.WithDefaults(constants.Wevpn),
|
||||
}.WithDefaults(providers.Wevpn),
|
||||
servers: []models.WevpnServer{
|
||||
{Hostname: "a", UDP: true},
|
||||
{Hostname: "b", UDP: true},
|
||||
|
||||
@@ -3,7 +3,7 @@ package wevpn
|
||||
import (
|
||||
"math/rand"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
"github.com/qdm12/gluetun/internal/constants/providers"
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
"github.com/qdm12/gluetun/internal/provider/utils"
|
||||
)
|
||||
@@ -18,6 +18,6 @@ func New(servers []models.WevpnServer, randSource rand.Source) *Wevpn {
|
||||
return &Wevpn{
|
||||
servers: servers,
|
||||
randSource: randSource,
|
||||
NoPortForwarder: utils.NewNoPortForwarding(constants.Wevpn),
|
||||
NoPortForwarder: utils.NewNoPortForwarding(providers.Wevpn),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user