mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-02-20 23:47:21 -05:00
style: remove unused code and comments
This commit is contained in:
parent
4b5f788b2f
commit
d1c3007d30
@ -55,19 +55,6 @@ func HandleTCP(handle func(tun_net.TCPConn)) StackOption {
|
|||||||
|
|
||||||
// TODO: set sockopt
|
// TODO: set sockopt
|
||||||
|
|
||||||
// tcpHandler := &TCPHandler{
|
|
||||||
// ctx: ctx,
|
|
||||||
// dispatcher: dispatcher,
|
|
||||||
// policyManager: policyManager,
|
|
||||||
// config: config,
|
|
||||||
// stack: s,
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if err := tcpHandler.Handle(gonet.NewTCPConn(wg, linkedEndpoint)); err != nil {
|
|
||||||
// // TODO: log
|
|
||||||
// // return newError("failed to handle tcp connection").Base(err)
|
|
||||||
// }
|
|
||||||
|
|
||||||
tcpConn := &tcpConn{
|
tcpConn := &tcpConn{
|
||||||
TCPConn: gonet.NewTCPConn(wg, linkedEndpoint),
|
TCPConn: gonet.NewTCPConn(wg, linkedEndpoint),
|
||||||
id: r.ID(),
|
id: r.ID(),
|
||||||
@ -103,7 +90,7 @@ func (h *TCPHandler) Handle(conn tun_net.TCPConn) error {
|
|||||||
dest := net.TCPDestination(tun_net.AddressFromTCPIPAddr(id.LocalAddress), net.Port(id.LocalPort))
|
dest := net.TCPDestination(tun_net.AddressFromTCPIPAddr(id.LocalAddress), net.Port(id.LocalPort))
|
||||||
src := net.TCPDestination(tun_net.AddressFromTCPIPAddr(id.RemoteAddress), net.Port(id.RemotePort))
|
src := net.TCPDestination(tun_net.AddressFromTCPIPAddr(id.RemoteAddress), net.Port(id.RemotePort))
|
||||||
ctx = log.ContextWithAccessMessage(ctx, &log.AccessMessage{
|
ctx = log.ContextWithAccessMessage(ctx, &log.AccessMessage{
|
||||||
From: src, // Parse IpAddr to Destination
|
From: src,
|
||||||
To: dest,
|
To: dest,
|
||||||
Status: log.AccessAccepted,
|
Status: log.AccessAccepted,
|
||||||
Reason: "",
|
Reason: "",
|
||||||
|
@ -75,7 +75,6 @@ func (h *UDPHandler) Handle(conn tun_net.UDPConn) error {
|
|||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
id := conn.ID()
|
id := conn.ID()
|
||||||
ctx := session.ContextWithInbound(h.ctx, &session.Inbound{Tag: h.config.Tag})
|
ctx := session.ContextWithInbound(h.ctx, &session.Inbound{Tag: h.config.Tag})
|
||||||
packetConn := conn.(net.PacketConn)
|
|
||||||
|
|
||||||
udpDispatcherConstructor := udp.NewSplitDispatcher
|
udpDispatcherConstructor := udp.NewSplitDispatcher
|
||||||
switch h.config.PacketEncoding {
|
switch h.config.PacketEncoding {
|
||||||
@ -90,7 +89,7 @@ func (h *UDPHandler) Handle(conn tun_net.UDPConn) error {
|
|||||||
src := net.UDPDestination(tun_net.AddressFromTCPIPAddr(id.RemoteAddress), net.Port(id.RemotePort))
|
src := net.UDPDestination(tun_net.AddressFromTCPIPAddr(id.RemoteAddress), net.Port(id.RemotePort))
|
||||||
|
|
||||||
udpServer := udpDispatcherConstructor(h.dispatcher, func(ctx context.Context, packet *udp_proto.Packet) {
|
udpServer := udpDispatcherConstructor(h.dispatcher, func(ctx context.Context, packet *udp_proto.Packet) {
|
||||||
if _, err := packetConn.WriteTo(packet.Payload.Bytes(), &net.UDPAddr{
|
if _, err := conn.WriteTo(packet.Payload.Bytes(), &net.UDPAddr{
|
||||||
IP: src.Address.IP(),
|
IP: src.Address.IP(),
|
||||||
Port: int(src.Port),
|
Port: int(src.Port),
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
@ -104,7 +103,7 @@ func (h *UDPHandler) Handle(conn tun_net.UDPConn) error {
|
|||||||
return nil
|
return nil
|
||||||
default:
|
default:
|
||||||
var buffer [2048]byte
|
var buffer [2048]byte
|
||||||
n, _, err := packetConn.ReadFrom(buffer[:])
|
n, _, err := conn.ReadFrom(buffer[:])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return newError("failed to read UDP packet").Base(err)
|
return newError("failed to read UDP packet").Base(err)
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ type TCPConn interface {
|
|||||||
|
|
||||||
type UDPConn interface {
|
type UDPConn interface {
|
||||||
net.Conn
|
net.Conn
|
||||||
|
net.PacketConn
|
||||||
|
|
||||||
ID() *stack.TransportEndpointID
|
ID() *stack.TransportEndpointID
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user