Skip to content

Commit

Permalink
Merge pull request #254 from LossyDragon/updates
Browse files Browse the repository at this point in the history
Updates
  • Loading branch information
LossyDragon authored Mar 11, 2024
2 parents bbeccf8 + fabf876 commit ddfbef7
Show file tree
Hide file tree
Showing 41 changed files with 222 additions and 356 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="javasteam [wrapper --gradle-version 8.4]" type="GradleRunConfiguration" factoryName="Gradle" nameIsGenerated="true">
<configuration default="false" name="javasteam [wrapper --gradle-version 8.6]" type="GradleRunConfiguration" factoryName="Gradle" nameIsGenerated="true">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
Expand All @@ -12,7 +12,7 @@
<list>
<option value="wrapper" />
<option value="--gradle-version" />
<option value="8.4" />
<option value="8.6" />
</list>
</option>
<option name="vmOptions" />
Expand Down
38 changes: 19 additions & 19 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
[versions]
# Java / Kotlin versions
java = "1.8"
kotlin = "1.9.10" # https://kotlinlang.org/docs/releases.html#release-details
ktlint = "11.6.1"
kotlin = "1.9.20" # https://kotlinlang.org/docs/releases.html#release-details || https://mvnrepository.com/artifact/org.jetbrains.dokka/dokka-gradle-plugin
ktlint = "12.1.0" # https://github.com/JLLeitschuh/ktlint-gradle/releases

# Standard Library versions
bouncyCastle = "1.70" # https://mvnrepository.com/artifact/org.bouncycastle/bcprov-jdk15on
commons-io = "2.14.0" # https://mvnrepository.com/artifact/commons-io/commons-io
commons-lang3 = "3.13.0" # https://mvnrepository.com/artifact/org.apache.commons/commons-lang3
commons-validator = "1.7" # https://mvnrepository.com/artifact/commons-validator/commons-validator
bouncyCastle = "1.77" # https://mvnrepository.com/artifact/org.bouncycastle/bcprov-jdk18on
commons-io = "2.15.1" # https://mvnrepository.com/artifact/commons-io/commons-io
commons-lang3 = "3.14.0" # https://mvnrepository.com/artifact/org.apache.commons/commons-lang3
commons-validator = "1.8.0" # https://mvnrepository.com/artifact/commons-validator/commons-validator
gson = "2.10.1" # https://mvnrepository.com/artifact/com.google.code.gson/gson
jacoco = "0.8.11" # https://www.eclemma.org/jacoco
javaWebSocket = "1.5.4" # https://mvnrepository.com/artifact/org.java-websocket/Java-WebSocket
kotlin-coroutines = "1.7.3" # https://mvnrepository.com/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core
okHttp = "5.0.0-alpha.11" # https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp
protobuf = "3.23.4" # https://mvnrepository.com/artifact/com.google.protobuf/protobuf-java
javaWebSocket = "1.5.6" # https://mvnrepository.com/artifact/org.java-websocket/Java-WebSocket
kotlin-coroutines = "1.8.0" # https://mvnrepository.com/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core
okHttp = "5.0.0-alpha.12" # https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp
protobuf = "3.25.3" # https://mvnrepository.com/artifact/com.google.protobuf/protobuf-java
protobuf-gradle = "0.9.4" # https://mvnrepository.com/artifact/com.google.protobuf/protobuf-gradle-plugin
publishPlugin = "1.1.0" # https://mvnrepository.com/artifact/io.github.gradle-nexus/publish-plugin
qrCode = "1.0.1" # https://mvnrepository.com/artifact/pro.leaco.qrcode/console-qrcode

# Testing Lib versions
commonsCodec = "1.16.0" # https://mvnrepository.com/artifact/commons-codec/commons-codec
jupiterVersion = "5.10.0" # https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api
mockWebServer = "5.0.0-alpha.11" # https://mvnrepository.com/artifact/com.squareup.okhttp3/mockwebserver3-junit5
commonsCodec = "1.16.1" # https://mvnrepository.com/artifact/commons-codec/commons-codec
junit5 = "5.10.2" # https://mvnrepository.com/artifact/org.junit/junit-bom
mockWebServer = "5.0.0-alpha.12" # https://mvnrepository.com/artifact/com.squareup.okhttp3/mockwebserver3-junit5
mockitoVersion = "4.11.0" # https://mvnrepository.com/artifact/org.mockito/mockito-core

[libraries]
bouncyCastle = { module = "org.bouncycastle:bcprov-jdk15on", version.ref = "bouncyCastle" }
bouncyCastle = { module = "org.bouncycastle:bcprov-jdk18on", version.ref = "bouncyCastle" }
commons-io = { module = "commons-io:commons-io", version.ref = "commons-io" }
commons-lang3 = { module = "org.apache.commons:commons-lang3", version.ref = "commons-lang3" }
commons-validator = { module = "commons-validator:commons-validator", version.ref = "commons-validator" }
Expand All @@ -40,17 +40,17 @@ qrCode = { module = "pro.leaco.qrcode:console-qrcode", version.ref = "qrCode" }
webSocket = { module = "org.java-websocket:Java-WebSocket", version.ref = "javaWebSocket" }

