See if it's a TLS issue...

This commit is contained in:
eyedeekay
2025-05-05 15:33:09 -04:00
parent 509c265a3d
commit b692f9c58f

View File

@ -2,6 +2,7 @@ package mirror
import (
"bufio"
"crypto/tls"
"log"
"net"
"net/http"
@ -43,14 +44,27 @@ func (ml *Mirror) Accept() (net.Conn, error) {
// Accept a connection from the listener
conn, err := ml.MetaListener.Accept()
if err != nil {
log.Println("Error accepting connection:", err)
return nil, err
}
// Check if the connection is a TLS connection
if tlsConn, ok := conn.(*tls.Conn); ok {
// If it is a TLS connection, perform the handshake
if err := tlsConn.Handshake(); err != nil {
log.Println("Error performing TLS handshake:", err)
return nil, err
}
// If the handshake is successful, get the underlying connection
conn = tlsConn.NetConn()
}
host := map[string]string{
"Host": ml.MetaListener.Addr().String(),
"X-Forwarded-For": conn.RemoteAddr().String(),
"X-Forwarded-Proto": "http",
}
// Add headers to the connection
conn = AddHeaders(conn, host)