-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
badtls: Support uTLS and TLS ECH for read waiter
- Loading branch information
1 parent
11bec79
commit 1ce8ae6
Showing
3 changed files
with
116 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
//go:build go1.21 && !without_badtls && with_ech | ||
|
||
package badtls | ||
|
||
import ( | ||
"net" | ||
_ "unsafe" | ||
|
||
"github.com/sagernet/cloudflare-tls" | ||
"github.com/sagernet/sing/common" | ||
) | ||
|
||
func init() { | ||
tlsRegistry = append(tlsRegistry, func(conn net.Conn) (loaded bool, tlsReadRecord func() error, tlsHandlePostHandshakeMessage func() error) { | ||
tlsConn, loaded := common.Cast[*tls.Conn](conn) | ||
if !loaded { | ||
return | ||
} | ||
return true, func() error { | ||
return echReadRecord(tlsConn) | ||
}, func() error { | ||
return echHandlePostHandshakeMessage(tlsConn) | ||
} | ||
}) | ||
} | ||
|
||
//go:linkname echReadRecord github.com/sagernet/cloudflare-tls.(*Conn).readRecord | ||
func echReadRecord(c *tls.Conn) error | ||
|
||
//go:linkname echHandlePostHandshakeMessage github.com/sagernet/cloudflare-tls.(*Conn).handlePostHandshakeMessage | ||
func echHandlePostHandshakeMessage(c *tls.Conn) error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
//go:build go1.21 && !without_badtls && with_utls | ||
|
||
package badtls | ||
|
||
import ( | ||
"net" | ||
_ "unsafe" | ||
|
||
"github.com/sagernet/sing/common" | ||
"github.com/sagernet/utls" | ||
) | ||
|
||
func init() { | ||
tlsRegistry = append(tlsRegistry, func(conn net.Conn) (loaded bool, tlsReadRecord func() error, tlsHandlePostHandshakeMessage func() error) { | ||
tlsConn, loaded := common.Cast[*tls.UConn](conn) | ||
if !loaded { | ||
return | ||
} | ||
return true, func() error { | ||
return utlsReadRecord(tlsConn.Conn) | ||
}, func() error { | ||
return utlsHandlePostHandshakeMessage(tlsConn.Conn) | ||
} | ||
}) | ||
} | ||
|
||
//go:linkname utlsReadRecord github.com/sagernet/utls.(*Conn).readRecord | ||
func utlsReadRecord(c *tls.Conn) error | ||
|
||
//go:linkname utlsHandlePostHandshakeMessage github.com/sagernet/utls.(*Conn).handlePostHandshakeMessage | ||
func utlsHandlePostHandshakeMessage(c *tls.Conn) error |