Fixes, changed to port 443, more fixes
Aaand I forgot to pull the master branch
This commit is contained in:
parent
aaa1b8e3ba
commit
f67d886000
7 changed files with 29 additions and 27 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -218,3 +218,5 @@ TheButtonAutoFlair/out/artifacts/Autoflair/Autoflair.jar
|
||||||
*.name
|
*.name
|
||||||
.idea/compiler.xml
|
.idea/compiler.xml
|
||||||
*.xml
|
*.xml
|
||||||
|
|
||||||
|
upload_key
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
eclipse.preferences.version=1
|
eclipse.preferences.version=1
|
||||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||||
|
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||||
org.eclipse.jdt.core.compiler.source=1.8
|
org.eclipse.jdt.core.compiler.source=1.8
|
||||||
|
|
2
pom.xml
2
pom.xml
|
@ -115,7 +115,7 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-io -->
|
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-io -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>commons-io</groupId>
|
||||||
<artifactId>commons-io</artifactId>
|
<artifactId>commons-io</artifactId>
|
||||||
<version>1.3.2</version>
|
<version>1.3.2</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
|
|
|
@ -244,28 +244,24 @@ public class AcmeClient {
|
||||||
* Domain name to be authorized
|
* Domain name to be authorized
|
||||||
* @return {@link Challenge} to verify
|
* @return {@link Challenge} to verify
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused")
|
|
||||||
public Challenge httpChallenge(Authorization auth, String domain) throws AcmeException {
|
public Challenge httpChallenge(Authorization auth, String domain) throws AcmeException {
|
||||||
// Find a single http-01 challenge
|
// Find a single http-01 challenge
|
||||||
Http01Challenge challenge = auth.findChallenge(Http01Challenge.TYPE);
|
Http01Challenge challenge = auth.findChallenge(Http01Challenge.TYPE);
|
||||||
if (challenge == null) {
|
if (challenge == null) {
|
||||||
throw new AcmeException("Found no " + Http01Challenge.TYPE + " challenge, don't know what to do...");
|
throw new AcmeException("Found no " + Http01Challenge.TYPE + " challenge, don't know what to do...");
|
||||||
}
|
}
|
||||||
if (ButtonWebsiteModule.PORT == 80)
|
// if (ButtonWebsiteModule.PORT == 443)
|
||||||
LOG.info("Storing the challenge data.");
|
LOG.info("Storing the challenge data.");
|
||||||
else
|
/*
|
||||||
LOG.info("Store the challenge data! Can't do automatically.");
|
* else LOG.info("Store the challenge data! Can't do automatically.");
|
||||||
|
*/
|
||||||
LOG.info("It should be reachable at: http://" + domain + "/.well-known/acme-challenge/" + challenge.getToken());
|
LOG.info("It should be reachable at: http://" + domain + "/.well-known/acme-challenge/" + challenge.getToken());
|
||||||
LOG.info("File name: " + challenge.getToken());
|
// LOG.info("File name: " + challenge.getToken());
|
||||||
LOG.info("Content: " + challenge.getAuthorization());
|
// LOG.info("Content: " + challenge.getAuthorization());
|
||||||
LOG.info("Press any key to continue...");
|
/*
|
||||||
if (ButtonWebsiteModule.PORT != 80)
|
* LOG.info("Press any key to continue..."); if (ButtonWebsiteModule.PORT != 443) try { System.in.read(); } catch (IOException e) { e.printStackTrace(); }
|
||||||
try {
|
*/
|
||||||
System.in.read();
|
AcmeChallengePage.setValues(challenge.getToken(), challenge.getAuthorization());
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
ButtonWebsiteModule.addPage(new AcmeChallengePage(challenge.getToken(), challenge.getAuthorization()));
|
|
||||||
return challenge;
|
return challenge;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ import buttondevteam.lib.TBMCCoreAPI;
|
||||||
import buttondevteam.website.page.*;
|
import buttondevteam.website.page.*;
|
||||||
|
|
||||||
public class ButtonWebsiteModule extends JavaPlugin {
|
public class ButtonWebsiteModule extends JavaPlugin {
|
||||||
public static final int PORT = 8080;
|
public static final int PORT = 443;
|
||||||
private static HttpsServer server;
|
private static HttpsServer server;
|
||||||
|
|
||||||
public ButtonWebsiteModule() {
|
public ButtonWebsiteModule() {
|
||||||
|
@ -111,19 +111,22 @@ public class ButtonWebsiteModule extends JavaPlugin {
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
addPage(new IndexPage());
|
addPage(new IndexPage());
|
||||||
|
addPage(new LoginPage());
|
||||||
|
addPage(new ProfilePage());
|
||||||
TBMCCoreAPI.RegisterUserClass(WebUser.class);
|
TBMCCoreAPI.RegisterUserClass(WebUser.class);
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(this, () -> {
|
Bukkit.getScheduler().runTaskAsynchronously(this, () -> {
|
||||||
this.getLogger().info("Starting webserver...");
|
this.getLogger().info("Starting webserver...");
|
||||||
server.setExecutor(
|
server.setExecutor(
|
||||||
new ThreadPoolExecutor(4, 8, 30, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(100)));
|
new ThreadPoolExecutor(4, 8, 30, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(100)));
|
||||||
((Runnable) server::start).run(); // Totally normal way of calling a method
|
|
||||||
this.getLogger().info("Webserver started");
|
|
||||||
final Calendar calendar = Calendar.getInstance();
|
final Calendar calendar = Calendar.getInstance();
|
||||||
if (calendar.get(Calendar.DAY_OF_WEEK) == Calendar.FRIDAY && !TBMCCoreAPI.IsTestServer()) { // Only update every week
|
if (calendar.get(Calendar.DAY_OF_WEEK) == Calendar.FRIDAY && !TBMCCoreAPI.IsTestServer()) { // Only update every week
|
||||||
|
addPage(new AcmeChallengePage()); // Add before the server gets started
|
||||||
Thread t = new Thread(() -> AcmeClient.main("server.figytuna.com"));
|
Thread t = new Thread(() -> AcmeClient.main("server.figytuna.com"));
|
||||||
t.setContextClassLoader(getClass().getClassLoader());
|
t.setContextClassLoader(getClass().getClassLoader());
|
||||||
t.start();
|
t.start();
|
||||||
}
|
}
|
||||||
|
((Runnable) server::start).run(); // Totally normal way of calling a method
|
||||||
|
this.getLogger().info("Webserver started");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,6 @@ public class WebUser extends ChromaGamerBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlayerData<UUID> sessionID() {
|
public PlayerData<UUID> sessionID() {
|
||||||
return data();
|
return data(new UUID(0, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,11 +6,6 @@ import buttondevteam.website.io.Response;
|
||||||
|
|
||||||
public class AcmeChallengePage extends Page {
|
public class AcmeChallengePage extends Page {
|
||||||
|
|
||||||
public AcmeChallengePage(String token, String content) {
|
|
||||||
this.token = token;
|
|
||||||
this.content = content;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String GetName() {
|
public String GetName() {
|
||||||
return ".well-known/acme-challenge/" + token;
|
return ".well-known/acme-challenge/" + token;
|
||||||
|
@ -23,7 +18,12 @@ public class AcmeChallengePage extends Page {
|
||||||
return new Response(200, content, exchange);
|
return new Response(200, content, exchange);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String token;
|
private static String token;
|
||||||
private String content;
|
private static String content;
|
||||||
|
|
||||||
|
public static void setValues(String token, String content) {
|
||||||
|
AcmeChallengePage.token = token;
|
||||||
|
AcmeChallengePage.content = content;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue