Skip to content

Commit 7727b85

Browse files
committed
cleanup: make internal-only funcs private
1 parent 6d61795 commit 7727b85

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

pkg/network/network.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ type Interface struct {
6666
IfaceMAC string
6767
}
6868

69-
// Inspect initialises IPv4 network parameters struct from given address.
69+
// inspect initialises IPv4 network parameters struct from given address.
7070
// address can be single address (like "192.168.17.42"), network address (like "192.168.17.0"), or in cidr form (like "192.168.17.42/24 or "192.168.17.0/24").
7171
// If addr is valid existsing interface address, network struct will also contain info about the respective interface.
72-
func Inspect(addr string) (*Parameters, error) {
72+
func inspect(addr string) (*Parameters, error) {
7373
n := &Parameters{}
7474

7575
// extract ip from addr
@@ -147,9 +147,9 @@ func Inspect(addr string) (*Parameters, error) {
147147
return n, nil
148148
}
149149

150-
// IsSubnetTaken returns if local network subnet exists and any error occurred.
150+
// isSubnetTaken returns if local network subnet exists and any error occurred.
151151
// If will return false in case of an error.
152-
func IsSubnetTaken(subnet string) (bool, error) {
152+
func isSubnetTaken(subnet string) (bool, error) {
153153
ips, err := net.InterfaceAddrs()
154154
if err != nil {
155155
return false, errors.Wrap(err, "listing local networks")
@@ -166,8 +166,8 @@ func IsSubnetTaken(subnet string) (bool, error) {
166166
return false, nil
167167
}
168168

169-
// IsSubnetPrivate returns if subnet is a private network.
170-
func IsSubnetPrivate(subnet string) bool {
169+
// isSubnetPrivate returns if subnet is a private network.
170+
func isSubnetPrivate(subnet string) bool {
171171
for _, ipnet := range privateSubnets {
172172
if ipnet.Contains(net.ParseIP(subnet)) {
173173
return true
@@ -179,13 +179,13 @@ func IsSubnetPrivate(subnet string) bool {
179179
// FreeSubnet will try to find free private network beginning with startSubnet, incrementing it in steps up to number of tries.
180180
func FreeSubnet(startSubnet string, step, tries int) (*Parameters, error) {
181181
for try := 0; try < tries; try++ {
182-
n, err := Inspect(startSubnet)
182+
n, err := inspect(startSubnet)
183183
if err != nil {
184184
return nil, err
185185
}
186186
startSubnet = n.IP
187-
if IsSubnetPrivate(startSubnet) {
188-
taken, err := IsSubnetTaken(startSubnet)
187+
if isSubnetPrivate(startSubnet) {
188+
taken, err := isSubnetTaken(startSubnet)
189189
if err != nil {
190190
return nil, err
191191
}

0 commit comments

Comments
 (0)