|
|
@ -6,7 +6,6 @@ package wgcfg
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
"bufio"
|
|
|
|
"bufio"
|
|
|
|
"encoding/hex"
|
|
|
|
|
|
|
|
"fmt"
|
|
|
|
"fmt"
|
|
|
|
"io"
|
|
|
|
"io"
|
|
|
|
"net"
|
|
|
|
"net"
|
|
|
@ -16,7 +15,6 @@ import (
|
|
|
|
"go4.org/mem"
|
|
|
|
"go4.org/mem"
|
|
|
|
"inet.af/netaddr"
|
|
|
|
"inet.af/netaddr"
|
|
|
|
"tailscale.com/types/key"
|
|
|
|
"tailscale.com/types/key"
|
|
|
|
"tailscale.com/types/wgkey"
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
type ParseError struct {
|
|
|
|
type ParseError struct {
|
|
|
@ -118,17 +116,6 @@ func FromUAPI(r io.Reader) (*Config, error) {
|
|
|
|
return cfg, nil
|
|
|
|
return cfg, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func parseKeyHex(s []byte, dst []byte) error {
|
|
|
|
|
|
|
|
n, err := hex.Decode(dst, s)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return &ParseError{"Invalid key: " + err.Error(), string(s)}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if n != wgkey.Size {
|
|
|
|
|
|
|
|
return &ParseError{"Keys must decode to exactly 32 bytes", string(s)}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (cfg *Config) handleDeviceLine(k, value mem.RO, valueBytes []byte) error {
|
|
|
|
func (cfg *Config) handleDeviceLine(k, value mem.RO, valueBytes []byte) error {
|
|
|
|
switch {
|
|
|
|
switch {
|
|
|
|
case k.EqualString("private_key"):
|
|
|
|
case k.EqualString("private_key"):
|
|
|
|