1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-04 09:17:32 -05:00
v2fly/proxy/handler_cache.go
2017-01-26 20:57:18 +01:00

35 lines
715 B
Go

package proxy
import (
"context"
"v2ray.com/core/common"
"v2ray.com/core/common/errors"
)
func CreateInboundHandler(ctx context.Context, config interface{}) (Inbound, error) {
handler, err := common.CreateObject(ctx, config)
if err != nil {
return nil, err
}
switch h := handler.(type) {
case Inbound:
return h, nil
default:
return nil, errors.New("Proxy: Not a InboundHandler.")
}
}
func CreateOutboundHandler(ctx context.Context, config interface{}) (Outbound, error) {
handler, err := common.CreateObject(ctx, config)
if err != nil {
return nil, err
}
switch h := handler.(type) {
case Outbound:
return h, nil
default:
return nil, errors.New("Proxy: Not a OutboundHandler.")
}
}