This repository was archived by the owner on Feb 4, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
Initial support for SVCB/HTTPS (unfinished). #80
Draft
gjherbiet
wants to merge
1
commit into
DNS-OARC:main
Choose a base branch
from
restena:feature/svcb
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| /* | ||
| * Part of DNS zone file validator `validns`. | ||
| * | ||
| * Copyright 2011-2017 Anton Berezin <tobez@tobez.org> | ||
| * Modified BSD license. | ||
| * (See LICENSE file in the distribution.) | ||
| * | ||
| */ | ||
| #include <string.h> | ||
| #include <sys/types.h> | ||
| #include <stdio.h> | ||
| #include <netinet/in.h> | ||
| #include <arpa/inet.h> | ||
| #include <stdlib.h> | ||
|
|
||
| #include "common.h" | ||
| #include "textparse.h" | ||
| #include "mempool.h" | ||
| #include "carp.h" | ||
| #include "rr.h" | ||
|
|
||
| static struct rr* svcb_parse(char *name, long ttl, int type, char *s) | ||
| { | ||
| struct rr_svcb *rr; | ||
| int p; | ||
| char *t; | ||
| struct binary_data params[20]; | ||
| int i; | ||
|
|
||
| p = extract_integer(&s, "priority", NULL); | ||
| if (p < 0) | ||
| return NULL; | ||
| if (p > 65536) | ||
| return bitch("priority range is not valid"); | ||
|
|
||
| t = extract_name(&s, "target", 0); | ||
| if (!t) | ||
| return NULL; | ||
|
|
||
| i = 0; | ||
| while (*s) { | ||
| if (i >= 20) | ||
| return bitch("program limit: too many SVC parameters"); | ||
| params[i] = extract_text(&s, "SVC parameter"); | ||
| if (params[i].length < 0) | ||
| return NULL; | ||
| if (params[i].length > 255) | ||
| return bitch("SVC parameter too long"); | ||
| i++; | ||
| } | ||
| if (p == 0 && i > 0) { | ||
| return bitch("non-empty parameters in alias mode"); | ||
| } else if (p > 0 && i == 0) { | ||
| return bitch("empty parameters in service mode"); | ||
| } | ||
|
|
||
| rr = getmem(sizeof(*rr) + sizeof(struct binary_data) * (i-1)); | ||
|
|
||
| rr->priority = p; | ||
| rr->target = t; | ||
| rr->count = i; | ||
| for (i = 0; i < rr->count; i++) { | ||
| rr->params[i] = params[i]; | ||
| } | ||
|
|
||
| return store_record(type, name, ttl, rr); | ||
| } | ||
|
|
||
| static char* svcb_human(struct rr *rrv) | ||
| { | ||
| RRCAST(svcb); | ||
| char ss[1024]; | ||
| int i; | ||
| char *s = ss; | ||
| int l; | ||
|
|
||
| l = snprintf(ss, 1024, "%hu %s", | ||
| rr->priority, rr->target); | ||
| s += l; | ||
|
|
||
| for (i = 0; i < rr->count; i++) { | ||
| l = snprintf(s, 1024-(s-ss), " %s", rr->params[i].data); | ||
| s += l; | ||
| } | ||
|
|
||
| return quickstrdup_temp(ss); | ||
| } | ||
|
|
||
| static struct binary_data svcb_wirerdata(struct rr *rrv) | ||
| { | ||
| RRCAST(svcb); | ||
| struct binary_data r, t; | ||
| int i; | ||
| char param[255]; | ||
| char *key; | ||
| char *val; | ||
| int idx; | ||
| int port; | ||
|
|
||
| r = bad_binary_data(); | ||
| t.length = 0; | ||
| t.data = NULL; | ||
|
|
||
| for (i = 0; i < rr->count; i++) { | ||
| strcpy(param, rr->params[i].data); | ||
| key = strtok(param, "="); | ||
| val = strtok(NULL, "="); | ||
| if (strcmp(key, "port") == 0) { | ||
| idx = 3; | ||
| port = atoi(val); | ||
| r = compose_binary_data("d222", 1, t, idx, sizeof(port)/2, port); | ||
| } | ||
| t = r; | ||
| } | ||
| r = compose_binary_data("2dd", 1, rr->priority, name2wire_name(rr->target), t); | ||
| return r; | ||
| } | ||
|
|
||
| struct rr_methods svcb_methods = { svcb_parse, svcb_human, svcb_wirerdata, NULL, NULL }; | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either
p > 65535orp >= 65536would be more correct here.