From 68c45585b40011889ba71647aa283fb1e8d91f96 Mon Sep 17 00:00:00 2001 From: Elizabeth Date: Fri, 12 Apr 2024 11:26:27 -0600 Subject: [PATCH] add .int to user-owned domains, allow internal records to have suffixes like .int --- api/dns/dns.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/api/dns/dns.go b/api/dns/dns.go index 6357dfc..35738aa 100644 --- a/api/dns/dns.go +++ b/api/dns/dns.go @@ -16,7 +16,7 @@ import ( const MaxUserRecords = 100 -var UserOwnedInternalFmtDomains = []string{"%s", "%s.endpoints"} +var UserOwnedInternalFmtDomains = []string{"%s", "%s.int", "%s.endpoints", "%s.", "%s.endpoints.", "%s.int."} func ListDNSRecordsContinuation(context *types.RequestContext, req *http.Request, resp http.ResponseWriter) types.ContinuationChain { return func(success types.Continuation, failure types.Continuation) types.ContinuationChain { @@ -163,15 +163,16 @@ func userCanFuckWithDNSRecord(dbConn *sql.DB, user *database.User, record *datab return false } - if !record.Internal { - for _, format := range ownedInternalDomainFormats { - domain := fmt.Sprintf(format, user.Username) + for _, format := range ownedInternalDomainFormats { + domain := fmt.Sprintf(format, user.Username) - isInSubDomain := strings.HasSuffix(record.Name, "."+domain) - if domain == record.Name || isInSubDomain { - return true - } + isInSubDomain := strings.HasSuffix(record.Name, "."+domain) + if domain == record.Name || isInSubDomain { + return true } + } + + if !record.Internal { return false } @@ -181,6 +182,5 @@ func userCanFuckWithDNSRecord(dbConn *sql.DB, user *database.User, record *datab return false } - userIsOwnerOfDomain := owner == user.ID - return ownedByUser && userIsOwnerOfDomain + return owner == user.ID }