github.com/sagernet/sing-box@v1.9.0-rc.20/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  
    16  const (
    17  	commandPaddingContinue byte = iota
    18  	commandPaddingEnd
    19  	commandPaddingDirect
    20  )
    21  
    22  var tls13CipherSuiteDic = map[uint16]string{
    23  	0x1301: "TLS_AES_128_GCM_SHA256",
    24  	0x1302: "TLS_AES_256_GCM_SHA384",
    25  	0x1303: "TLS_CHACHA20_POLY1305_SHA256",
    26  	0x1304: "TLS_AES_128_CCM_SHA256",
    27  	0x1305: "TLS_AES_128_CCM_8_SHA256",
    28  }
    29  
    30  func reshapeBuffer(b []byte) []*buf.Buffer {
    31  	const bufferLimit = 8192 - 21
    32  	if len(b) < bufferLimit {
    33  		return []*buf.Buffer{buf.As(b)}
    34  	}
    35  	index := int32(bytes.LastIndex(b, tlsApplicationDataStart))
    36  	if index <= 0 {
    37  		index = 8192 / 2
    38  	}
    39  	return []*buf.Buffer{buf.As(b[:index]), buf.As(b[index:])}
    40  }