mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-22 01:57:12 -05:00
change CreatePacketAddrConn signature
This commit is contained in:
parent
8bf3da7c7f
commit
75a2448c48
@ -1,6 +1,7 @@
|
|||||||
package packetaddr
|
package packetaddr
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
gonet "net"
|
gonet "net"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
@ -9,6 +10,7 @@ import (
|
|||||||
"github.com/v2fly/v2ray-core/v4/common/buf"
|
"github.com/v2fly/v2ray-core/v4/common/buf"
|
||||||
"github.com/v2fly/v2ray-core/v4/common/errors"
|
"github.com/v2fly/v2ray-core/v4/common/errors"
|
||||||
"github.com/v2fly/v2ray-core/v4/common/net"
|
"github.com/v2fly/v2ray-core/v4/common/net"
|
||||||
|
"github.com/v2fly/v2ray-core/v4/features/routing"
|
||||||
"github.com/v2fly/v2ray-core/v4/transport"
|
"github.com/v2fly/v2ray-core/v4/transport"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -31,18 +33,23 @@ func ToPacketAddrConn(link *transport.Link, dest net.Destination) (net.PacketCon
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreatePacketAddrConn(link *transport.Link, isStream bool) (net.PacketConn, net.Destination, error) {
|
func CreatePacketAddrConn(ctx context.Context, dispatcher routing.Dispatcher, isStream bool) (net.PacketConn, error) {
|
||||||
if isStream {
|
if isStream {
|
||||||
return nil, net.Destination{}, errUnsupported
|
return nil, errUnsupported
|
||||||
|
}
|
||||||
|
packetDest := net.Destination{
|
||||||
|
Address: net.DomainAddress(seqPacketMagicAddress),
|
||||||
|
Port: 0,
|
||||||
|
Network: net.Network_UDP,
|
||||||
|
}
|
||||||
|
link, err := dispatcher.Dispatch(ctx, packetDest)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
}
|
}
|
||||||
return &packetConnectionAdaptor{
|
return &packetConnectionAdaptor{
|
||||||
readerAccess: &sync.Mutex{},
|
readerAccess: &sync.Mutex{},
|
||||||
readerBuffer: nil,
|
readerBuffer: nil,
|
||||||
link: link,
|
link: link,
|
||||||
}, net.Destination{
|
|
||||||
Address: net.DomainAddress(seqPacketMagicAddress),
|
|
||||||
Port: 0,
|
|
||||||
Network: net.Network_UDP,
|
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user