Giter Club home page Giter Club logo

Comments (7)

vertexclique avatar vertexclique commented on June 1, 2024

@mfontanini

from libtins.

mfontanini avatar mfontanini commented on June 1, 2024

SOA records are not parsed, but you should still be able to perform a record.data() and get the binary representation of the data. Is this giving you wrong results?

from libtins.

vertexclique avatar vertexclique commented on June 1, 2024

I am trying to craft and i cannot craft because of that reasons… many libraries implemented this also inplemented in programming language level…


Mahmut Bulut

On 20 Jan 2015, at 21:54, Matias Fontanini [email protected] wrote:

SOA records are not parsed, but you should still be able to perform a record.data() and get the binary representation of the data. Is this giving you wrong results?


Reply to this email directly or view it on GitHub.

from libtins.

mfontanini avatar mfontanini commented on June 1, 2024

Yes, this should be implemented. I'll add this when I have some time.

Sorry for the inconvenience

On Tue, Jan 20, 2015 at 3:17 PM, Mahmut Bulut [email protected]
wrote:

I am trying to craft and i cannot craft because of that reasons… many
libraries implemented this also inplemented in programming language level…


Mahmut Bulut

On 20 Jan 2015, at 21:54, Matias Fontanini [email protected]
wrote:

SOA records are not parsed, but you should still be able to perform a
record.data() and get the binary representation of the data. Is this giving
you wrong results?


Reply to this email directly or view it on GitHub.


Reply to this email directly or view it on GitHub
#48 (comment).

from libtins.

roee88 avatar roee88 commented on June 1, 2024

I needed the same earlier today and wrote this code to encode strings like "ns.example.com. hostmaster.example.com. 2003080800 1d 15m 3w 2h". The encoded string can be passed to libtins in the resource record. Works well for my needs.

int parse_time(std::string time_str)
{
    static std::map<char, int> secs { {'s', 1}, { 'm', 60 }, { 'h',3600 }, { 'd',86400 }, { 'w',604800 }};

    char unit = ::tolower(time_str.back());
    if (secs.find(unit) != secs.end())
    {
        time_str.erase(time_str.end() - 1);
        return std::stoi(time_str) * secs[unit];
    }
    return std::stoi(time_str);
}

string encode_soa_data(const string& soa_string)
{
    byte_array bytes;
    std::istringstream iss(soa_string);
    std::string value;

    // add mname and rname
    for (int i = 0; i < 2; ++i)
    {
        iss >> value;
        if (value.back() == '.')
            value.erase(value.end() - 1);

        std::string encoded_value = DNS::encode_domain_name(value);
        bytes.insert(bytes.end(), encoded_value.begin(), encoded_value.end());
    }
    int added = bytes.size();

    // prepare memory for time integers
    bytes.insert(bytes.end(), sizeof(uint32_t) * 5, 0);

    // add times
    for (int i = 0; i < 5; ++i)
    {
        iss >> value;
        uint32_t encoded_int = Endian::host_to_be(parse_time(value));
        std::memcpy(bytes.data() + added, &encoded_int, sizeof(uint32_t));
        added += sizeof(uint32_t);
    }

    return std::string(bytes.begin(), bytes.end());
}

from libtins.

mfontanini avatar mfontanini commented on June 1, 2024

Okay, I added this to the develop branch. Note that I also changed some names, like DNS::Query is now DNS::query, DNS::Resource is DNS::resource and DNS::query::type is not DNS::query::query_type (so it's uniform with query_class). I added a typedef so Query still exists (and type() also), but they're both deprecated, so you will probably get some warnings from your compiler.

See the DNS::soa_record in dns.h to read the documentation on it.

from libtins.

vertexclique avatar vertexclique commented on June 1, 2024

@mfontanini nice to hear that, thanks

from libtins.

Related Issues (20)

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.