Comments (7)
from libtins.
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.
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.
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.
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.
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.
@mfontanini nice to hear that, thanks
from libtins.
Related Issues (20)
- I get "Anonymous types declared in an anonymous union are an extension" in icmpv6.h
- Consider using modern CMake (>=3.12) with targets
- Unable to compile Libtins for AIX
- how to call the Stream::user_data() to set and get the custom data ? HOT 1
- IPv6Address::to_string() return a local address HOT 1
- Error: live packet capture not supported on this system
- libtins.so.4.5: cannot open shared object file: No such file or directory HOT 1
- libtins 4.4 conan recipe is conan2.0 incompatible HOT 1
- Multicast packet ( specifically fieldbus) is not parsed
- Tagging a new release / fixup release with GCC 13 patch HOT 1
- 'unresolved external symbol' in Visual Studio 2022 HOT 3
- add #496 in the release notes for v4.5
- Send SYN packet failed on Windows 10 HOT 8
- Any passthru example?
- [bug] UDP::matches_response() return 0 when no inner PDU is available
- How to get gateway? HOT 1
- matches_response() implementation for EthernetII / Dot3
- DataTracker::advance_sequence removes too much data
- Seeing "android ifaddr not supported" regardless of Android version HOT 1
- failures with gtest 1.13+ HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libtins.