|  | @@ -2,7 +2,6 @@ package dokodemo
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  import (
 |  |  import (
 | 
											
												
													
														|  |  	"sync"
 |  |  	"sync"
 | 
											
												
													
														|  | -	"syscall"
 |  | 
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  	"github.com/v2ray/v2ray-core/app"
 |  |  	"github.com/v2ray/v2ray-core/app"
 | 
											
												
													
														|  |  	"github.com/v2ray/v2ray-core/app/dispatcher"
 |  |  	"github.com/v2ray/v2ray-core/app/dispatcher"
 | 
											
										
											
												
													
														|  | @@ -15,8 +14,6 @@ import (
 | 
											
												
													
														|  |  	"github.com/v2ray/v2ray-core/transport/hub"
 |  |  	"github.com/v2ray/v2ray-core/transport/hub"
 | 
											
												
													
														|  |  )
 |  |  )
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -const SO_ORIGINAL_DST = 80
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  |  type DokodemoDoor struct {
 |  |  type DokodemoDoor struct {
 | 
											
												
													
														|  |  	tcpMutex         sync.RWMutex
 |  |  	tcpMutex         sync.RWMutex
 | 
											
												
													
														|  |  	udpMutex         sync.RWMutex
 |  |  	udpMutex         sync.RWMutex
 | 
											
										
											
												
													
														|  | @@ -172,23 +169,6 @@ func (this *DokodemoDoor) HandleTCPConnection(conn *hub.Connection) {
 | 
											
												
													
														|  |  	inputFinish.Lock()
 |  |  	inputFinish.Lock()
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -func GetOriginalDestination(conn *hub.Connection) v2net.Destination {
 |  | 
 | 
											
												
													
														|  | -	fd, err := conn.SysFd()
 |  | 
 | 
											
												
													
														|  | -	if err != nil {
 |  | 
 | 
											
												
													
														|  | -		log.Info("Dokodemo: Failed to get original destination: ", err)
 |  | 
 | 
											
												
													
														|  | -		return nil
 |  | 
 | 
											
												
													
														|  | -	}
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -	addr, err := syscall.GetsockoptIPv6Mreq(fd, syscall.IPPROTO_IP, SO_ORIGINAL_DST)
 |  | 
 | 
											
												
													
														|  | -	if err != nil {
 |  | 
 | 
											
												
													
														|  | -		log.Info("Dokodemo: Failed to call getsockopt: ", err)
 |  | 
 | 
											
												
													
														|  | -		return nil
 |  | 
 | 
											
												
													
														|  | -	}
 |  | 
 | 
											
												
													
														|  | -	ip := v2net.IPAddress(addr.Multiaddr[4:8])
 |  | 
 | 
											
												
													
														|  | -	port := uint16(addr.Multiaddr[2])<<8 + uint16(addr.Multiaddr[3])
 |  | 
 | 
											
												
													
														|  | -	return v2net.TCPDestination(ip, v2net.Port(port))
 |  | 
 | 
											
												
													
														|  | -}
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  |  func init() {
 |  |  func init() {
 | 
											
												
													
														|  |  	internal.MustRegisterInboundHandlerCreator("dokodemo-door",
 |  |  	internal.MustRegisterInboundHandlerCreator("dokodemo-door",
 | 
											
												
													
														|  |  		func(space app.Space, rawConfig interface{}, meta *proxy.InboundHandlerMeta) (proxy.InboundHandler, error) {
 |  |  		func(space app.Space, rawConfig interface{}, meta *proxy.InboundHandlerMeta) (proxy.InboundHandler, error) {
 |