diff --git a/build.gradle b/build.gradle index c368e8d..b41e4c5 100644 --- a/build.gradle +++ b/build.gradle @@ -1,19 +1,31 @@ +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar + plugins { id 'java' - id 'application' + id 'com.gradleup.shadow' version '9.0.0-beta4' } group = 'net.pixtaded' -version = '1.0.4' +version = projectVersion repositories { mavenCentral() } -application { - mainClass = 'net.pixtaded.crab.Main' -} - dependencies { implementation('org.xerial:sqlite-jdbc:3.47.1.0') +} + +tasks.build.dependsOn tasks.shadowJar + +tasks.named('jar', Jar) { + manifest { + attributes 'Main-Class': 'net.pixtaded.crab.Main' + } +} + +tasks.named('shadowJar', ShadowJar) { + archiveBaseName = 'crab' + archiveClassifier = '' + archiveVersion = projectVersion } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..5f67769 --- /dev/null +++ b/gradle.properties @@ -0,0 +1 @@ +projectVersion=1.0.5 \ No newline at end of file diff --git a/src/main/java/net/pixtaded/crab/server/ServerThread.java b/src/main/java/net/pixtaded/crab/server/ServerThread.java index ee0ce2d..9889949 100644 --- a/src/main/java/net/pixtaded/crab/server/ServerThread.java +++ b/src/main/java/net/pixtaded/crab/server/ServerThread.java @@ -43,11 +43,11 @@ public class ServerThread implements Runnable { String msg = new String(input.readNBytes(4096), StandardCharsets.UTF_8).trim(); String address = socket.getInetAddress().getHostAddress(); - new Thread(new LogDBThread(date, address, msg)).start(); - String s = Sanitizer.sanitizeString(msg, true); String newContent = server.cache.content() + Sanitizer.formatMessage(date.getTime(), address, s); server.cache = new Logs(newContent.getBytes().length, newContent); + + new Thread(new LogDBThread(date, address, msg)).start(); } case LOGS -> { respond(server.cache.content()); } case LOGS_SIZE -> { @@ -75,15 +75,17 @@ public class ServerThread implements Runnable { Date date; String msg; + String address; public LogDBThread(Date date, String address, String msg) { this.date = date; this.msg = msg; + this.address = address; } @Override public void run() { - server.getDb().logMessage(date, socket.getInetAddress().getHostAddress(), msg); + server.getDb().logMessage(date, address, msg); } } }