mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 18:04:03 +03:00
Log proxt req header flags
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package rpc
|
||||
|
||||
import "encoding/binary"
|
||||
import (
|
||||
"encoding/binary"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type proxyRequestFlags uint32
|
||||
|
||||
@@ -22,3 +25,31 @@ func (r proxyRequestFlags) Bytes() []byte {
|
||||
|
||||
return converted
|
||||
}
|
||||
|
||||
func (r proxyRequestFlags) String() string {
|
||||
flags := make([]string, 0, 7)
|
||||
|
||||
if r&proxyRequestFlagsHasAdTag != 0 {
|
||||
flags = append(flags, "HAS_AD_TAG")
|
||||
}
|
||||
if r&proxyRequestFlagsEncrypted != 0 {
|
||||
flags = append(flags, "ENCRYPTED")
|
||||
}
|
||||
if r&proxyRequestFlagsMagic != 0 {
|
||||
flags = append(flags, "MAGIC")
|
||||
}
|
||||
if r&proxyRequestFlagsExtMode2 != 0 {
|
||||
flags = append(flags, "EXT_MODE_2")
|
||||
}
|
||||
if r&proxyRequestFlagsIntermediate != 0 {
|
||||
flags = append(flags, "INTERMEDIATE")
|
||||
}
|
||||
if r&proxyRequestFlagsAbdridged != 0 {
|
||||
flags = append(flags, "ABRIDGED")
|
||||
}
|
||||
if r&proxyRequestFlagsQuickAck != 0 {
|
||||
flags = append(flags, "QUICK_ACK")
|
||||
}
|
||||
|
||||
return strings.Join(flags, " | ")
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"crypto/rand"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"net"
|
||||
|
||||
"github.com/juju/errors"
|
||||
@@ -20,7 +21,7 @@ type ProxyRequest struct {
|
||||
Options *mtproto.ConnectionOpts
|
||||
}
|
||||
|
||||
func (r *ProxyRequest) MakeHeader(message []byte) *bytes.Buffer {
|
||||
func (r *ProxyRequest) MakeHeader(message []byte) (*bytes.Buffer, fmt.Stringer) {
|
||||
bufferLength := len(TagProxyRequest) +
|
||||
4 + // len(flags)
|
||||
len(r.ConnectionID) +
|
||||
@@ -55,7 +56,7 @@ func (r *ProxyRequest) MakeHeader(message []byte) *bytes.Buffer {
|
||||
buf.Write(r.ADTag)
|
||||
buf.Write(make([]byte, (4-buf.Len()%4)%4))
|
||||
|
||||
return buf
|
||||
return buf, flags
|
||||
}
|
||||
|
||||
func NewProxyRequest(clientAddr, ownAddr *net.TCPAddr, opts *mtproto.ConnectionOpts, adTag []byte) (*ProxyRequest, error) {
|
||||
|
||||
Reference in New Issue
Block a user