Giter Site home page Giter Site logo

Comments (8)

miekg avatar miekg commented on July 19, 2024

[ Quoting <reply+i-4392099-43bc40389> in "[dns] DNS Server - panic: runtime e..." ]

I'm running Go 1.0.1.

When run the "reflect" example and them I run a nmap UDP port scan (nmap -sU localhost), the following error success (complete output log):

panic: runtime error: index out of range

Thanks for your report. I believe this is fixed in the latest Git version of
dns.

grtz Miek

from dns.

h2non avatar h2non commented on July 19, 2024

Thanks Miek for your fast support!

In other context, I'm looking for an easy example for implement a DNS server parsing zones files, so I'm newbie with Go and I don't know how to use some functionalities and the API.

You can provide another easy example about how to make this?
Thanks a lot again!

from dns.

miekg avatar miekg commented on July 19, 2024

[ Quoting <reply+i-4392099-43bc40389> in "Re: [dns] DNS Server - panic: runti..." ]

Thanks Miek for your fast support!

In other context, I'm looking for an easy example for implement a DNS server
parsing zones files, so I'm newbie with Go and I don't know how to use some
functionalities and the API.

You'll need a simple server that reads and parses a single zonefile? I can make
a example for that. A more complete nameserver is more difficult as Go dns does
not has a zone structure -- I might add that, but I'm still looking for a fast
tree structure for that.

For reading zone files you can use: ParseZone and of course
ex/reflect/reflect.go is a simple nameserver in itself.

Regards,

Miek Gieben

from dns.

h2non avatar h2non commented on July 19, 2024

A basic example helps a lot!

So, I just need to insert the next code into reflec.go for implement the zone parsing?

zone := `$ORIGIN .
$TTL 3600       ; 1 hour
name                    IN SOA  a6.nstld.com. hostmaster.nic.name. (
                                203362132  ; serial
                                300        ; refresh (5 minutes)
                                300        ; retry (5 minutes)
                                1209600    ; expire (2 weeks)
                                300        ; minimum (5 minutes)
                                )
$TTL 10800      ; 3 hours
@   10800   IN  NS  @
               IN       NS      g6.nstld.com.
               7200     NS      h6.nstld.com.
             3600 IN    NS      j6.nstld.com.
             IN 3600    NS      k6.nstld.com.
                        NS      l6.nstld.com.
                        NS      a6.nstld.com.
                        NS      c6.nstld.com.
                        NS      d6.nstld.com.
                        NS      f6.nstld.com.
                        NS      m6.nstld.com.
$ORIGIN name.
0-0onlus                NS      ns7.ehiweb.it.
                        NS      ns8.ehiweb.it.
0-g                     MX      10 mx01.nic
                        MX      10 mx02.nic
                        MX      10 mx03.nic
                        MX      10 mx04.nic
                        TXT     "10 mx\"04.nic"
$ORIGIN 0-g.name
moutamassey             NS      ns01.yahoodomains.jp.
                        NS      ns02.yahoodomains.jp.
`
to := ParseZone(strings.NewReader(zone), "", "testzone")

from dns.

miekg avatar miekg commented on July 19, 2024

[ Quoting <reply+i-4392099-43bc40389> in "Re: [dns] DNS Server - panic: runti..." ]

A basic example helps a lot!

So, I just need to insert the next code into reflec.go for implement the zone parsing?

almost.

         zone := `$ORIGIN .
$TTL 3600       ; 1 hour
name                    IN SOA  a6.nstld.com. hostmaster.nic.name. (
                                203362132  ; serial
                                300        ; refresh (5 minutes)
                                300        ; retry (5 minutes)
                                1209600    ; expire (2 weeks)
                                300        ; minimum (5 minutes)
                                )
$TTL 10800      ; 3 hours
@ 10800   IN  NS  @
               IN       NS      g6.nstld.com.
               7200     NS      h6.nstld.com.
             3600 IN    NS      j6.nstld.com.
             IN 3600    NS      k6.nstld.com.
                        NS      l6.nstld.com.
                        NS      a6.nstld.com.
                        NS      c6.nstld.com.
                        NS      d6.nstld.com.
                        NS      f6.nstld.com.
                        NS      m6.nstld.com.
$ORIGIN name.
0-0onlus                NS      ns7.ehiweb.it.
                        NS      ns8.ehiweb.it.
0-g                     MX      10 mx01.nic
                        MX      10 mx02.nic
                        MX      10 mx03.nic
                        MX      10 mx04.nic
                        TXT     "10 mx\"04.nic"
$ORIGIN 0-g.name
moutamassey             NS      ns01.yahoodomains.jp.
                        NS      ns02.yahoodomains.jp.
`
  to := ParseZone(strings.NewReader(zone), "", "testzone")

(also see parse_test the ExampleZone() function.

You'll need to add:

// Get the RRs from the zone being read
for x := range to {
if x.Error == nil {
// Print is for now
fmt.Printf("%s\n", x.RR)
} else {
// Error occured, just continue?
}
}

Resource record lookups and combining RRs to RRsets is not implemented. This is
sorta on the TODO.

Regards,

Miek Gieben

from dns.

h2non avatar h2non commented on July 19, 2024

Thanks a lot again!

I added the above code,to the reflec example and then I try to compile it, but fails with the following error:

./reflect.go:113: undefined: ParseZone

I just want to load a zone to serve via the DNS server instance, so I'm newbie with Go and I don't understand the library API.
Please, you can provide an example about how to create a simple DNS server parsing zones from variables or files?

I think, at least for Go not experimented users, a well API documentation and some more examples will be really helpful.

Thanks a lot for your time and patience :)

from dns.

miekg avatar miekg commented on July 19, 2024

[ Quoting <reply+i-4392099-43bc40389> in "Re: [dns] DNS Server - panic: runti..." ]

Thanks a lot again!

I added the above code,to the reflec example and then I try to compile it, but fail with the following error:

./reflect.go:113: undefined: ParseZone

dns.ParseZone

you need to prefix the funcion with the package name, in this case "dns".

I just want to load a zone the serve via the DNS server instance, so I'm newbie with Go and I don't understand the library API.
Please, you can provide an example about how to create a simple DNS server parsing zones from variables or files?

This is on my TODO, but I'm strapped for time, so I don't know when this will
happen.

I think, at least for Go not experimented users, a well API documentation and some more examples will be really helpful.

There is a lot of documentation there, and also in the ex/ directory you'll find
more (client)side examples. Learning Go and learning DNS at the same time may
not be the most efficient way to learn Go :)

Are you aware of miek.nl/files/go with copies of "Learning Go"?

What documentation do you need, besides a complete nameserver :) ?

Regards,

Miek Gieben

from dns.

h2non avatar h2non commented on July 19, 2024

Thanks a lot Miek :)

I will take a look to your book for learning the bases of Go, a then I try again to use your library.

Congratulations for your book and code, is really amazing :)
Cheers!

from dns.

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.