Compare commits

..

2 commits

Author SHA1 Message Date
e70714f257
update readme
unfortunately I'm getting bored of this project so I'll unfortunately leave it for... unfortunately summer break ends soon and as such reduced activity because of school is imminent unfortunately so more than a bit probably unfortunately
2024-08-25 13:45:27 +02:00
677269d4fc
make it secure 2024-08-25 13:31:14 +02:00
2 changed files with 22 additions and 2 deletions

View file

@ -1,6 +1,11 @@
# rwws - RealWeather Web Server # rwws - RealWeather Web Server
This contacts APIs instead of the servers because we scrape some, and we don't want to draw attention RealWeather Web Server is a web server that proxies requests to APIs that are used by [RealWeather](/Minecon724/RealWeather)
Good if you want to share your API key, but don't want to give it away, for example if you pay for it and want to resell \
Also reduces load on the services that are "scraped" (only if many users share the same instance) \
Or if you want to better firewall your server \
Just use it
### Usage ### Usage
See `RUNNING.md`[^1] See `RUNNING.md`[^1]
@ -10,4 +15,4 @@ See `PROTOCOL.md`
--- ---
[^1]: This is the default Quarkus readme that I wish was available online [^1]: This is the default Quarkus readme that I wish was available online because it's so nice

View file

@ -1,20 +1,35 @@
package eu.m724; package eu.m724;
import eu.m724.orm.Token; import eu.m724.orm.Token;
import io.quarkus.runtime.LaunchMode;
import io.quarkus.runtime.StartupEvent; import io.quarkus.runtime.StartupEvent;
import jakarta.enterprise.event.Observes; import jakarta.enterprise.event.Observes;
import jakarta.inject.Inject;
import jakarta.inject.Singleton; import jakarta.inject.Singleton;
import jakarta.transaction.Transactional; import jakarta.transaction.Transactional;
import java.security.SecureRandom;
import java.util.Base64; import java.util.Base64;
@Singleton @Singleton
public class Startup { public class Startup {
@Inject
LaunchMode launchMode;
@Transactional @Transactional
public void loadUsers(@Observes StartupEvent ignoredEvent) { public void loadUsers(@Observes StartupEvent ignoredEvent) {
GlobalAccessLimits.initialize(); GlobalAccessLimits.initialize();
Token.deleteAll(); Token.deleteAll();
byte[] adminKey = new byte[18]; byte[] adminKey = new byte[18];
System.out.printf("Launch mode: %s\n", launchMode.toString());
if (launchMode == LaunchMode.NORMAL) {
System.out.println("Admin token is random");
new SecureRandom().nextBytes(adminKey);
} else {
// I don't know, but let it be
System.out.println("\n IF THIS IS RUNNING IN PRODUCTION, stop this program now and ask for help.\n");
}
Token token = new Token(); Token token = new Token();
token.accessLimits = GlobalAccessLimits.kilo; token.accessLimits = GlobalAccessLimits.kilo;