embed types without alias properly
This commit is contained in:
parent
586292a25a
commit
b7ed21f2ec
2
add.go
2
add.go
@ -1,8 +1,8 @@
|
|||||||
package dsnet
|
package dsnet
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"text/template"
|
"text/template"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ type PeerConfig struct {
|
|||||||
// Description of what the host is and/or does
|
// Description of what the host is and/or does
|
||||||
Description string `validate:"required,gte=1,lte=255"`
|
Description string `validate:"required,gte=1,lte=255"`
|
||||||
// Internal VPN IP address. Added to AllowedIPs in server config as a /32
|
// Internal VPN IP address. Added to AllowedIPs in server config as a /32
|
||||||
IP net.IP `validate:"required`
|
net.IP `validate:"required`
|
||||||
PublicKey JSONKey `validate:"required,len=44"`
|
PublicKey JSONKey `validate:"required,len=44"`
|
||||||
PrivateKey JSONKey `json:"-"` // omitted from config!
|
PrivateKey JSONKey `json:"-"` // omitted from config!
|
||||||
PresharedKey JSONKey `validate:"required,len=44"`
|
PresharedKey JSONKey `validate:"required,len=44"`
|
||||||
@ -40,7 +40,7 @@ type DsnetConfig struct {
|
|||||||
// IP network from which to allocate automatic sequential addresses
|
// IP network from which to allocate automatic sequential addresses
|
||||||
// Network is chosen randomly when not specified
|
// Network is chosen randomly when not specified
|
||||||
Network JSONIPNet `validate:"required"`
|
Network JSONIPNet `validate:"required"`
|
||||||
IP net.IP `validate:"required"`
|
net.IP `validate:"required"`
|
||||||
DNS net.IP `validate:"required"`
|
DNS net.IP `validate:"required"`
|
||||||
// TODO Default subnets to route via VPN
|
// TODO Default subnets to route via VPN
|
||||||
ReportFile string `validate:"required"`
|
ReportFile string `validate:"required"`
|
||||||
@ -111,7 +111,7 @@ func (conf *DsnetConfig) MustAddPeer(peer PeerConfig) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (conf *DsnetConfig) MustRemovePeer(hostname string) {
|
func (conf *DsnetConfig) MustRemovePeer(hostname string) {
|
||||||
peerIndex := -1;
|
peerIndex := -1
|
||||||
|
|
||||||
for i, peer := range conf.Peers {
|
for i, peer := range conf.Peers {
|
||||||
if peer.Hostname == hostname {
|
if peer.Hostname == hostname {
|
||||||
@ -129,7 +129,6 @@ func (conf *DsnetConfig) MustRemovePeer(hostname string) {
|
|||||||
conf.Peers = conf.Peers[:len(conf.Peers)-1]
|
conf.Peers = conf.Peers[:len(conf.Peers)-1]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (conf DsnetConfig) IPAllocated(IP net.IP) bool {
|
func (conf DsnetConfig) IPAllocated(IP net.IP) bool {
|
||||||
if IP.Equal(conf.IP) {
|
if IP.Equal(conf.IP) {
|
||||||
return true
|
return true
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type JSONIPNet struct {
|
type JSONIPNet struct {
|
||||||
IPNet net.IPNet
|
net.IPNet
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n JSONIPNet) MarshalJSON() ([]byte, error) {
|
func (n JSONIPNet) MarshalJSON() ([]byte, error) {
|
||||||
@ -28,7 +28,7 @@ func (n *JSONIPNet) String() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type JSONKey struct {
|
type JSONKey struct {
|
||||||
Key wgtypes.Key
|
wgtypes.Key
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k JSONKey) MarshalJSON() ([]byte, error) {
|
func (k JSONKey) MarshalJSON() ([]byte, error) {
|
||||||
|
@ -51,7 +51,7 @@ type DsnetReport struct {
|
|||||||
// IP network from which to allocate automatic sequential addresses
|
// IP network from which to allocate automatic sequential addresses
|
||||||
// Network is chosen randomly when not specified
|
// Network is chosen randomly when not specified
|
||||||
Network JSONIPNet
|
Network JSONIPNet
|
||||||
IP net.IP
|
net.IP
|
||||||
DNS net.IP
|
DNS net.IP
|
||||||
Peers []PeerReport
|
Peers []PeerReport
|
||||||
}
|
}
|
||||||
@ -74,8 +74,8 @@ type PeerReport struct {
|
|||||||
// Description of what the host is and/or does
|
// Description of what the host is and/or does
|
||||||
Description string
|
Description string
|
||||||
// Internal VPN IP address. Added to AllowedIPs in server config as a /32
|
// Internal VPN IP address. Added to AllowedIPs in server config as a /32
|
||||||
IP net.IP
|
net.IP
|
||||||
Status Status
|
Status
|
||||||
// TODO ExternalIP support (Endpoint)
|
// TODO ExternalIP support (Endpoint)
|
||||||
//ExternalIP net.UDPAddr `validate:"required,udp4_addr"`
|
//ExternalIP net.UDPAddr `validate:"required,udp4_addr"`
|
||||||
// TODO support routing additional networks (AllowedIPs)
|
// TODO support routing additional networks (AllowedIPs)
|
||||||
|
Loading…
Reference in New Issue
Block a user