mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-06-28 05:15:54 +00:00
Go back to 503 rejections instead of TLS aborts
This commit is contained in:
parent
0d3d8b5868
commit
360420022d
5 changed files with 5 additions and 15 deletions
|
@ -82,7 +82,6 @@ func main() {
|
||||||
Handler: http.DefaultServeMux,
|
Handler: http.DefaultServeMux,
|
||||||
TLSConfig: &tls.Config{
|
TLSConfig: &tls.Config{
|
||||||
GetCertificate: reloader.GetCertificateFunc(),
|
GetCertificate: reloader.GetCertificateFunc(),
|
||||||
GetConfigForClient: server.TLSEarlyReject,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
go func() {
|
go func() {
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"bitbucket.org/stendec/frankerfacez/socketserver/server"
|
"github.com/FrankerFaceZ/FrankerFaceZ/socketserver/server"
|
||||||
)
|
)
|
||||||
|
|
||||||
type CalendarData struct {
|
type CalendarData struct {
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"bitbucket.org/stendec/frankerfacez/socketserver/server"
|
"github.com/FrankerFaceZ/FrankerFaceZ/socketserver/server"
|
||||||
"github.com/clarkduvall/hyperloglog"
|
"github.com/clarkduvall/hyperloglog"
|
||||||
lru "github.com/hashicorp/golang-lru"
|
lru "github.com/hashicorp/golang-lru"
|
||||||
)
|
)
|
||||||
|
|
|
@ -12,7 +12,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"bitbucket.org/stendec/frankerfacez/socketserver/server"
|
"github.com/FrankerFaceZ/FrankerFaceZ/socketserver/server"
|
||||||
"github.com/clarkduvall/hyperloglog"
|
"github.com/clarkduvall/hyperloglog"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@ package server // import "github.com/FrankerFaceZ/FrankerFaceZ/socketserver/serv
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"crypto/tls"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -254,15 +253,6 @@ func shouldRejectConnection() bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
var errEarlyTLSReject = errors.New("over capacity")
|
|
||||||
|
|
||||||
func TLSEarlyReject(*tls.ClientHelloInfo) (*tls.Config, error) {
|
|
||||||
if shouldRejectConnection() {
|
|
||||||
return nil, errEarlyTLSReject
|
|
||||||
}
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// HTTPHandleRootURL is the http.HandleFunc for requests on `/`.
|
// HTTPHandleRootURL is the http.HandleFunc for requests on `/`.
|
||||||
// It either uses the SocketUpgrader or writes out the BannerHTML.
|
// It either uses the SocketUpgrader or writes out the BannerHTML.
|
||||||
func HTTPHandleRootURL(w http.ResponseWriter, r *http.Request) {
|
func HTTPHandleRootURL(w http.ResponseWriter, r *http.Request) {
|
||||||
|
@ -283,6 +273,7 @@ func HTTPHandleRootURL(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
conn, err := SocketUpgrader.Upgrade(w, r, nil)
|
conn, err := SocketUpgrader.Upgrade(w, r, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
w.WriteHeader(400)
|
||||||
fmt.Fprintf(w, "error: %v", err)
|
fmt.Fprintf(w, "error: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue