Bugfix proxy request handler

This commit is contained in:
9seconds
2018-07-05 14:59:33 +03:00
parent 4ed877efbc
commit 4210cf014e
3 changed files with 7 additions and 8 deletions
+4 -4
View File
@@ -34,14 +34,14 @@ func (r *ProxyRequest) Bytes(message []byte) []byte {
buf.Write(TagProxyRequest)
buf.Write(flags.Bytes())
buf.Write(r.ConnectionID[:])
buf.Write(r.ClientIPPort[:])
buf.Write(r.OurIPPort[:])
buf.Write(r.ConnectionID)
buf.Write(r.ClientIPPort)
buf.Write(r.OurIPPort)
buf.Write(ProxyRequestExtraSize)
buf.Write(ProxyRequestProxyTag)
buf.WriteByte(byte(len(r.ADTag)))
buf.Write(r.ADTag)
buf.Write(bytes.Repeat([]byte{0x00}, buf.Len()%4))
buf.Write(make([]byte, (4-buf.Len()%4)%4))
buf.Write(message)
return buf.Bytes()
+3 -2
View File
@@ -4,6 +4,7 @@ import (
"bytes"
"crypto/aes"
"encoding/binary"
"fmt"
"hash/crc32"
"io"
"io/ioutil"
@@ -20,7 +21,7 @@ const (
frameRWCMaxMessageLength = 16777216
)
var frameRWCPadding = [4]byte{0x04, 0x00, 0x00, 0x00}
var frameRWCPadding = []byte{0x04, 0x00, 0x00, 0x00}
type FrameRWC struct {
wrappers.BufferedReader
@@ -48,7 +49,7 @@ func (f *FrameRWC) Write(buf []byte) (int, error) {
checksum := crc32.ChecksumIEEE(writeBuf.Bytes())
binary.Write(writeBuf, binary.LittleEndian, checksum)
writeBuf.Write(bytes.Repeat(frameRWCPadding[:], paddingLength/4))
writeBuf.Write(bytes.Repeat(frameRWCPadding, paddingLength/4))
_, err := f.conn.Write(writeBuf.Bytes())
return len(buf), err
-2
View File
@@ -1,7 +1,6 @@
package telegram
import (
"fmt"
"io"
"net"
"net/http"
@@ -131,7 +130,6 @@ func (t *middleTelegram) receiveRPCHandshakeResponse(conn io.Reader, req *rpc.Ha
if err = rpcHandshakeResp.Valid(req); err != nil {
return nil, errors.Annotate(err, "Invalid RPC handshake response")
}
fmt.Println("VICTORY")
return rpcHandshakeResp, nil
}