Fixes, changed to port 443, more fixes

Aaand I forgot to pull the master branch
This commit is contained in:
Norbi Peti 2017-11-23 23:25:56 +01:00
parent aaa1b8e3ba
commit f67d886000
7 changed files with 29 additions and 27 deletions

2
.gitignore vendored
View file

@ -218,3 +218,5 @@ TheButtonAutoFlair/out/artifacts/Autoflair/Autoflair.jar
*.name
.idea/compiler.xml
*.xml
upload_key

View file

@ -1,4 +1,5 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=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

View file

@ -115,7 +115,7 @@
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-io -->
<dependency>
<groupId>org.apache.commons</groupId>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
<scope>provided</scope>

View file

@ -244,28 +244,24 @@ public class AcmeClient {
* Domain name to be authorized
* @return {@link Challenge} to verify
*/
@SuppressWarnings("unused")
public Challenge httpChallenge(Authorization auth, String domain) throws AcmeException {
// Find a single http-01 challenge
Http01Challenge challenge = auth.findChallenge(Http01Challenge.TYPE);
if (challenge == null) {
throw new AcmeException("Found no " + Http01Challenge.TYPE + " challenge, don't know what to do...");
}
if (ButtonWebsiteModule.PORT == 80)
LOG.info("Storing the challenge data.");
else
LOG.info("Store the challenge data! Can't do automatically.");
// if (ButtonWebsiteModule.PORT == 443)
LOG.info("Storing the challenge data.");
/*
* 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("File name: " + challenge.getToken());
LOG.info("Content: " + challenge.getAuthorization());
LOG.info("Press any key to continue...");
if (ButtonWebsiteModule.PORT != 80)
try {
System.in.read();
} catch (IOException e) {
e.printStackTrace();
}
ButtonWebsiteModule.addPage(new AcmeChallengePage(challenge.getToken(), challenge.getAuthorization()));
// LOG.info("File name: " + challenge.getToken());
// LOG.info("Content: " + challenge.getAuthorization());
/*
* LOG.info("Press any key to continue..."); if (ButtonWebsiteModule.PORT != 443) try { System.in.read(); } catch (IOException e) { e.printStackTrace(); }
*/
AcmeChallengePage.setValues(challenge.getToken(), challenge.getAuthorization());
return challenge;
}

View file

@ -31,7 +31,7 @@ import buttondevteam.lib.TBMCCoreAPI;
import buttondevteam.website.page.*;
public class ButtonWebsiteModule extends JavaPlugin {
public static final int PORT = 8080;
public static final int PORT = 443;
private static HttpsServer server;
public ButtonWebsiteModule() {
@ -111,19 +111,22 @@ public class ButtonWebsiteModule extends JavaPlugin {
@Override
public void onEnable() {
addPage(new IndexPage());
addPage(new LoginPage());
addPage(new ProfilePage());
TBMCCoreAPI.RegisterUserClass(WebUser.class);
Bukkit.getScheduler().runTaskAsynchronously(this, () -> {
this.getLogger().info("Starting webserver...");
server.setExecutor(
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();
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"));
t.setContextClassLoader(getClass().getClassLoader());
t.start();
}
((Runnable) server::start).run(); // Totally normal way of calling a method
this.getLogger().info("Webserver started");
});
}

View file

@ -17,6 +17,6 @@ public class WebUser extends ChromaGamerBase {
}
public PlayerData<UUID> sessionID() {
return data();
return data(new UUID(0, 0));
}
}

View file

@ -6,11 +6,6 @@ import buttondevteam.website.io.Response;
public class AcmeChallengePage extends Page {
public AcmeChallengePage(String token, String content) {
this.token = token;
this.content = content;
}
@Override
public String GetName() {
return ".well-known/acme-challenge/" + token;
@ -23,7 +18,12 @@ public class AcmeChallengePage extends Page {
return new Response(200, content, exchange);
}
private String token;
private String content;
private static String token;
private static String content;
public static void setValues(String token, String content) {
AcmeChallengePage.token = token;
AcmeChallengePage.content = content;
}
}