|  | @@ -3,12 +3,17 @@ package blackhole
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import (
 | 
	
		
			
				|  |  |  	"context"
 | 
	
		
			
				|  |  | +	"errors"
 | 
	
		
			
				|  |  |  	"time"
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	"v2ray.com/core/common"
 | 
	
		
			
				|  |  |  	"v2ray.com/core/transport/ray"
 | 
	
		
			
				|  |  |  )
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +var (
 | 
	
		
			
				|  |  | +	errConnectionBlocked = errors.New("Blackhole: connection blocked.")
 | 
	
		
			
				|  |  | +)
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  // Handler is an outbound connection that sliently swallow the entire payload.
 | 
	
		
			
				|  |  |  type Handler struct {
 | 
	
		
			
				|  |  |  	response ResponseConfig
 | 
	
	
		
			
				|  | @@ -28,12 +33,9 @@ func New(ctx context.Context, config *Config) (*Handler, error) {
 | 
	
		
			
				|  |  |  // Dispatch implements OutboundHandler.Dispatch().
 | 
	
		
			
				|  |  |  func (v *Handler) Process(ctx context.Context, outboundRay ray.OutboundRay) error {
 | 
	
		
			
				|  |  |  	v.response.WriteTo(outboundRay.OutboundOutput())
 | 
	
		
			
				|  |  | -	// CloseError() will immediately close the connection.
 | 
	
		
			
				|  |  |  	// Sleep a little here to make sure the response is sent to client.
 | 
	
		
			
				|  |  | -	time.Sleep(time.Millisecond * 500)
 | 
	
		
			
				|  |  | -	outboundRay.OutboundInput().CloseError()
 | 
	
		
			
				|  |  | -	outboundRay.OutboundOutput().CloseError()
 | 
	
		
			
				|  |  | -	return nil
 | 
	
		
			
				|  |  | +	time.Sleep(time.Second)
 | 
	
		
			
				|  |  | +	return errConnectionBlocked
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  func init() {
 |