Files
gluetun/internal/provider/utils/targetip.go
Quentin McGaw (desktop) 3d8e61900b Maint: make VPN connection not specific to OpenVPN
- Add VPN field to ServerSelection struct
- Set VPN type to server selection at start using VPN_TYPE
- Change OpenVPNConnection to Connection with Type field
- Rename Provider GetOpenVPNConnection to GetConnection
- Rename GetTargetIPOpenVPNConnection to GetTargetIPConnection
- Rename PickRandomOpenVPNConnection to PickRandomConnection
- Add 'OpenVPN' prefix to OpenVPN specific methods on connection
2021-08-19 14:09:41 +00:00

23 lines
507 B
Go

package utils
import (
"errors"
"fmt"
"net"
"github.com/qdm12/gluetun/internal/models"
)
var ErrTargetIPNotFound = errors.New("target IP address not found")
func GetTargetIPConnection(connections []models.Connection,
targetIP net.IP) (connection models.Connection, err error) {
for _, connection := range connections {
if targetIP.Equal(connection.IP) {
return connection, nil
}
}
return connection, fmt.Errorf("%w: in %d filtered connections",
ErrTargetIPNotFound, len(connections))
}