mirror of
https://github.com/go-i2p/go-meta-listener.git
synced 2025-06-18 04:39:55 -04:00
See if it's a TLS issue...
This commit is contained in:
@ -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)
|
||||
|
||||
|
Reference in New Issue
Block a user