Mikrotik improvements (#521)
Some checks failed
Docker / Build and Push (push) Has been cancelled
github-pages / deploy (push) Has been cancelled
Docker / release (push) Has been cancelled

* allow to specify ignored interfaces (#514)

* only set endpoint info for "responder" peers (#516)
This commit is contained in:
h44z
2025-09-09 21:43:16 +02:00
committed by GitHub
parent 6d2a5fa6de
commit 765fb09770
7 changed files with 125 additions and 66 deletions

View File

@@ -3,14 +3,13 @@ package wgcontroller
import (
"context"
"fmt"
"log/slog"
"slices"
"strconv"
"strings"
"sync"
"time"
"log/slog"
"github.com/h44z/wg-portal/internal/config"
"github.com/h44z/wg-portal/internal/domain"
"github.com/h44z/wg-portal/internal/lowlevel"
@@ -678,11 +677,15 @@ func (c *MikrotikController) updatePeer(
extras := pp.GetExtras().(domain.MikrotikPeerExtras)
peerId := extras.Id
endpoint := pp.Endpoint
endpointPort := "51820" // default port if not set
if s := strings.Split(endpoint, ":"); len(s) == 2 {
endpoint = s[0]
endpointPort = s[1]
endpoint := "" // by default, we have no endpoint (the peer does not initiate a connection)
endpointPort := "0" // by default, we have no endpoint port (the peer does not initiate a connection)
if !extras.IsResponder { // if the peer is not only a responder, it needs the endpoint to initiate a connection
endpoint = pp.Endpoint
endpointPort = "51820" // default port if not set
if s := strings.Split(endpoint, ":"); len(s) == 2 {
endpoint = s[0]
endpointPort = s[1]
}
}
allowedAddressStr := domain.CidrsToString(pp.AllowedIPs)