mirror of
				https://github.com/v2fly/v2ray-core.git
				synced 2025-10-31 09:49:40 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			35 lines
		
	
	
		
			757 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			35 lines
		
	
	
		
			757 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package testing
 | |
| 
 | |
| import (
 | |
| 	"fmt"
 | |
| 
 | |
| 	"github.com/v2ray/v2ray-core/proxy/internal"
 | |
| )
 | |
| 
 | |
| var count = 0
 | |
| 
 | |
| func randomString() string {
 | |
| 	count++
 | |
| 	return fmt.Sprintf("-%d", count)
 | |
| }
 | |
| 
 | |
| func RegisterInboundConnectionHandlerCreator(prefix string, creator internal.InboundHandlerCreator) (string, error) {
 | |
| 	for {
 | |
| 		name := prefix + randomString()
 | |
| 		err := internal.RegisterInboundHandlerCreator(name, creator)
 | |
| 		if err != internal.ErrorNameExists {
 | |
| 			return name, err
 | |
| 		}
 | |
| 	}
 | |
| }
 | |
| 
 | |
| func RegisterOutboundConnectionHandlerCreator(prefix string, creator internal.OutboundHandlerCreator) (string, error) {
 | |
| 	for {
 | |
| 		name := prefix + randomString()
 | |
| 		err := internal.RegisterOutboundHandlerCreator(name, creator)
 | |
| 		if err != internal.ErrorNameExists {
 | |
| 			return name, err
 | |
| 		}
 | |
| 	}
 | |
| }
 | 
