We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi, I am trying to issue query to a server that supports ECS. I see example code for creating the option, but how to attach it to an outgoing message?
I see there is ways to read using Msg.IsEdns0 when acting as server, but how do I set it as a client?
Msg.IsEdns0
Example code:-
package main import ( "github.com/miekg/dns" "log" "net" "strings" ) func main() { c := new(dns.Client) m := new(dns.Msg) m.SetQuestion("something.example.org.", dns.TypeCNAME) o := new(dns.OPT) o.Hdr.Name = "." o.Hdr.Rrtype = dns.TypeOPT e := new(dns.EDNS0_SUBNET) e.Code = dns.EDNS0SUBNET e.Family = 1 // 1 for IPv4 source address, 2 for IPv6 e.SourceNetmask = 32 // 32 for IPV4, 128 for IPv6 e.SourceScope = 0 e.Address = net.ParseIP("1.2.3.4").To4() o.Option = append(o.Option, e) //QUESTION: How do I attach o to m? //log.Println(o) //m.SetEdns0(4096, false) //log.Println(m.IsEdns0()) //log.Println(m) in, rtt, err := c.Exchange(m, "ns1.example.org:53") if err != nil { log.Fatal(err) } log.Println(in) log.Println(rtt) if t, ok := in.Answer[0].(*dns.CNAME); ok { log.Println(strings.ToUpper(strings.Split(t.Target, ".")[0])) } else { log.Fatal("should not reach here...") } }
The text was updated successfully, but these errors were encountered:
[ Quoting notifications@github.com in "[miekg/dns] How to add EDNS Client ..." ]
m := new(dns.Msg) m.SetQuestion("something.example.org.", dns.TypeCNAME) o := new(dns.OPT) o.Hdr.Name = "." o.Hdr.Rrtype = dns.TypeOPT e := new(dns.EDNS0_SUBNET) e.Code = dns.EDNS0SUBNET e.Family = 1 // 1 for IPv4 source address, 2 for IPv6 e.SourceNetmask = 32 // 32 for IPV4, 128 for IPv6 e.SourceScope = 0 e.Address = net.ParseIP("1.2.3.4").To4() o.Option = append(o.Option, e) //QUESTION: How do I attach o to m?
m := new(dns.Msg) m.SetQuestion("something.example.org.", dns.TypeCNAME)
o := new(dns.OPT) o.Hdr.Name = "." o.Hdr.Rrtype = dns.TypeOPT e := new(dns.EDNS0_SUBNET) e.Code = dns.EDNS0SUBNET e.Family = 1 // 1 for IPv4 source address, 2 for IPv6 e.SourceNetmask = 32 // 32 for IPV4, 128 for IPv6 e.SourceScope = 0 e.Address = net.ParseIP("1.2.3.4").To4() o.Option = append(o.Option, e)
//QUESTION: How do I attach o to m?
m.Extra = append(m.Extra, o)
Sorry, something went wrong.
Thanks a lot. Works as intended.
No branches or pull requests
Hi, I am trying to issue query to a server that supports ECS. I see example code for creating the option, but how to attach it to an outgoing message?
I see there is ways to read using
Msg.IsEdns0
when acting as server, but how do I set it as a client?Example code:-
The text was updated successfully, but these errors were encountered: