Commit 35365b97 authored by Russ Cox's avatar Russ Cox

net: restore LookupPort for integer strings

This worked in Go 1.4 but was lost in the "pure Go" lookup
routines substituted late in the Go 1.5 cycle.

Fixes #12263.

Change-Id: I77ec9d97cd8e67ace99d6ac965e5bc16c151ba83
Reviewed-on: https://go-review.googlesource.com/13915Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 8261c887
......@@ -123,6 +123,9 @@ func lookupIPDeadline(host string, deadline time.Time) (addrs []IPAddr, err erro
// LookupPort looks up the port for the given network and service.
func LookupPort(network, service string) (port int, err error) {
if n, i, ok := dtoi(service, 0); ok && i == len(service) {
return n, nil
}
return lookupPort(network, service)
}
......
......@@ -27,6 +27,7 @@ var portTests = []struct {
{"tcp", "time", 37, true},
{"tcp", "domain", 53, true},
{"tcp", "finger", 79, true},
{"tcp", "42", 42, true},
{"udp", "echo", 7, true},
{"udp", "tftp", 69, true},
......@@ -36,6 +37,7 @@ var portTests = []struct {
{"udp", "ntp", 123, true},
{"udp", "snmp", 161, true},
{"udp", "syslog", 514, true},
{"udp", "42", 42, true},
{"--badnet--", "zzz", 0, false},
{"tcp", "--badport--", 0, false},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment