2020-07-22 23:02:15 +08:00
|
|
|
package protocol
|
|
|
|
|
2021-02-15 14:32:03 +08:00
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"net"
|
2023-05-28 22:51:26 +08:00
|
|
|
|
2023-11-03 21:01:45 +08:00
|
|
|
N "github.com/metacubex/mihomo/common/net"
|
2021-02-15 14:32:03 +08:00
|
|
|
)
|
2020-07-22 23:02:15 +08:00
|
|
|
|
2021-02-15 14:32:03 +08:00
|
|
|
type origin struct{}
|
2020-07-22 23:02:15 +08:00
|
|
|
|
2021-02-15 14:32:03 +08:00
|
|
|
func init() { register("origin", newOrigin, 0) }
|
2020-07-22 23:02:15 +08:00
|
|
|
|
2021-02-15 14:32:03 +08:00
|
|
|
func newOrigin(b *Base) Protocol { return &origin{} }
|
2020-07-22 23:02:15 +08:00
|
|
|
|
2021-02-15 14:32:03 +08:00
|
|
|
func (o *origin) StreamConn(c net.Conn, iv []byte) net.Conn { return c }
|
2020-07-22 23:02:15 +08:00
|
|
|
|
2023-05-28 22:51:26 +08:00
|
|
|
func (o *origin) PacketConn(c N.EnhancePacketConn) N.EnhancePacketConn { return c }
|
2020-07-22 23:02:15 +08:00
|
|
|
|
2021-02-15 14:32:03 +08:00
|
|
|
func (o *origin) Decode(dst, src *bytes.Buffer) error {
|
|
|
|
dst.ReadFrom(src)
|
|
|
|
return nil
|
2020-07-22 23:02:15 +08:00
|
|
|
}
|
|
|
|
|
2021-02-15 14:32:03 +08:00
|
|
|
func (o *origin) Encode(buf *bytes.Buffer, b []byte) error {
|
|
|
|
buf.Write(b)
|
|
|
|
return nil
|
2020-07-22 23:02:15 +08:00
|
|
|
}
|
|
|
|
|
2021-02-15 14:32:03 +08:00
|
|
|
func (o *origin) DecodePacket(b []byte) ([]byte, error) { return b, nil }
|
2020-07-22 23:02:15 +08:00
|
|
|
|
2021-02-15 14:32:03 +08:00
|
|
|
func (o *origin) EncodePacket(buf *bytes.Buffer, b []byte) error {
|
|
|
|
buf.Write(b)
|
|
|
|
return nil
|
2020-07-22 23:02:15 +08:00
|
|
|
}
|