Added function implementations to generate hosts by subnet and CIDR

This commit is contained in:
David J. Allen 2023-10-16 14:37:23 -06:00
parent 994bf07716
commit 555ecf679d
3 changed files with 92 additions and 6 deletions

View file

@ -5,6 +5,7 @@ import (
"crypto/tls"
"fmt"
"io"
"net"
"net/http"
"os"
"time"
@ -17,6 +18,17 @@ func PathExists(path string) (bool, error) {
return false, err
}
func GetNextIP(ip net.IP, inc uint) net.IP {
i := ip.To4()
v := uint(i[0])<<24 + uint(i[1])<<16 + uint(i[2])<<8 + uint(i[3])
v += inc
v3 := byte(v & 0xFF)
v2 := byte((v >> 8) & 0xFF)
v1 := byte((v >> 16) & 0xFF)
v0 := byte((v >> 24) & 0xFF)
return net.IPv4(v0, v1, v2, v3)
}
func MakeRequest(url string, httpMethod string, body []byte, headers map[string]string) (*http.Response, []byte, error) {
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
req, err := http.NewRequest(httpMethod, url, bytes.NewBuffer(body))