Skip to content

Commit

Permalink
excess cured
Browse files Browse the repository at this point in the history
  • Loading branch information
UltimateHikari committed Dec 13, 2021
1 parent 6d55736 commit c836843
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
3 changes: 0 additions & 3 deletions src/main/java/me/hikari/socks/Attachment.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ public void decouple() {
if (sendoff != null) {
this.coupled = null;
if(sendoff.isValid()) {
if ((sendoff.interestOps() & SelectionKey.OP_WRITE) == 0) {
SocksUtils.getAttachment(sendoff).out.flip();
}
sendoff.interestOps(SelectionKey.OP_WRITE);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/me/hikari/socks/SocksMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ public static void putConnResponse(ByteBuffer in) {
IP_V4,
NOB, NOB, NOB, NOB,
NOB, NOB,
}).flip();
});
}

public static void putNoAuthResponse(SelectionKey key) {
SocksUtils.useInAsOut(key);
SocksUtils.clearOut(key);
SocksUtils.getAttachment(key).getOut().put(new byte[] {SOCKS_VERSION, NO_AUTH}).flip();
SocksUtils.getAttachment(key).getOut().put(new byte[] {SOCKS_VERSION, NO_AUTH});
}

public static boolean inTooSmall(SelectionKey key, byte smallness){
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/me/hikari/socks/SocksUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ public static void partiallyClose(SelectionKey key) throws IOException {
}

public static boolean tryWriteToBuffer(SelectionKey key) throws IOException {
var res = getByteChannel(key).write(getAttachment(key).getOut());
log.info(key.channel());
var buf = getAttachment(key).getOut();
buf.flip();
var res = getByteChannel(key).write(buf);
log.info("write2buffer: " + res);
return (res > 0);
}
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/me/hikari/socks/TinyServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ private void prepareCoupledWrite(SelectionKey key) throws IOException {
// couple exists 'cause of conn earlier in switch
// disable read + enable coupled read
log.info(key);
SocksUtils.clearIn(key);
SocksUtils.getAttachment(key).addCoupledWrite();
key.interestOps(key.interestOps() ^ SelectionKey.OP_READ);
}
Expand Down Expand Up @@ -207,7 +206,7 @@ var record = Record.newRecord(Name.fromString(hostname + '.').canonicalize(), or
header.setFlag(Flags.AD);
header.setFlag(Flags.RD);

dnsAttach.getIn().put(message.toWire()).flip();
dnsAttach.getIn().put(message.toWire());
dnsAttach.useInAsOut();

dnsKey.attach(dnsAttach);
Expand Down

0 comments on commit c836843

Please sign in to comment.