LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // DNS packet assembly. See RFC 1035. | 5 // DNS packet assembly. See RFC 1035. |
6 // | 6 // |
7 // This is intended to support name resolution during Dial. | 7 // This is intended to support name resolution during Dial. |
8 // It doesn't have to be blazing fast. | 8 // It doesn't have to be blazing fast. |
9 // | 9 // |
10 // Each message structure has a Walk method that is used by | 10 // Each message structure has a Walk method that is used by |
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 s := "{" | 611 s := "{" |
612 i := 0 | 612 i := 0 |
613 any.Walk(func(val interface{}, name, tag string) bool { | 613 any.Walk(func(val interface{}, name, tag string) bool { |
614 i++ | 614 i++ |
615 if i > 1 { | 615 if i > 1 { |
616 s += ", " | 616 s += ", " |
617 } | 617 } |
618 s += name + "=" | 618 s += name + "=" |
619 switch tag { | 619 switch tag { |
620 case "ipv4": | 620 case "ipv4": |
621 » » » i := val.(uint32) | 621 » » » i := *val.(*uint32) |
622 s += IPv4(byte(i>>24), byte(i>>16), byte(i>>8), byte(i))
.String() | 622 s += IPv4(byte(i>>24), byte(i>>16), byte(i>>8), byte(i))
.String() |
623 case "ipv6": | 623 case "ipv6": |
624 i := val.([]byte) | 624 i := val.([]byte) |
625 s += IP(i).String() | 625 s += IP(i).String() |
626 default: | 626 default: |
627 var i int64 | 627 var i int64 |
628 switch v := val.(type) { | 628 switch v := val.(type) { |
629 default: | 629 default: |
630 // can't really happen. | 630 // can't really happen. |
631 s += "<unknown type>" | 631 s += "<unknown type>" |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
878 } | 878 } |
879 } | 879 } |
880 if len(dns.extra) > 0 { | 880 if len(dns.extra) > 0 { |
881 s += "-- Extra\n" | 881 s += "-- Extra\n" |
882 for i := 0; i < len(dns.extra); i++ { | 882 for i := 0; i < len(dns.extra); i++ { |
883 s += printStruct(dns.extra[i]) + "\n" | 883 s += printStruct(dns.extra[i]) + "\n" |
884 } | 884 } |
885 } | 885 } |
886 return s | 886 return s |
887 } | 887 } |
LEFT | RIGHT |