constant.go 926 B

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