1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2026-05-05 20:19:15 -04:00

move port out of address

This commit is contained in:
v2ray
2015-12-16 23:53:38 +01:00
parent 4be7cd7908
commit 34a0cb0b70
34 changed files with 194 additions and 172 deletions

View File

@@ -6,6 +6,7 @@ import (
type Config interface {
Address() v2net.Address
Port() v2net.Port
Network() v2net.NetworkList
Timeout() int
}

View File

@@ -16,6 +16,7 @@ type DokodemoDoor struct {
config Config
accepting bool
address v2net.Address
port v2net.Port
space app.Space
}
@@ -24,6 +25,7 @@ func NewDokodemoDoor(space app.Space, config Config) *DokodemoDoor {
config: config,
space: space,
address: config.Address(),
port: config.Port(),
}
}
@@ -71,7 +73,7 @@ func (this *DokodemoDoor) handleUDPPackets(udpConn *net.UDPConn) {
return
}
packet := v2net.NewPacket(v2net.NewUDPDestination(this.address), buffer, false)
packet := v2net.NewPacket(v2net.UDPDestination(this.address, this.port), buffer, false)
ray := this.space.PacketDispatcher().DispatchToOutbound(packet)
close(ray.InboundInput())
@@ -112,7 +114,7 @@ func (this *DokodemoDoor) AcceptTCPConnections(tcpListener *net.TCPListener) {
func (this *DokodemoDoor) HandleTCPConnection(conn *net.TCPConn) {
defer conn.Close()
packet := v2net.NewPacket(v2net.NewTCPDestination(this.address), nil, true)
packet := v2net.NewPacket(v2net.TCPDestination(this.address, this.port), nil, true)
ray := this.space.PacketDispatcher().DispatchToOutbound(packet)
var inputFinish, outputFinish sync.Mutex

View File

@@ -43,7 +43,7 @@ func TestDokodemoTCP(t *testing.T) {
ProtocolValue: "dokodemo-door",
SettingsValue: &json.DokodemoConfig{
Host: v2netjson.NewIPHost(net.ParseIP("127.0.0.1")),
Port: port,
PortValue: port,
NetworkList: &networkList,
TimeoutValue: 0,
},
@@ -105,7 +105,7 @@ func TestDokodemoUDP(t *testing.T) {
ProtocolValue: "dokodemo-door",
SettingsValue: &json.DokodemoConfig{
Host: v2netjson.NewIPHost(net.ParseIP("127.0.0.1")),
Port: port,
PortValue: port,
NetworkList: &networkList,
TimeoutValue: 0,
},

View File

@@ -8,19 +8,23 @@ import (
type DokodemoConfig struct {
Host *v2netjson.Host `json:"address"`
Port v2net.Port `json:"port"`
PortValue v2net.Port `json:"port"`
NetworkList *v2netjson.NetworkList `json:"network"`
TimeoutValue int `json:"timeout"`
}
func (this *DokodemoConfig) Address() v2net.Address {
if this.Host.IsIP() {
return v2net.IPAddress(this.Host.IP(), this.Port)
return v2net.IPAddress(this.Host.IP())
} else {
return v2net.DomainAddress(this.Host.Domain(), this.Port)
return v2net.DomainAddress(this.Host.Domain())
}
}
func (this *DokodemoConfig) Port() v2net.Port {
return this.PortValue
}
func (this *DokodemoConfig) Network() v2net.NetworkList {
return this.NetworkList
}

View File

@@ -15,7 +15,7 @@ type FreedomConnection struct {
}
func (this *FreedomConnection) Dispatch(firstPacket v2net.Packet, ray ray.OutboundRay) error {
conn, err := net.Dial(firstPacket.Destination().Network(), firstPacket.Destination().Address().String())
conn, err := net.Dial(firstPacket.Destination().Network(), firstPacket.Destination().NetAddr())
log.Info("Freedom: Opening connection to %s", firstPacket.Destination().String())
if err != nil {
close(ray.OutboundOutput())

View File

@@ -70,8 +70,7 @@ func TestUDPSend(t *testing.T) {
data2SendBuffer := alloc.NewBuffer().Clear()
data2SendBuffer.Append([]byte(data2Send))
dest := v2net.NewUDPDestination(udpServerAddr)
ich.Communicate(v2net.NewPacket(dest, data2SendBuffer, false))
ich.Communicate(v2net.NewPacket(udpServerAddr, data2SendBuffer, false))
assert.Bytes(connOutput.Bytes()).Equals([]byte("Processed: Data to be sent to remote"))
}

View File

@@ -53,7 +53,7 @@ func (this *HttpProxyServer) accept(listener *net.TCPListener) {
}
}
func parseHost(rawHost string, defaultPort v2net.Port) (v2net.Address, error) {
func parseHost(rawHost string, defaultPort v2net.Port) (v2net.Destination, error) {
port := defaultPort
host, rawPort, err := net.SplitHostPort(rawHost)
if err != nil {
@@ -71,9 +71,9 @@ func parseHost(rawHost string, defaultPort v2net.Port) (v2net.Address, error) {
}
if ip := net.ParseIP(host); ip != nil {
return v2net.IPAddress(ip, port), nil
return v2net.TCPDestination(v2net.IPAddress(ip), port), nil
}
return v2net.DomainAddress(host, port), nil
return v2net.TCPDestination(v2net.DomainAddress(host), port), nil
}
func (this *HttpProxyServer) handleConnection(conn *net.TCPConn) {
@@ -93,12 +93,12 @@ func (this *HttpProxyServer) handleConnection(conn *net.TCPConn) {
if len(host) == 0 {
host = request.URL.Host
}
address, err := parseHost(host, defaultPort)
dest, err := parseHost(host, defaultPort)
if err != nil {
log.Warning("Malformed proxy host (%s): %v", host, err)
}
if strings.ToUpper(request.Method) == "CONNECT" {
this.handleConnect(request, address, reader, conn)
this.handleConnect(request, dest, reader, conn)
} else if len(request.URL.Host) > 0 {
request.Host = request.URL.Host
request.Header.Set("Connection", "keep-alive")
@@ -106,7 +106,7 @@ func (this *HttpProxyServer) handleConnection(conn *net.TCPConn) {
buffer := alloc.NewBuffer().Clear()
request.Write(buffer)
log.Info("Request to remote: %s", string(buffer.Value))
packet := v2net.NewPacket(v2net.NewTCPDestination(address), buffer, true)
packet := v2net.NewPacket(dest, buffer, true)
ray := this.space.PacketDispatcher().DispatchToOutbound(packet)
go func() {
defer close(ray.InboundInput())
@@ -142,7 +142,7 @@ func (this *HttpProxyServer) handleConnection(conn *net.TCPConn) {
}
}
func (this *HttpProxyServer) handleConnect(request *http.Request, address v2net.Address, reader io.Reader, writer io.Writer) {
func (this *HttpProxyServer) handleConnect(request *http.Request, destination v2net.Destination, reader io.Reader, writer io.Writer) {
response := &http.Response{
Status: "200 OK",
StatusCode: 200,
@@ -160,7 +160,7 @@ func (this *HttpProxyServer) handleConnect(request *http.Request, address v2net.
writer.Write(buffer.Value)
buffer.Release()
packet := v2net.NewPacket(v2net.NewTCPDestination(address), nil, true)
packet := v2net.NewPacket(destination, nil, true)
ray := this.space.PacketDispatcher().DispatchToOutbound(packet)
this.transport(reader, writer, ray)
}

View File

@@ -261,23 +261,21 @@ func ReadRequest(reader io.Reader) (request *Socks5Request, err error) {
}
func (request *Socks5Request) Destination() v2net.Destination {
var address v2net.Address
switch request.AddrType {
case AddrTypeIPv4:
address = v2net.IPAddress(request.IPv4[:], request.Port)
return v2net.TCPDestination(v2net.IPAddress(request.IPv4[:]), request.Port)
case AddrTypeIPv6:
address = v2net.IPAddress(request.IPv6[:], request.Port)
return v2net.TCPDestination(v2net.IPAddress(request.IPv6[:]), request.Port)
case AddrTypeDomain:
maybeIP := net.ParseIP(request.Domain)
if maybeIP != nil {
address = v2net.IPAddress(maybeIP, request.Port)
return v2net.TCPDestination(v2net.IPAddress(maybeIP), request.Port)
} else {
address = v2net.DomainAddress(request.Domain, request.Port)
return v2net.TCPDestination(v2net.DomainAddress(request.Domain), request.Port)
}
default:
panic("Unknown address type")
}
return v2net.NewTCPDestination(address)
}
const (

View File

@@ -17,11 +17,12 @@ var (
type Socks5UDPRequest struct {
Fragment byte
Address v2net.Address
Port v2net.Port
Data *alloc.Buffer
}
func (request *Socks5UDPRequest) Destination() v2net.Destination {
return v2net.NewUDPDestination(request.Address)
return v2net.UDPDestination(request.Address, request.Port)
}
func (request *Socks5UDPRequest) Write(buffer *alloc.Buffer) {
@@ -34,7 +35,7 @@ func (request *Socks5UDPRequest) Write(buffer *alloc.Buffer) {
case request.Address.IsDomain():
buffer.AppendBytes(AddrTypeDomain, byte(len(request.Address.Domain()))).Append([]byte(request.Address.Domain()))
}
buffer.Append(request.Address.Port().Bytes())
buffer.Append(request.Port.Bytes())
buffer.Append(request.Data.Value)
}
@@ -56,16 +57,16 @@ func ReadUDPRequest(packet []byte) (*Socks5UDPRequest, error) {
return nil, transport.CorruptedPacket
}
ip := packet[4:8]
port := v2net.PortFromBytes(packet[8:10])
request.Address = v2net.IPAddress(ip, port)
request.Port = v2net.PortFromBytes(packet[8:10])
request.Address = v2net.IPAddress(ip)
dataBegin = 10
case AddrTypeIPv6:
if len(packet) < 22 {
return nil, transport.CorruptedPacket
}
ip := packet[4:20]
port := v2net.PortFromBytes(packet[20:22])
request.Address = v2net.IPAddress(ip, port)
request.Port = v2net.PortFromBytes(packet[20:22])
request.Address = v2net.IPAddress(ip)
dataBegin = 22
case AddrTypeDomain:
domainLength := int(packet[4])
@@ -73,12 +74,12 @@ func ReadUDPRequest(packet []byte) (*Socks5UDPRequest, error) {
return nil, transport.CorruptedPacket
}
domain := string(packet[5 : 5+domainLength])
port := v2net.PortFromBytes(packet[5+domainLength : 5+domainLength+2])
request.Port = v2net.PortFromBytes(packet[5+domainLength : 5+domainLength+2])
maybeIP := net.ParseIP(domain)
if maybeIP != nil {
request.Address = v2net.IPAddress(maybeIP, port)
request.Address = v2net.IPAddress(maybeIP)
} else {
request.Address = v2net.DomainAddress(domain, port)
request.Address = v2net.DomainAddress(domain)
}
dataBegin = 5 + domainLength + 2
default:

View File

@@ -3,6 +3,8 @@ package protocol
import (
"testing"
v2net "github.com/v2ray/v2ray-core/common/net"
netassert "github.com/v2ray/v2ray-core/common/net/testing/assert"
v2testing "github.com/v2ray/v2ray-core/testing"
"github.com/v2ray/v2ray-core/testing/assert"
"github.com/v2ray/v2ray-core/transport"
@@ -31,6 +33,7 @@ func TestDomainAddressRequest(t *testing.T) {
assert.Error(err).IsNil()
assert.Byte(request.Fragment).Equals(1)
assert.String(request.Address).Equals("v2ray.com:80")
assert.String(request.Address).Equals("v2ray.com")
netassert.Port(request.Port).Equals(v2net.Port(80))
assert.Bytes(request.Data.Value).Equals([]byte("Actual payload"))
}

View File

@@ -191,12 +191,12 @@ func (this *SocksServer) handleUDP(reader *v2net.TimeOutReader, writer io.Writer
response.Port = udpAddr.Port()
switch {
case udpAddr.IsIPv4():
response.SetIPv4(udpAddr.IP())
case udpAddr.IsIPv6():
response.SetIPv6(udpAddr.IP())
case udpAddr.IsDomain():
response.SetDomain(udpAddr.Domain())
case udpAddr.Address().IsIPv4():
response.SetIPv4(udpAddr.Address().IP())
case udpAddr.Address().IsIPv6():
response.SetIPv6(udpAddr.Address().IP())
case udpAddr.Address().IsDomain():
response.SetDomain(udpAddr.Address().Domain())
}
responseBuffer := alloc.NewSmallBuffer().Clear()
@@ -236,7 +236,7 @@ func (this *SocksServer) handleSocks4(reader io.Reader, writer io.Writer, auth p
return UnsupportedSocksCommand
}
dest := v2net.NewTCPDestination(v2net.IPAddress(auth.IP[:], auth.Port))
dest := v2net.TCPDestination(v2net.IPAddress(auth.IP[:]), auth.Port)
packet := v2net.NewPacket(dest, nil, true)
this.transport(reader, writer, packet)
return nil

View File

@@ -71,7 +71,7 @@ func TestSocksTcpConnect(t *testing.T) {
assert.Bytes([]byte(data2Send)).Equals(connOutput.Bytes())
assert.Bytes(dataReturned).Equals(connInput)
assert.StringLiteral(targetServer).Equals(och.Destination.Address().String())
assert.StringLiteral(targetServer).Equals(och.Destination.NetAddr())
}
func TestSocksTcpConnectWithUserPass(t *testing.T) {
@@ -129,7 +129,7 @@ func TestSocksTcpConnectWithUserPass(t *testing.T) {
assert.Bytes([]byte(data2Send)).Equals(connOutput.Bytes())
assert.Bytes(dataReturned).Equals(connInput)
assert.StringLiteral(targetServer).Equals(och.Destination.Address().String())
assert.StringLiteral(targetServer).Equals(och.Destination.NetAddr())
}
func TestSocksTcpConnectWithWrongUserPass(t *testing.T) {

View File

@@ -9,7 +9,7 @@ import (
"github.com/v2ray/v2ray-core/proxy/socks/protocol"
)
var udpAddress v2net.Address
var udpAddress v2net.Destination
func (this *SocksServer) ListenUDP(port v2net.Port) error {
addr := &net.UDPAddr{
@@ -22,13 +22,13 @@ func (this *SocksServer) ListenUDP(port v2net.Port) error {
log.Error("Socks failed to listen UDP on port %d: %v", port, err)
return err
}
udpAddress = v2net.IPAddress(this.config.IP(), port)
udpAddress = v2net.UDPDestination(v2net.IPAddress(this.config.IP()), port)
go this.AcceptPackets(conn)
return nil
}
func (this *SocksServer) getUDPAddr() v2net.Address {
func (this *SocksServer) getUDPAddr() v2net.Destination {
return udpAddress
}
@@ -60,11 +60,11 @@ func (this *SocksServer) AcceptPackets(conn *net.UDPConn) error {
udpPacket := v2net.NewPacket(request.Destination(), request.Data, false)
log.Info("Send packet to %s with %d bytes", udpPacket.Destination().String(), request.Data.Len())
go this.handlePacket(conn, udpPacket, addr, request.Address)
go this.handlePacket(conn, udpPacket, addr, request.Address, request.Port)
}
}
func (this *SocksServer) handlePacket(conn *net.UDPConn, packet v2net.Packet, clientAddr *net.UDPAddr, targetAddr v2net.Address) {
func (this *SocksServer) handlePacket(conn *net.UDPConn, packet v2net.Packet, clientAddr *net.UDPAddr, targetAddr v2net.Address, port v2net.Port) {
ray := this.space.PacketDispatcher().DispatchToOutbound(packet)
close(ray.InboundInput())
@@ -72,6 +72,7 @@ func (this *SocksServer) handlePacket(conn *net.UDPConn, packet v2net.Packet, cl
response := &protocol.Socks5UDPRequest{
Fragment: 0,
Address: targetAddr,
Port: port,
Data: data,
}
log.Info("Writing back UDP response with %d bytes from %s to %s", data.Len(), targetAddr.String(), clientAddr.String())

View File

@@ -14,8 +14,8 @@ import (
)
type ConfigTarget struct {
Address v2net.Address
Users []*vmessjson.ConfigUser
Destination v2net.Destination
Users []*vmessjson.ConfigUser
}
func (t *ConfigTarget) UnmarshalJSON(data []byte) error {
@@ -38,9 +38,9 @@ func (t *ConfigTarget) UnmarshalJSON(data []byte) error {
return proxyconfig.BadConfiguration
}
if rawConfig.Address.IsIP() {
t.Address = v2net.IPAddress(rawConfig.Address.IP(), rawConfig.Port)
t.Destination = v2net.TCPDestination(v2net.IPAddress(rawConfig.Address.IP()), rawConfig.Port)
} else {
t.Address = v2net.DomainAddress(rawConfig.Address.Domain(), rawConfig.Port)
t.Destination = v2net.TCPDestination(v2net.DomainAddress(rawConfig.Address.Domain()), rawConfig.Port)
}
return nil
}
@@ -74,8 +74,8 @@ func (o *Outbound) Receivers() []*outbound.Receiver {
users = append(users, rawUser)
}
targets = append(targets, &outbound.Receiver{
Address: rawTarget.Address,
Accounts: users,
Destination: rawTarget.Destination,
Accounts: users,
})
}
return targets

View File

@@ -27,7 +27,7 @@ func TestConfigTargetParsing(t *testing.T) {
var target *jsonconfig.ConfigTarget
err := json.Unmarshal([]byte(rawJson), &target)
assert.Error(err).IsNil()
assert.String(target.Address).Equals("127.0.0.1:80")
assert.String(target.Destination).Equals("tcp:127.0.0.1:80")
assert.Int(len(target.Users)).Equals(1)
assert.String(target.Users[0].ID()).Equals("e641f5ad-9397-41e3-bf1a-e8740dfed019")
}

View File

@@ -34,6 +34,7 @@ func (this *VMessOutboundHandler) Dispatch(firstPacket v2net.Packet, ray ray.Out
User: vNextUser,
Command: command,
Address: firstPacket.Destination().Address(),
Port: firstPacket.Destination().Port(),
}
buffer := alloc.NewSmallBuffer()
@@ -46,8 +47,21 @@ func (this *VMessOutboundHandler) Dispatch(firstPacket v2net.Packet, ray ray.Out
return startCommunicate(request, vNextAddress, ray, firstPacket)
}
func startCommunicate(request *protocol.VMessRequest, dest v2net.Address, ray ray.OutboundRay, firstPacket v2net.Packet) error {
conn, err := net.Dial("tcp", dest.String())
func startCommunicate(request *protocol.VMessRequest, dest v2net.Destination, ray ray.OutboundRay, firstPacket v2net.Packet) error {
var destIp net.IP
if dest.Address().IsIPv4() || dest.Address().IsIPv6() {
destIp = dest.Address().IP()
} else {
ips, err := net.LookupIP(dest.Address().Domain())
if err != nil {
return err
}
destIp = ips[0]
}
conn, err := net.DialTCP("tcp", nil, &net.TCPAddr{
IP: destIp,
Port: int(dest.Port()),
})
if err != nil {
log.Error("Failed to open %s: %v", dest.String(), err)
if ray != nil {
@@ -69,9 +83,7 @@ func startCommunicate(request *protocol.VMessRequest, dest v2net.Address, ray ra
go handleResponse(conn, request, output, &responseFinish, (request.Command == protocol.CmdUDP))
requestFinish.Lock()
if tcpConn, ok := conn.(*net.TCPConn); ok {
tcpConn.CloseWrite()
}
conn.CloseWrite()
responseFinish.Lock()
return nil
}

View File

@@ -8,8 +8,8 @@ import (
)
type Receiver struct {
Address v2net.Address
Accounts []vmess.User
Destination v2net.Destination
Accounts []vmess.User
}
type ReceiverManager struct {
@@ -22,7 +22,7 @@ func NewReceiverManager(receivers []*Receiver) *ReceiverManager {
}
}
func (this *ReceiverManager) PickReceiver() (v2net.Address, vmess.User) {
func (this *ReceiverManager) PickReceiver() (v2net.Destination, vmess.User) {
receiverLen := len(this.receivers)
receiverIdx := 0
if receiverLen > 1 {
@@ -37,5 +37,5 @@ func (this *ReceiverManager) PickReceiver() (v2net.Address, vmess.User) {
userIdx = rand.Intn(userLen)
}
user := receiver.Accounts[userIdx]
return receiver.Address, user
return receiver.Destination, user
}

View File

@@ -41,14 +41,15 @@ type VMessRequest struct {
ResponseHeader []byte
Command byte
Address v2net.Address
Port v2net.Port
}
// Destination is the final destination of this request.
func (this *VMessRequest) Destination() v2net.Destination {
if this.Command == CmdTCP {
return v2net.NewTCPDestination(this.Address)
return v2net.TCPDestination(this.Address, this.Port)
} else {
return v2net.NewUDPDestination(this.Address)
return v2net.UDPDestination(this.Address, this.Port)
}
}
@@ -106,7 +107,7 @@ func (this *VMessRequestReader) Read(reader io.Reader) (*VMessRequest, error) {
request.ResponseHeader = buffer.Value[33:37] // 4 bytes
request.Command = buffer.Value[37]
port := v2net.PortFromBytes(buffer.Value[38:40])
request.Port = v2net.PortFromBytes(buffer.Value[38:40])
switch buffer.Value[40] {
case addrTypeIPv4:
@@ -115,14 +116,14 @@ func (this *VMessRequestReader) Read(reader io.Reader) (*VMessRequest, error) {
if err != nil {
return nil, err
}
request.Address = v2net.IPAddress(buffer.Value[41:45], port)
request.Address = v2net.IPAddress(buffer.Value[41:45])
case addrTypeIPv6:
_, err = v2net.ReadAllBytes(decryptor, buffer.Value[41:57]) // 16 bytes
bufferLen += 16
if err != nil {
return nil, err
}
request.Address = v2net.IPAddress(buffer.Value[41:57], port)
request.Address = v2net.IPAddress(buffer.Value[41:57])
case addrTypeDomain:
_, err = v2net.ReadAllBytes(decryptor, buffer.Value[41:42])
if err != nil {
@@ -134,7 +135,7 @@ func (this *VMessRequestReader) Read(reader io.Reader) (*VMessRequest, error) {
return nil, err
}
bufferLen += 1 + domainLength
request.Address = v2net.DomainAddress(string(buffer.Value[42:42+domainLength]), port)
request.Address = v2net.DomainAddress(string(buffer.Value[42 : 42+domainLength]))
}
_, err = v2net.ReadAllBytes(decryptor, buffer.Value[bufferLen:bufferLen+4])
@@ -172,7 +173,7 @@ func (this *VMessRequest) ToBytes(idHash user.CounterHash, randomRangeInt64 user
buffer.Append(this.RequestKey)
buffer.Append(this.ResponseHeader)
buffer.AppendBytes(this.Command)
buffer.Append(this.Address.Port().Bytes())
buffer.Append(this.Port.Bytes())
switch {
case this.Address.IsIPv4():

View File

@@ -55,7 +55,8 @@ func TestVMessSerialization(t *testing.T) {
request.ResponseHeader = randBytes[32:]
request.Command = byte(0x01)
request.Address = v2net.DomainAddress("v2ray.com", 80)
request.Address = v2net.DomainAddress("v2ray.com")
request.Port = v2net.Port(80)
mockTime := int64(1823730)
@@ -113,7 +114,8 @@ func BenchmarkVMessRequestWriting(b *testing.B) {
request.ResponseHeader = randBytes[32:]
request.Command = byte(0x01)
request.Address = v2net.DomainAddress("v2ray.com", 80)
request.Address = v2net.DomainAddress("v2ray.com")
request.Port = v2net.Port(80)
for i := 0; i < b.N; i++ {
request.ToBytes(user.NewTimeHash(user.HMACHash{}), user.GenerateRandomInt64InRange, nil)

View File

@@ -52,7 +52,7 @@ func TestVMessInAndOut(t *testing.T) {
SettingsValue: &outboundjson.Outbound{
[]*outboundjson.ConfigTarget{
&outboundjson.ConfigTarget{
Address: v2net.IPAddress([]byte{127, 0, 0, 1}, portB),
Destination: v2net.TCPDestination(v2net.IPAddress([]byte{127, 0, 0, 1}), portB),
Users: []*vmessjson.ConfigUser{
&vmessjson.ConfigUser{Id: testAccount},
},
@@ -99,7 +99,7 @@ func TestVMessInAndOut(t *testing.T) {
err = pointB.Start()
assert.Error(err).IsNil()
dest := v2net.NewTCPDestination(v2net.IPAddress([]byte{1, 2, 3, 4}, 80))
dest := v2net.TCPDestination(v2net.IPAddress([]byte{1, 2, 3, 4}), 80)
ich.Communicate(v2net.NewPacket(dest, nil, true))
assert.Bytes(ichConnInput).Equals(ochConnOutput.Bytes())
assert.Bytes(ichConnOutput.Bytes()).Equals(ochConnInput)