1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-12-28 13:05:28 -05:00

test case for socks.net

This commit is contained in:
V2Ray
2015-09-19 15:35:20 +02:00
parent 729312f3b5
commit 8be5d695c8
8 changed files with 166 additions and 101 deletions

View File

@@ -0,0 +1,38 @@
package mocks
import (
"bytes"
"github.com/v2ray/v2ray-core"
v2net "github.com/v2ray/v2ray-core/net"
)
type OutboundConnectionHandler struct {
Data2Send *bytes.Buffer
Data2Return []byte
Destination v2net.Address
}
func (handler *OutboundConnectionHandler) Start(ray core.OutboundRay) error {
input := ray.OutboundInput()
output := ray.OutboundOutput()
go func() {
for {
data, open := <-input
if !open {
break
}
handler.Data2Send.Write(data)
}
output <- handler.Data2Return
close(output)
}()
return nil
}
func (handler *OutboundConnectionHandler) Create(point *core.Point, config []byte, dest v2net.Address) (core.OutboundConnectionHandler, error) {
handler.Destination = dest
return handler, nil
}