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? ItemsPerPage int // ? - Move this into the settings table?
MaxTopicTitleLength int MaxTopicTitleLength int
MaxUsernameLength int MaxUsernameLength int
ReadTimeout int
WriteTimeout int
IdleTimeout int
} }
type devConfig struct { type devConfig struct {
@ -99,7 +103,9 @@ type devConfig struct {
TemplateDebug bool TemplateDebug bool
Profiling bool Profiling bool
TestDB 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 // 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) counters.AgentViewCounter.Bump(27)
return return
} }
if common.Dev.FullReqLog {
r.DumpRequest(req,"")
}
// TODO: Cover more suspicious strings and at a lower layer than this // TODO: Cover more suspicious strings and at a lower layer than this
for _, char := range req.URL.Path { for _, char := range req.URL.Path {

18
main.go
View File

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

View File

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

View File

@ -214,14 +214,14 @@ function fetchPhrases(plist) {
let toLoad = 2; let toLoad = 2;
// TODO: Shunt this into loggedIn if there aren't any search and filter widgets? // TODO: Shunt this into loggedIn if there aren't any search and filter widgets?
notifyOnScriptW("template_topics_topic", () => { notifyOnScriptW("template_topics_topic", () => {
if(!Template_topics_topic) throw("template function not found");
toLoad--; toLoad--;
if(toLoad===0) initPhrases(); if(toLoad===0) initPhrases();
if(!Template_topics_topic) throw("template function not found");
}); });
notifyOnScriptW("template_paginator", () => { notifyOnScriptW("template_paginator", () => {
if(!Template_paginator) throw("template function not found");
toLoad--; toLoad--;
if(toLoad===0) initPhrases(); if(toLoad===0) initPhrases();
if(!Template_paginator) throw("template function not found");
}); });
let loggedIn = document.head.querySelector("[property='x-loggedin']").content; 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}}) counters.AgentViewCounter.Bump({{.AllAgentMap.malformed}})
return return
} }
if common.Dev.FullReqLog {
r.DumpRequest(req,"")
}
// TODO: Cover more suspicious strings and at a lower layer than this // TODO: Cover more suspicious strings and at a lower layer than this
for _, char := range req.URL.Path { for _, char := range req.URL.Path {

View File

@ -1,6 +1,6 @@
<nav class="colstack_left" aria-label="{{lang "panel_menu_aria"}}"> <nav class="colstack_left" aria-label="{{lang "panel_menu_aria"}}">
<div class="colstack_item colstack_head"> <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>
<div class="colstack_item colstack_head"> <div class="colstack_item colstack_head">
<div class="rowitem"><a href="/panel/groups/edit/{{.ID}}">{{lang "panel_group_menu_head"}}</a></div> <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"}}"> <nav class="colstack_left" aria-label="{{lang "panel_menu_aria"}}">
<div class="colstack_item colstack_head"> <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>
{{template "panel_inner_menu.html" . }}</nav> {{template "panel_inner_menu.html" . }}</nav>