2016-01-01 22:44:11 +00:00
|
|
|
package testing
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/v2ray/v2ray-core/proxy/internal"
|
|
|
|
)
|
|
|
|
|
|
|
|
var count = 0
|
|
|
|
|
|
|
|
func randomString() string {
|
|
|
|
count++
|
|
|
|
return fmt.Sprintf("-%d", count)
|
|
|
|
}
|
|
|
|
|
2016-06-14 20:54:08 +00:00
|
|
|
func RegisterInboundConnectionHandlerCreator(prefix string, creator internal.InboundHandlerFactory) (string, error) {
|
2016-01-01 22:44:11 +00:00
|
|
|
for {
|
|
|
|
name := prefix + randomString()
|
2016-01-25 16:20:44 +00:00
|
|
|
err := internal.RegisterInboundHandlerCreator(name, creator)
|
2016-06-27 06:53:35 +00:00
|
|
|
if err != internal.ErrNameExists {
|
2016-01-01 22:44:11 +00:00
|
|
|
return name, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-14 20:54:08 +00:00
|
|
|
func RegisterOutboundConnectionHandlerCreator(prefix string, creator internal.OutboundHandlerFactory) (string, error) {
|
2016-01-01 22:44:11 +00:00
|
|
|
for {
|
|
|
|
name := prefix + randomString()
|
2016-01-25 16:20:44 +00:00
|
|
|
err := internal.RegisterOutboundHandlerCreator(name, creator)
|
2016-06-27 06:53:35 +00:00
|
|
|
if err != internal.ErrNameExists {
|
2016-01-01 22:44:11 +00:00
|
|
|
return name, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|