This commit is contained in:
parent
3520b1bd17
commit
8c929c43f9
@ -14,6 +14,7 @@ type DataYaml struct {
|
||||
MCProtocolVersion int `yaml:"mcProtocolVersion"`
|
||||
MCClientGUID int64 `yaml:"mcClientGUID"`
|
||||
MCTimeout time.Duration `yaml:"mcTimeout"`
|
||||
MCQueryInterval time.Duration `yaml:"mcQueryInterval"`
|
||||
AllowDisplayState bool `yaml:"allowDisplayState"`
|
||||
AllowDisplayVersion bool `yaml:"allowDisplayVersion"`
|
||||
AllowDisplayActualAddress bool `yaml:"allowDisplayActualAddress"`
|
||||
|
@ -38,6 +38,8 @@ type Page struct {
|
||||
PageTemplateMutex *sync.Mutex
|
||||
PageTemplate *template.Template
|
||||
LastModifiedTemplate time.Time
|
||||
CachedMC *MC
|
||||
CollectedMCExpiry time.Time
|
||||
}
|
||||
|
||||
func (p *Page) GetPath() string {
|
||||
@ -95,11 +97,25 @@ func (p *Page) GetContents(urlParameters url.Values) (contentType string, conten
|
||||
Parameters: template.URL(p.getNonThemedCleanQuery(urlParameters)),
|
||||
Online: true,
|
||||
}
|
||||
theMC, err := theMarshal.NewMC()
|
||||
theMarshal.Queried = theMC
|
||||
if err != nil {
|
||||
theMarshal.Online = false
|
||||
var theMC MC
|
||||
if time.Now().After(p.CollectedMCExpiry) || time.Now().Equal(p.CollectedMCExpiry) {
|
||||
theMC, err = theMarshal.NewMC()
|
||||
if err == nil {
|
||||
p.CachedMC = &theMC
|
||||
} else {
|
||||
theMarshal.Online = false
|
||||
p.CachedMC = nil
|
||||
}
|
||||
p.CollectedMCExpiry = time.Now().Add(theData.MCQueryInterval)
|
||||
} else {
|
||||
if p.CachedMC == nil {
|
||||
theMC = MC{}
|
||||
theMarshal.Online = false
|
||||
} else {
|
||||
theMC = *p.CachedMC
|
||||
}
|
||||
}
|
||||
theMarshal.Queried = theMC
|
||||
theBuffer := &io.BufferedWriter{}
|
||||
err = theTemplate.ExecuteTemplate(theBuffer, templateName, theMarshal)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user