mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 21:24:01 +03:00
Add base for faketls
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
package faketls
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
|
||||
"github.com/9seconds/mtg/conntypes"
|
||||
"github.com/9seconds/mtg/obfuscated2"
|
||||
"github.com/9seconds/mtg/wrappers/stream"
|
||||
)
|
||||
|
||||
type ClientProtocol struct {
|
||||
obfuscated2.ClientProtocol
|
||||
}
|
||||
|
||||
func (c *ClientProtocol) Handshake(socket conntypes.StreamReadWriteCloser) (conntypes.StreamReadWriteCloser, error) {
|
||||
rewinded := stream.NewRewind(socket)
|
||||
bufferedReader := bufio.NewReader(rewinded)
|
||||
|
||||
for _, expected := range faketlsStartBytes {
|
||||
if actual, err := bufferedReader.ReadByte(); err != nil || actual != expected {
|
||||
return nil, c.simulateWebsite(rewinded)
|
||||
}
|
||||
}
|
||||
|
||||
if err := c.tlsHandshake(rewinded); err != nil {
|
||||
return nil, c.simulateWebsite(rewinded)
|
||||
}
|
||||
|
||||
conn, err := c.ClientProtocol.Handshake(socket)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return conn, err
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package faketls
|
||||
|
||||
const (
|
||||
TLSHandshakeLength = 1 + 2 + 2 + 512
|
||||
)
|
||||
|
||||
var (
|
||||
faketlsStartBytes = [...]byte{
|
||||
0x16,
|
||||
0x03,
|
||||
0x01,
|
||||
0x02,
|
||||
0x00,
|
||||
0x01,
|
||||
0x00,
|
||||
0x01,
|
||||
0xfc,
|
||||
0x03,
|
||||
0x03,
|
||||
}
|
||||
)
|
||||
@@ -0,0 +1,10 @@
|
||||
package faketls
|
||||
|
||||
import (
|
||||
"github.com/9seconds/mtg/conntypes"
|
||||
"github.com/9seconds/mtg/protocol"
|
||||
)
|
||||
|
||||
func TelegramProtocol(req *protocol.TelegramRequest) (conntypes.StreamReadWriteCloser, error) {
|
||||
return nil, nil
|
||||
}
|
||||
Reference in New Issue
Block a user