test-commons-codec = { module = "commons-codec:commons-codec", version.ref = "commonsCodec" }
test-jupiter-api = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "jupiterVersion" }
test-jupiter-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "jupiterVersion" }
test-jupiter-params = { module = "org.junit.jupiter:junit-jupiter-params", version.ref = "jupiterVersion" }
test-jupiter-api = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "junit5" }
test-jupiter-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "junit5" }
test-jupiter-params = { module = "org.junit.jupiter:junit-jupiter-params", version.ref = "junit5" }
test-mock-webserver3 = { module = "com.squareup.okhttp3:mockwebserver3-junit5", version.ref = "mockWebServer" }
test-mockito-core = { module = "org.mockito:mockito-core", version.ref = "mockitoVersion" }
test-mockito-jupiter = { module = "org.mockito:mockito-junit-jupiter", version.ref = "mockitoVersion" }

[plugins]
kotlin-dokka = { id = "org.jetbrains.dokka", version.ref = "kotlin" }
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kotlin-lint = { id = "org.jlleitschuh.gradle.ktlint", version.ref ="ktlint" }
kotlin-lint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlint" }
maven-publish = { id = "io.github.gradle-nexus.publish-plugin", version.ref = "publishPlugin" }
protobuf-gradle = { id = "com.google.protobuf", version.ref = "protobuf-gradle" }

Expand All @@ -61,7 +61,7 @@ testing = [
"test-jupiter-api",
"test-jupiter-engine",
"test-jupiter-params",
"test-mock-webserver3",
"test-mockito-core",
"test-mockito-jupiter",
"test-mock-webserver3"
]
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
17 changes: 9 additions & 8 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -144,15 +145,15 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -201,11 +202,11 @@ fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

import java.util.concurrent.CancellationException;

// TODO: https://github.com/SteamRE/SteamKit/pull/1129#issuecomment-1473758793
// NOTE: https://github.com/SteamRE/SteamKit/pull/1129#issuecomment-1473758793
// CM will kick you in 60 seconds if you don't auth.
// Steam client also has this issue, but it will reconnect and just continue polling.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import pro.leaco.console.qrcode.ConsoleQrcode.print
import java.lang.Runnable
import java.util.concurrent.CancellationException

