Skip to content

Commit 340b75a

Browse files
committed
simplify
1 parent 5df1bee commit 340b75a

File tree

3 files changed

+1
-30
lines changed

3 files changed

+1
-30
lines changed

model/vpn.go

-8
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import (
55
"regexp"
66
"strings"
77
"time"
8-
9-
"github.com/nettica-com/nettica-admin/util"
108
)
119

1210
// VPN structure
@@ -87,12 +85,6 @@ func (a VPN) IsValid() []error {
8785
if len(a.Current.Address) == 0 {
8886
errs = append(errs, fmt.Errorf("address field is required"))
8987
}
90-
// check if the address are valid
91-
for _, address := range a.Current.Address {
92-
if !util.IsValidCidr(address) {
93-
errs = append(errs, fmt.Errorf("address %s is invalid", address))
94-
}
95-
}
9688

9789
return errs
9890
}

ui/src/components/Network.vue

-14
Original file line numberDiff line numberDiff line change
@@ -1119,20 +1119,6 @@ export default {
11191119
"196.0.0.0/6", "200.0.0.0/5", "208.0.0.0/4", "::/1", "8000::/2", "c000::/3", "e000::/4", "f000::/5", "f800::/6", "fe00::/9", "fe80::/10", "ff00::/8")
11201120
}
11211121

1122-
// check allowed IPs
1123-
/* for (let i = 0; i < this.vpn.current.allowedIPs.length; i++) {
1124-
if (this.$isCidr(this.vpn.current.allowedIPs[i]) === 0) {
1125-
this.errorNet('Invalid CIDR detected, please correct before submitting');
1126-
return
1127-
}
1128-
}
1129-
// check address
1130-
for (let i = 0; i < this.vpn.current.address.length; i++) {
1131-
if (this.$isCidr(this.vpn.current.address[i]) === 0) {
1132-
this.errorNet('Invalid CIDR detected, please correct before submitting');
1133-
return
1134-
}
1135-
}*/
11361122

11371123
this.inEdit = false;
11381124
this.updatevpn(this.vpn)

util/util.go

+1-8
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,6 @@ func GetNetworkAddress(cidr string) (string, error) {
8383
// GetAvailableCidr search for an available ip in cidr against a list of reserved ips
8484
func GetAvailableCidr(cidr string, reserved []string) (string, error) {
8585

86-
parts := strings.Split(cidr, "/")
87-
if len(parts) != 2 {
88-
return "", errors.New("invalid cidr")
89-
}
90-
91-
prefix := parts[1]
92-
9386
ip, ipnet, err := net.ParseCIDR(cidr)
9487
if err != nil {
9588
return "", err
@@ -109,7 +102,7 @@ func GetAvailableCidr(cidr string, reserved []string) (string, error) {
109102
}
110103
}
111104
if ok && address != networkAddr && address != broadcastAddr {
112-
return address + "/" + prefix, nil
105+
return address, nil
113106
}
114107
}
115108

0 commit comments

Comments
 (0)