mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-08-12 09:00:54 +00:00
start converting to backend as a struct
This commit is contained in:
parent
d49c88a222
commit
80179abc36
1 changed files with 14 additions and 5 deletions
|
@ -12,7 +12,6 @@ import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/pmylund/go-cache"
|
"github.com/pmylund/go-cache"
|
||||||
|
@ -24,6 +23,20 @@ const bPathAddTopic = "/topics"
|
||||||
const bPathAggStats = "/stats"
|
const bPathAggStats = "/stats"
|
||||||
const bPathOtherCommand = "/cmd/"
|
const bPathOtherCommand = "/cmd/"
|
||||||
|
|
||||||
|
type backend struct {
|
||||||
|
HTTPClient http.Client
|
||||||
|
baseURL string
|
||||||
|
responseCache *cache.Cache
|
||||||
|
|
||||||
|
postStatsURL string
|
||||||
|
addTopicURL string
|
||||||
|
announceStartupURL string
|
||||||
|
|
||||||
|
sharedKey [32]byte
|
||||||
|
serverID int
|
||||||
|
|
||||||
|
lastSuccess map[string]time.Time
|
||||||
|
}
|
||||||
var backendHTTPClient http.Client
|
var backendHTTPClient http.Client
|
||||||
var backendURL string
|
var backendURL string
|
||||||
var responseCache *cache.Cache
|
var responseCache *cache.Cache
|
||||||
|
@ -35,8 +48,6 @@ var announceStartupURL string
|
||||||
var backendSharedKey [32]byte
|
var backendSharedKey [32]byte
|
||||||
var serverID int
|
var serverID int
|
||||||
|
|
||||||
var messageBufferPool sync.Pool
|
|
||||||
|
|
||||||
var lastBackendSuccess map[string]time.Time
|
var lastBackendSuccess map[string]time.Time
|
||||||
|
|
||||||
func setupBackend(config *ConfigFile) {
|
func setupBackend(config *ConfigFile) {
|
||||||
|
@ -61,8 +72,6 @@ func setupBackend(config *ConfigFile) {
|
||||||
}
|
}
|
||||||
Statistics.Health.Backend = lastBackendSuccess
|
Statistics.Health.Backend = lastBackendSuccess
|
||||||
|
|
||||||
messageBufferPool.New = New4KByteBuffer
|
|
||||||
|
|
||||||
var theirPublic, ourPrivate [32]byte
|
var theirPublic, ourPrivate [32]byte
|
||||||
copy(theirPublic[:], config.BackendPublicKey)
|
copy(theirPublic[:], config.BackendPublicKey)
|
||||||
copy(ourPrivate[:], config.OurPrivateKey)
|
copy(ourPrivate[:], config.OurPrivateKey)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue