1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-23 02:26:49 -05:00
v2fly/proxy/handler_cache.go

34 lines
663 B
Go
Raw Normal View History

2016-12-15 09:46:20 -05:00
package proxy
2016-01-02 17:08:36 -05:00
import (
"context"
2016-08-20 14:55:45 -04:00
"v2ray.com/core/common"
2016-01-02 17:08:36 -05:00
)
2017-01-26 14:57:18 -05:00
func CreateInboundHandler(ctx context.Context, config interface{}) (Inbound, error) {
handler, err := common.CreateObject(ctx, config)
if err != nil {
return nil, err
2016-01-02 17:08:36 -05:00
}
switch h := handler.(type) {
2017-01-26 14:57:18 -05:00
case Inbound:
return h, nil
default:
2017-04-09 09:04:04 -04:00
return nil, newError("not a InboundHandler")
2016-01-02 17:08:36 -05:00
}
}
2017-01-26 14:57:18 -05:00
func CreateOutboundHandler(ctx context.Context, config interface{}) (Outbound, error) {
handler, err := common.CreateObject(ctx, config)
if err != nil {
return nil, err
2016-01-02 17:08:36 -05:00
}
switch h := handler.(type) {
2017-01-26 14:57:18 -05:00
case Outbound:
return h, nil
default:
2017-04-09 09:04:04 -04:00
return nil, newError("not a OutboundHandler")
2016-01-02 17:08:36 -05:00
}
}