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.
v2ray-core/app/sender/sender.go

39 lines
852 B

package sender
import (
"v2ray.com/core/app"
"v2ray.com/core/common"
"v2ray.com/core/common/net"
"v2ray.com/core/common/serial"
"v2ray.com/core/transport/internet"
)
type Sender interface {
SendTo(net.Destination) (internet.Connection, error)
}
type SenderManager struct {
}
func New(space app.Space, config *Config) (*SenderManager, error) {
return &SenderManager{}, nil
}
type SenderManagerFactory struct{}
func (SenderManagerFactory) Create(space app.Space, config interface{}) (app.Application, error) {
return New(space, config.(*Config))
}
func FromSpace(space app.Space) *SenderManager {
app := space.(app.AppGetter).GetApp(serial.GetMessageType((*Config)(nil)))
if app == nil {
return nil
}
return app.(*SenderManager)
}
func init() {
common.Must(app.RegisterApplicationFactory((*Config)(nil), SenderManagerFactory{}))
}