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

Add libp2p-mdns #590

Merged
merged 20 commits into from
Nov 24, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use append_u16
  • Loading branch information
tomaka committed Nov 2, 2018
commit ff9b1c36d14d76f1d37fb0a748e6ce45d2abc30f
12 changes: 4 additions & 8 deletions misc/mdns/src/dns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,8 @@ pub fn build_query_response(
append_qname(&mut out, SERVICE_NAME);

// Flags.
out.push(0x00);
out.push(0x0c); // PTR record.
out.push(0x80);
out.push(0x01);
append_u16(&mut out, 0x000c);
append_u16(&mut out, 0x8001);
Copy link
Contributor

Choose a reason for hiding this comment

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

IIUC this sets the flush-cache bit saying that this record is the sole truth. I guess this implies that this responder owns the name and no other responder is expected to answer that query.

Copy link
Member Author

Choose a reason for hiding this comment

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

If I set this to 0x8000, then the dnsparser crate is incapable of parsing the response w generate. Not sure why.

Copy link
Contributor

Choose a reason for hiding this comment

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

Without the flush-cache-bit you would use 1 (internet class).

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, ok!


// TTL for the answer
append_u32(&mut out, ttl);
Expand Down Expand Up @@ -171,10 +169,8 @@ pub fn build_service_discovery_response(id: u16, ttl: Duration) -> Vec<u8> {
append_qname(&mut out, META_QUERY_SERVICE);

// Flags.
out.push(0x00);
out.push(0x0c); // PTR record requested.
out.push(0x80);
out.push(0x01);
append_u16(&mut out, 0x000c);
append_u16(&mut out, 0x8001);

// TTL for the answer
append_u32(&mut out, ttl);
Expand Down