|  | @@ -17,17 +17,17 @@ import (
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  // VNext is the next Point server in the connection chain.
 |  |  // VNext is the next Point server in the connection chain.
 | 
											
												
													
														|  |  type VNextServer struct {
 |  |  type VNextServer struct {
 | 
											
												
													
														|  | -	Destination *v2net.Destination // Address of VNext server
 |  | 
 | 
											
												
													
														|  | -	Users       []user.User        // User accounts for accessing VNext.
 |  | 
 | 
											
												
													
														|  | 
 |  | +	Destination v2net.Destination // Address of VNext server
 | 
											
												
													
														|  | 
 |  | +	Users       []user.User       // User accounts for accessing VNext.
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  type VMessOutboundHandler struct {
 |  |  type VMessOutboundHandler struct {
 | 
											
												
													
														|  |  	vPoint    *core.Point
 |  |  	vPoint    *core.Point
 | 
											
												
													
														|  | -	dest      *v2net.Destination
 |  | 
 | 
											
												
													
														|  | 
 |  | +	dest      v2net.Destination
 | 
											
												
													
														|  |  	vNextList []VNextServer
 |  |  	vNextList []VNextServer
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -func NewVMessOutboundHandler(vp *core.Point, vNextList []VNextServer, dest *v2net.Destination) *VMessOutboundHandler {
 |  | 
 | 
											
												
													
														|  | 
 |  | +func NewVMessOutboundHandler(vp *core.Point, vNextList []VNextServer, dest v2net.Destination) *VMessOutboundHandler {
 | 
											
												
													
														|  |  	return &VMessOutboundHandler{
 |  |  	return &VMessOutboundHandler{
 | 
											
												
													
														|  |  		vPoint:    vp,
 |  |  		vPoint:    vp,
 | 
											
												
													
														|  |  		dest:      dest,
 |  |  		dest:      dest,
 | 
											
										
											
												
													
														|  | @@ -35,7 +35,7 @@ func NewVMessOutboundHandler(vp *core.Point, vNextList []VNextServer, dest *v2ne
 | 
											
												
													
														|  |  	}
 |  |  	}
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -func (handler *VMessOutboundHandler) pickVNext() (*v2net.Destination, user.User) {
 |  | 
 | 
											
												
													
														|  | 
 |  | +func (handler *VMessOutboundHandler) pickVNext() (v2net.Destination, user.User) {
 | 
											
												
													
														|  |  	vNextLen := len(handler.vNextList)
 |  |  	vNextLen := len(handler.vNextList)
 | 
											
												
													
														|  |  	if vNextLen == 0 {
 |  |  	if vNextLen == 0 {
 | 
											
												
													
														|  |  		panic("VMessOut: Zero vNext is configured.")
 |  |  		panic("VMessOut: Zero vNext is configured.")
 | 
											
										
											
												
													
														|  | @@ -54,10 +54,14 @@ func (handler *VMessOutboundHandler) pickVNext() (*v2net.Destination, user.User)
 | 
											
												
													
														|  |  func (handler *VMessOutboundHandler) Start(ray core.OutboundRay) error {
 |  |  func (handler *VMessOutboundHandler) Start(ray core.OutboundRay) error {
 | 
											
												
													
														|  |  	vNextAddress, vNextUser := handler.pickVNext()
 |  |  	vNextAddress, vNextUser := handler.pickVNext()
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +	command := protocol.CmdTCP
 | 
											
												
													
														|  | 
 |  | +	if handler.dest.IsUDP() {
 | 
											
												
													
														|  | 
 |  | +		command = protocol.CmdUDP
 | 
											
												
													
														|  | 
 |  | +	}
 | 
											
												
													
														|  |  	request := &protocol.VMessRequest{
 |  |  	request := &protocol.VMessRequest{
 | 
											
												
													
														|  |  		Version: protocol.Version,
 |  |  		Version: protocol.Version,
 | 
											
												
													
														|  |  		UserId:  vNextUser.Id,
 |  |  		UserId:  vNextUser.Id,
 | 
											
												
													
														|  | -		Command: handler.dest.NetworkByte(),
 |  | 
 | 
											
												
													
														|  | 
 |  | +		Command: command,
 | 
											
												
													
														|  |  		Address: handler.dest.Address(),
 |  |  		Address: handler.dest.Address(),
 | 
											
												
													
														|  |  	}
 |  |  	}
 | 
											
												
													
														|  |  	rand.Read(request.RequestIV[:])
 |  |  	rand.Read(request.RequestIV[:])
 | 
											
										
											
												
													
														|  | @@ -68,7 +72,7 @@ func (handler *VMessOutboundHandler) Start(ray core.OutboundRay) error {
 | 
											
												
													
														|  |  	return nil
 |  |  	return nil
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -func startCommunicate(request *protocol.VMessRequest, dest *v2net.Destination, ray core.OutboundRay) error {
 |  | 
 | 
											
												
													
														|  | 
 |  | +func startCommunicate(request *protocol.VMessRequest, dest v2net.Destination, ray core.OutboundRay) error {
 | 
											
												
													
														|  |  	input := ray.OutboundInput()
 |  |  	input := ray.OutboundInput()
 | 
											
												
													
														|  |  	output := ray.OutboundOutput()
 |  |  	output := ray.OutboundOutput()
 | 
											
												
													
														|  |  
 |  |  
 | 
											
										
											
												
													
														|  | @@ -155,7 +159,7 @@ func handleResponse(conn *net.TCPConn, request *protocol.VMessRequest, output ch
 | 
											
												
													
														|  |  type VMessOutboundHandlerFactory struct {
 |  |  type VMessOutboundHandlerFactory struct {
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -func (factory *VMessOutboundHandlerFactory) Create(vp *core.Point, rawConfig []byte, destination *v2net.Destination) (core.OutboundConnectionHandler, error) {
 |  | 
 | 
											
												
													
														|  | 
 |  | +func (factory *VMessOutboundHandlerFactory) Create(vp *core.Point, rawConfig []byte, destination v2net.Destination) (core.OutboundConnectionHandler, error) {
 | 
											
												
													
														|  |  	config, err := loadOutboundConfig(rawConfig)
 |  |  	config, err := loadOutboundConfig(rawConfig)
 | 
											
												
													
														|  |  	if err != nil {
 |  |  	if err != nil {
 | 
											
												
													
														|  |  		panic(log.Error("Failed to load VMess outbound config: %v", err))
 |  |  		panic(log.Error("Failed to load VMess outbound config: %v", err))
 |