Merge pull request #85 from keloyang/allowHost

Allow host
This commit is contained in:
Quentin Machu 2016-03-09 16:28:23 -05:00
commit 81363b4411

View File

@ -22,6 +22,7 @@ import (
"flag"
"fmt"
"io/ioutil"
"net"
"net/http"
"os"
"os/exec"
@ -257,7 +258,8 @@ func listenHTTP(path, allowedHost string) {
restrictedFileServer := func(path, allowedHost string) http.Handler {
fc := func(w http.ResponseWriter, r *http.Request) {
if r.Host == allowedHost {
host, _, err := net.SplitHostPort(r.RemoteAddr)
if err == nil && strings.EqualFold(host, allowedHost) {
http.FileServer(http.Dir(path)).ServeHTTP(w, r)
return
}