mirror of
https://github.com/fumiama/terasu.git
synced 2026-06-12 14:10:32 +08:00
feat: new implementations
This commit is contained in:
10
terasu.go
10
terasu.go
@@ -6,25 +6,27 @@ import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
var DefaultFirstFragmentLen uint8 = 4
|
||||
|
||||
// Use terasu in this TLS conn
|
||||
func Use(conn *tls.Conn) *Conn {
|
||||
return (*Conn)(conn)
|
||||
}
|
||||
|
||||
// Handshake do terasu handshake in this TLS conn
|
||||
func (conn *Conn) Handshake() error {
|
||||
func (conn *Conn) Handshake(firstFragmentLen uint8) error {
|
||||
expose := (*_trsconn)(unsafe.Pointer(conn))
|
||||
fnbak := expose.handshakeFn
|
||||
expose.handshakeFn = conn.clientHandshake
|
||||
expose.handshakeFn = conn.clientHandshake(firstFragmentLen)
|
||||
defer func() { expose.handshakeFn = fnbak }()
|
||||
return (*tls.Conn)(conn).Handshake()
|
||||
}
|
||||
|
||||
// Handshake do terasu handshake with ctx in this TLS conn
|
||||
func (conn *Conn) HandshakeContext(ctx context.Context) error {
|
||||
func (conn *Conn) HandshakeContext(ctx context.Context, firstFragmentLen uint8) error {
|
||||
expose := (*_trsconn)(unsafe.Pointer(conn))
|
||||
fnbak := expose.handshakeFn
|
||||
expose.handshakeFn = conn.clientHandshake
|
||||
expose.handshakeFn = conn.clientHandshake(firstFragmentLen)
|
||||
defer func() { expose.handshakeFn = fnbak }()
|
||||
return (*tls.Conn)(conn).HandshakeContext(ctx)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user