Skip to content

Commit 7960bca

Browse files
committed
chore: code cleanup
1 parent 664ddb8 commit 7960bca

File tree

1 file changed

+1
-25
lines changed

1 file changed

+1
-25
lines changed

transport/vless/vision/padding.go

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,30 +19,6 @@ const (
1919
commandPaddingDirect byte = 0x02
2020
)
2121

22-
func WriteWithPadding(buffer *buf.Buffer, p []byte, command byte, userUUID *uuid.UUID, paddingTLS bool) {
23-
contentLen := int32(len(p))
24-
var paddingLen int32
25-
if contentLen < 900 {
26-
if paddingTLS {
27-
//log.Debugln("long padding")
28-
paddingLen = randv2.Int32N(500) + 900 - contentLen
29-
} else {
30-
paddingLen = randv2.Int32N(256)
31-
}
32-
}
33-
if userUUID != nil {
34-
buffer.Write(userUUID.Bytes())
35-
}
36-
37-
buffer.WriteByte(command)
38-
binary.BigEndian.PutUint16(buffer.Extend(2), uint16(contentLen))
39-
binary.BigEndian.PutUint16(buffer.Extend(2), uint16(paddingLen))
40-
buffer.Write(p)
41-
42-
buffer.Extend(int(paddingLen))
43-
log.Debugln("XTLS Vision write padding1: command=%v, payloadLen=%v, paddingLen=%v", command, contentLen, paddingLen)
44-
}
45-
4622
func ApplyPadding(buffer *buf.Buffer, command byte, userUUID *uuid.UUID, paddingTLS bool) {
4723
contentLen := int32(buffer.Len())
4824
var paddingLen int32
@@ -63,7 +39,7 @@ func ApplyPadding(buffer *buf.Buffer, command byte, userUUID *uuid.UUID, padding
6339
}
6440

6541
buffer.Extend(int(paddingLen))
66-
log.Debugln("XTLS Vision write padding2: command=%d, payloadLen=%d, paddingLen=%d", command, contentLen, paddingLen)
42+
log.Debugln("XTLS Vision write padding: command=%d, payloadLen=%d, paddingLen=%d", command, contentLen, paddingLen)
6743
}
6844

6945
func ReshapeBuffer(buffer *buf.Buffer) *buf.Buffer {

0 commit comments

Comments
 (0)