Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct { proxy.EmptyDispatch // contains filtered or unexported fields }
func (*Client) PacketConn ¶
type QuicAddr ¶
func (s *Server) handleQuicDatagram(b []byte, session quic.Connection) error { if len(b) <= 5 { return fmt.Errorf("invalid datagram") } id := binary.BigEndian.Uint16(b[:2]) addr, err := s5c.ResolveAddr(bytes.NewBuffer(b[2:])) if err != nil { return err } log.Println("new udp from", session.RemoteAddr(), "id", id, "to", addr.Address(statistic.Type_udp)) return c.nat.Write(&nat.Packet{ SourceAddress: &QuicAddr{ addr: session.RemoteAddr(), id: quic.StreamID(id), }, DestinationAddress: addr.Address(statistic.Type_udp), Payload: b[2+len(addr):], WriteBack: func(b []byte, addr net.Addr) (int, error) { add, err := proxy.ParseSysAddr(addr) if err != nil { return 0, err } buf := pool.GetBuffer() defer pool.PutBuffer(buf) binary.Write(buf, binary.BigEndian, id) s5c.ParseAddrWriter(add, buf) buf.Write(b) // log.Println("write back to", session.RemoteAddr(), "id", id) if err = session.SendMessage(buf.Bytes()); err != nil { return 0, err } return len(b), nil }, }) }
Click to show internal directories.
Click to hide internal directories.