Add wireguard test

This commit is contained in:
yuhan6665 2024-06-01 19:34:31 -04:00
parent bbf25b14d9
commit 075051a693
2 changed files with 128 additions and 4 deletions

View file

@ -22,14 +22,14 @@ func (c *WireGuardPeerConfig) Build() (proto.Message, error) {
config := new(wireguard.PeerConfig)
if c.PublicKey != "" {
config.PublicKey, err = parseWireGuardKey(c.PublicKey)
config.PublicKey, err = ParseWireGuardKey(c.PublicKey)
if err != nil {
return nil, err
}
}
if c.PreSharedKey != "" {
config.PreSharedKey, err = parseWireGuardKey(c.PreSharedKey)
config.PreSharedKey, err = ParseWireGuardKey(c.PreSharedKey)
if err != nil {
return nil, err
}
@ -64,7 +64,7 @@ func (c *WireGuardConfig) Build() (proto.Message, error) {
config := new(wireguard.DeviceConfig)
var err error
config.SecretKey, err = parseWireGuardKey(c.SecretKey)
config.SecretKey, err = ParseWireGuardKey(c.SecretKey)
if err != nil {
return nil, err
}
@ -132,7 +132,7 @@ func (c *WireGuardConfig) Build() (proto.Message, error) {
return config, nil
}
func parseWireGuardKey(str string) (string, error) {
func ParseWireGuardKey(str string) (string, error) {
var err error
if len(str)%2 == 0 {