Private server
+Nothing to see here.
+diff --git a/app.js b/app.js index d20c908..4972b72 100644 --- a/app.js +++ b/app.js @@ -1547,7 +1547,7 @@ } }, ['debug', 'info', 'warn', 'error'].map((l) => h('option', { value: l, selected: s.log.level === l }, l))); // decoy - const decoyPages = [['nginx', 'nginx welcome page'], ['apache', 'Apache "It works!" page'], ['soon', '"Coming soon" page']]; + const decoyPages = [['nginx', 'nginx welcome page'], ['apache', 'Apache "It works!" page'], ['soon', '"Coming soon" page'], ['blank', 'Blank page'], ['forbidden', '"Forbidden" page'], ['private', '"Private server" page']]; const decoyBox = h('input', { type: 'checkbox', id: 'dc', checked: s.decoy.enabled, onChange: async (e) => { const on = e.target.checked; if (on) { diff --git a/decoy.go b/decoy.go index e7f7894..828f8c0 100644 --- a/decoy.go +++ b/decoy.go @@ -11,15 +11,20 @@ import ( // front page is its stock welcome page and everything else is its stock // error page. Only /api/v1 and live setup links get past it. type decoyPage struct { - server string // Server header, "" for none - index func(host string) string // the front page - error func(code int, r *http.Request) string // body for 404 and 405 + server string // Server header, "" for none + index func(host string) string // the front page + indexCode int // status of the front page, 0 for 200 + error func(code int, r *http.Request) string // body for 404 and 405 } var decoyPages = map[string]decoyPage{ "nginx": {server: nginxServer, index: func(string) string { return nginxIndex }, error: nginxError}, "apache": {server: apacheServer, index: func(string) string { return apacheIndex }, error: apacheError}, "soon": {index: soonIndex, error: soonError}, + // Generic pages that name no server software. + "blank": {index: func(string) string { return "" }, error: func(int, *http.Request) string { return "" }}, + "forbidden": {index: func(string) string { return forbiddenIndex }, indexCode: http.StatusForbidden, error: soonError}, + "private": {index: func(string) string { return privateIndex }, error: soonError}, } // serveDecoy writes the decoy's answer for r. It drops the headers the web @@ -43,6 +48,9 @@ func serveDecoy(w http.ResponseWriter, r *http.Request, name string) { code, body = http.StatusMethodNotAllowed, d.error(http.StatusMethodNotAllowed, r) case r.URL.Path == "/" || r.URL.Path == "/index.html": body = d.index(hostOnly(r.Host)) + if d.indexCode != 0 { + code = d.indexCode + } default: code, body = http.StatusNotFound, d.error(http.StatusNotFound, r) } @@ -537,3 +545,36 @@ const apacheIndex = ` +
+ + +Nothing to see here.
+