mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-08-29 07:44:18 -04:00
36 lines
769 B
Go
36 lines
769 B
Go
package testing
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"v2ray.com/core/common"
|
|
"v2ray.com/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
|
|
}
|
|
}
|
|
}
|