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.
|
|
|
package proxy
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"v2ray.com/core/common"
|
|
|
|
)
|
|
|
|
|
|
|
|
func CreateInboundHandler(ctx context.Context, config interface{}) (Inbound, error) {
|
|
|
|
handler, err := common.CreateObject(ctx, config)
|
|
|
|
if err != nil {
|
|
|
|
return nil, newError("failed to create inbound handler").Base(err)
|
|
|
|
}
|
|
|
|
switch h := handler.(type) {
|
|
|
|
case Inbound:
|
|
|
|
return h, nil
|
|
|
|
default:
|
|
|
|
return nil, newError("not a InboundHandler")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func CreateOutboundHandler(ctx context.Context, config interface{}) (Outbound, error) {
|
|
|
|
handler, err := common.CreateObject(ctx, config)
|
|
|
|
if err != nil {
|
|
|
|
return nil, newError("failed to create outbound handler").Base(err)
|
|
|
|
}
|
|
|
|
switch h := handler.(type) {
|
|
|
|
case Outbound:
|
|
|
|
return h, nil
|
|
|
|
default:
|
|
|
|
return nil, newError("not a OutboundHandler")
|
|
|
|
}
|
|
|
|
}
|