// TODO: https://github.com/SteamRE/SteamKit/pull/1129#issuecomment-1473758793
// NOTE: https://github.com/SteamRE/SteamKit/pull/1129#issuecomment-1473758793
// CM will kick you in 60 seconds if you don't auth.
// Steam client also has this issue, but it will reconnect and just continue polling.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
/**
* Represents a protobuf backed client message. Only contains the header information.
*/
@SuppressWarnings("unused")
public class AClientMsgProtobuf extends MsgBase<MsgHdrProtoBuf> {

private static final Logger logger = LogManager.getLogger(AClientMsgProtobuf.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
/**
* This class provides a payload backing to client messages.
*/
@SuppressWarnings("unused")
public abstract class AbstractMsgBase {

protected MemoryStream payload;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/in/dragonbra/javasteam/base/ClientGCMsg.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*
* @param <BodyType> The body type of this message.
*/
@SuppressWarnings("unused")
public class ClientGCMsg<BodyType extends IGCSerializableMessage> extends GCMsgBase<MsgGCHdr> {

private static final Logger logger = LogManager.getLogger(ClientGCMsg.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
*
* @param <BodyType> The body type of this message.
*/
@SuppressWarnings("unused")
public class ClientGCMsgProtobuf<BodyType extends GeneratedMessageV3.Builder<BodyType>> extends GCMsgBase<MsgGCHdrProtoBuf> {

private static final Logger logger = LogManager.getLogger(ClientGCMsgProtobuf.class);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/in/dragonbra/javasteam/base/ClientMsg.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*
* @param <BodyType> The body type of this message.
*/
@SuppressWarnings("unused")
public class ClientMsg<BodyType extends ISteamSerializableMessage> extends MsgBase<ExtendedClientMsgHdr> {

private static final Logger logger = LogManager.getLogger(ClientMsg.class);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/in/dragonbra/javasteam/base/GCMsgBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*
* @param <HdrType> The header type for this gc message.
*/
@SuppressWarnings("unused")
public abstract class GCMsgBase<HdrType extends IGCSerializableHeader> extends AbstractMsgBase implements IClientGCMsg {

private static final Logger logger = LogManager.getLogger(MsgBase.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
/**
* Represents a unified interface into client messages.
*/
@SuppressWarnings("unused")
public interface IClientGCMsg {

/**
Expand Down
1 change: 1 addition & 0 deletions src/main/java/in/dragonbra/javasteam/base/IClientMsg.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
/**
* Represents a unified interface into client messages.
*/
@SuppressWarnings("unused")
public interface IClientMsg {

/**
Expand Down
1 change: 1 addition & 0 deletions src/main/java/in/dragonbra/javasteam/base/Msg.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
/**
* Represents a struct backed message without session or client info.
*/
@SuppressWarnings("unused")
public class Msg<BodyType extends ISteamSerializableMessage> extends MsgBase<MsgHdr> {

private static final Logger logger = LogManager.getLogger(Msg.class);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/in/dragonbra/javasteam/base/MsgBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* This is the abstract base class for all available client messages.
* It's used to maintain packet payloads and provide a header for all client messages.
*/
@SuppressWarnings("unused")
public abstract class MsgBase<HdrType extends ISteamSerializable> extends AbstractMsgBase implements IClientMsg {

private static final Logger logger = LogManager.getLogger(MsgBase.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
/**
* This class implements the base requirements every message handler should inherit from.
*/
@SuppressWarnings("unused")
public abstract class ClientMsgHandler {

protected SteamClient client;
Expand All @@ -33,6 +34,7 @@ protected boolean isExpectDisconnection() {
*
* @param expectDisconnection whether or not the related {@link SteamClient} should imminently expect the server to close the connection.
*/
@SuppressWarnings("SameParameterValue")
protected void setExpectDisconnection(boolean expectDisconnection) {
client.setExpectDisconnection(expectDisconnection);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,28 @@ public abstract class Connection {
/**
* Occurs when a net message is received over the network.
*/
Event<NetMsgEventArgs> netMsgReceived = new Event<>();
final Event<NetMsgEventArgs> netMsgReceived = new Event<>();

/**
* Occurs when the physical connection is established.
*/
Event<EventArgs> connected = new Event<>();
final Event<EventArgs> connected = new Event<>();

/**
* Occurs when the physical connection is broken.
*/
Event<DisconnectedEventArgs> disconnected = new Event<>();
final Event<DisconnectedEventArgs> disconnected = new Event<>();

void onNetMsgReceived(NetMsgEventArgs e) {
if (netMsgReceived != null) {
netMsgReceived.handleEvent(this, e);
}
netMsgReceived.handleEvent(this, e);
}

void onConnected() {
if (connected != null) {
connected.handleEvent(this, null);
}
connected.handleEvent(this, null);
}

void onDisconnected(boolean e) {
if (disconnected != null) {
disconnected.handleEvent(this, new DisconnectedEventArgs(e));
}
disconnected.handleEvent(this, new DisconnectedEventArgs(e));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* @author lngtr
* @since 2018-02-20
*/
@SuppressWarnings("unused")
public class NetMsgEventArgs extends EventArgs {

private final byte[] data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,7 @@ public void run() {
receivePacket(udpPacket);
try {
sock.receive(packet);
//noinspection DataFlowIssue
received = true;
} catch (SocketTimeoutException e) {
received = false;
Expand Down Expand Up @@ -592,9 +593,7 @@ public void run() {
}
}

if (sock != null) {
sock.close();
}
sock.close();

logger.debug("Calling onDisconnected");
onDisconnected(userRequestDisconnect);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class WebSocketCMClient extends WebSocketClient {
}

@Override
public void onOpen(ServerHandshake handshakedata) {
public void onOpen(ServerHandshake handshakeData) {
if (listener != null) {
listener.onOpen();
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/in/dragonbra/javasteam/steam/CMClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@
import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.time.Duration;
import java.util.*;
import java.util.zip.GZIPInputStream;

/**
* This base client handles the underlying connection to a CM server. This class should not be use directly, but through
* the {@link in.dragonbra.javasteam.steam.steamclient.SteamClient SteamClient} class.
*/
@SuppressWarnings("unused")
public abstract class CMClient {

private static final Logger logger = LogManager.getLogger(CMClient.class);
Expand Down Expand Up @@ -385,7 +385,7 @@ private void handleMulti(IPacketMsg packetMsg) {

private void handleLogOnResponse(IPacketMsg packetMsg) {
if (!packetMsg.isProto()) {
// a non proto ClientLogonResponse can come in as a result of connecting but never sending a ClientLogon
// a non-proto ClientLogonResponse can come in as a result of connecting but never sending a ClientLogon
// in this case, it always fails, so we don't need to do anything special here
logger.debug("Got non-proto logon response, this is indicative of no logon attempt after connecting.");
return;
Expand Down
Loading

0 comments on commit ddfbef7

Please sign in to comment.