mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-02 07:26:24 -05:00
add packetaddr support for socks
This commit is contained in:
parent
79726111e3
commit
690b4924ae
@ -2,6 +2,7 @@ package socks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/v2fly/v2ray-core/v4/common/net/packetaddr"
|
||||
"io"
|
||||
"time"
|
||||
|
||||
@ -186,7 +187,14 @@ func (s *Server) transport(ctx context.Context, reader io.Reader, writer io.Writ
|
||||
}
|
||||
|
||||
func (s *Server) handleUDPPayload(ctx context.Context, conn internet.Connection, dispatcher routing.Dispatcher) error {
|
||||
udpServer := udp.NewSplitDispatcher(dispatcher, func(ctx context.Context, packet *udp_proto.Packet) {
|
||||
udpDispatcherConstructor := udp.NewSplitDispatcher
|
||||
switch s.config.PacketEncoding {
|
||||
case packetaddr.PacketAddrType_None:
|
||||
break
|
||||
case packetaddr.PacketAddrType_Packet:
|
||||
udpDispatcherConstructor = udp.NewPacketAddrDispatcherCreator(ctx).NewPacketAddrDispatcher
|
||||
}
|
||||
udpServer := udpDispatcherConstructor(dispatcher, func(ctx context.Context, packet *udp_proto.Packet) {
|
||||
payload := packet.Payload
|
||||
newError("writing back UDP response with ", payload.Len(), " bytes").AtDebug().WriteToLog(session.ExportIDToError(ctx))
|
||||
|
||||
|
@ -46,12 +46,9 @@ func NewPacketAddrDispatcherCreator(ctx context.Context) PacketAddrDispatcherCre
|
||||
}
|
||||
|
||||
func (pdc *PacketAddrDispatcherCreator) NewPacketAddrDispatcher(
|
||||
dispatcher routing.Dispatcher, callback ResponseCallback) (DispatcherI, error) {
|
||||
packetConn, err := packetaddr.CreatePacketAddrConn(pdc.ctx, dispatcher, false)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
dispatcher routing.Dispatcher, callback ResponseCallback) DispatcherI {
|
||||
packetConn, _ := packetaddr.CreatePacketAddrConn(pdc.ctx, dispatcher, false)
|
||||
pd := &PacketAddrDispatcher{conn: packetConn, callback: callback, ctx: pdc.ctx}
|
||||
go pd.readWorker()
|
||||
return pd, nil
|
||||
return pd
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user