Skip to content

Commit

Permalink
Disable PIN/PIC and remove most references
Browse files Browse the repository at this point in the history
  • Loading branch information
MarloDelatorre committed Aug 6, 2024
1 parent a64aad0 commit c59d44b
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 122 deletions.
6 changes: 0 additions & 6 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,6 @@ server:
COUPON_INTERVAL: 3600000 #60 minutes, 3600000.
UPDATE_INTERVAL: 777 #Dictates the frequency on which the "centralized server time" is updated.

ENABLE_PIC: true #Pick true/false to enable or disable Pic. Delete character requires PIC available.
ENABLE_PIN: true #Pick true/false to enable or disable Pin.

BYPASS_PIC_EXPIRATION: 20 #Enables PIC bypass, which will remain active for that account by that client machine for N minutes. Set 0 to disable.
BYPASS_PIN_EXPIRATION: 15 #Enables PIN bypass, which will remain active for that account by that client machine for N minutes. Set 0 to disable.

AUTOMATIC_REGISTER: true #Automatically register players when they login with a nonexistent username.
BCRYPT_MIGRATION: true #Performs a migration from old SHA-1 and SHA-512 password to bcrypt.
COLLECTIVE_CHARSLOT: false #Available character slots are contabilized globally rather than per world server.
Expand Down
38 changes: 2 additions & 36 deletions src/main/java/client/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -589,20 +589,7 @@ public String getPin() {
}

public boolean checkPin(String other) {
if (!(YamlConfig.config.server.ENABLE_PIN && !canBypassPin())) {
return true;
}

pinattempt++;
if (pinattempt > 5) {
SessionCoordinator.getInstance().closeSession(this, false);
}
if (pin.equals(other)) {
pinattempt = 0;
LoginBypassCoordinator.getInstance().registerLoginBypassEntry(hwid, accId, false);
return true;
}
return false;
return true;
}

