Skip to content

Implement type-specific forms for records #742

@alehaa

Description

@alehaa

Is your feature request related to a problem? Please describe.

Currently, I use a custom plugin for managing DNS and IP blocklists. To reduce maintenance overhead and leverage existing APIs, I’d like to switch to DNS Response Policy Zones, which also cover these types of blocklists. However, this requires users to understand the semantics of policy records to implement the desired behavior of the blocklist.

Similarly, to avoid errors, users need to understand the structure of more complex DNS records, such as SRV and NAPTR.

Describe the solution you'd like

I propose providing custom forms for more complex DNS record types to help users input the correct data. Once saved, the appropriate DNS value will be generated from the form fields and stored in the database. When editing existing DNS record objects, the record value will be automatically broken down before being displayed as individual form fields.

This modification does not require any changes to the database or API. My primary intention is to implement visual changes to simplify the process.

In the first iteration I propose implementing this change for these record types:

  • CAA
  • MX
  • NAPTR
  • SRV
  • TLSA

I believe there’s more potential in this feature, which makes this feature request somewhat complex. For instance, there are various types of TXT records that require a specific structure (e.g., SPF, DMARC, or RPZ, as mentioned earlier). An abstract form model should simplify the registration of new formats, thereby reducing maintenance overhead and improving data quality. This logic should be implemented in a subsequent feature request.

Describe alternatives you've considered

One could argue whether DNS Response Policy Zones is a feature of this plugin and should be implemented elsewhere. However, since this technique heavily relies on DNS for its service, I believe it falls under the category of DNS record values like MX or SRV.

With this feature request, I intend to enhance user experience not only for implementing RPZ but also for managing various complex DNS records.

Additional context

In a proof of concept, I’ve already verified that the RecordEditView form can be dynamically selected by replacing the form attribute with a static method:

@register_model_view(Record, "add", detail=False)
@register_model_view(Record, "edit")
class RecordEditView(generic.ObjectEditView):
    queryset = Record.objects.filter(managed=False).prefetch_related(
        "zone", "ptr_record"
    )
    
    @staticmethod
    def form(instance: Record | None, *args, **kwargs):
        return RecordForm(instance=instance, *args, **kwargs)

The appropriate form should be selected based on the instance’s record type. For creating new records, a query parameter can be used instead. This parameter will be passed by a drop-down menu on the Add Record button in the zone record view. If no specific form is available, a fallback to the generic form will always be used.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions