Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Add SVCB record #110

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft

WIP: Add SVCB record #110

wants to merge 6 commits into from

Conversation

Ch4t4r
Copy link

@Ch4t4r Ch4t4r commented Oct 1, 2020

SVCB is a new record type currently in draft: https://tools.ietf.org/html/draft-ietf-dnsop-svcb-https-01

Support for it has already been added to Safari in iOS 14 (where it is used by default instead of A/AAAA), Cloudflare also added support for it just recently. Mozilla announced to implement it soon as well.

This PR adds the TYPE (RR type 64 according to the RFC) and the Data class for it.

Copy link
Collaborator

@Flowdalic Flowdalic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks you very much for your contribution. I've added some feedback. Could you also squash all commits into one? That would be much appreciated.

/**
* SVCB Record Type (Service binding)
*
* https://tools.ietf.org/html/draft-ietf-dnsop-svcb-httpssvc-01
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This link, and all other links in javadoc in this file, should ideally be using @see. For example in this case

* @see <a href="https://tools.ietf.org/html/draft-ietf-dnsop-svcb-https-01">draft-ietf-dnsop-svcb-https-01: Service binding and parameter specification via the DNS (DNS SVCB and HTTPS RRs)</a>

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I'm going to add it.


// The first group is the key. They key can only be a-z, 0-9 or "-"
// The second group is the value. It can be a lot of things (see https://tools.ietf.org/html/draft-ietf-dnsop-svcb-httpssvc-01#section-2.1.1)
// except for DQUOTE (hence it can be excluded from the regex-group)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: superfluous whitespace at the front

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's meant as an indent for the previous line (which would be too long as a single line)


/**
* The priority indicates the SvcRecordType.
* https://tools.ietf.org/html/draft-ietf-dnsop-svcb-httpssvc-01#section-2.4
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should use @see

/**
* SvcFieldValue
* A set of key=value pairs.
* https://tools.ietf.org/html/draft-ietf-dnsop-svcb-httpssvc-01#section-2.1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should use @see

}

/**
* Parses pairs according to format from https://tools.ietf.org/html/draft-ietf-dnsop-svcb-httpssvc-01#section-2.1.1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use @see.

while(matcher.find()) {
values.put(matcher.group(1), matcher.group(2));
}
return values;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The map should here be made immutable.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed

}

private String createValuesString() {
StringBuilder builder = new StringBuilder();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't there be some escaping for commas in this method?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like I have to update this regardless. There are two RFCs floating around for this RR and I based this on the older one. The one I linked in the PR description is the correct one.

Right now the wireformat is not valid.

@Ch4t4r Ch4t4r marked this pull request as draft October 1, 2020 10:24
@Ch4t4r
Copy link
Author

Ch4t4r commented Oct 1, 2020

I updated the PR with the comments. One thing that I think is still wrong is how the values of the key-value pairs are decoded (key decoding is fine, it's a plain UShort). According to the RFC the value is an octet String (which is why I currently simply decode with UTF-8), but the Appendix has some encoding for the value. I can't make any sense of it, but maybe you can?
I suspect the encoding is the same as in a TXT entry, but I couldn't find any conversion from String -> the encoded value, only from encoded value -> String (´getText()´ in TXT.java). With the former missing there would be no way to create a SVCB entry, only reading it from Wireformat.

@Ch4t4r
Copy link
Author

Ch4t4r commented Oct 1, 2020

I'm going to close this PR. I don't have enough knowledge about the encoding and wireformat to make this work. I published my last changes (which don't work right now).

SVCB support would be nice though, it'd be awesome if you could somehow finish this, if you've got time.

@Ch4t4r Ch4t4r closed this Oct 1, 2020
@Flowdalic Flowdalic changed the title Add SVCB record WIP: Add SVCB record Oct 2, 2020
@Flowdalic
Copy link
Collaborator

I think it is best to mark this PR as WIP and leave it open then.

@Flowdalic Flowdalic reopened this Oct 2, 2020
String blobAsString = new String(blob, StandardCharsets.UTF_8);
Matcher matcher = valuesPattern.matcher(blobAsString);
while(matcher.find()) {
values.put(matcher.group(1), matcher.group(2));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't there be some unescaping for commas in this method?

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.

2 participants