[FIX] public.key больше не требуется для ServerWrapper

This commit is contained in:
Gravit 2019-10-28 01:24:09 +07:00
parent 085924c831
commit c0b476a494
No known key found for this signature in database
GPG key ID: 061981E1E85D3216
3 changed files with 6 additions and 12 deletions

View file

@ -87,7 +87,7 @@ public LauncherConfig(HInput input) throws IOException, InvalidKeySpecException
@LauncherAPI @LauncherAPI
public LauncherConfig(String address, ECPublicKey publicKey, Map<String, byte[]> runtime, String projectName) { public LauncherConfig(String address, ECPublicKey publicKey, Map<String, byte[]> runtime, String projectName) {
this.address = address; this.address = address;
this.publicKey = Objects.requireNonNull(publicKey, "publicKey"); this.publicKey = publicKey;
this.runtime = Collections.unmodifiableMap(new HashMap<>(runtime)); this.runtime = Collections.unmodifiableMap(new HashMap<>(runtime));
this.projectName = projectName; this.projectName = projectName;
this.clientPort = 32148; this.clientPort = 32148;

View file

@ -27,6 +27,7 @@
import java.net.URL; import java.net.URL;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.security.interfaces.ECPublicKey;
import java.security.spec.InvalidKeySpecException; import java.security.spec.InvalidKeySpecException;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
@ -190,7 +191,10 @@ public void updateLauncherConfig() {
LauncherConfig cfg = null; LauncherConfig cfg = null;
try { try {
cfg = new LauncherConfig(config.address, SecurityHelper.toPublicECKey(IOHelper.read(publicKeyFile)), new HashMap<>(), config.projectname); ECPublicKey publicKey = null;
if(IOHelper.isFile(publicKeyFile))
publicKey = SecurityHelper.toPublicECKey(IOHelper.read(publicKeyFile));
cfg = new LauncherConfig(config.address, publicKey, new HashMap<>(), config.projectname);
cfg.isNettyEnabled = true; cfg.isNettyEnabled = true;
cfg.address = config.address; cfg.address = config.address;
} catch (InvalidKeySpecException | IOException e) { } catch (InvalidKeySpecException | IOException e) {

View file

@ -46,16 +46,6 @@ public void run() throws IOException {
String address = commands.commandHandler.readLine(); String address = commands.commandHandler.readLine();
wrapper.config.mainclass = mainClassName; wrapper.config.mainclass = mainClassName;
wrapper.config.address = address; wrapper.config.address = address;
if (!Files.exists(ServerWrapper.publicKeyFile)) {
LogHelper.error("public.key not found");
for (int i = 0; i < 10; ++i) {
System.out.println("Print F to continue:");
String printF = commands.commandHandler.readLine();
if (printF.equals("stop")) return;
if (Files.exists(ServerWrapper.publicKeyFile)) break;
else LogHelper.error("public.key not found");
}
}
boolean stopOnError = wrapper.config.stopOnError; boolean stopOnError = wrapper.config.stopOnError;
for (int i = 0; i < 10; ++i) { for (int i = 0; i < 10; ++i) {
System.out.println("Print server account login:"); System.out.println("Print server account login:");