Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
b43cf81c
Commit
b43cf81c
authored
Nov 02, 2011
by
Alex Brainman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
net: implement LookupTXT for windows
R=rsc CC=golang-dev
https://golang.org/cl/5318056
parent
4d3c9990
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
10 deletions
+24
-10
lookup_test.go
src/pkg/net/lookup_test.go
+0
-4
lookup_windows.go
src/pkg/net/lookup_windows.go
+19
-6
ztypes_windows.go
src/pkg/syscall/ztypes_windows.go
+5
-0
No files found.
src/pkg/net/lookup_test.go
View file @
b43cf81c
...
...
@@ -52,10 +52,6 @@ func TestGmailMX(t *testing.T) {
}
func
TestGmailTXT
(
t
*
testing
.
T
)
{
if
runtime
.
GOOS
==
"windows"
{
t
.
Logf
(
"LookupTXT is not implemented on Windows"
)
return
}
if
testing
.
Short
()
||
avoidMacFirewall
{
t
.
Logf
(
"skipping test to avoid external network"
)
return
...
...
src/pkg/net/lookup_windows.go
View file @
b43cf81c
...
...
@@ -5,7 +5,6 @@
package
net
import
(
"errors"
"syscall"
"unsafe"
"os"
...
...
@@ -81,7 +80,7 @@ func LookupPort(network, service string) (port int, err error) {
func
LookupCNAME
(
name
string
)
(
cname
string
,
err
error
)
{
var
r
*
syscall
.
DNSRecord
e
:=
syscall
.
DnsQuery
(
name
,
syscall
.
DNS_TYPE_CNAME
,
0
,
nil
,
&
r
,
nil
)
if
int
(
e
)
!=
0
{
if
e
!=
0
{
return
""
,
os
.
NewSyscallError
(
"LookupCNAME"
,
int
(
e
))
}
defer
syscall
.
DnsRecordListFree
(
r
,
1
)
...
...
@@ -110,7 +109,7 @@ func LookupSRV(service, proto, name string) (cname string, addrs []*SRV, err err
}
var
r
*
syscall
.
DNSRecord
e
:=
syscall
.
DnsQuery
(
target
,
syscall
.
DNS_TYPE_SRV
,
0
,
nil
,
&
r
,
nil
)
if
int
(
e
)
!=
0
{
if
e
!=
0
{
return
""
,
nil
,
os
.
NewSyscallError
(
"LookupSRV"
,
int
(
e
))
}
defer
syscall
.
DnsRecordListFree
(
r
,
1
)
...
...
@@ -126,7 +125,7 @@ func LookupSRV(service, proto, name string) (cname string, addrs []*SRV, err err
func
LookupMX
(
name
string
)
(
mx
[]
*
MX
,
err
error
)
{
var
r
*
syscall
.
DNSRecord
e
:=
syscall
.
DnsQuery
(
name
,
syscall
.
DNS_TYPE_MX
,
0
,
nil
,
&
r
,
nil
)
if
int
(
e
)
!=
0
{
if
e
!=
0
{
return
nil
,
os
.
NewSyscallError
(
"LookupMX"
,
int
(
e
))
}
defer
syscall
.
DnsRecordListFree
(
r
,
1
)
...
...
@@ -140,7 +139,21 @@ func LookupMX(name string) (mx []*MX, err error) {
}
func
LookupTXT
(
name
string
)
(
txt
[]
string
,
err
error
)
{
return
nil
,
errors
.
New
(
"net.LookupTXT is not implemented on Windows"
)
var
r
*
syscall
.
DNSRecord
e
:=
syscall
.
DnsQuery
(
name
,
syscall
.
DNS_TYPE_TEXT
,
0
,
nil
,
&
r
,
nil
)
if
e
!=
0
{
return
nil
,
os
.
NewSyscallError
(
"LookupTXT"
,
int
(
e
))
}
defer
syscall
.
DnsRecordListFree
(
r
,
1
)
txt
=
make
([]
string
,
0
,
10
)
if
r
!=
nil
&&
r
.
Type
==
syscall
.
DNS_TYPE_TEXT
{
d
:=
(
*
syscall
.
DNSTXTData
)(
unsafe
.
Pointer
(
&
r
.
Data
[
0
]))
for
_
,
v
:=
range
(
*
[
1
<<
10
]
*
uint16
)(
unsafe
.
Pointer
(
&
(
d
.
StringArray
[
0
])))[
:
d
.
StringCount
]
{
s
:=
syscall
.
UTF16ToString
((
*
[
1
<<
20
]
uint16
)(
unsafe
.
Pointer
(
v
))[
:
])
txt
=
append
(
txt
,
s
)
}
}
return
}
func
LookupAddr
(
addr
string
)
(
name
[]
string
,
err
error
)
{
...
...
@@ -150,7 +163,7 @@ func LookupAddr(addr string) (name []string, err error) {
}
var
r
*
syscall
.
DNSRecord
e
:=
syscall
.
DnsQuery
(
arpa
,
syscall
.
DNS_TYPE_PTR
,
0
,
nil
,
&
r
,
nil
)
if
int
(
e
)
!=
0
{
if
e
!=
0
{
return
nil
,
os
.
NewSyscallError
(
"LookupAddr"
,
int
(
e
))
}
defer
syscall
.
DnsRecordListFree
(
r
,
1
)
...
...
src/pkg/syscall/ztypes_windows.go
View file @
b43cf81c
...
...
@@ -530,6 +530,11 @@ type DNSMXData struct {
Pad
uint16
}
type
DNSTXTData
struct
{
StringCount
uint16
StringArray
[
1
]
*
uint16
}
type
DNSRecord
struct
{
Next
*
DNSRecord
Name
*
uint16
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment