mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-08-13 17:40:53 +00:00
Add MaxClientCount to configuration
This commit is contained in:
parent
e117766eb6
commit
ba73186a99
2 changed files with 18 additions and 0 deletions
|
@ -203,9 +203,19 @@ func HTTPHandleRootURL(w http.ResponseWriter, r *http.Request) {
|
||||||
if Statistics.SysMemFreeKB > 0 && Statistics.SysMemFreeKB < Configuration.MinMemoryKBytes {
|
if Statistics.SysMemFreeKB > 0 && Statistics.SysMemFreeKB < Configuration.MinMemoryKBytes {
|
||||||
atomic.AddUint64(&Statistics.LowMemDroppedConnections, 1)
|
atomic.AddUint64(&Statistics.LowMemDroppedConnections, 1)
|
||||||
w.WriteHeader(503)
|
w.WriteHeader(503)
|
||||||
|
fmt.Fprint(w, "error: low memory")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if Configuration.MaxClientCount != 0 {
|
||||||
|
curClients := atomic.LoadUint64(&Statistics.CurrentClientCount)
|
||||||
|
if curClients >= Configuration.MaxClientCount {
|
||||||
|
w.WriteHeader(503)
|
||||||
|
fmt.Fprint(w, "error: client limit reached")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
conn, err := SocketUpgrader.Upgrade(w, r, nil)
|
conn, err := SocketUpgrader.Upgrade(w, r, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(w, "error: %v", err)
|
fmt.Fprintf(w, "error: %v", err)
|
||||||
|
|
|
@ -16,17 +16,24 @@ const NegativeOne = ^uint64(0)
|
||||||
type ConfigFile struct {
|
type ConfigFile struct {
|
||||||
// Numeric server id known to the backend
|
// Numeric server id known to the backend
|
||||||
ServerID int
|
ServerID int
|
||||||
|
// Address to bind the HTTP server to on startup.
|
||||||
ListenAddr string
|
ListenAddr string
|
||||||
|
// Address to bind the TLS server to on startup.
|
||||||
SSLListenAddr string
|
SSLListenAddr string
|
||||||
// URL to the backend server
|
// URL to the backend server
|
||||||
BackendURL string
|
BackendURL string
|
||||||
|
|
||||||
// Minimum memory to accept a new connection
|
// Minimum memory to accept a new connection
|
||||||
MinMemoryKBytes uint64
|
MinMemoryKBytes uint64
|
||||||
|
// Maximum # of clients that can be connected. 0 to disable.
|
||||||
|
MaxClientCount uint64
|
||||||
|
|
||||||
// SSL/TLS
|
// SSL/TLS
|
||||||
|
// Enable the use of SSL.
|
||||||
UseSSL bool
|
UseSSL bool
|
||||||
|
// Path to certificate file.
|
||||||
SSLCertificateFile string
|
SSLCertificateFile string
|
||||||
|
// Path to key file.
|
||||||
SSLKeyFile string
|
SSLKeyFile string
|
||||||
|
|
||||||
UseESLogStashing bool
|
UseESLogStashing bool
|
||||||
|
@ -39,6 +46,7 @@ type ConfigFile struct {
|
||||||
OurPublicKey []byte
|
OurPublicKey []byte
|
||||||
BackendPublicKey []byte
|
BackendPublicKey []byte
|
||||||
|
|
||||||
|
// Request username validation from all new clients.
|
||||||
SendAuthToNewClients bool
|
SendAuthToNewClients bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue