Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ func newIPValue(val net.IP, p *net.IP) *ipValue {

func (i *ipValue) String() string { return net.IP(*i).String() }
func (i *ipValue) Set(s string) error {
if s == "" {
return nil
}
ip := net.ParseIP(strings.TrimSpace(s))
if ip == nil {
return fmt.Errorf("failed to parse IP: %q", s)
Expand Down
2 changes: 1 addition & 1 deletion ip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestIP(t *testing.T) {
{"1.2.3.4", true, "1.2.3.4"},
{"127.0.0.1", true, "127.0.0.1"},
{"255.255.255.255", true, "255.255.255.255"},
{"", false, ""},
{"", true, "0.0.0.0"},
{"0", false, ""},
{"localhost", false, ""},
{"0.0.0", false, ""},
Expand Down