separate internal/external IP
This commit is contained in:
parent
e02a1552e9
commit
c4cb15c45e
1
add.go
1
add.go
@ -33,7 +33,6 @@ func Add(hostname string, owner string, description string) { //, publicKey stri
|
|||||||
conf.MustSave()
|
conf.MustSave()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func GetPeerWgQuickConf(peer PeerConfig, privKey JSONKey) string {
|
func GetPeerWgQuickConf(peer PeerConfig, privKey JSONKey) string {
|
||||||
return `[Interface]
|
return `[Interface]
|
||||||
Address = 10.50.60.2/24
|
Address = 10.50.60.2/24
|
||||||
|
4
init.go
4
init.go
@ -22,8 +22,8 @@ func Init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
IP := conf.MustAllocateIP()
|
IP := conf.MustAllocateIP()
|
||||||
conf.IP = IP
|
conf.InternalIP = IP
|
||||||
conf.DNS = IP
|
conf.InternalDNS = IP
|
||||||
|
|
||||||
conf.MustSave()
|
conf.MustSave()
|
||||||
|
|
||||||
|
11
types.go
11
types.go
@ -55,9 +55,10 @@ 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,cidr"`
|
ExternalIP net.IP `validate:"required,cidr"`
|
||||||
Port int `validate:"gte=1024,lte=65535"`
|
ExternalPort int `validate:"gte=1024,lte=65535"`
|
||||||
DNS net.IP `validate:"required,cidr"`
|
InternalIP net.IP `validate:"required,cidr"`
|
||||||
|
InternalDNS net.IP `validate:"required,cidr"`
|
||||||
// TODO Default subnets to route via VPN
|
// TODO Default subnets to route via VPN
|
||||||
ReportFile string `validate:"required"`
|
ReportFile string `validate:"required"`
|
||||||
PrivateKey JSONKey `validate:"required,len=44"`
|
PrivateKey JSONKey `validate:"required,len=44"`
|
||||||
@ -99,7 +100,7 @@ func (conf *DsnetConfig) MustAddPeer(peer PeerConfig) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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.InternalIP) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,7 +133,7 @@ func (conf DsnetConfig) MustAllocateIP() net.IP {
|
|||||||
IP[j] = IP[j] | byte(i>>shift)
|
IP[j] = IP[j] | byte(i>>shift)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ! conf.IPAllocated(IP) {
|
if !conf.IPAllocated(IP) {
|
||||||
return IP
|
return IP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user