v2ray-core/app/proxyman/proxyman.go

53 lines
1.3 KiB
Go
Raw Normal View History

2017-01-03 13:21:59 +00:00
// Package proxyman defines applications for manageing inbound and outbound proxies.
2016-01-31 16:01:28 +00:00
package proxyman
2017-04-08 23:43:25 +00:00
//go:generate go run $GOPATH/src/v2ray.com/core/tools/generrorgen/main.go -pkg proxyman -path App,Proxyman
2016-01-31 16:01:28 +00:00
import (
2017-01-14 23:48:37 +00:00
"context"
2016-08-20 18:55:45 +00:00
"v2ray.com/core/app"
2017-01-14 23:48:37 +00:00
"v2ray.com/core/common/net"
2016-08-20 18:55:45 +00:00
"v2ray.com/core/proxy"
2017-01-14 23:48:37 +00:00
"v2ray.com/core/transport/ray"
2016-01-31 16:01:28 +00:00
)
type InboundHandlerManager interface {
GetHandler(ctx context.Context, tag string) (InboundHandler, error)
AddHandler(ctx context.Context, config *InboundHandlerConfig) error
2016-01-31 16:01:28 +00:00
}
2017-01-14 23:17:06 +00:00
type InboundHandler interface {
Start() error
Close()
// For migration
2017-01-26 19:57:18 +00:00
GetRandomInboundProxy() (proxy.Inbound, net.Port, int)
2017-01-14 23:17:06 +00:00
}
2016-05-18 06:05:52 +00:00
type OutboundHandlerManager interface {
GetHandler(tag string) OutboundHandler
GetDefaultHandler() OutboundHandler
AddHandler(ctx context.Context, config *OutboundHandlerConfig) error
2016-01-31 16:01:28 +00:00
}
2017-01-06 14:32:36 +00:00
2017-01-14 23:48:37 +00:00
type OutboundHandler interface {
Dispatch(ctx context.Context, outboundRay ray.OutboundRay)
2017-01-14 23:48:37 +00:00
}
2017-01-06 14:32:36 +00:00
func InboundHandlerManagerFromSpace(space app.Space) InboundHandlerManager {
2017-01-13 12:41:40 +00:00
app := space.GetApplication((*InboundHandlerManager)(nil))
2017-01-06 14:32:36 +00:00
if app == nil {
return nil
}
return app.(InboundHandlerManager)
}
func OutboundHandlerManagerFromSpace(space app.Space) OutboundHandlerManager {
2017-01-13 12:41:40 +00:00
app := space.GetApplication((*OutboundHandlerManager)(nil))
2017-01-06 14:32:36 +00:00
if app == nil {
return nil
}
return app.(OutboundHandlerManager)
}