Merge branch 'develop' into NET-1994

This commit is contained in:
Abhishek K 2025-06-23 17:50:21 +05:30 committed by GitHub
commit 0a47cc5461
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 24 additions and 4 deletions

View file

@ -308,6 +308,7 @@ func updateHost(w http.ResponseWriter, r *http.Request) {
}
}
}()
logic.LogEvent(&models.Event{
Action: models.Update,
Source: models.Subject{

View file

@ -178,7 +178,7 @@ func Authorize(
// check if host instead of user
if hostAllowed {
// TODO --- should ensure that node is only operating on itself
if hostID, macAddr, _, err := logic.VerifyHostToken(authToken); err == nil && macAddr != "" {
if hostID, _, _, err := logic.VerifyHostToken(authToken); err == nil {
r.Header.Set(hostIDHeader, hostID)
// this indicates request is from a node
// used for failover - if a getNode comes from node, this will trigger a metrics wipe

View file

@ -193,7 +193,8 @@ func GetPeerUpdateForHost(network string, host *models.Host, allNodes []models.N
continue
}
if !node.Connected || node.PendingDelete || node.Action == models.NODE_DELETE || time.Since(node.LastCheckIn) > time.Hour {
if !node.Connected || node.PendingDelete || node.Action == models.NODE_DELETE ||
(!node.LastCheckIn.IsZero() && time.Since(node.LastCheckIn) > time.Hour) {
continue
}
acls, _ := ListAclsByNetwork(models.NetworkID(node.Network))

View file

@ -592,7 +592,7 @@ func settings() {
}
settings := logic.GetServerSettings()
if settings.AuditLogsRetentionPeriodInDays == 0 {
settings.AuditLogsRetentionPeriodInDays = 30
settings.AuditLogsRetentionPeriodInDays = 7
}
if settings.DefaultDomain == "" {
settings.DefaultDomain = servercfg.GetDefaultDomain()

View file

@ -98,7 +98,7 @@ var oauthNotConfigured = fmt.Sprintf(htmlBaseTemplate, `<h2>Your Netmaker server
var oauthStateInvalid = fmt.Sprintf(htmlBaseTemplate, `<h2>Invalid OAuth Session. Please re-try again.</h2>`)
var userNotAllowed = fmt.Sprintf(htmlBaseTemplate, `<h2>Your account does not have access to the dashboard. Please contact your administrator for more information about your account.</h2>
<p>Non-Admins can access the netmaker networks using <a href="https://docs.netmaker.io/docs/remote-access-client-rac#downloadinstallation" target="_blank" rel="noopener">our Netmaker Desktop App.</a></p>`)
<p>Non-Admins can access the netmaker networks using <a href="https://docs.netmaker.io/docs/client-installation/netmaker-desktop#downloadinstallation" target="_blank" rel="noopener">our Netmaker Desktop App.</a></p>`)
var userFirstTimeSignUp = fmt.Sprintf(htmlBaseTemplate, `<h2>Thank you for signing up. Please contact your administrator for access.</h2>`)

View file

@ -1304,6 +1304,12 @@ func getUserRemoteAccessGwsV1(w http.ResponseWriter, r *http.Request) {
if extClient.DNS == "" {
extClient.DNS = node.IngressDNS
}
extClient.IngressGatewayEndpoint = utils.GetExtClientEndpoint(
host.EndpointIP,
host.EndpointIPv6,
logic.GetPeerListenPort(host),
)
extClient.AllowedIPs = logic.GetExtclientAllowedIPs(extClient)
gws = append(gws, models.UserRemoteGws{
GwID: node.ID.String(),

View file

@ -191,6 +191,7 @@ func GetFailOverPeerIps(peer, node *models.Node) []net.IPNet {
if failOverpeer.IsRelay {
for _, id := range failOverpeer.RelayedNodes {
rNode, _ := logic.GetNodeByID(id)
logic.GetNodeEgressInfo(&rNode, eli, acls)
if rNode.Address.IP != nil {
allowed := net.IPNet{
IP: rNode.Address.IP,

View file

@ -1,7 +1,9 @@
package utils
import (
"fmt"
"log/slog"
"net"
"runtime"
"strings"
"time"
@ -75,3 +77,12 @@ func NoEmptyStringToCsv(strs ...string) string {
}
return sb.String()
}
// GetExtClientEndpoint returns the external client endpoint in the format "host:port" or "[host]:port" for IPv6
func GetExtClientEndpoint(hostIpv4Endpoint, hostIpv6Endpoint net.IP, hostListenPort int) string {
if hostIpv4Endpoint.To4() == nil {
return fmt.Sprintf("[%s]:%d", hostIpv6Endpoint.String(), hostListenPort)
} else {
return fmt.Sprintf("%s:%d", hostIpv4Endpoint.String(), hostListenPort)
}
}