1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-06-13 03:10:44 +00:00

test case for socks protocol

This commit is contained in:
v2ray 2015-12-03 23:31:04 +01:00
parent f69b83f3e6
commit 36b7a3fe07

View File

@ -100,6 +100,32 @@ func TestResponseWrite(t *testing.T) {
assert.Bytes(buffer.Value).Named("raw response").Equals(expectedBytes)
}
func TestSetIPv6(t *testing.T) {
v2testing.Current(t)
response := NewSocks5Response()
response.SetIPv6([]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15})
buffer := alloc.NewSmallBuffer().Clear()
defer buffer.Release()
response.Write(buffer)
assert.Bytes(buffer.Value).Equals([]byte{
socksVersion, 0, 0, AddrTypeIPv6, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 0})
}
func TestSetDomain(t *testing.T) {
v2testing.Current(t)
response := NewSocks5Response()
response.SetDomain("v2ray.com")
buffer := alloc.NewSmallBuffer().Clear()
defer buffer.Release()
response.Write(buffer)
assert.Bytes(buffer.Value).Equals([]byte{
socksVersion, 0, 0, AddrTypeDomain, 9, 118, 50, 114, 97, 121, 46, 99, 111, 109, 0, 0})
}
func TestEOF(t *testing.T) {
v2testing.Current(t)