forked from v2ray/v2ray-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
proxy.go
34 lines (28 loc) · 757 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
package testing
import (
"fmt"
"github.com/v2ray/v2ray-core/proxy/internal"
)
var count = 0
func randomString() string {
count++
return fmt.Sprintf("-%d", count)
}
func RegisterInboundConnectionHandlerCreator(prefix string, creator internal.InboundHandlerFactory) (string, error) {
for {
name := prefix + randomString()
err := internal.RegisterInboundHandlerCreator(name, creator)
if err != internal.ErrorNameExists {
return name, err
}
}
}
func RegisterOutboundConnectionHandlerCreator(prefix string, creator internal.OutboundHandlerFactory) (string, error) {
for {
name := prefix + randomString()
err := internal.RegisterOutboundHandlerCreator(name, creator)
if err != internal.ErrorNameExists {
return name, err
}
}
}