mirror of https://github.com/v2ray/v2ray-core
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
795 B
36 lines
795 B
package testing
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/v2ray/v2ray-core/common"
|
|
"github.com/v2ray/v2ray-core/proxy/registry"
|
|
)
|
|
|
|
var count = 0
|
|
|
|
func randomString() string {
|
|
count++
|
|
return fmt.Sprintf("-%d", count)
|
|
}
|
|
|
|
func RegisterInboundConnectionHandlerCreator(prefix string, creator registry.InboundHandlerFactory) (string, error) {
|
|
for {
|
|
name := prefix + randomString()
|
|
err := registry.RegisterInboundHandlerCreator(name, creator)
|
|
if err != common.ErrDuplicatedName {
|
|
return name, err
|
|
}
|
|
}
|
|
}
|
|
|
|
func RegisterOutboundConnectionHandlerCreator(prefix string, creator registry.OutboundHandlerFactory) (string, error) {
|
|
for {
|
|
name := prefix + randomString()
|
|
err := registry.RegisterOutboundHandlerCreator(name, creator)
|
|
if err != common.ErrDuplicatedName {
|
|
return name, err
|
|
}
|
|
}
|
|
}
|