Coder Social home page Coder Social logo

dns's Introduction

DNS Record Types

A Swift implementation of DNS Record Types. Used for example in mDNS / NetService.

Build Status

Usage

// Encoding a message
let request = Message(
    type: .query,
    questions: [Question(name: "apple.com.", type: .pointer)]
)
let requestData = try request.serialize()

// Not shown here: send to DNS server over UDP, receive reply.

// Decoding a message
let responseData = Data()
let response = try Message.init(deserialize: responseData)
print(response.answers.first)

Credits

This library was written by Bouke Haarsma.

dns's People

Contributors

bouke avatar krivoblotsky avatar mcfedr avatar selcuk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

dns's Issues

Support truncation

UDP DNS messages are limited to 512 bytes. If messages are over 512 bytes, the message is cut-off at 512 bytes and the truncation bit is set. Currently the bit is parsed, but the message isn't handled differently, resulting in a parsing failure. The correct way here would be parsing only a partial message without throwing.

The other way around should also be supported, cutting off messages when truncation is supported.

Also, I need to read up on the spec to see how truncation actually works.

Is it okay that fuzz tests fail?

Hi. I enabled the fuzz tests and swift test always crashes. Is this okay (like, the library should fail when Message(deserialize: data) finds that data is corrupted), or is it a bug?

I'm on Linux, Swift 4.1

Unicode Support

Hi!

I'm using DNS as a dependency of HAP in a Linux box. I'm getting error logs when replying to DNS Messages because of unicode encoding not supported. Nearly all of my members of my family have accents on their names, so their iDevices, shared libraries, and even some rooms, like "baño" have them...

Is unicode not supported by design or is it simply not implemented? If you can give me some pointers maybe I can try to fix it.

Thanks in advance!

Unable to Use Libary

Hello Everyone,
I am unable to use this library. would be great to get some help.

I found out, that what I need to use is resolving a DNS SRV Records.
so what I did was using the

func testReadMe() throws {
    // If the code below doesn't work, also update the README.md to
    // demonstrate the changes in the API.
    let request = Message(
        type: .query,
        questions: [Question(name: "_sip._tls", type: .service)]  //Changed this to Service
    )
    let requestData = try request.serialize()

    // Not shown here: send to DNS server over UDP, receive reply.
    let responseData = requestData

    // Decoding a message
    let response = try Message(deserialize: responseData)
    print(response.answers.first ?? "No answers")
}
  1. This is not using the DNS Search List, as far as I can see
  2. This is not Returning any result.

What is wrong here?

Error found during fuzzing

The following message could not be deserialized:

000084000001000200000002085f61692e706c6179045f746370065f6c6f63616c00000c0001c00c000c0001000000780013076578616d706c65085f616972706c6179c015c03200210001000000780015000000001b58076578616d706c65056c6f63616c00c057000100010000007800040a000102c00c000c000100000078000c0b68656c6c6f3d776f726c64

Xcode reports INVOP in Bytes.swift:25 (let step = data[position]).

Wrong IP address decoding

Environment:
SPM.
Package version 1.2.0
macOS 10.15.6.

When I use DNS messages with debug configuration everything looks good, but once I switch to release, IP addresses could not be parsed:

Release build:

Request: DNS Request(id: 0, authoritativeAnswer: true, truncation: false, recursionDesired: true, recursionAvailable: false, questions: [DNS.Question(name: "amazon.com", type: A, unique: true, internetClass: A)], answers: [], authorities: [], additional: [])
Response: DNS Response(id: 0, returnCode: 0, authoritativeAnswer: false, truncation: false, recursionDesired: true, recursionAvailable: true, questions: [DNS.Question(name: "amazon.com.", type: A, unique: false, internetClass: A)], answers: [DNS.HostRecord<DNS.IPv4>(name: "amazon.com.", unique: false, internetClass: A, ttl: 31, ip: �[�ޭ�), DNS.HostRecord<DNS.IPv4>(name: "amazon.com.", unique: false, internetClass: A, ttl: 31, ip: �[�ޭ�), DNS.HostRecord<DNS.IPv4>(name: "amazon.com.", unique: false, internetClass: A, ttl: 31, ip: �[�ޭ�)], authorities: [], additional: [])

Debug build:

Request: DNS Request(id: 0, authoritativeAnswer: true, truncation: false, recursionDesired: true, recursionAvailable: false, questions: [DNS.Question(name: "amazon.com", type: A, unique: true, internetClass: A)], answers: [], authorities: [], additional: [])
Response: DNS Response(id: 0, returnCode: 0, authoritativeAnswer: false, truncation: false, recursionDesired: true, recursionAvailable: true, questions: [DNS.Question(name: "amazon.com.", type: A, unique: false, internetClass: A)], answers: [DNS.HostRecord<DNS.IPv4>(name: "amazon.com.", unique: false, internetClass: A, ttl: 55, ip: 176.32.103.205), DNS.HostRecord<DNS.IPv4>(name: "amazon.com.", unique: false, internetClass: A, ttl: 55, ip: 176.32.98.166), DNS.HostRecord<DNS.IPv4>(name: "amazon.com.", unique: false, internetClass: A, ttl: 55, ip: 205.251.242.103)], authorities: [], additional: [])

I need some tome to investigate it more and get the real cause, but as far as I can see now, this this PR https://github.com/Bouke/DNS/pull/25/files fixes the problem.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.