mirror of
https://github.com/kuroppoi/entralinked.git
synced 2026-09-08 08:45:14 -05:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8e614e0d27 | ||
|
|
774794f751 | ||
|
|
9d288bde09 | ||
|
|
18b86a42e0 | ||
|
|
39e0b27cec | ||
|
|
1af975ffb6 | ||
|
|
6f2e4a06a0 |
@@ -12,6 +12,8 @@ Its purpose is to serve as a simple utility for downloading Pokémon, Items, C-G
|
||||
and, in Black 2 & White 2 only, Join Avenue visitors to your game without needing to edit your save file.\
|
||||
It can also be used to Memory Link with a Black or White save file if you don't have a second DS system.
|
||||
|
||||

|
||||
|
||||
For users: [Quick Setup Guide](https://github.com/kuroppoi/entralinked/wiki/Setup)
|
||||
|
||||
## Building
|
||||
|
||||
BIN
images/preview-2x.gif
Normal file
BIN
images/preview-2x.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 356 KiB |
BIN
images/preview.gif
Normal file
BIN
images/preview.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 210 KiB |
@@ -24,6 +24,13 @@ public class User {
|
||||
return "%s000".formatted(id).replaceAll("(.{4})(?!$)", "$1-");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The user's id, redacted for logging.
|
||||
*/
|
||||
public String getRedactedId() {
|
||||
return "%s-XXXX-XXXX-XXXX".formatted(id.substring(0, 4));
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ public class GameSpyHandler extends SimpleChannelInboundHandler<GameSpyRequest>
|
||||
|
||||
@Override
|
||||
public void channelInactive(ChannelHandlerContext ctx) {
|
||||
logger.debug("User {} disconnected from GameSpy server", user == null ? null : user.getFormattedId());
|
||||
logger.debug("User {} disconnected from GameSpy server", user == null ? null : user.getRedactedId());
|
||||
|
||||
// Clear data
|
||||
serverChallenge = null;
|
||||
@@ -86,7 +86,7 @@ public class GameSpyHandler extends SimpleChannelInboundHandler<GameSpyRequest>
|
||||
|
||||
// Handle timeout
|
||||
if(cause instanceof ReadTimeoutException) {
|
||||
logger.debug("User {} timed out", user == null ? null : user.getFormattedId());
|
||||
logger.debug("User {} timed out", user == null ? null : user.getRedactedId());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ public class GameSpyHandler extends SimpleChannelInboundHandler<GameSpyRequest>
|
||||
userManager.saveUser(user); // It's not too big of a deal if this fails for some reason
|
||||
}
|
||||
|
||||
logger.info("User {} logged in with profile {}", user.getFormattedId(), profile.getId());
|
||||
logger.info("User {} logged in with profile {}", user.getRedactedId(), profile.getId());
|
||||
|
||||
// Prepare and send response
|
||||
sessionKey = secureRandom.nextInt(Integer.MAX_VALUE);
|
||||
@@ -197,7 +197,7 @@ public class GameSpyHandler extends SimpleChannelInboundHandler<GameSpyRequest>
|
||||
}
|
||||
|
||||
public void handleLogout() {
|
||||
logger.info("User {} logged out of profile {}", user.getFormattedId(), profile.getId());
|
||||
logger.info("User {} logged out of profile {}", user.getRedactedId(), profile.getId());
|
||||
sessionKey = -1; // Is there a point?
|
||||
}
|
||||
|
||||
|
||||
@@ -31,8 +31,8 @@ public record GameSpyLoginRequest(
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ("GameSpyLoginRequest[sequenceId=%s, userId=%s, gameName=%s, profileId=%s, namespaceId=%s, partnerId=%s, productId=%s, "
|
||||
return ("GameSpyLoginRequest[sequenceId=%s, gameName=%s, profileId=%s, namespaceId=%s, partnerId=%s, productId=%s, "
|
||||
+ "sdkRevision=%s, firewall=%s, port=%s, quiet=%s]")
|
||||
.formatted(sequenceId, userId, gameName, profileId, namespaceId, partnerId, productId, sdkRevision, firewall, port, quiet);
|
||||
.formatted(sequenceId, gameName, profileId, namespaceId, partnerId, productId, sdkRevision, firewall, port, quiet);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,8 +24,6 @@ public record GameSpyProfileUpdateRequest(
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
// Exlude session key
|
||||
return "GameSpyProfileUpdateRequest[partnerId=%s, firstName=%s, lastName=%s, aimName=%s, zipCode=%s]"
|
||||
.formatted(partnerId, firstName, lastName, aimName, zipCode);
|
||||
return "GameSpyProfileUpdateRequest[partnerId=%s]".formatted(partnerId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ public record GameSpyStatusRequest(
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
// Exlude session key
|
||||
return "GameSpyStatusRequest[statusString=%s, locationString=%s]".formatted(statusString, locationString);
|
||||
return "GameSpyStatusRequest[]";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import entralinked.LauncherAgent;
|
||||
import entralinked.utility.CertificateGenerator;
|
||||
import io.javalin.Javalin;
|
||||
import io.javalin.http.HttpStatus;
|
||||
import io.javalin.util.ConcurrencyUtil;
|
||||
import io.javalin.util.JavalinException;
|
||||
|
||||
public class HttpServer {
|
||||
@@ -32,7 +33,9 @@ public class HttpServer {
|
||||
private final Javalin javalin;
|
||||
private boolean started;
|
||||
|
||||
public HttpServer(Entralinked entralinked) {
|
||||
public HttpServer(Entralinked entralinked) {
|
||||
ConcurrencyUtil.INSTANCE.setUseLoom(false);
|
||||
|
||||
// Create certificate keystore
|
||||
KeyStore keyStore = null;
|
||||
|
||||
|
||||
@@ -26,8 +26,7 @@ public record DlsRequest(
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ("DlsRequest[userId=%s, gameCode=%s, accessPointInfo=%s, action=%s, dlcGameCode=%s, dlcName=%s, dlcType=%s, "
|
||||
+ "dlcIndex=%s, offset=%s, num=%s]")
|
||||
.formatted(userId, gameCode, accessPointInfo, action, dlcGameCode, dlcName, dlcType, dlcIndex, offset, num);
|
||||
return ("DlsRequest[gameCode=%s, action=%s, dlcGameCode=%s, dlcName=%s, dlcType=%s, dlcIndex=%s, offset=%s, num=%s]")
|
||||
.formatted(gameCode, action, dlcGameCode, dlcName, dlcType, dlcIndex, offset, num);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,12 +91,12 @@ public class NasHandler implements HttpHandler {
|
||||
|
||||
// Should *never* return null in this location
|
||||
user = userManager.authenticateUser(userId, request.password());
|
||||
logger.info("Created account for user {}", user.getFormattedId());
|
||||
logger.info("Created account for user {}", user.getRedactedId());
|
||||
}
|
||||
|
||||
// Prepare GameSpy server credentials
|
||||
ServiceCredentials credentials = userManager.createServiceSession(user, "gamespy", request.branchCode());
|
||||
logger.info("Created GameSpy session for user {}", user.getFormattedId());
|
||||
logger.info("Created GameSpy session for user {}", user.getRedactedId());
|
||||
result(ctx, new NasLoginResponse("gamespy.com", credentials.authToken(), credentials.challenge()));
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ public class NasHandler implements HttpHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
logger.info("Created account for user {}", user.getFormattedId());
|
||||
logger.info("Created account for user {}", user.getRedactedId());
|
||||
result(ctx, NasReturnCode.REGISTRATION_SUCCESS);
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ public class NasHandler implements HttpHandler {
|
||||
// Prepare user credentials
|
||||
ServiceCredentials credentials = userManager.createServiceSession(user, service, null);
|
||||
logger.info("Created {} session for user {}",
|
||||
type.equals("0000") ? "PGL" : type.equals("9000") ? "DLS1" : "this should never be logged", user.getFormattedId());
|
||||
type.equals("0000") ? "PGL" : type.equals("9000") ? "DLS1" : "this should never be logged", user.getRedactedId());
|
||||
result(ctx, new NasServiceLocationResponse(true, service, credentials.authToken()));
|
||||
}
|
||||
|
||||
|
||||
@@ -33,9 +33,7 @@ public record NasRequest(
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ("NasRequest[userId=%s, gameCode=%s, makerCode=%s, unitCode=%s, sdkVersion=%s, language=%s, bssid=%s, "
|
||||
+ "accessPointInfo=%s, deviceTime=%s, action=%s, serviceType=%s]")
|
||||
.formatted(userId, gameCode, makerCode, unitCode, sdkVersion, language, bssid,
|
||||
accessPointInfo, deviceTime, action, serviceType);
|
||||
return ("NasRequest[gameCode=%s, makerCode=%s, unitCode=%s, sdkVersion=%s, language=%s, action=%s, serviceType=%s]")
|
||||
.formatted(gameCode, makerCode, unitCode, sdkVersion, language, action, serviceType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,7 +201,7 @@ public class PglHandler implements HttpHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
logger.info("Player {} is downloading save data as user {}", player.getGameSyncId(), user.getFormattedId());
|
||||
logger.info("Player {} is downloading save data as user {}", player.getGameSyncId(), user.getRedactedId());
|
||||
|
||||
// Write status code
|
||||
writeStatusCode(outputStream, 0);
|
||||
@@ -369,7 +369,7 @@ public class PglHandler implements HttpHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
logger.info("User {} is Memory Linking with player {}", user.getFormattedId(), player.getGameSyncId());
|
||||
logger.info("User {} is Memory Linking with player {}", user.getRedactedId(), player.getGameSyncId());
|
||||
|
||||
// Send the save data!
|
||||
try(FileInputStream inputStream = new FileInputStream(file)) {
|
||||
@@ -450,7 +450,7 @@ public class PglHandler implements HttpHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
logger.info("Player {} is uploading save data as user {}", player.getGameSyncId(), user.getFormattedId());
|
||||
logger.info("Player {} is uploading save data as user {}", player.getGameSyncId(), user.getRedactedId());
|
||||
|
||||
// Try to store save data
|
||||
if(!playerManager.storePlayerGameSaveFile(player, ctx.bodyInputStream())) {
|
||||
|
||||
Reference in New Issue
Block a user