diff --git a/config/config.go b/config/config.go index f0405c8..5384758 100644 --- a/config/config.go +++ b/config/config.go @@ -22,7 +22,7 @@ var NameFilter = regexp.MustCompile(PWDHostPortGroupRegex) var AliasFilter = regexp.MustCompile(AliasPortGroupRegex) var PortNumber, Key, Cert, SessionsFile, PWDContainerName, L2ContainerName, L2Subdomain, PWDCName, HashKey, SSHKeyPath, L2RouterIP, DindVolumeSize string -var UseLetsEncrypt, ExternalDindVolume bool +var UseLetsEncrypt, ExternalDindVolume, NoWindows bool var LetsEncryptCertsDir string var LetsEncryptDomains stringslice var MaxLoadAvg float64 @@ -54,6 +54,7 @@ func ParseFlags() { flag.StringVar(&PWDCName, "cname", "", "CNAME given to this host") flag.StringVar(&HashKey, "hash_key", "salmonrosado", "Hash key to use for cookies") flag.StringVar(&DindVolumeSize, "dind-volume-size", "5G", "Dind volume folder size") + flag.BoolVar(&NoWindows, "no-windows", false, "Don't allow windows instances") flag.BoolVar(&ExternalDindVolume, "external-dind-volume", false, "Use external dind volume") flag.Float64Var(&MaxLoadAvg, "maxload", 100, "Maximum allowed load average before failing ping requests") flag.StringVar(&SSHKeyPath, "ssh_key_path", "", "SSH Private Key to use") diff --git a/handlers/home.go b/handlers/home.go index ee29e62..44f70f3 100644 --- a/handlers/home.go +++ b/handlers/home.go @@ -4,6 +4,7 @@ import ( "net/http" "github.com/gorilla/mux" + "github.com/play-with-docker/play-with-docker/config" ) func Home(w http.ResponseWriter, r *http.Request) { @@ -21,5 +22,9 @@ func Home(w http.ResponseWriter, r *http.Request) { go core.SessionDeployStack(s) } - http.ServeFile(w, r, "./www/index.html") + if config.NoWindows { + http.ServeFile(w, r, "./www/index-nw.html") + } else { + http.ServeFile(w, r, "./www/index.html") + } } diff --git a/handlers/new_instance.go b/handlers/new_instance.go index 940f352..c9853ba 100644 --- a/handlers/new_instance.go +++ b/handlers/new_instance.go @@ -7,6 +7,7 @@ import ( "net/http" "github.com/gorilla/mux" + "github.com/play-with-docker/play-with-docker/config" "github.com/play-with-docker/play-with-docker/provisioner" "github.com/play-with-docker/play-with-docker/pwd" "github.com/play-with-docker/play-with-docker/pwd/types" @@ -22,6 +23,11 @@ func NewInstance(rw http.ResponseWriter, req *http.Request) { s := core.SessionGet(sessionId) + if body.Type == "windows" && config.NoWindows { + rw.WriteHeader(http.StatusUnauthorized) + return + } + i, err := core.InstanceNew(s, body) if err != nil { if pwd.SessionComplete(err) { diff --git a/www/index-nw.html b/www/index-nw.html new file mode 100644 index 0000000..7e1029f --- /dev/null +++ b/www/index-nw.html @@ -0,0 +1,314 @@ + + +
++ Your session has expired. +
+Add instances to your playground.
+Sessions and all their instances are deleted after {{ttl}} hours.
+