v2ray-core/app/sender/sender.go

40 lines
793 B
Go
Raw Normal View History

2017-01-08 09:10:37 +00:00
package sender
import (
2017-01-13 12:41:40 +00:00
"context"
2017-01-08 09:10:37 +00:00
"v2ray.com/core/app"
"v2ray.com/core/common"
"v2ray.com/core/common/net"
"v2ray.com/core/transport/internet"
)
type Sender interface {
SendTo(net.Destination) (internet.Connection, error)
}
type SenderManager struct {
}
2017-01-13 12:41:40 +00:00
func New(ctx context.Context, config *Config) (*SenderManager, error) {
2017-01-08 09:10:37 +00:00
return &SenderManager{}, nil
}
2017-01-13 12:41:40 +00:00
func (SenderManager) Interface() interface{} {
return (*SenderManager)(nil)
2017-01-08 09:10:37 +00:00
}
func FromSpace(space app.Space) *SenderManager {
2017-01-13 12:41:40 +00:00
app := space.GetApplication((*SenderManager)(nil))
2017-01-08 09:10:37 +00:00
if app == nil {
return nil
}
return app.(*SenderManager)
}
func init() {
2017-01-13 12:41:40 +00:00
common.Must(common.RegisterConfig((*Config)(nil), func(ctx context.Context, config interface{}) (interface{}, error) {
return New(ctx, config.(*Config))
}))
2017-01-08 09:10:37 +00:00
}