mirror of
https://github.com/ngoduykhanh/wireguard-ui.git
synced 2025-04-21 20:12:33 +03:00
Added option to publish forwarded port to clients.
This commit is contained in:
parent
024aadbfd2
commit
3e1210ba9d
1 changed files with 13 additions and 1 deletions
14
util/util.go
14
util/util.go
|
@ -6,6 +6,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"text/template"
|
"text/template"
|
||||||
"time"
|
"time"
|
||||||
|
@ -27,7 +28,18 @@ func BuildClientConfig(client model.Client, server model.Server, setting model.G
|
||||||
peerPublicKey := fmt.Sprintf("PublicKey = %s", server.KeyPair.PublicKey)
|
peerPublicKey := fmt.Sprintf("PublicKey = %s", server.KeyPair.PublicKey)
|
||||||
peerPresharedKey := fmt.Sprintf("PresharedKey = %s", client.PresharedKey)
|
peerPresharedKey := fmt.Sprintf("PresharedKey = %s", client.PresharedKey)
|
||||||
peerAllowedIPs := fmt.Sprintf("AllowedIPs = %s", strings.Join(client.AllowedIPs, ","))
|
peerAllowedIPs := fmt.Sprintf("AllowedIPs = %s", strings.Join(client.AllowedIPs, ","))
|
||||||
peerEndpoint := fmt.Sprintf("Endpoint = %s:%d", setting.EndpointAddress, server.Interface.ListenPort)
|
|
||||||
|
desiredHost := setting.EndpointAddress
|
||||||
|
desiredPort := server.Interface.ListenPort
|
||||||
|
if strings.Contains(desiredHost, ":") {
|
||||||
|
split := strings.Split(desiredHost, ":")
|
||||||
|
desiredHost = split[0]
|
||||||
|
if n, err := strconv.Atoi(split[1]); err == nil {
|
||||||
|
desiredPort = n
|
||||||
|
}
|
||||||
|
}
|
||||||
|
peerEndpoint := fmt.Sprintf("Endpoint = %s:%d", desiredHost, desiredPort)
|
||||||
|
|
||||||
peerPersistentKeepalive := fmt.Sprintf("PersistentKeepalive = %d", setting.PersistentKeepalive)
|
peerPersistentKeepalive := fmt.Sprintf("PersistentKeepalive = %d", setting.PersistentKeepalive)
|
||||||
|
|
||||||
// build the config as string
|
// build the config as string
|
||||||
|
|
Loading…
Add table
Reference in a new issue