mirror of
				https://github.com/v2fly/v2ray-core.git
				synced 2025-10-31 09:49:40 +00:00 
			
		
		
		
	Allow IP address is passed as domain in socks5 protocol
This commit is contained in:
		
							parent
							
								
									cf56b89898
								
							
						
					
					
						commit
						88851f2bc9
					
				| @ -2,6 +2,7 @@ package protocol | |||||||
| 
 | 
 | ||||||
| import ( | import ( | ||||||
| 	"io" | 	"io" | ||||||
|  | 	"net" | ||||||
| 
 | 
 | ||||||
| 	"github.com/v2ray/v2ray-core/common/alloc" | 	"github.com/v2ray/v2ray-core/common/alloc" | ||||||
| 	"github.com/v2ray/v2ray-core/common/log" | 	"github.com/v2ray/v2ray-core/common/log" | ||||||
| @ -267,7 +268,12 @@ func (request *Socks5Request) Destination() v2net.Destination { | |||||||
| 	case AddrTypeIPv6: | 	case AddrTypeIPv6: | ||||||
| 		address = v2net.IPAddress(request.IPv6[:], request.Port) | 		address = v2net.IPAddress(request.IPv6[:], request.Port) | ||||||
| 	case AddrTypeDomain: | 	case AddrTypeDomain: | ||||||
|  | 		maybeIP := net.ParseIP(request.Domain) | ||||||
|  | 		if maybeIP != nil { | ||||||
|  | 			address = v2net.IPAddress(maybeIP, request.Port) | ||||||
|  | 		} else { | ||||||
| 			address = v2net.DomainAddress(request.Domain, request.Port) | 			address = v2net.DomainAddress(request.Domain, request.Port) | ||||||
|  | 		} | ||||||
| 	default: | 	default: | ||||||
| 		panic("Unknown address type") | 		panic("Unknown address type") | ||||||
| 	} | 	} | ||||||
|  | |||||||
| @ -2,6 +2,7 @@ package protocol | |||||||
| 
 | 
 | ||||||
| import ( | import ( | ||||||
| 	"errors" | 	"errors" | ||||||
|  | 	"net" | ||||||
| 
 | 
 | ||||||
| 	"github.com/v2ray/v2ray-core/common/alloc" | 	"github.com/v2ray/v2ray-core/common/alloc" | ||||||
| 	"github.com/v2ray/v2ray-core/common/log" | 	"github.com/v2ray/v2ray-core/common/log" | ||||||
| @ -73,7 +74,12 @@ func ReadUDPRequest(packet []byte) (*Socks5UDPRequest, error) { | |||||||
| 		} | 		} | ||||||
| 		domain := string(packet[5 : 5+domainLength]) | 		domain := string(packet[5 : 5+domainLength]) | ||||||
| 		port := v2net.PortFromBytes(packet[5+domainLength : 5+domainLength+2]) | 		port := v2net.PortFromBytes(packet[5+domainLength : 5+domainLength+2]) | ||||||
|  | 		maybeIP := net.ParseIP(domain) | ||||||
|  | 		if maybeIP != nil { | ||||||
|  | 			request.Address = v2net.IPAddress(maybeIP, port) | ||||||
|  | 		} else { | ||||||
| 			request.Address = v2net.DomainAddress(domain, port) | 			request.Address = v2net.DomainAddress(domain, port) | ||||||
|  | 		} | ||||||
| 		dataBegin = 5 + domainLength + 2 | 		dataBegin = 5 + domainLength + 2 | ||||||
| 	default: | 	default: | ||||||
| 		log.Warning("Unknown address type %d", addrType) | 		log.Warning("Unknown address type %d", addrType) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 v2ray
						v2ray