github.com/kelleygo/clashcore@v1.0.2/transport/ssr/protocol/origin.go (about)

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