mirror of
https://github.com/v2ray/v2ray-core.git
synced 2026-11-05 16:30:07 +00:00
test case for net.vmess
This commit is contained in:
1 parent
ab723fa0b5
commit
76200e2764
2 files changed
+113
No files matched your search
@@ -0,0 +1,38 @@
|
||||
package mocks
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
||||
"github.com/v2ray/v2ray-core"
|
||||
v2net "github.com/v2ray/v2ray-core/net"
|
||||
)
|
||||
|
||||
type InboundConnectionHandler struct {
|
||||
Data2Send []byte
|
||||
DataReturned *bytes.Buffer
|
||||
Port uint16
|
||||
Server *core.Point
|
||||
}
|
||||
|
||||
func (handler *InboundConnectionHandler) Listen(port uint16) error {
|
||||
handler.Port = port
|
||||
return nil
|
||||
}
|
||||
|
||||
func (handler *InboundConnectionHandler) Communicate(dest v2net.Address) error {
|
||||
ray := handler.Server.NewInboundConnectionAccepted(dest)
|
||||
|
||||
input := ray.InboundInput()
|
||||
output := ray.InboundOutput()
|
||||
|
||||
input <- handler.Data2Send
|
||||
close(input)
|
||||
|
||||
v2net.ChanToWriter(handler.DataReturned, output)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (handler *InboundConnectionHandler) Create(point *core.Point, config []byte) (core.InboundConnectionHandler, error) {
|
||||
handler.Server = point
|
||||
return handler, nil
|
||||
}
|
||||
Reference in new issue
Block a user