mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-27 12:36:34 -05:00
comments
This commit is contained in:
parent
25c64f9694
commit
25533412db
@ -8,24 +8,26 @@ import (
|
|||||||
"v2ray.com/core/transport/ray"
|
"v2ray.com/core/transport/ray"
|
||||||
)
|
)
|
||||||
|
|
||||||
// BlackHole is an outbound connection that sliently swallow the entire payload.
|
// Handler is an outbound connection that sliently swallow the entire payload.
|
||||||
type BlackHole struct {
|
type Handler struct {
|
||||||
meta *proxy.OutboundHandlerMeta
|
meta *proxy.OutboundHandlerMeta
|
||||||
response ResponseConfig
|
response ResponseConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewBlackHole(space app.Space, config *Config, meta *proxy.OutboundHandlerMeta) (*BlackHole, error) {
|
// New creates a new blackhole handler.
|
||||||
|
func New(space app.Space, config *Config, meta *proxy.OutboundHandlerMeta) (proxy.OutboundHandler, error) {
|
||||||
response, err := config.GetInternalResponse()
|
response, err := config.GetInternalResponse()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &BlackHole{
|
return &Handler{
|
||||||
meta: meta,
|
meta: meta,
|
||||||
response: response,
|
response: response,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *BlackHole) Dispatch(destination v2net.Destination, payload *buf.Buffer, ray ray.OutboundRay) {
|
// Dispatch implements OutboundHandler.Dispatch().
|
||||||
|
func (v *Handler) Dispatch(destination v2net.Destination, payload *buf.Buffer, ray ray.OutboundRay) {
|
||||||
payload.Release()
|
payload.Release()
|
||||||
|
|
||||||
v.response.WriteTo(ray.OutboundOutput())
|
v.response.WriteTo(ray.OutboundOutput())
|
||||||
@ -34,14 +36,17 @@ func (v *BlackHole) Dispatch(destination v2net.Destination, payload *buf.Buffer,
|
|||||||
ray.OutboundInput().Release()
|
ray.OutboundInput().Release()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Factory is an utility for creating blackhole handlers.
|
||||||
type Factory struct{}
|
type Factory struct{}
|
||||||
|
|
||||||
|
// StreamCapability implements OutboundHandlerFactory.StreamCapability().
|
||||||
func (v *Factory) StreamCapability() v2net.NetworkList {
|
func (v *Factory) StreamCapability() v2net.NetworkList {
|
||||||
return v2net.NetworkList{
|
return v2net.NetworkList{
|
||||||
Network: []v2net.Network{v2net.Network_RawTCP},
|
Network: []v2net.Network{v2net.Network_RawTCP},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create implements OutboundHandlerFactory.Create().
|
||||||
func (v *Factory) Create(space app.Space, config interface{}, meta *proxy.OutboundHandlerMeta) (proxy.OutboundHandler, error) {
|
func (v *Factory) Create(space app.Space, config interface{}, meta *proxy.OutboundHandlerMeta) (proxy.OutboundHandler, error) {
|
||||||
return NewBlackHole(space, config.(*Config), meta)
|
return New(space, config.(*Config), meta)
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package conf
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"v2ray.com/core/common/errors"
|
"v2ray.com/core/common/errors"
|
||||||
"v2ray.com/core/common/serial"
|
"v2ray.com/core/common/serial"
|
||||||
"v2ray.com/core/proxy/blackhole"
|
"v2ray.com/core/proxy/blackhole"
|
||||||
|
Loading…
Reference in New Issue
Block a user