forked from v2fly/v2ray-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
proxy.go
35 lines (29 loc) · 769 Bytes
/
proxy.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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
}
}
}