mirror of
https://github.com/ergochat/ergo.git
synced 2026-01-09 20:02:07 -08:00
more permissive hostname validation
In particular, allow hostnames without periods (like on a LAN). This shouldn't be a client compability concern since we allow vhosts without periods.
This commit is contained in:
parent
4b37b5dd3e
commit
f1e2bbc0e4
3 changed files with 28 additions and 12 deletions
|
|
@ -24,14 +24,18 @@ var (
|
|||
"gsf.ds342.co.uk",
|
||||
"324.net.uk",
|
||||
"xn--bcher-kva.ch",
|
||||
"pentos",
|
||||
"pentos.",
|
||||
"www.google.com.",
|
||||
}
|
||||
|
||||
badHostnames = []string{
|
||||
"-lol-.net.uk",
|
||||
"-lol.net.uk",
|
||||
"_irc._sctp.lol.net.uk",
|
||||
"irc",
|
||||
"com",
|
||||
"irc.l%l.net.uk",
|
||||
"irc..net.uk",
|
||||
".",
|
||||
"",
|
||||
}
|
||||
)
|
||||
|
|
@ -56,6 +60,15 @@ func TestIsHostname(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestIsServerName(t *testing.T) {
|
||||
if IsServerName("pentos") {
|
||||
t.Error("irc server names must contain a period")
|
||||
}
|
||||
if !IsServerName("darwin.network") {
|
||||
t.Error("failed to validate a perfectly good server name")
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormalizeToNet(t *testing.T) {
|
||||
a := net.ParseIP("8.8.8.8")
|
||||
b := net.ParseIP("8.8.4.4")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue