add port argument
This commit is contained in:
		
							parent
							
								
									4201a704f8
								
							
						
					
					
						commit
						5bbc9b922c
					
				
							
								
								
									
										10
									
								
								whoami.go
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								whoami.go
									
									
									
									
									
								
							| @ -5,6 +5,7 @@ import ( | |||||||
| 	"net" | 	"net" | ||||||
| 	"strings"	 | 	"strings"	 | ||||||
|         "encoding/base32" |         "encoding/base32" | ||||||
|  | 	"os" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| // DomainFromIP derives a meshname subdomain for the authoritative DNS server address
 | // 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() { | func main() { | ||||||
| 	http.HandleFunc("/", handler) | 	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) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user