mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-19 15:57:04 -05:00
add packetaddr support for socks
This commit is contained in:
parent
79726111e3
commit
690b4924ae
@ -2,6 +2,7 @@ package socks
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"github.com/v2fly/v2ray-core/v4/common/net/packetaddr"
|
||||||
"io"
|
"io"
|
||||||
"time"
|
"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 {
|
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
|
payload := packet.Payload
|
||||||
newError("writing back UDP response with ", payload.Len(), " bytes").AtDebug().WriteToLog(session.ExportIDToError(ctx))
|
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(
|
func (pdc *PacketAddrDispatcherCreator) NewPacketAddrDispatcher(
|
||||||
dispatcher routing.Dispatcher, callback ResponseCallback) (DispatcherI, error) {
|
dispatcher routing.Dispatcher, callback ResponseCallback) DispatcherI {
|
||||||
packetConn, err := packetaddr.CreatePacketAddrConn(pdc.ctx, dispatcher, false)
|
packetConn, _ := packetaddr.CreatePacketAddrConn(pdc.ctx, dispatcher, false)
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
pd := &PacketAddrDispatcher{conn: packetConn, callback: callback, ctx: pdc.ctx}
|
pd := &PacketAddrDispatcher{conn: packetConn, callback: callback, ctx: pdc.ctx}
|
||||||
go pd.readWorker()
|
go pd.readWorker()
|
||||||
return pd, nil
|
return pd
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user