Skip to content

Commit 655ac56

Browse files
committed
f
Signed-off-by: Date Huang <tjjh89017@hotmail.com>
1 parent eff1539 commit 655ac56

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

internal/ctrl/establish_freebsd.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,18 @@ import (
66
"context"
77
"encoding/base64"
88
"os/exec"
9+
"strconv"
910

1011
"github.com/tjjh89017/stunmesh-go/internal/entity"
1112
)
1213

1314
func (c *EstablishController) ConfigureDevice(ctx context.Context, peer *entity.Peer, res *EndpointDecryptResponse) error {
14-
c.logger.Debug().Str("peer", peer.LocalId()).Str("remote", res.Host+":"+string(res.Port)).Msg("configuring device for peer")
15+
remoteEndpoint := res.Host + ":" + strconv.FormatInt(int64(res.Port), 10)
16+
c.logger.Debug().Str("peer", peer.LocalId()).Str("remote", remoteEndpoint).Msg("configuring device for peer")
1517

1618
var publicKeyArray [32]byte = peer.PublicKey()
1719
publicKey := base64.StdEncoding.EncodeToString(publicKeyArray[:])
18-
r, err := exec.Command("wg", "set", peer.DeviceName(), "peer", publicKey, "endpoint", res.Host+":"+string(res.Port)).Output()
20+
r, err := exec.Command("wg", "set", peer.DeviceName(), "peer", publicKey, "endpoint", remoteEndpoint).Output()
1921
c.logger.Debug().Str("output", string(r)).Msg("wg set command executed")
2022
return err
2123
}

0 commit comments

Comments
 (0)