Skip to content

Add non-Pro DNS management API#19

Merged
chiconws merged 1 commit into
devfrom
add-non-pro-dns-api
May 17, 2026
Merged

Add non-Pro DNS management API#19
chiconws merged 1 commit into
devfrom
add-non-pro-dns-api

Conversation

@chiconws
Copy link
Copy Markdown
Collaborator

Summary

Adds client support for NanoKVM 2.4.1 non-Pro DNS management APIs.

This covers the upstream DNS endpoints added to Network settings:

  • GET /network/dns
  • POST /network/dns

Details

  • Adds non-Pro DNS models:
    • DNSMode
    • DNSInfo
    • GetDNSRsp
    • SetDNSReq
  • Adds NanoKVMClient.get_dns().
  • Adds NanoKVMClient.set_dns(mode, servers=None).
  • Restricts both methods to non-Pro hardware.
  • Gates both methods behind non_pro="2.4.1" using the application-version guard.
  • Supports source-compatible string modes like set_dns("dhcp").
  • Sends DHCP mode as {"mode": "dhcp", "servers": []} when servers are omitted.
  • Leaves DNS server validation to the NanoKVM device, matching upstream behavior.

get_dns() Example Response

GetDNSRsp(
    mode=DNSMode.MANUAL,
    servers=["1.1.1.1", "2606:4700:4700::1111"],
    effective=["1.1.1.1"],
    dhcp=["192.168.1.1"],
    info=DNSInfo(
        interface="eth0",
        type="Wired",
        address="192.168.1.20/24",
        subnet_mask="255.255.255.0",
        gateway="192.168.1.1",
        search_domains=["lan"],
    ),
)

set_dns() Example Response

set_dns() returns None on success.

Example manual DNS call:

await client.set_dns(DNSMode.MANUAL, ["1.1.1.1", "8.8.8.8"])

Request JSON sent to NanoKVM:

{
  "mode": "manual",
  "servers": ["1.1.1.1", "8.8.8.8"]
}

Successful upstream response envelope:

{
  "code": 0,
  "msg": "success",
  "data": null
}

Example DHCP DNS call:

await client.set_dns("dhcp")

Request JSON sent to NanoKVM:

{
  "mode": "dhcp",
  "servers": []
}

Compatibility Notes

This is additive for supported non-Pro devices.

On unsupported hardware or older firmware, the client raises NanoKVMNotSupportedError before calling the DNS endpoint. This avoids exposing lower-level HTTP/API errors for endpoints that are known not to exist.

NanoKVM-Pro was tested directly and returned HTTP 404 Not Found for GET /network/dns, so these methods remain non-Pro-only.

Validation

Live device validation was previously performed against a NanoKVM PCIe device on application 2.4.1, including manual DNS mode and restoring DHCP afterward.

@chiconws chiconws merged commit 81592ee into dev May 17, 2026
2 checks passed
@chiconws chiconws deleted the add-non-pro-dns-api branch May 18, 2026 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant