2016-01-01 17:44:11 -05: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-01-25 11:27:15 -05:00
|
|
|
func RegisterInboundConnectionHandlerCreator(prefix string, creator internal.InboundHandlerCreator) (string, error) {
|
2016-01-01 17:44:11 -05:00
|
|
|
for {
|
|
|
|
name := prefix + randomString()
|
2016-01-25 11:20:44 -05:00
|
|
|
err := internal.RegisterInboundHandlerCreator(name, creator)
|
2016-01-02 17:08:36 -05:00
|
|
|
if err != internal.ErrorNameExists {
|
2016-01-01 17:44:11 -05:00
|
|
|
return name, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-25 11:27:15 -05:00
|
|
|
func RegisterOutboundConnectionHandlerCreator(prefix string, creator internal.OutboundHandlerCreator) (string, error) {
|
2016-01-01 17:44:11 -05:00
|
|
|
for {
|
|
|
|
name := prefix + randomString()
|
2016-01-25 11:20:44 -05:00
|
|
|
err := internal.RegisterOutboundHandlerCreator(name, creator)
|
2016-01-02 17:08:36 -05:00
|
|
|
if err != internal.ErrorNameExists {
|
2016-01-01 17:44:11 -05:00
|
|
|
return name, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|