diff --git a/README.md b/README.md index 13ebfca..de7e877 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,25 @@ ## Tiny SOCKS5 Proxy -curl -v --socks5-hostname localhost:8080 google.com +Build & run: + +``` +$ mvn verify assembly:single +$ java -jar ./target/TinySocks-1.0-SNAPSHOT.jar +``` + +Tests: + +``` +$curl --socks5-hostname localhost:8080 https://mirror.yandex.ru/archlinux/community/os/x86_64/zathura-pdf-mupdf-0.3.7-1-x86_64.pkg.tar.zst > /dev/null + % Total % Received % Xferd Average Speed Time Time Time Current + Dload Upload Total Spent Left Speed +100 21.2M 100 21.2M 0 0 1065k 0 0:00:20 0:00:20 --:--:-- 1004k + +$curl https://mirror.yandex.ru/archlinux/community/os/x86_64/zathura-pdf-mupdf-0.3.7-1-x86_64.pkg.tar.zst > /dev/null + % Total % Received % Xferd Average Speed Time Time Time Current + Dload Upload Total Spent Left Speed +100 21.2M 100 21.2M 0 0 1091k 0 0:00:19 0:00:19 --:--:-- 1137k + +``` ![tiny socks](http://fit.ippolitov.me/CN_2/2021/socks.jpg) diff --git a/src/main/java/me/hikari/socks/Attachment.java b/src/main/java/me/hikari/socks/Attachment.java index 539b35e..5d46ef0 100644 --- a/src/main/java/me/hikari/socks/Attachment.java +++ b/src/main/java/me/hikari/socks/Attachment.java @@ -13,8 +13,6 @@ enum Type { NONE, - READ, - WRITE, CONN_READ, CONN_WRITE, DNS_READ, @@ -93,13 +91,13 @@ public void finishCouple(){ public void addCoupledWrite() { coupled.interestOpsOr(SelectionKey.OP_WRITE); - SocksUtils.getAttachment(coupled).setType(Type.WRITE); + SocksUtils.getAttachment(coupled).setType(Type.NONE); type = Type.NONE; } public void addCoupledRead() { coupled.interestOpsOr(SelectionKey.OP_READ); - SocksUtils.getAttachment(coupled).setType(Type.READ); + SocksUtils.getAttachment(coupled).setType(Type.NONE); type = Type.NONE; } diff --git a/src/main/java/me/hikari/socks/DnsUtils.java b/src/main/java/me/hikari/socks/DnsUtils.java index 7b38302..bc0d320 100644 --- a/src/main/java/me/hikari/socks/DnsUtils.java +++ b/src/main/java/me/hikari/socks/DnsUtils.java @@ -22,7 +22,7 @@ public static void read(SelectionKey key) throws IOException { log.info("Resolved: " + maybeRecord.get().rdataToString()); SocksUtils.getAttachment(attach.getCoupled()).couple(addr, attach.getPort(), attach.getCoupled()); - SocksUtils.getAttachment(attach.getCoupled()).setType(Type.READ); + SocksUtils.getAttachment(attach.getCoupled()).setType(Type.NONE); key.interestOps(0); SocksUtils.partiallyClose(key); } else {