mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 23:54:03 +03:00
Update to go 1.19
This commit is contained in:
@@ -93,12 +93,14 @@ func (c *ClientProtocol) Handshake(socket conntypes.StreamReadWriteCloser) (conn
|
||||
return stream.NewObfuscated2(socket, encryptor, decryptor), nil
|
||||
}
|
||||
|
||||
func (c *ClientProtocol) ReadFrame(socket conntypes.StreamReader) (fm Frame, err error) {
|
||||
if _, err = io.ReadFull(handshakeReader{socket}, fm.Bytes()); err != nil {
|
||||
err = fmt.Errorf("cannot extract obfuscated2 frame: %w", err)
|
||||
func (c *ClientProtocol) ReadFrame(socket conntypes.StreamReader) (Frame, error) {
|
||||
fm := Frame{}
|
||||
|
||||
if _, err := io.ReadFull(handshakeReader{socket}, fm.Bytes()); err != nil {
|
||||
return fm, fmt.Errorf("cannot extract obfuscated2 frame: %w", err)
|
||||
}
|
||||
|
||||
return
|
||||
return fm, nil
|
||||
}
|
||||
|
||||
type handshakeReader struct {
|
||||
@@ -106,7 +108,7 @@ type handshakeReader struct {
|
||||
}
|
||||
|
||||
func (h handshakeReader) Read(p []byte) (int, error) {
|
||||
return h.parent.ReadTimeout(p, clientProtocolHandshakeTimeout) // nolint: wrapcheck
|
||||
return h.parent.ReadTimeout(p, clientProtocolHandshakeTimeout) //nolint: wrapcheck
|
||||
}
|
||||
|
||||
func MakeClientProtocol() protocol.ClientProtocol {
|
||||
|
||||
@@ -44,11 +44,11 @@ func (f *Frame) Unique() []byte {
|
||||
return f.data[frameOffsetFirst:frameOffsetDC]
|
||||
}
|
||||
|
||||
func (f *Frame) Invert() (nf Frame) {
|
||||
nf = *f
|
||||
func (f *Frame) Invert() Frame {
|
||||
nf := *f
|
||||
for i := 0; i < frameLenKey+frameLenIV; i++ {
|
||||
nf.data[frameOffsetFirst+i] = f.data[frameOffsetIV-1-i]
|
||||
}
|
||||
|
||||
return
|
||||
return nf
|
||||
}
|
||||
|
||||
@@ -39,7 +39,8 @@ func TelegramProtocol(req *protocol.TelegramRequest) (conntypes.StreamReadWriteC
|
||||
return stream.NewObfuscated2(conn, encryptor, decryptor), nil
|
||||
}
|
||||
|
||||
func generateFrame(cp protocol.ClientProtocol) (fm Frame) {
|
||||
func generateFrame(cp protocol.ClientProtocol) Frame {
|
||||
fm := Frame{}
|
||||
data := fm.Bytes()
|
||||
|
||||
for {
|
||||
@@ -47,22 +48,22 @@ func generateFrame(cp protocol.ClientProtocol) (fm Frame) {
|
||||
continue
|
||||
}
|
||||
|
||||
if data[0] == 0xef { // nolint: gomnd
|
||||
if data[0] == 0xef { //nolint: gomnd
|
||||
continue
|
||||
}
|
||||
|
||||
val := (uint32(data[3]) << 24) | (uint32(data[2]) << 16) | (uint32(data[1]) << 8) | uint32(data[0]) // nolint: gomnd, lll
|
||||
if val == 0x44414548 || val == 0x54534f50 || val == 0x20544547 || val == 0x4954504f || val == 0xeeeeeeee { // nolint: lll
|
||||
val := (uint32(data[3]) << 24) | (uint32(data[2]) << 16) | (uint32(data[1]) << 8) | uint32(data[0]) //nolint: gomnd, lll
|
||||
if val == 0x44414548 || val == 0x54534f50 || val == 0x20544547 || val == 0x4954504f || val == 0xeeeeeeee { //nolint: lll
|
||||
continue
|
||||
}
|
||||
|
||||
val = (uint32(data[7]) << 24) | (uint32(data[6]) << 16) | (uint32(data[5]) << 8) | uint32(data[4]) // nolint: gomnd
|
||||
if val == 0x00000000 { // nolint: gomnd
|
||||
val = (uint32(data[7]) << 24) | (uint32(data[6]) << 16) | (uint32(data[5]) << 8) | uint32(data[4]) //nolint: gomnd
|
||||
if val == 0x00000000 { //nolint: gomnd
|
||||
continue
|
||||
}
|
||||
|
||||
copy(fm.Magic(), cp.ConnectionType().Tag())
|
||||
|
||||
return
|
||||
return fm
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user