Documentation ¶
Index ¶
- Constants
- Variables
- func AlterId(user uuid.UUID) uuid.UUID
- func AuthID(key [16]byte, time time.Time, buffer *buf.Buffer)
- func AutoSecurityType() byte
- func CreateReader(upstream io.Reader, streamReader io.Reader, requestKey []byte, ...) io.Reader
- func CreateWriter(upstream io.Writer, streamWriter io.Writer, requestKey []byte, ...) io.Writer
- func GenerateChacha20Poly1305Key(b []byte) []byte
- func HandleMuxConnection(ctx context.Context, conn net.Conn, handler Handler) error
- func KDF(key []byte, salt string, path ...[]byte) []byte
- func Key(user uuid.UUID) (key [16]byte)
- type AEADChunkReader
- func NewAEADChunkReader(upstream io.Reader, cipher cipher.AEAD, nonce []byte, ...) *AEADChunkReader
- func NewAes128GcmChunkReader(upstream io.Reader, key []byte, nonce []byte, globalPadding sha3.ShakeHash) *AEADChunkReader
- func NewChacha20Poly1305ChunkReader(upstream io.Reader, key []byte, nonce []byte, globalPadding sha3.ShakeHash) *AEADChunkReader
- type AEADChunkWriter
- func NewAEADChunkWriter(upstream io.Writer, cipher cipher.AEAD, nonce []byte, ...) *AEADChunkWriter
- func NewAes128GcmChunkWriter(upstream io.Writer, key []byte, nonce []byte, globalPadding sha3.ShakeHash) *AEADChunkWriter
- func NewChacha20Poly1305ChunkWriter(upstream io.Writer, key []byte, nonce []byte, globalPadding sha3.ShakeHash) *AEADChunkWriter
- type AEADReader
- type AEADWriter
- type Client
- func (c *Client) DialConn(upstream net.Conn, destination M.Socksaddr) (N.ExtendedConn, error)
- func (c *Client) DialEarlyConn(upstream net.Conn, destination M.Socksaddr) N.ExtendedConn
- func (c *Client) DialEarlyPacketConn(upstream net.Conn, destination M.Socksaddr) PacketConn
- func (c *Client) DialEarlyXUDPPacketConn(upstream net.Conn, destination M.Socksaddr) PacketConn
- func (c *Client) DialPacketConn(upstream net.Conn, destination M.Socksaddr) (PacketConn, error)
- func (c *Client) DialXUDPPacketConn(upstream net.Conn, destination M.Socksaddr) (PacketConn, error)
- type ClientOption
- type Handler
- type MuxConnWrapper
- func (c *MuxConnWrapper) FrontHeadroom() int
- func (c *MuxConnWrapper) Read(p []byte) (n int, err error)
- func (c *MuxConnWrapper) ReadBuffer(buffer *buf.Buffer) error
- func (c *MuxConnWrapper) Upstream() any
- func (c *MuxConnWrapper) Write(p []byte) (n int, err error)
- func (c *MuxConnWrapper) WriteBuffer(buffer *buf.Buffer) error
- type PacketConn
- type Service
- type ServiceOption
- type StreamChecksumReader
- type StreamChecksumWriter
- type StreamChunkReader
- type StreamChunkWriter
- func (w *StreamChunkWriter) FrontHeadroom() int
- func (w *StreamChunkWriter) RearHeadroom() int
- func (w *StreamChunkWriter) Upstream() any
- func (w *StreamChunkWriter) Write(p []byte) (n int, err error)
- func (w *StreamChunkWriter) WriteBuffer(buffer *buf.Buffer) error
- func (w *StreamChunkWriter) WriteWithChecksum(checksum uint32, p []byte) (n int, err error)
- type StreamReader
- type StreamWriter
- type TimeFunc
- type XUDPConn
- func (c *XUDPConn) FrontHeadroom() int
- func (c *XUDPConn) NeedAdditionalReadDeadline() bool
- func (c *XUDPConn) NeedHandshake() bool
- func (c *XUDPConn) Read(p []byte) (n int, err error)
- func (c *XUDPConn) ReadFrom(p []byte) (n int, addr net.Addr, err error)
- func (c *XUDPConn) ReadPacket(buffer *buf.Buffer) (destination M.Socksaddr, err error)
- func (c *XUDPConn) Upstream() any
- func (c *XUDPConn) Write(p []byte) (n int, err error)
- func (c *XUDPConn) WritePacket(buffer *buf.Buffer, destination M.Socksaddr) error
- func (c *XUDPConn) WriteTo(p []byte, addr net.Addr) (n int, err error)
Constants ¶
View Source
const ( Version = 1 ReadChunkSize = 16384 WriteChunkSize = 15000 CacheDurationSeconds = 120 MaxPaddingSize = 64 MaxFrontHeadroom = 2 + CipherOverhead MaxRearHeadroom = CipherOverhead*2 + MaxPaddingSize )
View Source
const ( SecurityTypeLegacy = 1 SecurityTypeAuto = 2 SecurityTypeAes128Gcm = 3 SecurityTypeChacha20Poly1305 = 4 SecurityTypeNone = 5 SecurityTypeZero = 6 )
View Source
const ( CommandTCP = 1 CommandUDP = 2 CommandMux = 3 )
View Source
const ( RequestOptionChunkStream = 1 RequestOptionConnectionReuse = 2 RequestOptionChunkMasking = 4 RequestOptionGlobalPadding = 8 RequestOptionAuthenticatedLength = 16 )
View Source
const ( KDFSaltConstAuthIDEncryptionKey = "AES Auth ID Encryption" KDFSaltConstAEADRespHeaderLenKey = "AEAD Resp Header Len Key" KDFSaltConstAEADRespHeaderLenIV = "AEAD Resp Header Len IV" KDFSaltConstAEADRespHeaderPayloadKey = "AEAD Resp Header Key" KDFSaltConstAEADRespHeaderPayloadIV = "AEAD Resp Header IV" KDFSaltConstVMessAEADKDF = "VMess AEAD KDF" KDFSaltConstVMessHeaderPayloadAEADKey = "VMess Header AEAD Key" KDFSaltConstVMessHeaderPayloadAEADIV = "VMess Header AEAD Nonce" KDFSaltConstVMessHeaderPayloadLengthAEADKey = "VMess Header AEAD Key_Length" KDFSaltConstVMessHeaderPayloadLengthAEADIV = "VMess Header AEAD Nonce_Length" )
View Source
const ( StatusNew = 1 StatusKeep = 2 StatusEnd = 3 StatusKeepAlive = 4 OptionData = 1 OptionError = 2 NetworkTCP = 1 NetworkUDP = 2 )
View Source
const (
CipherOverhead = 16
)
Variables ¶
View Source
var ( ErrUnsupportedSecurityType = E.New("vmess: unsupported security type") ErrInvalidChecksum = E.New("vmess: invalid chunk checksum") )
View Source
var ( ErrBadHeader = E.New("bad header") ErrBadTimestamp = E.New("bad timestamp") ErrReplay = E.New("replayed request") ErrBadRequest = E.New("bad request") ErrBadVersion = E.New("bad version") )
View Source
var AddressSerializer = M.NewSerializer( M.AddressFamilyByte(0x01, M.AddressFamilyIPv4), M.AddressFamilyByte(0x03, M.AddressFamilyIPv6), M.AddressFamilyByte(0x02, M.AddressFamilyFqdn), M.PortThenAddress(), )
View Source
var ErrBadLengthChunk = E.New("bad length chunk")
View Source
var MuxDestination = M.Socksaddr{
Fqdn: "v1.mux.cool",
Port: 666,
}
Functions ¶
func AutoSecurityType ¶
func AutoSecurityType() byte
func CreateReader ¶
func CreateWriter ¶
func HandleMuxConnection ¶
Types ¶
type AEADChunkReader ¶
type AEADChunkReader struct {
// contains filtered or unexported fields
}
func NewAEADChunkReader ¶
func NewAes128GcmChunkReader ¶
func (*AEADChunkReader) Upstream ¶
func (r *AEADChunkReader) Upstream() any
type AEADChunkWriter ¶
type AEADChunkWriter struct {
// contains filtered or unexported fields
}
func NewAEADChunkWriter ¶
func NewAes128GcmChunkWriter ¶
func (*AEADChunkWriter) FrontHeadroom ¶
func (w *AEADChunkWriter) FrontHeadroom() int
func (*AEADChunkWriter) RearHeadroom ¶
func (w *AEADChunkWriter) RearHeadroom() int
func (*AEADChunkWriter) Upstream ¶
func (w *AEADChunkWriter) Upstream() any
func (*AEADChunkWriter) WriteBuffer ¶
func (w *AEADChunkWriter) WriteBuffer(buffer *buf.Buffer) error
type AEADReader ¶
type AEADReader struct {
// contains filtered or unexported fields
}
func NewAEADReader ¶
func NewAes128GcmReader ¶
func NewAes128GcmReader(upstream io.Reader, key []byte, nonce []byte) *AEADReader
func NewChacha20Poly1305Reader ¶
func NewChacha20Poly1305Reader(upstream io.Reader, key []byte, nonce []byte) *AEADReader
func (*AEADReader) ReadBuffer ¶
func (r *AEADReader) ReadBuffer(buffer *buf.Buffer) error
func (*AEADReader) Upstream ¶
func (r *AEADReader) Upstream() any
type AEADWriter ¶
type AEADWriter struct {
// contains filtered or unexported fields
}
func NewAEADWriter ¶
func NewAes128GcmWriter ¶
func NewAes128GcmWriter(upstream io.Writer, key []byte, nonce []byte) *AEADWriter
func NewChacha20Poly1305Writer ¶
func NewChacha20Poly1305Writer(upstream io.Writer, key []byte, nonce []byte) *AEADWriter
func (*AEADWriter) RearHeadroom ¶
func (w *AEADWriter) RearHeadroom() int
func (*AEADWriter) Upstream ¶
func (w *AEADWriter) Upstream() any
func (*AEADWriter) WriteBuffer ¶
func (w *AEADWriter) WriteBuffer(buffer *buf.Buffer) error
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) DialEarlyConn ¶
func (*Client) DialEarlyPacketConn ¶
func (*Client) DialEarlyXUDPPacketConn ¶
func (*Client) DialPacketConn ¶
func (*Client) DialXUDPPacketConn ¶
type ClientOption ¶
type ClientOption func(*Client)
func ClientWithAuthenticatedLength ¶
func ClientWithAuthenticatedLength() ClientOption
func ClientWithGlobalPadding ¶
func ClientWithGlobalPadding() ClientOption
func ClientWithTimeFunc ¶
func ClientWithTimeFunc(timeFunc TimeFunc) ClientOption
type Handler ¶
type Handler interface { N.TCPConnectionHandler N.UDPConnectionHandler E.Handler }
type MuxConnWrapper ¶
func NewMuxConnWrapper ¶
func NewMuxConnWrapper(conn net.Conn, destination M.Socksaddr) *MuxConnWrapper
func (*MuxConnWrapper) FrontHeadroom ¶
func (c *MuxConnWrapper) FrontHeadroom() int
func (*MuxConnWrapper) ReadBuffer ¶
func (c *MuxConnWrapper) ReadBuffer(buffer *buf.Buffer) error
func (*MuxConnWrapper) Upstream ¶
func (c *MuxConnWrapper) Upstream() any
func (*MuxConnWrapper) WriteBuffer ¶
func (c *MuxConnWrapper) WriteBuffer(buffer *buf.Buffer) error
type PacketConn ¶
type PacketConn interface { net.Conn N.NetPacketConn }
type Service ¶
type Service[U comparable] struct { // contains filtered or unexported fields }
func NewService ¶
func NewService[U comparable](handler Handler, options ...ServiceOption) *Service[U]
func (*Service[U]) NewConnection ¶
type ServiceOption ¶
func ServiceWithDisableHeaderProtection ¶
func ServiceWithDisableHeaderProtection() ServiceOption
func ServiceWithTimeFunc ¶
func ServiceWithTimeFunc(timeFunc TimeFunc) ServiceOption
type StreamChecksumReader ¶
type StreamChecksumReader struct {
// contains filtered or unexported fields
}
func NewStreamChecksumReader ¶
func NewStreamChecksumReader(reader io.Reader) *StreamChecksumReader
func (*StreamChecksumReader) Read ¶
func (r *StreamChecksumReader) Read(p []byte) (n int, err error)
func (*StreamChecksumReader) ReadBuffer ¶
func (r *StreamChecksumReader) ReadBuffer(buffer *buf.Buffer) error
func (*StreamChecksumReader) Upstream ¶
func (r *StreamChecksumReader) Upstream() any
type StreamChecksumWriter ¶
type StreamChecksumWriter struct {
// contains filtered or unexported fields
}
func NewStreamChecksumWriter ¶
func NewStreamChecksumWriter(upstream *StreamChunkWriter) *StreamChecksumWriter
func (*StreamChecksumWriter) FrontHeadroom ¶
func (w *StreamChecksumWriter) FrontHeadroom() int
func (*StreamChecksumWriter) Upstream ¶
func (w *StreamChecksumWriter) Upstream() any
func (*StreamChecksumWriter) Write ¶
func (w *StreamChecksumWriter) Write(p []byte) (n int, err error)
func (*StreamChecksumWriter) WriteBuffer ¶
func (w *StreamChecksumWriter) WriteBuffer(buffer *buf.Buffer) error
type StreamChunkReader ¶
type StreamChunkReader struct {
// contains filtered or unexported fields
}
func NewStreamChunkReader ¶
func (*StreamChunkReader) Upstream ¶
func (r *StreamChunkReader) Upstream() any
type StreamChunkWriter ¶
type StreamChunkWriter struct {
// contains filtered or unexported fields
}
func NewStreamChunkWriter ¶
func (*StreamChunkWriter) FrontHeadroom ¶
func (w *StreamChunkWriter) FrontHeadroom() int
func (*StreamChunkWriter) RearHeadroom ¶
func (w *StreamChunkWriter) RearHeadroom() int
func (*StreamChunkWriter) Upstream ¶
func (w *StreamChunkWriter) Upstream() any
func (*StreamChunkWriter) WriteBuffer ¶
func (w *StreamChunkWriter) WriteBuffer(buffer *buf.Buffer) error
func (*StreamChunkWriter) WriteWithChecksum ¶
func (w *StreamChunkWriter) WriteWithChecksum(checksum uint32, p []byte) (n int, err error)
type StreamReader ¶
type StreamReader struct {
// contains filtered or unexported fields
}
func NewStreamReader ¶
func NewStreamReader(upstream io.Reader, key []byte, iv []byte) *StreamReader
func (*StreamReader) ReadBuffer ¶
func (r *StreamReader) ReadBuffer(buffer *buf.Buffer) error
func (*StreamReader) Upstream ¶
func (r *StreamReader) Upstream() any
type StreamWriter ¶
type StreamWriter struct {
// contains filtered or unexported fields
}
func NewStreamWriter ¶
func NewStreamWriter(upstream io.Writer, key []byte, iv []byte) *StreamWriter
func (*StreamWriter) Upstream ¶
func (w *StreamWriter) Upstream() any
func (*StreamWriter) WriteBuffer ¶
func (w *StreamWriter) WriteBuffer(buffer *buf.Buffer) error
type XUDPConn ¶
func (*XUDPConn) FrontHeadroom ¶
func (*XUDPConn) NeedAdditionalReadDeadline ¶
func (*XUDPConn) NeedHandshake ¶
func (*XUDPConn) ReadPacket ¶
func (*XUDPConn) WritePacket ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.