-
-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DCC 2: Electric Boogaloo #172
Conversation
Current coverage is 32.61% (diff: 0.00%)@@ master #172 diff @@
==========================================
Files 152 161 +9
Lines 3818 4093 +275
Methods 0 0
Messages 0 0
Branches 536 567 +31
==========================================
+ Hits 1334 1335 +1
- Misses 2431 2705 +274
Partials 53 53
|
/** | ||
* Represents an exchange using DCC. | ||
*/ | ||
public interface DccExchange extends Actor, Closeable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be DCCExchange
.
|
||
import javax.annotation.Nonnull; | ||
|
||
public interface DccChat extends DccExchange { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be DCCChat
.
* a {@link DccConnectedEvent} will be fired. If the connection fails, a | ||
* {@link DccFailedEvent} will be fired.</p> | ||
*/ | ||
void requestDccChat(@Nonnull User target); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be requestDCCChat
.
* | ||
* @see Client#requestDccChat(User) | ||
*/ | ||
default void requestDccChat() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be requestDCCChat
.
/** | ||
* Fires when a DCC CHAT message is received. | ||
*/ | ||
public class DccChatMessageEvent extends ActorMessageEventBase<DccChat> implements ReplyableEvent { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be DCCChatMessageEvent
.
Any objections if I write some tests? |
No, @lol768. |
super(client, originalMessages, actor); | ||
Sanity.nullCheck(type, "type cannot be null"); | ||
Sanity.nullCheck(ip, "ip cannot be null"); | ||
this.type = type; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.type = Sanity.nullCheck(type, "type cannot be null");
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather follow the existing style:
- https://github.com/KittehOrg/KittehIRCClientLib/blob/master/src/main/java/org/kitteh/irc/client/library/event/client/ClientConnectedEvent.java#L55-L56
- https://github.com/KittehOrg/KittehIRCClientLib/blob/master/src/main/java/org/kitteh/irc/client/library/event/abstractbase/ClientEventBase.java#L48
- https://github.com/KittehOrg/KittehIRCClientLib/blob/master/src/main/java/org/kitteh/irc/client/library/event/capabilities/CapabilitiesAcknowledgedEvent.java#L58
- etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've actually meant to migrate to that style for a while now. ^_^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then change it on master
first and I'll follow up :P
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
|
||
/** | ||
* @return the readable reason for the failure |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing full javadocs.
Incoming DCCs will generate events but cannot be accepted yet.
4996261
to
de2f8e6
Compare
return this.type; | ||
} | ||
|
||
public String getIp() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be convenient to have this return an InetAddress
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
InetSocketAddress
now, and dropped getPort
.
/** | ||
* Denies the request. | ||
*/ | ||
public abstract void deny(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my mind, the opposite of accept is reject, and the opposite of deny is allow. It's something to consider, although not hugely relevant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My thoughts
import java.util.Optional; | ||
|
||
/** | ||
* Represents an exchange using DCC. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
immutable exchange snapshot?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the other immutable snapshots are written this way. Is there anything special about this that sets it apart?
/** | ||
* Returns the exception that caused the failure. | ||
* | ||
* @return the exception that caused the failure |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When is he present?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or she
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When is they present?
/** | ||
* Returns the human-readable reason for the failure. | ||
* | ||
* @return the human-readable reason for the failure |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When is he present?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or she
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When is they present?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They is always present.
@@ -996,6 +1002,69 @@ public void ctcp(ClientReceiveCommandEvent event) { | |||
} | |||
} | |||
|
|||
private void handleDCCEvent(User user, List<ServerMessage> originalMessages, List<String> parameters) { | |||
// TODO should unknown requests or improperly formatted requests get logged? just to clarify to the user that they are still noticed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We throw server exceptions for invalid server messages.. could do the same here but not sure since it's a user originating message..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really user but client originating. Still could be maliciously crafted easily.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed on IRC.
return addressLong.toString(); | ||
} | ||
|
||
private static final BigInteger X_FFFF = BigInteger.valueOf(0xFFFF); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be better up top?
@@ -996,6 +1002,69 @@ public void ctcp(ClientReceiveCommandEvent event) { | |||
} | |||
} | |||
|
|||
private void handleDCCEvent(User user, List<ServerMessage> originalMessages, List<String> parameters) { | |||
// TODO should unknown requests or improperly formatted requests get logged? just to clarify to the user that they are still noticed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logged in the background? yes. Silently dropping things is bad. will also allow covering for possible exploit attempts
|
||
public final class IPUtil { | ||
private static final BigInteger X_FFFF = BigInteger.valueOf(0xFFFF); | ||
private static final int LENGTH_OF_LARGEST_IPV6_INTEGER = BigInteger.valueOf(2).pow(128).toString().length(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO this is missing a -1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I follow?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
is
340282366920938463463374607431768211455
2^128 is
340282366920938463463374607431768211456
But that is, of course, not relevant. They're both the same length, which is 39.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, I don't really think that matters too much. We could even just hardcode the 39 and add a comment 😛
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's now just a 39.
|
||
import javax.annotation.Nonnull; | ||
|
||
public interface DCCChat extends DCCExchange { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing javadocs.
* @param ipInteger the IP integer string | ||
* @return the corresponding IP address as an InetAddress instance | ||
*/ | ||
public static InetAddress getInetAdressFromIntString(String ipInteger) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing a d
in address
.
getInetAdressFromIntString
getInetAddressFromIntString
2017 is off to a great start |
Closing this PR to give the dcc branch's PR the spotlight. #181 |
Back from the dead, it's DCC support!
This closes #93, and replaces #138.
Things to do:
DCCConnectionClosedEvent
:P