mirror of
https://github.com/gravitl/netmaker.git
synced 2025-09-14 00:54:21 +08:00
Merge branch 'develop' into NET-1994
This commit is contained in:
commit
0a47cc5461
8 changed files with 24 additions and 4 deletions
|
@ -308,6 +308,7 @@ func updateHost(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
}
|
||||
}()
|
||||
|
||||
logic.LogEvent(&models.Event{
|
||||
Action: models.Update,
|
||||
Source: models.Subject{
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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>`)
|
||||
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue