1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-08-13 09:30:53 +00:00

Add MaxClientCount to configuration

This commit is contained in:
Kane York 2016-01-15 20:59:33 -08:00
parent e117766eb6
commit ba73186a99
2 changed files with 18 additions and 0 deletions

View file

@ -203,9 +203,19 @@ func HTTPHandleRootURL(w http.ResponseWriter, r *http.Request) {
if Statistics.SysMemFreeKB > 0 && Statistics.SysMemFreeKB < Configuration.MinMemoryKBytes {
atomic.AddUint64(&Statistics.LowMemDroppedConnections, 1)
w.WriteHeader(503)
fmt.Fprint(w, "error: low memory")
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)
if err != nil {
fmt.Fprintf(w, "error: %v", err)

View file

@ -16,17 +16,24 @@ const NegativeOne = ^uint64(0)
type ConfigFile struct {
// Numeric server id known to the backend
ServerID int
// Address to bind the HTTP server to on startup.
ListenAddr string
// Address to bind the TLS server to on startup.
SSLListenAddr string
// URL to the backend server
BackendURL string
// Minimum memory to accept a new connection
MinMemoryKBytes uint64
// Maximum # of clients that can be connected. 0 to disable.
MaxClientCount uint64
// SSL/TLS
// Enable the use of SSL.
UseSSL bool
// Path to certificate file.
SSLCertificateFile string
// Path to key file.
SSLKeyFile string
UseESLogStashing bool
@ -39,6 +46,7 @@ type ConfigFile struct {
OurPublicKey []byte
BackendPublicKey []byte
// Request username validation from all new clients.
SendAuthToNewClients bool
}