github.com/sagernet/sing-box@v1.2.7/transport/vless/constant.go (about)

     1  package vless
     2  
     3  import (
     4  	"bytes"
     5  
     6  	"github.com/sagernet/sing/common/buf"
     7  )
     8  
     9  var (
    10  	tls13SupportedVersions  = []byte{0x00, 0x2b, 0x00, 0x02, 0x03, 0x04}
    11  	tlsClientHandShakeStart = []byte{0x16, 0x03}
    12  	tlsServerHandShakeStart = []byte{0x16, 0x03, 0x03}
    13  	tlsApplicationDataStart = []byte{0x17, 0x03, 0x03}
    14  
    15  	commandPaddingContinue byte = 0
    16  	commandPaddingEnd      byte = 1
    17  	commandPaddingDirect   byte = 2
    18  )
    19  
    20  var tls13CipherSuiteDic = map[uint16]string{
    21  	0x1301: "TLS_AES_128_GCM_SHA256",
    22  	0x1302: "TLS_AES_256_GCM_SHA384",
    23  	0x1303: "TLS_CHACHA20_POLY1305_SHA256",
    24  	0x1304: "TLS_AES_128_CCM_SHA256",
    25  	0x1305: "TLS_AES_128_CCM_8_SHA256",
    26  }
    27  
    28  func reshapeBuffer(b []byte) []*buf.Buffer {
    29  	const bufferLimit = 8192 - 21
    30  	if len(b) < bufferLimit {
    31  		return []*buf.Buffer{buf.As(b)}
    32  	}
    33  	index := int32(bytes.LastIndex(b, tlsApplicationDataStart))
    34  	if index <= 0 {
    35  		index = 8192 / 2
    36  	}
    37  	return []*buf.Buffer{buf.As(b[:index]), buf.As(b[index:])}
    38  }