aboutsummaryrefslogtreecommitdiff
path: root/services/dns/records.go
diff options
context:
space:
mode:
Diffstat (limited to 'services/dns/records.go')
-rw-r--r--services/dns/records.go47
1 files changed, 16 insertions, 31 deletions
diff --git a/services/dns/records.go b/services/dns/records.go
index 782b943..6a66ab7 100644
--- a/services/dns/records.go
+++ b/services/dns/records.go
@@ -1,7 +1,6 @@
package dns
import (
- "fmt"
"net"
"strings"
@@ -13,13 +12,12 @@ import (
)
type RecordEntry struct {
- ID uint `json:"id"`
- Type string `json:"type"`
- Name string `json:"name"`
- Value string `json:"value"`
- TTL uint32 `json:"ttl"`
- Priority uint16 `json:"priority"`
- IsManaged bool `json:"is_managed"`
+ ID uint `json:"id"`
+ Type string `json:"type"`
+ Name string `json:"name"`
+ Value string `json:"value"`
+ TTL uint32 `json:"ttl"`
+ Priority uint16 `json:"priority"`
}
type DomainRecordsResponse struct {
@@ -44,7 +42,6 @@ type CreateRecordRequest struct {
Weight uint16 `form:"weight"`
Port uint16 `form:"port"`
Protocol string `form:"protocol"`
- PortMap int `form:"port_map"`
}
func DomainRecords(domainID uint) (*DomainRecordsResponse, *shortcuts.Error) {
@@ -71,12 +68,12 @@ func CreateRecord(request CreateRecordRequest) *shortcuts.Error {
value := strings.TrimSpace(request.Value)
ttl := request.TTL
if ttl == 0 {
- ttl = 300
+ ttl = 1
}
switch request.RecordType {
case "A":
- return createARecord(request.DomainID, name, value, ttl, request.PortMap)
+ return createARecord(request.DomainID, name, value, ttl)
case "AAAA":
return createAAAARecord(request.DomainID, name, value, ttl)
case "CNAME":
@@ -154,9 +151,6 @@ func UpdateRecord(recordType string, recordID uint, request UpdateRecordRequest)
if record == nil {
return shortcuts.ServiceError(shortcuts.NotFound, RecordNotFound)
}
- if record.IsManaged {
- return shortcuts.ServiceError(shortcuts.Forbidden, ManagedRecordUpdate)
- }
if name != "" {
record.Name = name
}
@@ -247,9 +241,6 @@ func DeleteRecord(recordType string, recordID uint) *shortcuts.Error {
if record == nil {
return shortcuts.ServiceError(shortcuts.NotFound, RecordNotFound)
}
- if record.IsManaged {
- return shortcuts.ServiceError(shortcuts.Forbidden, ManagedRecordLocked)
- }
if deleteError := dnsRepo.DeleteMXRecord(record); deleteError != nil {
return shortcuts.ServiceError(shortcuts.Internal, RecordDeletionFailed)
}
@@ -283,15 +274,11 @@ func collectAllRecords(domainID uint) []RecordEntry {
var entries []RecordEntry
for _, record := range dnsRepo.FindARecordsByDomainID(domainID) {
- value := record.Address
- if record.Port > 0 {
- value = fmt.Sprintf("%s (port %d)", record.Address, record.Port)
- }
entries = append(entries, RecordEntry{
ID: record.ID,
Type: "A",
Name: record.Name,
- Value: value,
+ Value: record.Address,
TTL: record.TTL,
})
}
@@ -318,13 +305,12 @@ func collectAllRecords(domainID uint) []RecordEntry {
for _, record := range dnsRepo.FindMXRecordsByDomainID(domainID) {
entries = append(entries, RecordEntry{
- ID: record.ID,
- Type: "MX",
- Name: record.Name,
- Value: record.Target,
- TTL: record.TTL,
- Priority: record.Priority,
- IsManaged: record.IsManaged,
+ ID: record.ID,
+ Type: "MX",
+ Name: record.Name,
+ Value: record.Target,
+ TTL: record.TTL,
+ Priority: record.Priority,
})
}
@@ -352,7 +338,7 @@ func collectAllRecords(domainID uint) []RecordEntry {
return entries
}
-func createARecord(domainID uint, name string, address string, ttl uint32, portMap int) *shortcuts.Error {
+func createARecord(domainID uint, name string, address string, ttl uint32) *shortcuts.Error {
if address == "" {
return shortcuts.ServiceError(shortcuts.BadRequest, AddressRequired)
}
@@ -370,7 +356,6 @@ func createARecord(domainID uint, name string, address string, ttl uint32, portM
DomainID: domainID,
Name: name,
Address: address,
- Port: portMap,
TTL: ttl,
}