Skip to content

Commit

Permalink
Client will now notice if the server forgets to send a reply
Browse files Browse the repository at this point in the history
- Added a new catch-clause, so the client will notice if the server forgets to send a reply (sendReply(Socket, Object...)).
- Slightly improved Diffie Hellman Factory
- Added Java version to contributing guidelines
  • Loading branch information
DeBukkIt committed Apr 7, 2018
1 parent 4b257fb commit 304d86f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
11 changes: 9 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Contributing Guidelines

## Code Style
- Do not use a single line for a {, but put it at the end of the previous line
- Do not leave { or } out if possible, e.g. when writing an if statement with just one line in its body
- Do not change the line breaks of the Javadoc
- Do not leave { or } out even if this is possible, e.g. when writing an if statement with just one line in its body
- Do not change the line breaks of the Javadoc

## Java Version
- Only use language features that are possible in Java 8 or earlier.


Thank you for contributing!
2 changes: 1 addition & 1 deletion src/com/blogspot/debukkitsblog/crypt/DHKeyFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class DHKeyFactory {
public DHKeyFactory() {
System.out.println("[DHKey] Generating secure key...");
p = new BigInteger(2048, 12, new Random());
g = new BigInteger(String.valueOf(12 - new Random().nextInt(10)));
g = new BigInteger(String.valueOf(4 - new Random().nextInt(3)));
do {
s = new BigInteger(160, new Random());
} while (s.compareTo(new BigInteger("2")) == -1 || s.compareTo(p.subtract(new BigInteger("1"))) == 0);
Expand Down
3 changes: 3 additions & 0 deletions src/com/blogspot/debukkitsblog/net/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.EOFException;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
Expand Down Expand Up @@ -438,6 +439,8 @@ public Datapackage sendMessage(Datapackage message, int timeout) {
if (raw instanceof Datapackage) {
return (Datapackage) raw;
}
} catch(EOFException ex) {
onLogError("[Client] Error right after sending message: EOFException (did the server forget to send a reply?)");
} catch (IOException | ClassNotFoundException ex) {
onLogError("[Client] Error while sending message");
ex.printStackTrace();
Expand Down

0 comments on commit 304d86f

Please sign in to comment.