Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
e7183e75
Commit
e7183e75
authored
Jan 24, 2011
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
net: return cname in LookupHost
Fixes #1395. R=adg CC=golang-dev
https://golang.org/cl/4036044
parent
4871d0d1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
15 deletions
+12
-15
src/pkg/net/dnsclient.go
src/pkg/net/dnsclient.go
+12
-15
No files found.
src/pkg/net/dnsclient.go
View file @
e7183e75
...
...
@@ -98,18 +98,18 @@ func exchange(cfg *dnsConfig, c Conn, name string, qtype uint16) (*dnsMsg, os.Er
// Find answer for name in dns message.
// On return, if err == nil, addrs != nil.
func
answer
(
name
,
server
string
,
dns
*
dnsMsg
,
qtype
uint16
)
(
addrs
[]
dnsRR
,
err
os
.
Error
)
{
func
answer
(
name
,
server
string
,
dns
*
dnsMsg
,
qtype
uint16
)
(
cname
string
,
addrs
[]
dnsRR
,
err
os
.
Error
)
{
addrs
=
make
([]
dnsRR
,
0
,
len
(
dns
.
answer
))
if
dns
.
rcode
==
dnsRcodeNameError
&&
dns
.
recursion_available
{
return
nil
,
&
DNSError
{
Error
:
noSuchHost
,
Name
:
name
}
return
""
,
nil
,
&
DNSError
{
Error
:
noSuchHost
,
Name
:
name
}
}
if
dns
.
rcode
!=
dnsRcodeSuccess
{
// None of the error codes make sense
// for the query we sent. If we didn't get
// a name error and we didn't get success,
// the server is behaving incorrectly.
return
nil
,
&
DNSError
{
Error
:
"server misbehaving"
,
Name
:
name
,
Server
:
server
}
return
""
,
nil
,
&
DNSError
{
Error
:
"server misbehaving"
,
Name
:
name
,
Server
:
server
}
}
// Look for the name.
...
...
@@ -137,19 +137,19 @@ Cname:
}
}
if
len
(
addrs
)
==
0
{
return
nil
,
&
DNSError
{
Error
:
noSuchHost
,
Name
:
name
,
Server
:
server
}
return
""
,
nil
,
&
DNSError
{
Error
:
noSuchHost
,
Name
:
name
,
Server
:
server
}
}
return
addrs
,
nil
return
name
,
addrs
,
nil
}
return
nil
,
&
DNSError
{
Error
:
"too many redirects"
,
Name
:
name
,
Server
:
server
}
return
""
,
nil
,
&
DNSError
{
Error
:
"too many redirects"
,
Name
:
name
,
Server
:
server
}
}
// Do a lookup for a single name, which must be rooted
// (otherwise answer will not find the answers).
func
tryOneName
(
cfg
*
dnsConfig
,
name
string
,
qtype
uint16
)
(
addrs
[]
dnsRR
,
err
os
.
Error
)
{
func
tryOneName
(
cfg
*
dnsConfig
,
name
string
,
qtype
uint16
)
(
cname
string
,
addrs
[]
dnsRR
,
err
os
.
Error
)
{
if
len
(
cfg
.
servers
)
==
0
{
return
nil
,
&
DNSError
{
Error
:
"no DNS servers"
,
Name
:
name
}
return
""
,
nil
,
&
DNSError
{
Error
:
"no DNS servers"
,
Name
:
name
}
}
for
i
:=
0
;
i
<
len
(
cfg
.
servers
);
i
++
{
// Calling Dial here is scary -- we have to be sure
...
...
@@ -170,7 +170,7 @@ func tryOneName(cfg *dnsConfig, name string, qtype uint16) (addrs []dnsRR, err o
err
=
merr
continue
}
addrs
,
err
=
answer
(
name
,
server
,
msg
,
qtype
)
cname
,
addrs
,
err
=
answer
(
name
,
server
,
msg
,
qtype
)
if
err
==
nil
||
err
.
(
*
DNSError
)
.
Error
==
noSuchHost
{
break
}
...
...
@@ -261,9 +261,8 @@ func lookup(name string, qtype uint16) (cname string, addrs []dnsRR, err os.Erro
rname
+=
"."
}
// Can try as ordinary name.
addrs
,
err
=
tryOneName
(
cfg
,
rname
,
qtype
)
cname
,
addrs
,
err
=
tryOneName
(
cfg
,
rname
,
qtype
)
if
err
==
nil
{
cname
=
rname
return
}
}
...
...
@@ -277,9 +276,8 @@ func lookup(name string, qtype uint16) (cname string, addrs []dnsRR, err os.Erro
if
rname
[
len
(
rname
)
-
1
]
!=
'.'
{
rname
+=
"."
}
addrs
,
err
=
tryOneName
(
cfg
,
rname
,
qtype
)
cname
,
addrs
,
err
=
tryOneName
(
cfg
,
rname
,
qtype
)
if
err
==
nil
{
cname
=
rname
return
}
}
...
...
@@ -289,9 +287,8 @@ func lookup(name string, qtype uint16) (cname string, addrs []dnsRR, err os.Erro
if
!
rooted
{
rname
+=
"."
}
addrs
,
err
=
tryOneName
(
cfg
,
rname
,
qtype
)
cname
,
addrs
,
err
=
tryOneName
(
cfg
,
rname
,
qtype
)
if
err
==
nil
{
cname
=
rname
return
}
return
...
...
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