github.com/chwjbn/xclash@v0.2.0/transport/ssr/protocol/origin.go (about)

     1  package protocol
     2  
     3  import (
     4  	"bytes"
     5  	"net"
     6  )
     7  
     8  type origin struct{}
     9  
    10  func init() { register("origin", newOrigin, 0) }
    11  
    12  func newOrigin(b *Base) Protocol { return &origin{} }
    13  
    14  func (o *origin) StreamConn(c net.Conn, iv []byte) net.Conn { return c }
    15  
    16  func (o *origin) PacketConn(c net.PacketConn) net.PacketConn { return c }
    17  
    18  func (o *origin) Decode(dst, src *bytes.Buffer) error {
    19  	dst.ReadFrom(src)
    20  	return nil
    21  }
    22  
    23  func (o *origin) Encode(buf *bytes.Buffer, b []byte) error {
    24  	buf.Write(b)
    25  	return nil
    26  }
    27  
    28  func (o *origin) DecodePacket(b []byte) ([]byte, error) { return b, nil }
    29  
    30  func (o *origin) EncodePacket(buf *bytes.Buffer, b []byte) error {
    31  	buf.Write(b)
    32  	return nil
    33  }