+ Added no response and I'm a Teapot (config file editing only) to default site options
This commit is contained in:
Toby Chui 2024-12-17 22:08:32 +08:00
parent 2423d0fb3a
commit 49555c1191
3 changed files with 37 additions and 0 deletions

View File

@ -217,5 +217,27 @@ func (h *ProxyHandler) handleRootRouting(w http.ResponseWriter, r *http.Request)
} else {
w.Write(template)
}
case DefaultSite_NoResponse:
//No response. Just close the connection
h.Parent.logRequest(r, false, 444, "root-noresponse", domainOnly)
hijacker, ok := w.(http.Hijacker)
if !ok {
http.Error(w, "Hijacking not supported", http.StatusInternalServerError)
return
}
conn, _, err := hijacker.Hijack()
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
conn.Close()
case DefaultSite_TeaPot:
//I'm a teapot
h.Parent.logRequest(r, false, 418, "root-teapot", domainOnly)
http.Error(w, "I'm a teapot", http.StatusTeapot)
default:
//Unknown routing option. Send empty response
h.Parent.logRequest(r, false, 544, "root-unknown", domainOnly)
http.Error(w, "544 - No Route Defined", 544)
}
}

View File

@ -201,6 +201,9 @@ const (
DefaultSite_ReverseProxy = 1
DefaultSite_Redirect = 2
DefaultSite_NotFoundPage = 3
DefaultSite_NoResponse = 4
DefaultSite_TeaPot = 418 //I'm a teapot
)
/*

View File

@ -37,6 +37,14 @@
</label>
</div>
</div>
<div class="field">
<div class="ui radio defaultsite checkbox">
<input type="radio" name="defaultsiteOption" value="closeresp">
<label>Close Connection<br>
<small>Close the connection without any response</small>
</label>
</div>
</div>
</div>
</div>
@ -105,6 +113,8 @@
currentDefaultSiteOption = 2;
}else if (selectedDefaultSite == "notfound"){
currentDefaultSiteOption = 3;
}else if (selectedDefaultSite == "closeresp"){
currentDefaultSiteOption = 4;
}else{
//Unknown option
return;
@ -137,6 +147,8 @@
$("#redirectDomain").val(data.DefaultSiteValue);
}else if (proxyType == 3){
$radios.filter('[value=notfound]').prop('checked', true);
}else if (proxyType == 4){
$radios.filter('[value=closeresp]').prop('checked', true);
}
updateAvaibleDefaultSiteOptions();