File: validation.go

package info (click to toggle)
hcloud-cli 1.39.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,628 kB
  • sloc: sh: 36; makefile: 7
file content (18 lines) | stat: -rw-r--r-- 320 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package firewall

import (
	"fmt"
	"net"
)

func validateFirewallIP(ip string) (*net.IPNet, error) {
	i, n, err := net.ParseCIDR(ip)
	if err != nil {
		return nil, fmt.Errorf("%s", err)
	}
	if i.String() != n.IP.String() {
		return nil, fmt.Errorf("%s is not the start of the cidr block %s", ip, n)
	}

	return n, nil
}