add port argument

This commit is contained in:
cynic 2024-06-13 21:02:13 +00:00
parent 4201a704f8
commit 5bbc9b922c

View File

@ -5,6 +5,7 @@ import (
"net"
"strings"
"encoding/base32"
"os"
)
// DomainFromIP derives a meshname subdomain for the authoritative DNS server address
@ -27,6 +28,13 @@ func handler(w http.ResponseWriter, r *http.Request) {
func main() {
http.HandleFunc("/", handler)
http.ListenAndServe(":3000", nil)
listenPort := "3000"
// Get the first command-line argument
if len(os.Args) > 1 {
listenPort = os.Args[1]
}
print("Listening on port:", listenPort, "\n")
listenPort = strings.Join([]string{":", listenPort}, "")
http.ListenAndServe(listenPort, nil)
}