Merge pull request #3177 from gravitl/NET-1732

NET-1732: Remove setting of default dns, fix default enrollment key deletion
This commit is contained in:
Abhishek K 2024-11-04 16:01:57 +04:00 committed by GitHub
commit 3448d634fc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 26 additions and 21 deletions

View file

@ -287,22 +287,22 @@ func getExtClientConf(w http.ResponseWriter, r *http.Request) {
} else if gwnode.IngressDNS != "" { } else if gwnode.IngressDNS != "" {
defaultDNS = "DNS = " + gwnode.IngressDNS defaultDNS = "DNS = " + gwnode.IngressDNS
} }
if servercfg.GetManageDNS() { // if servercfg.GetManageDNS() {
if gwnode.Address6.IP != nil { // if gwnode.Address6.IP != nil {
if defaultDNS == "" { // if defaultDNS == "" {
defaultDNS = "DNS = " + gwnode.Address6.IP.String() // defaultDNS = "DNS = " + gwnode.Address6.IP.String()
} else { // } else {
defaultDNS = defaultDNS + ", " + gwnode.Address6.IP.String() // defaultDNS = defaultDNS + ", " + gwnode.Address6.IP.String()
} // }
} // }
if gwnode.Address.IP != nil { // if gwnode.Address.IP != nil {
if defaultDNS == "" { // if defaultDNS == "" {
defaultDNS = "DNS = " + gwnode.Address.IP.String() // defaultDNS = "DNS = " + gwnode.Address.IP.String()
} else { // } else {
defaultDNS = defaultDNS + ", " + gwnode.Address.IP.String() // defaultDNS = defaultDNS + ", " + gwnode.Address.IP.String()
} // }
} // }
} // }
defaultMTU := 1420 defaultMTU := 1420
if host.MTU != 0 { if host.MTU != 0 {

View file

@ -52,6 +52,7 @@ func CreateEnrollmentKey(uses int, expiration time.Time, networks, tags []string
Type: models.Undefined, Type: models.Undefined,
Relay: relay, Relay: relay,
Groups: groups, Groups: groups,
Default: defaultKey,
} }
if uses > 0 { if uses > 0 {
k.UsesRemaining = uses k.UsesRemaining = uses

View file

@ -423,9 +423,8 @@ func SetNodeDefaults(node *models.Node, resetConnected bool) {
} }
node.SetLastModified() node.SetLastModified()
if node.LastCheckIn.IsZero() { node.SetLastCheckIn()
node.SetLastCheckIn()
}
if resetConnected { if resetConnected {
node.SetDefaultConnected() node.SetDefaultConnected()
} }

View file

@ -43,13 +43,18 @@ func racAutoDisableHook() error {
currentTime := time.Now() currentTime := time.Now()
validityDuration := servercfg.GetJwtValidityDuration() validityDuration := servercfg.GetJwtValidityDuration()
for _, user := range users { for _, user := range users {
if user.PlatformRoleID == models.AdminRole ||
user.PlatformRoleID == models.SuperAdminRole {
continue
}
if !currentTime.After(user.LastLoginTime.Add(validityDuration)) { if !currentTime.After(user.LastLoginTime.Add(validityDuration)) {
continue continue
} }
for _, client := range clients { for _, client := range clients {
if client.RemoteAccessClientID == "" {
continue
}
if (client.OwnerID == user.UserName) && if (client.OwnerID == user.UserName) &&
user.PlatformRoleID != models.SuperAdminRole &&
user.PlatformRoleID != models.AdminRole &&
client.Enabled { client.Enabled {
slog.Info(fmt.Sprintf("disabling ext client %s for user %s due to RAC autodisabling", client.ClientID, client.OwnerID)) slog.Info(fmt.Sprintf("disabling ext client %s for user %s due to RAC autodisabling", client.ClientID, client.OwnerID))
if err := disableExtClient(&client); err != nil { if err := disableExtClient(&client); err != nil {