merge develop into master #21
@ -5,6 +5,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"mpbl3p/proxy"
|
"mpbl3p/proxy"
|
||||||
"net"
|
"net"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ComparableUdpAddress struct {
|
type ComparableUdpAddress struct {
|
||||||
@ -45,15 +46,19 @@ func NewListener(ctx context.Context, p *proxy.Proxy, local string, v func() pro
|
|||||||
receivedConnections := make(map[ComparableUdpAddress]*Flow)
|
receivedConnections := make(map[ComparableUdpAddress]*Flow)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for ctx.Err() == nil {
|
||||||
buf := make([]byte, 6000)
|
buf := make([]byte, 6000)
|
||||||
|
|
||||||
log.Println("listening...")
|
if err := pconn.SetReadDeadline(time.Now().Add(time.Second)); err != nil {
|
||||||
n, addr, err := pconn.ReadFromUDP(buf)
|
panic(err)
|
||||||
if err != nil {
|
}
|
||||||
|
n, addr, err := pconn.ReadFromUDP(buf)
|
||||||
|
if err != nil {
|
||||||
|
if e, ok := err.(net.Error); ok && e.Timeout() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
log.Println("listened")
|
|
||||||
|
|
||||||
raddr := fromUdpAddress(*addr)
|
raddr := fromUdpAddress(*addr)
|
||||||
if f, exists := receivedConnections[raddr]; exists {
|
if f, exists := receivedConnections[raddr]; exists {
|
||||||
@ -84,7 +89,9 @@ func NewListener(ctx context.Context, p *proxy.Proxy, local string, v func() pro
|
|||||||
p.AddProducer(ctx, &f, v)
|
p.AddProducer(ctx, &f, v)
|
||||||
|
|
||||||
log.Println("handling...")
|
log.Println("handling...")
|
||||||
f.queueDatagram(ctx, buf[:n])
|
if err := f.queueDatagram(ctx, buf[:n]); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
log.Println("handled")
|
log.Println("handled")
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
Loading…
Reference in New Issue
Block a user