Skip to content

Commit d4efa94

Browse files
committed
fix tests for socks5. fix proxy script. Add docker shell fils
1 parent 392a41e commit d4efa94

File tree

7 files changed

+14
-9
lines changed

7 files changed

+14
-9
lines changed

build_docker.sh

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env sh
2+
3+
docker build . --tag asyncsocket

docker.sh

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env sh
2+
3+
docker run asyncsocket ./run_tests.sh

src/main/kotlin/com/theevilroot/asyncsocket/Socks4CoroutineSocket.kt

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package com.theevilroot.asyncsocket
22

3-
import java.lang.Exception
4-
import java.net.ConnectException
53
import java.net.InetAddress
64
import java.net.InetSocketAddress
75
import java.nio.ByteBuffer

src/main/kotlin/com/theevilroot/asyncsocket/SocksCoroutineSocket.kt

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.theevilroot.asyncsocket
22

3-
import java.io.IOException
43
import java.net.ConnectException
54
import java.net.InetAddress
65
import java.net.InetSocketAddress

src/test/kotlin/com/theevilroot/asyncsocket/Socks4Test.kt

+5-2
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,15 @@ class Socks4Test {
2929
val request = "GET /?format=json HTTP/1.1\r\nConnection: close\r\nHost: api.ipify.org\r\nAccept: */*\r\nUser-Agent: curl/1.1.1\r\n\r\n"
3030
Assert.assertEquals(request.length, socket.write(ByteBuffer.wrap(request.toByteArray())))
3131

32-
3332
// read some data, we don't need much
3433
val response = ByteBuffer.allocate(32)
3534
Assert.assertTrue(socket.read(response) > 0)
3635

36+
val http = ByteArray(4)
37+
response.position(0)
38+
response.get(http, 0, 4)
39+
Assert.assertTrue(http.contentEquals("HTTP".toByteArray()))
40+
3741
socket.close()
3842
}
39-
4043
}

src/test/kotlin/com/theevilroot/asyncsocket/SocksTest.kt

-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ class SocksTest {
4545
socket.close()
4646
}
4747

48-
4948
@Test
5049
fun testUserPassAuthIncorrect(): Unit = runBlocking {
5150
val credentials = "username" to "blah"

test_proxy.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@ fi
2222

2323
if [ $# -eq 1 ]
2424
then
25-
echo ':: using no auth. port: 1081'
25+
echo ":: using $protocol no auth. port: $port"
2626
pproxy -l "$protocol://0.0.0.0:$port"
2727
exit 0
2828
fi
2929

3030
if [ $# -eq 3 ]
3131
then
32-
echo ':: using user/pass auth. port: 1080'
3332
port=1080
34-
pproxy -l "$protocol://0.0.0.0:$port#$1:$2"
33+
echo ":: using $protocol user/pass auth. port: $port"
34+
pproxy -l "$protocol://0.0.0.0:$port#$2:$3"
3535
exit 0
3636
fi
3737

0 commit comments

Comments
 (0)