public void setPic(String pic) {
Expand All @@ -622,20 +609,7 @@ public String getPic() {
}

public boolean checkPic(String other) {
if (!(YamlConfig.config.server.ENABLE_PIC && !canBypassPic())) {
return true;
}

picattempt++;
if (picattempt > 5) {
SessionCoordinator.getInstance().closeSession(this, false);
}
if (pic.equals(other)) { // thanks ryantpayton (HeavenClient) for noticing null pics being checked here
picattempt = 0;
LoginBypassCoordinator.getInstance().registerLoginBypassEntry(hwid, accId, true);
return true;
}
return false;
return true;
}

public int login(String login, String pwd, Hwid hwid) {
Expand Down Expand Up @@ -1583,14 +1557,6 @@ public void enableCSActions() {
sendPacket(PacketCreator.enableCSUse(player));
}

public boolean canBypassPin() {
return LoginBypassCoordinator.getInstance().canLoginBypass(hwid, accId, false);
}

public boolean canBypassPic() {
return LoginBypassCoordinator.getInstance().canLoginBypass(hwid, accId, true);
}

public int getLanguage() {
return lang;
}
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/client/command/CommandsExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import client.command.commands.gm0.ChangeLanguageCommand;
import client.command.commands.gm0.DisposeCommand;
import client.command.commands.gm0.DropLimitCommand;
import client.command.commands.gm0.EnableAuthCommand;
import client.command.commands.gm0.EquipLvCommand;
import client.command.commands.gm0.GachaCommand;
import client.command.commands.gm0.GmCommand;
Expand Down Expand Up @@ -362,7 +361,6 @@ private void registerLv0Commands() {
addCommand("dex", StatDexCommand.class);
addCommand("int", StatIntCommand.class);
addCommand("luk", StatLukCommand.class);
addCommand("enableauth", EnableAuthCommand.class);
addCommand("toggleexp", ToggleExpCommand.class);
addCommand("mylawn", MapOwnerClaimCommand.class);
addCommand("bosshp", BossHpCommand.class);
Expand Down
45 changes: 0 additions & 45 deletions src/main/java/client/command/commands/gm0/EnableAuthCommand.java

This file was deleted.

6 changes: 0 additions & 6 deletions src/main/java/config/ServerConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@ public class ServerConfig {
public long COUPON_INTERVAL;
public long UPDATE_INTERVAL;

public boolean ENABLE_PIC;
public boolean ENABLE_PIN;

public int BYPASS_PIC_EXPIRATION;
public int BYPASS_PIN_EXPIRATION;

public boolean AUTOMATIC_REGISTER;
public boolean BCRYPT_MIGRATION;
public boolean COLLECTIVE_CHARSLOT;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,27 +59,6 @@ public boolean canLoginBypass(Hwid hwid, int accId, boolean pic) {
}
}

public void registerLoginBypassEntry(Hwid hwid, int accId, boolean pic) {
long expireTime = (pic ? YamlConfig.config.server.BYPASS_PIC_EXPIRATION : YamlConfig.config.server.BYPASS_PIN_EXPIRATION);
if (expireTime > 0) {
Pair<Hwid, Integer> entry = new Pair<>(hwid, accId);
expireTime = Server.getInstance().getCurrentTime() + MINUTES.toMillis(expireTime);
try {
pic |= loginBypass.get(entry).getLeft();
expireTime = Math.max(loginBypass.get(entry).getRight(), expireTime);
} catch (NullPointerException npe) {
}

loginBypass.put(entry, new Pair<>(pic, expireTime));
}
}

public void unregisterLoginBypassEntry(Hwid hwid, int accId) {
String hwidValue = hwid == null ? null : hwid.hwid();
Pair<String, Integer> entry = new Pair<>(hwidValue, accId);
loginBypass.remove(entry);
}

public void runUpdateLoginBypass() {
if (!loginBypass.isEmpty()) {
List<Pair<Hwid, Integer>> toRemove = new LinkedList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,8 @@ public final void handlePacket(InPacket p, Client c) {
int totalChrs = countTotalChrs(worldChrs);
c.sendPacket(PacketCreator.showAllCharacter(totalWorlds, totalChrs));

final boolean usePic = YamlConfig.config.server.ENABLE_PIC && !c.canBypassPic();
worldChrs.forEach((worldId, chrs) ->
c.sendPacket(PacketCreator.showAllCharacterInfo(worldId, chrs, usePic))
c.sendPacket(PacketCreator.showAllCharacterInfo(worldId, chrs, false))
);
} catch (Exception e) {
e.printStackTrace();
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/tools/PacketCreator.java
Original file line number Diff line number Diff line change
Expand Up @@ -730,9 +730,8 @@ public static Packet getAuthSuccess(Client c) {

p.writeInt(1); // 1: Remove the "Select the world you want to play in"

p.writeByte(YamlConfig.config.server.ENABLE_PIN && !c.canBypassPin() ? 0 : 1); // 0 = Pin-System Enabled, 1 = Disabled
p.writeByte(YamlConfig.config.server.ENABLE_PIC && !c.canBypassPic() ? (c.getPic() == null || c.getPic().equals("") ? 0 : 1) : 2); // 0 = Register PIC, 1 = Ask for PIC, 2 = Disabled

p.writeByte(1); // Disable PIN
p.writeByte(2); // Disable PIC
return p;
}

Expand Down Expand Up @@ -908,7 +907,7 @@ public static Packet getCharList(Client c, int serverId, int status) {
addCharEntry(p, chr, false);
}

p.writeByte(YamlConfig.config.server.ENABLE_PIC && !c.canBypassPic() ? (c.getPic() == null || c.getPic().equals("") ? 0 : 1) : 2);
p.writeByte(2);
p.writeInt(YamlConfig.config.server.COLLECTIVE_CHARSLOT ? chars.size() + c.getAvailableCharacterSlots() : c.getCharacterSlots());
return p;
}
Expand Down

0 comments on commit c59d44b

Please sign in to comment.