add automatic localhost and local ip to allow origin

This commit is contained in:
Adrian Zuercher
2025-06-29 21:18:15 +02:00
parent 59c7705ca1
commit e75d7c8b03
3 changed files with 34 additions and 9 deletions

View File

@@ -1,5 +1,10 @@
package utils
import (
"fmt"
"net"
)
func ListofA2ZZ() (list []string) {
for i := 'A'; i <= 'Z'; i++ {
list = append(list, string(i))
@@ -9,12 +14,21 @@ func ListofA2ZZ() (list []string) {
list = append(list, string(i)+string(j))
}
}
// for i := 'A'; i <= 'Z'; i++ {
// for j := 'A'; j <= 'Z'; j++ {
// for k := 'A'; k <= 'Z'; k++ {
// list = append(list, string(i)+string(j)+string(k))
// }
// }
// }
return
}
func GetLocalIP() (string, error) {
addrs, err := net.InterfaceAddrs()
if err != nil {
return "", err
}
for _, addr := range addrs {
if ipNet, ok := addr.(*net.IPNet); ok && !ipNet.IP.IsLoopback() {
if ipNet.IP.To4() != nil {
return ipNet.IP.String(), nil
}
}
}
return "", fmt.Errorf("no local IP address found")
}