Fixed the analytics charts.

Fixed the back to site link destination.

Added the ReadTimeout, WriteTimeout, IdleTimeout and FullReqLog config settings.
This commit is contained in:
Azareal 2019-03-16 22:50:31 +10:00
parent cb58c1c83f
commit f2572fc3bd
8 changed files with 33 additions and 8 deletions

View File

@ -91,6 +91,10 @@ type config struct {
ItemsPerPage int // ? - Move this into the settings table?
MaxTopicTitleLength int
MaxUsernameLength int
ReadTimeout int
WriteTimeout int
IdleTimeout int
}
type devConfig struct {
@ -99,7 +103,9 @@ type devConfig struct {
TemplateDebug bool
Profiling bool
TestDB bool
NoFsnotify bool // Super Experimental!
NoFsnotify bool // Super Experimental!
FullReqLog bool
}
// configHolder is purely for having a big struct to unmarshal data into

View File

@ -709,6 +709,9 @@ func (r *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
counters.AgentViewCounter.Bump(27)
return
}
if common.Dev.FullReqLog {
r.DumpRequest(req,"")
}
// TODO: Cover more suspicious strings and at a lower layer than this
for _, char := range req.URL.Path {

18
main.go
View File

@ -470,13 +470,25 @@ func main() {
func startServer() {
// We might not need the timeouts, if we're behind a reverse-proxy like Nginx
var newServer = func(addr string, handler http.Handler) *http.Server {
rtime := common.Config.ReadTimeout
if rtime == 0 {
rtime = 5
}
wtime := common.Config.WriteTimeout
if wtime == 0 {
wtime = 10
}
itime := common.Config.IdleTimeout
if itime == 0 {
itime = 120
}
return &http.Server{
Addr: addr,
Handler: handler,
ReadTimeout: 5 * time.Second,
WriteTimeout: 10 * time.Second,
IdleTimeout: 120 * time.Second,
ReadTimeout: time.Duration(rtime) * time.Second,
WriteTimeout: time.Duration(wtime) * time.Second,
IdleTimeout: time.Duration(itime) * time.Second,
TLSConfig: &tls.Config{
PreferServerCipherSuites: true,

View File

@ -5,6 +5,7 @@
// TODO: Fully localise this
// TODO: Load rawLabels and seriesData dynamically rather than potentially fiddling with nonces for the CSP?
function buildStatsChart(rawLabels, seriesData, timeRange, legendNames) {
console.log("buildStatsChart");
let labels = [];
let aphrases = phraseBox["analytics"];
if(timeRange=="one-year") {

View File

@ -214,14 +214,14 @@ function fetchPhrases(plist) {
let toLoad = 2;
// TODO: Shunt this into loggedIn if there aren't any search and filter widgets?
notifyOnScriptW("template_topics_topic", () => {
if(!Template_topics_topic) throw("template function not found");
toLoad--;
if(toLoad===0) initPhrases();
if(!Template_topics_topic) throw("template function not found");
});
notifyOnScriptW("template_paginator", () => {
if(!Template_paginator) throw("template function not found");
toLoad--;
if(toLoad===0) initPhrases();
if(!Template_paginator) throw("template function not found");
});
let loggedIn = document.head.querySelector("[property='x-loggedin']").content;

View File

@ -490,6 +490,9 @@ func (r *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
counters.AgentViewCounter.Bump({{.AllAgentMap.malformed}})
return
}
if common.Dev.FullReqLog {
r.DumpRequest(req,"")
}
// TODO: Cover more suspicious strings and at a lower layer than this
for _, char := range req.URL.Path {

View File

@ -1,6 +1,6 @@
<nav class="colstack_left" aria-label="{{lang "panel_menu_aria"}}">
<div class="colstack_item colstack_head">
<div class="rowitem back_to_site"><a href="/panel/">Back to site</a></div>
<div class="rowitem back_to_site"><a href="/">Back to site</a></div>
</div>
<div class="colstack_item colstack_head">
<div class="rowitem"><a href="/panel/groups/edit/{{.ID}}">{{lang "panel_group_menu_head"}}</a></div>

View File

@ -1,5 +1,5 @@
<nav class="colstack_left" aria-label="{{lang "panel_menu_aria"}}">
<div class="colstack_item colstack_head">
<div class="rowitem back_to_site"><a href="/panel/">Back to site</a></div>
<div class="rowitem back_to_site"><a href="/">Back to site</a></div>
</div>
{{template "panel_inner_menu.html" . }}</nav>