Git Product home page Git Product logo

Comments (8)

rthalley avatar rthalley commented on July 24, 2024

On Apr 2, 2014, at 20:03, hanbaga [email protected] wrote:

ttl is the _MasterReader 's attribute.
but how can I get it.

What are you trying to do? "default TTL" is meaningful only when reading a masterfile, and is set with a $TTL statement in the masterfile.

/Bob

from dnspython.

hanbaga avatar hanbaga commented on July 24, 2024

I want to parse a zone file, and want to know everything of the zone file.

from dnspython.

rthalley avatar rthalley commented on July 24, 2024

On Apr 2, 2014, at 20:42, hanbaga [email protected] wrote:

I want to parse a zone file, and want to know everything of the zone file.

After you parse the zone file, all rdatasets in the zone will have TTLs. There is no meaning to "default TTL" once the masterfile has been read.

/Bob

from dnspython.

spacekpe avatar spacekpe commented on July 24, 2024

Another problem is that you can have multiple $TTL values in one master file. What value should be returned as "default"?

However I can see hanbaga's point. I personally do zone file -> LDIF conversions and I will have to solve the same problem in future.

Bob, would you accept a patch adding "default_ttl" attribute to the Zone class?

I would initialize it to None and fill it with an value only if zone file contained $TTL directives with the same value (and set None otherwise). It seems like pretty straightforward patch. I think I can write it...

from dnspython.

rthalley avatar rthalley commented on July 24, 2024

On Apr 4, 2014, at 11:35, spacekpe [email protected] wrote:

Another problem is that you can have multiple $TTL values in one master file. What value should be returned as "default"?

However I can see hanbaga's point. I personally do zone file -> LDIF conversions and I will have to solve the same problem in future.

Bob, would you accept a patch adding "default_ttl" attribute to the Zone class?

I would initialize it to None and fill it with an value only if zone file contained $TTL directives with the same value (and set None otherwise). It seems like pretty straightforward patch. I think I can write it..

I've got some issues with it.

As you said, there can be multiple $TTL values in masterfiles, why is one of them "the default TTL" and the others forgotten?

What are you going to do with this information? Use it when adding new RRs to the zone?

I wouldn't recommend using such a value for generating masterfiles as it can cause a subtle problem. Consider:

masterfile 1

$TTL 30
a 30 in a 10.0.0.1
b in a 10.0.0.2

In this masterfile, 'a' has been explicitly given a TTL of 30, and 'b' is given the default TTL (at the time!) which happens to be 30. If we used this "default TTL" value to regenerate the masterfile we'd get

masterfile 2

$TTL 30
a in a 10.0.0.1
b in a 10.0.0.2

which is subtly different. In the first file if someone changes $TTL to 300, then only 'b' is affected, but in the second file both 'a' and 'b' are changed. That may be OK, or it may be bad!

from dnspython.

spacekpe avatar spacekpe commented on July 24, 2024

why is one of them "the default TTL" and the others forgotten?

I propose to return default_ttl if and only if all $TTL values in a master file are equal (which typically means that there is single instance of $TTL). I would return None if multiple conflicting $TTL directives are present.

What are you going to do with this information?

As I said before, I'm converting master files from format defined in RFC 1035 to LDIF format (used for import to LDAP database).

I wouldn't recommend using such a value for generating masterfiles as it can cause a subtle problem.

I agree that it can create interesting problems. However, I'm interested only in reading.

from dnspython.

rthalley avatar rthalley commented on July 24, 2024

I'm still concerned about the default_ttl proposal as it doesn't differentiate between "I set the TTL on this record by using the value of $TTL", and "the value of the TTL on this record was explicitly specified but happens to be the same as the current value of $TTL". In the later case, when converting you will say something has the "default value", which potentially destroys information in the target format.

Nevertheless, I'll merge the fix spacekpe proposes if it gets written. I'd request that the comment on the default_ttl zone attribute carefully describes the risks.

from dnspython.

tungstencarbide avatar tungstencarbide commented on July 24, 2024

Late to the party here, but it seems as though even the current way it's handled some information is lost about the zone "as-written" even though all the "as-it-functions" information is preserved (obviously the most important part). For a given record, was that the TTL assigned to it, or was it from a previous $TTL directive?

Perhaps each record in in a record set can be marked with "ttl" as it is now (the "effective" TTL), and then the "default_ttl" and the "specified_ttl" if you're interested in the "as-written" information. Still not the whole "as-written" picture, but perhaps more than was captured previously. Perhaps the default_ttl could even be a simple object instead of just the int value so that individual records could be tied back to the actual $TTL directive that commanded them and perhaps be changed as a group. Still might not even capture the whole intent of a given zone file, but theres only so much we can do given the limitations of $TTL as descriptor of the "why".

I'll give it consideration and maybe when I'm done with my current push at work circle around to this.

from dnspython.

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.