Recover from panic in HTTPS code

This commit is contained in:
mkwcat 2024-01-07 15:59:32 -05:00
parent 31a32db633
commit d9945b29f5
No known key found for this signature in database
GPG Key ID: 7A505679CE9E7AA9

View File

@ -150,6 +150,13 @@ func startHTTPSProxy(config common.Config) {
// handleWiiTLS handles the TLS request from the Wii. It may call handleRealTLS if the request is from a modern web browser.
func handleWiiTLS(moduleName string, rawConn net.Conn, nasAddr string, privKeyPath string, certsPath string, serverCertsRecord []byte, certLen uint32, rsaKey *rsa.PrivateKey) {
// Recover from panics
defer func() {
if r := recover(); r != nil {
logging.Error(moduleName, "Panic:", r)
}
}()
conn := newBufferedConn(rawConn)
defer conn.Close()
@ -456,6 +463,13 @@ func handleWiiTLS(moduleName string, rawConn net.Conn, nasAddr string, privKeyPa
// handleRealTLS handles the TLS request legitimately using crypto/tls
func handleRealTLS(moduleName string, conn net.Conn, nasAddr string, privKeyPath string, certsPath string) {
// Recover from panics
defer func() {
if r := recover(); r != nil {
logging.Error(moduleName, "Panic:", r)
}
}()
// Read server key and certs
// TODO: Cache this
serverKey, err := os.ReadFile(privKeyPath)