mirror of
https://github.com/v2fly/v2ray-core.git
synced 2026-04-26 07:29:09 -04:00
clean imports
This commit is contained in:
@@ -6,7 +6,7 @@ import (
|
||||
"time"
|
||||
|
||||
"v2ray.com/core/common"
|
||||
v2net "v2ray.com/core/common/net"
|
||||
"v2ray.com/core/common/net"
|
||||
"v2ray.com/core/transport/ray"
|
||||
)
|
||||
|
||||
@@ -27,7 +27,7 @@ func New(ctx context.Context, config *Config) (*Handler, error) {
|
||||
}
|
||||
|
||||
// Dispatch implements OutboundHandler.Dispatch().
|
||||
func (v *Handler) Dispatch(destination v2net.Destination, ray ray.OutboundRay) {
|
||||
func (v *Handler) Dispatch(destination net.Destination, ray ray.OutboundRay) {
|
||||
v.response.WriteTo(ray.OutboundOutput())
|
||||
// CloseError() will immediately close the connection.
|
||||
// Sleep a little here to make sure the response is sent to client.
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package dokodemo
|
||||
|
||||
import (
|
||||
v2net "v2ray.com/core/common/net"
|
||||
"v2ray.com/core/common/net"
|
||||
)
|
||||
|
||||
// GetPredefinedAddress returns the defined address from proto config. Null if address is not valid.
|
||||
func (v *Config) GetPredefinedAddress() v2net.Address {
|
||||
func (v *Config) GetPredefinedAddress() net.Address {
|
||||
addr := v.Address.AsAddress()
|
||||
if addr == nil {
|
||||
return nil
|
||||
|
||||
@@ -6,30 +6,30 @@ import (
|
||||
"syscall"
|
||||
|
||||
"v2ray.com/core/common/log"
|
||||
v2net "v2ray.com/core/common/net"
|
||||
"v2ray.com/core/common/net"
|
||||
"v2ray.com/core/transport/internet"
|
||||
)
|
||||
|
||||
const SO_ORIGINAL_DST = 80
|
||||
|
||||
func GetOriginalDestination(conn internet.Connection) v2net.Destination {
|
||||
func GetOriginalDestination(conn internet.Connection) net.Destination {
|
||||
tcpConn, ok := conn.(internet.SysFd)
|
||||
if !ok {
|
||||
log.Info("Dokodemo: Failed to get sys fd.")
|
||||
return v2net.Destination{}
|
||||
return net.Destination{}
|
||||
}
|
||||
fd, err := tcpConn.SysFd()
|
||||
if err != nil {
|
||||
log.Info("Dokodemo: Failed to get original destination: ", err)
|
||||
return v2net.Destination{}
|
||||
return net.Destination{}
|
||||
}
|
||||
|
||||
addr, err := syscall.GetsockoptIPv6Mreq(fd, syscall.IPPROTO_IP, SO_ORIGINAL_DST)
|
||||
if err != nil {
|
||||
log.Info("Dokodemo: Failed to call getsockopt: ", err)
|
||||
return v2net.Destination{}
|
||||
return net.Destination{}
|
||||
}
|
||||
ip := v2net.IPAddress(addr.Multiaddr[4:8])
|
||||
ip := net.IPAddress(addr.Multiaddr[4:8])
|
||||
port := uint16(addr.Multiaddr[2])<<8 + uint16(addr.Multiaddr[3])
|
||||
return v2net.TCPDestination(ip, v2net.Port(port))
|
||||
return net.TCPDestination(ip, net.Port(port))
|
||||
}
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
package dokodemo
|
||||
|
||||
import (
|
||||
v2net "v2ray.com/core/common/net"
|
||||
"v2ray.com/core/common/net"
|
||||
"v2ray.com/core/transport/internet"
|
||||
)
|
||||
|
||||
func GetOriginalDestination(conn internet.Connection) v2net.Destination {
|
||||
return v2net.Destination{}
|
||||
func GetOriginalDestination(conn internet.Connection) net.Destination {
|
||||
return net.Destination{}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
package proxy
|
||||
|
||||
import (
|
||||
v2net "v2ray.com/core/common/net"
|
||||
"v2ray.com/core/common/net"
|
||||
"v2ray.com/core/common/protocol"
|
||||
"v2ray.com/core/transport/internet"
|
||||
"v2ray.com/core/transport/ray"
|
||||
@@ -16,23 +16,23 @@ const (
|
||||
)
|
||||
|
||||
type SessionInfo struct {
|
||||
Source v2net.Destination
|
||||
Destination v2net.Destination
|
||||
Source net.Destination
|
||||
Destination net.Destination
|
||||
User *protocol.User
|
||||
Inbound *InboundHandlerMeta
|
||||
}
|
||||
|
||||
type InboundHandlerMeta struct {
|
||||
Tag string
|
||||
Address v2net.Address
|
||||
Port v2net.Port
|
||||
Address net.Address
|
||||
Port net.Port
|
||||
AllowPassiveConnection bool
|
||||
StreamSettings *internet.StreamConfig
|
||||
}
|
||||
|
||||
type OutboundHandlerMeta struct {
|
||||
Tag string
|
||||
Address v2net.Address
|
||||
Address net.Address
|
||||
StreamSettings *internet.StreamConfig
|
||||
ProxySettings *internet.ProxyConfig
|
||||
}
|
||||
@@ -51,11 +51,11 @@ type InboundHandler interface {
|
||||
// Close stops the handler to accepting anymore inbound connections.
|
||||
Close()
|
||||
// Port returns the port that the handler is listening on.
|
||||
Port() v2net.Port
|
||||
Port() net.Port
|
||||
}
|
||||
|
||||
// An OutboundHandler handles outbound network connection for V2Ray.
|
||||
type OutboundHandler interface {
|
||||
// Dispatch sends one or more Packets to its destination.
|
||||
Dispatch(destination v2net.Destination, ray ray.OutboundRay)
|
||||
Dispatch(destination net.Destination, ray ray.OutboundRay)
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package socks
|
||||
|
||||
import (
|
||||
v2net "v2ray.com/core/common/net"
|
||||
"v2ray.com/core/common/net"
|
||||
"v2ray.com/core/common/protocol"
|
||||
)
|
||||
|
||||
@@ -27,9 +27,9 @@ func (v *ServerConfig) HasAccount(username, password string) bool {
|
||||
return storedPassed == password
|
||||
}
|
||||
|
||||
func (v *ServerConfig) GetNetAddress() v2net.Address {
|
||||
func (v *ServerConfig) GetNetAddress() net.Address {
|
||||
if v.Address == nil {
|
||||
return v2net.LocalHostIP
|
||||
return net.LocalHostIP
|
||||
}
|
||||
return v.Address.AsAddress()
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package socks
|
||||
import (
|
||||
"v2ray.com/core/common/buf"
|
||||
"v2ray.com/core/common/log"
|
||||
v2net "v2ray.com/core/common/net"
|
||||
"v2ray.com/core/common/net"
|
||||
"v2ray.com/core/proxy"
|
||||
"v2ray.com/core/transport/internet/udp"
|
||||
)
|
||||
@@ -16,7 +16,7 @@ func (v *Server) listenUDP() error {
|
||||
return err
|
||||
}
|
||||
v.udpMutex.Lock()
|
||||
v.udpAddress = v2net.UDPDestination(v.config.GetNetAddress(), v.meta.Port)
|
||||
v.udpAddress = net.UDPDestination(v.config.GetNetAddress(), v.meta.Port)
|
||||
v.udpHub = udpHub
|
||||
v.udpMutex.Unlock()
|
||||
return nil
|
||||
@@ -43,7 +43,7 @@ func (v *Server) handleUDPPayload(payload *buf.Buffer, session *proxy.SessionInf
|
||||
|
||||
dataBuf := buf.NewSmall()
|
||||
dataBuf.Append(data)
|
||||
v.udpServer.Dispatch(&proxy.SessionInfo{Source: source, Destination: request.Destination(), Inbound: v.meta}, dataBuf, func(destination v2net.Destination, payload *buf.Buffer) {
|
||||
v.udpServer.Dispatch(&proxy.SessionInfo{Source: source, Destination: request.Destination(), Inbound: v.meta}, dataBuf, func(destination net.Destination, payload *buf.Buffer) {
|
||||
defer payload.Release()
|
||||
|
||||
log.Info("Socks: Writing back UDP response with ", payload.Len(), " bytes to ", destination)
|
||||
|
||||
Reference in New Issue
Block a user