Skip to content

Commit

Permalink
0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Immueggpain authored and Immueggpain committed Dec 29, 2019
1 parent cf5e190 commit a0f0539
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.github.immueggpain</groupId>
<artifactId>simple-streaming</artifactId>
<version>0.0.9</version>
<version>0.1.0</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
subcommands = { HelpCommand.class, StreamUpload.class, StreamServer.class, Serve.class })
public class Launcher implements Callable<Void> {

public static final String VERSTR = "0.0.9";
public static final String VERSTR = "0.1.0";
public static final int LOCAL_PORT = 2233;
public static final int LOCAL_OVPN_PORT = 1194;
public static final int BUFLEN = 1024 * 64;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ private static class Downloader {
}

private HashMap<Socket, Downloader> activeDownloaders = new HashMap<>();
private Socket currentSocket;

@Override
public Void call() throws Exception {
Expand Down Expand Up @@ -110,8 +111,9 @@ private void upload_thread() {
while (true) {
Socket socket = serverSocket.accept();
System.out.println("new uploader");
Thread uploadThread = Util.execAsync("upload_thread", () -> upload_thread(socket));
uploadThread.join();
Util.closeQuietly(currentSocket);
currentSocket = socket;
Util.execAsync("upload_thread", () -> upload_thread(socket));
}
} catch (Exception e) {
e.printStackTrace();
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/com/github/immueggpain/simplestreaming/Util.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.github.immueggpain.simplestreaming;

import java.io.Closeable;
import java.io.IOException;
import java.net.Socket;
import java.security.GeneralSecurityException;
import java.security.Key;

Expand Down Expand Up @@ -54,4 +57,14 @@ public static byte[] decrypt(Cipher decrypter, Key secretKey, byte[] input, int
return decryptedBytes;
}

public static void closeQuietly(final Closeable sock) {
if (sock != null) {
try {
sock.close();
} catch (final IOException ioe) {
// ignored
}
}
}

}

0 comments on commit a0f0539

Please sign in to comment.