go fmt
This commit is contained in:
parent
12e8158725
commit
2fcda8b90a
10
add.go
10
add.go
@ -1,6 +1,6 @@
|
|||||||
package dsnet
|
package dsnet
|
||||||
|
|
||||||
func Add(hostname string, owner string, description string) {//, publicKey string) {
|
func Add(hostname string, owner string, description string) { //, publicKey string) {
|
||||||
conf := MustLoadDsnetConfig()
|
conf := MustLoadDsnetConfig()
|
||||||
|
|
||||||
privateKey := GenerateJSONPrivateKey()
|
privateKey := GenerateJSONPrivateKey()
|
||||||
@ -12,10 +12,10 @@ func Add(hostname string, owner string, description string) {//, publicKey strin
|
|||||||
check(err)
|
check(err)
|
||||||
|
|
||||||
peer := PeerConfig{
|
peer := PeerConfig{
|
||||||
Owner: owner,
|
Owner: owner,
|
||||||
Hostname: hostname,
|
Hostname: hostname,
|
||||||
Description: description,
|
Description: description,
|
||||||
PublicKey: publicKey,
|
PublicKey: publicKey,
|
||||||
PresharedKey: presharedKey,
|
PresharedKey: presharedKey,
|
||||||
// TODO Endpoint:
|
// TODO Endpoint:
|
||||||
// TODO pick an available IP AllowedIPs
|
// TODO pick an available IP AllowedIPs
|
||||||
|
8
types.go
8
types.go
@ -2,12 +2,12 @@ package dsnet
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net"
|
"net"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
"fmt"
|
|
||||||
"errors"
|
|
||||||
|
|
||||||
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
|
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
|
||||||
)
|
)
|
||||||
@ -100,8 +100,8 @@ func (conf DsnetConfig) ChooseIP() (net.IP, error) {
|
|||||||
network := conf.Network.IPNet
|
network := conf.Network.IPNet
|
||||||
ones, bits := network.Mask.Size()
|
ones, bits := network.Mask.Size()
|
||||||
zeros := bits - ones
|
zeros := bits - ones
|
||||||
min := 1 // avoids network addr
|
min := 1 // avoids network addr
|
||||||
max := (1 << zeros) -2 // avoids broadcast addr + overflow
|
max := (1 << zeros) - 2 // avoids broadcast addr + overflow
|
||||||
|
|
||||||
for i := min; i <= max; i++ {
|
for i := min; i <= max; i++ {
|
||||||
IP := make(net.IP, len(network.IP))
|
IP := make(net.IP, len(network.IP))
|
||||||
|
Loading…
Reference in New Issue
Block a user