Added logic to find next available IP address

This commit is contained in:
Mike Conrad
2025-04-14 15:50:08 -04:00
parent 2964391f0a
commit d0e3d6777d
5 changed files with 159 additions and 4 deletions

15
main.go
View File

@ -5,12 +5,12 @@ import (
"fmt"
"log"
"net/http"
"strings"
"os"
"strings"
"github.com/coreos/go-oidc"
"golang.org/x/oauth2"
"golang.org/x/oauth2/microsoft"
"github.com/coreos/go-oidc"
)
var (
@ -26,10 +26,16 @@ var (
func main() {
nextIP, err := getNextFreeIP()
if err != nil {
fmt.Println("Error:", err)
} else {
fmt.Println("Next available IP:", nextIP)
}
ctx := context.Background()
issuer := fmt.Sprintf("https://login.microsoftonline.com/%s/v2.0", tenantID)
var err error
provider, err = oidc.NewProvider(ctx, issuer)
if err != nil {
log.Fatalf("failed to get provider: %v", err)
@ -50,6 +56,7 @@ func main() {
log.Println("Server started at http://localhost:5000")
log.Fatal(http.ListenAndServe(":5000", nil))
}
func handleIndex(w http.ResponseWriter, r *http.Request) {
@ -77,7 +84,7 @@ func handleIndex(w http.ResponseWriter, r *http.Request) {
}
var claims struct {
Email string `json:"email"`
Email string `json:"email"`
PreferredUsername string `json:"preferred_username"`
Name string `json:"name"`
}