chore(storage): runtime defaults on servers data

- `openvpn` default VPN protocol for servers
- True UDP if VPN protocol is Wireguard
This commit is contained in:
Quentin McGaw
2022-04-18 11:59:15 +00:00
parent 934fafb64b
commit ac9571c6b2
4 changed files with 45 additions and 0 deletions

View File

@@ -2,6 +2,8 @@ package models
import (
"net"
"github.com/qdm12/gluetun/internal/constants/vpn"
)
type Server struct {
@@ -26,3 +28,15 @@ type Server struct {
PortForward bool `json:"port_forward,omitempty"`
IPs []net.IP `json:"ips,omitempty"`
}
func (s *Server) setDefaults() {
// TODO v4 precise these in servers.json rather than here
if s.VPN == "" {
s.VPN = vpn.OpenVPN
}
if s.VPN == vpn.Wireguard {
s.UDP = true
s.TCP = false
}
}