[GH-ISSUE #1282] NameServerConfig and Protocol serde serialization options #643

Closed
opened 2026-03-15 23:36:03 +03:00 by kerem · 1 comment
Owner

Originally created by @zonyitoo on GitHub (Nov 11, 2020).
Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/1282

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

NameServerConfig is now consist of 3 mandatory fields, if we deserialize it from JSON, it will look like:

{
    "socket_addr": "8.8.8.8:53",
    "protocol": "Tcp",
    "trust_nx_responses": false
}

It would be a lot nicer that Tcp could be represented as tcp, and trust_nx_responses become an optional field (default false.

Describe the solution you'd like

For NameServerConfig:

pub struct NameServerConfig {
    // Set default value to this field if it doesn't include in input
    #[cfg_attr(feature = "serde-config", serde(default))]
    pub trust_nx_responses: bool,
}

For Protocol:

pub enum Protocol {
    #[cfg_attr(feature = "serde-config", serde(alias = "udp", alias = "UDP"))]
    Udp,

    #[cfg_attr(feature = "serde-config", serde(alias = "tcp", alias = "TCP"))]
    Tcp,

    // ... And so on...
}

I could make a PR for this if it is Ok.

Originally created by @zonyitoo on GitHub (Nov 11, 2020). Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/1282 **Is your feature request related to a problem? Please describe.** `NameServerConfig` is now consist of 3 mandatory fields, if we deserialize it from JSON, it will look like: ```json { "socket_addr": "8.8.8.8:53", "protocol": "Tcp", "trust_nx_responses": false } ``` It would be a lot nicer that `Tcp` could be represented as `tcp`, and `trust_nx_responses` become an optional field (default `false`. **Describe the solution you'd like** For `NameServerConfig`: ```rust pub struct NameServerConfig { // Set default value to this field if it doesn't include in input #[cfg_attr(feature = "serde-config", serde(default))] pub trust_nx_responses: bool, } ``` For `Protocol`: ```rust pub enum Protocol { #[cfg_attr(feature = "serde-config", serde(alias = "udp", alias = "UDP"))] Udp, #[cfg_attr(feature = "serde-config", serde(alias = "tcp", alias = "TCP"))] Tcp, // ... And so on... } ``` I could make a PR for this if it is Ok.
kerem closed this issue 2026-03-15 23:36:09 +03:00
Author
Owner

@bluejekyll commented on GitHub (Nov 11, 2020):

That sounds great. Feel free.

<!-- gh-comment-id:725537194 --> @bluejekyll commented on GitHub (Nov 11, 2020): That sounds great. Feel free.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hickory-dns#643
No description provided.