fix test cases

This commit is contained in:
Darien Raymond
2017-01-29 09:02:19 +01:00
parent 6629b6dd28
commit ebf15aa6bb
4 changed files with 16 additions and 57 deletions
+7 -5
View File
@@ -3,12 +3,17 @@ package blackhole
import (
"context"
"errors"
"time"
"v2ray.com/core/common"
"v2ray.com/core/transport/ray"
)
var (
errConnectionBlocked = errors.New("Blackhole: connection blocked.")
)
// Handler is an outbound connection that sliently swallow the entire payload.
type Handler struct {
response ResponseConfig
@@ -28,12 +33,9 @@ func New(ctx context.Context, config *Config) (*Handler, error) {
// Dispatch implements OutboundHandler.Dispatch().
func (v *Handler) Process(ctx context.Context, outboundRay ray.OutboundRay) error {
v.response.WriteTo(outboundRay.OutboundOutput())
// CloseError() will immediately close the connection.
// Sleep a little here to make sure the response is sent to client.
time.Sleep(time.Millisecond * 500)
outboundRay.OutboundInput().CloseError()
outboundRay.OutboundOutput().CloseError()
return nil
time.Sleep(time.Second)
return errConnectionBlocked
}
func init() {