MCPcopy Create free account
hub / github.com/SenseUnit/dumbproxy / dispatchIncomingBuffer

Method dispatchIncomingBuffer

dialer/tt.go:294–318  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

292}
293
294func (m *udpDemuxConn) dispatchIncomingBuffer() error {
295 for {
296 b := m.wbuf.Bytes()
297 l := len(b)
298 if l < 4 {
299 return nil
300 }
301 size := binary.BigEndian.Uint32(b)
302 if size < 37 || size > 37+65535 {
303 return fmt.Errorf("bad UDP encap frame length: %d", size)
304 }
305 if int64(l) < int64(size)+4 {
306 return nil
307 }
308 cPkt := new(ClientOriginatedPacket)
309 if err := cPkt.UnmarshalBinary(b[:size+4]); err != nil {
310 m.logger.Error("demux failed: %v", err)
311 return err
312 }
313 if err := m.dispatchIncomingPacket(cPkt); err != nil {
314 m.logger.Error("packet <%s => %s> dispatch failed: %v", cPkt.Src.String(), cPkt.Dst.String(), err)
315 }
316 io.CopyN(io.Discard, &m.wbuf, int64(size+4))
317 }
318}
319
320func (m *udpDemuxConn) isDstDenied(dst netip.Addr) bool {
321 dst = dst.Unmap()

Callers 1

WriteMethod · 0.95

Calls 5

ErrorfMethod · 0.80
UnmarshalBinaryMethod · 0.45
ErrorMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected