mirror of
https://github.com/v2fly/v2ray-core.git
synced 2026-01-23 01:15:31 -05:00
sample socks proxy
This commit is contained in:
33
testing/mocks/fakeoutboundhandler.go
Normal file
33
testing/mocks/fakeoutboundhandler.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package mocks
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
||||
"github.com/v2ray/v2ray-core"
|
||||
v2net "github.com/v2ray/v2ray-core/net"
|
||||
)
|
||||
|
||||
type FakeOutboundConnectionHandler struct {
|
||||
Data2Send bytes.Buffer
|
||||
Data2Return []byte
|
||||
Destination v2net.VAddress
|
||||
}
|
||||
|
||||
func (handler *FakeOutboundConnectionHandler) Start(ray core.OutboundVRay) error {
|
||||
input := ray.OutboundInput()
|
||||
output := ray.OutboundOutput()
|
||||
|
||||
output <- handler.Data2Return
|
||||
for {
|
||||
data, open := <-input
|
||||
if !open {
|
||||
break
|
||||
}
|
||||
handler.Data2Send.Write(data)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (handler *FakeOutboundConnectionHandler) Create(vPoint *core.VPoint, dest v2net.VAddress) (core.OutboundConnectionHandler, error) {
|
||||
return handler, nil
|
||||
}
|
||||
Reference in New Issue
Block a user