mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-06-28 15:27:43 +00:00
convert serverID
This commit is contained in:
parent
80179abc36
commit
cd7faaba38
2 changed files with 11 additions and 5 deletions
|
@ -23,7 +23,7 @@ const bPathAddTopic = "/topics"
|
||||||
const bPathAggStats = "/stats"
|
const bPathAggStats = "/stats"
|
||||||
const bPathOtherCommand = "/cmd/"
|
const bPathOtherCommand = "/cmd/"
|
||||||
|
|
||||||
type backend struct {
|
type backendInfo struct {
|
||||||
HTTPClient http.Client
|
HTTPClient http.Client
|
||||||
baseURL string
|
baseURL string
|
||||||
responseCache *cache.Cache
|
responseCache *cache.Cache
|
||||||
|
@ -37,6 +37,9 @@ type backend struct {
|
||||||
|
|
||||||
lastSuccess map[string]time.Time
|
lastSuccess map[string]time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var Backend *backendInfo
|
||||||
|
|
||||||
var backendHTTPClient http.Client
|
var backendHTTPClient http.Client
|
||||||
var backendURL string
|
var backendURL string
|
||||||
var responseCache *cache.Cache
|
var responseCache *cache.Cache
|
||||||
|
@ -46,12 +49,13 @@ var addTopicURL string
|
||||||
var announceStartupURL string
|
var announceStartupURL string
|
||||||
|
|
||||||
var backendSharedKey [32]byte
|
var backendSharedKey [32]byte
|
||||||
var serverID int
|
|
||||||
|
|
||||||
var lastBackendSuccess map[string]time.Time
|
var lastBackendSuccess map[string]time.Time
|
||||||
|
|
||||||
func setupBackend(config *ConfigFile) {
|
func setupBackend(config *ConfigFile) *backendInfo {
|
||||||
serverID = config.ServerID
|
b := new(backendInfo)
|
||||||
|
Backend = b
|
||||||
|
b.serverID = config.ServerID
|
||||||
|
|
||||||
backendHTTPClient.Timeout = 60 * time.Second
|
backendHTTPClient.Timeout = 60 * time.Second
|
||||||
backendURL = config.BackendURL
|
backendURL = config.BackendURL
|
||||||
|
@ -77,6 +81,8 @@ func setupBackend(config *ConfigFile) {
|
||||||
copy(ourPrivate[:], config.OurPrivateKey)
|
copy(ourPrivate[:], config.OurPrivateKey)
|
||||||
|
|
||||||
box.Precompute(&backendSharedKey, &theirPublic, &ourPrivate)
|
box.Precompute(&backendSharedKey, &theirPublic, &ourPrivate)
|
||||||
|
|
||||||
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
func getCacheKey(remoteCommand, data string) string {
|
func getCacheKey(remoteCommand, data string) string {
|
||||||
|
|
|
@ -58,7 +58,7 @@ func SealRequest(form url.Values) (url.Values, error) {
|
||||||
retval := url.Values{
|
retval := url.Values{
|
||||||
"nonce": []string{nonceString},
|
"nonce": []string{nonceString},
|
||||||
"msg": []string{cipherString},
|
"msg": []string{cipherString},
|
||||||
"id": []string{strconv.Itoa(serverID)},
|
"id": []string{strconv.Itoa(Backend.serverID)},
|
||||||
}
|
}
|
||||||
|
|
||||||
return retval, nil
|
return retval, nil
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue