Compare commits

...

40 Commits
b2 ... b6

Author SHA1 Message Date
Cai Xukun e782cccf72 Add files via upload 2023-04-22 21:31:47 +08:00
Cai Xukun eaa0fba587 Add files via upload 2023-04-22 21:29:16 +08:00
Cai Xukun cc248c3459 Add files via upload 2023-04-22 21:15:26 +08:00
Cai Xukun ab24793861 Add files via upload 2023-04-22 21:13:12 +08:00
Cai Xukun 25ebbf6f20 Add files via upload 2023-04-22 20:49:30 +08:00
Cai Xukun d3e463165d Update B6 sha file 2023-04-22 19:20:25 +08:00
Cai Xukun a459e6bad8 Add files via upload 2023-04-22 19:16:00 +08:00
Cai Xukun 6a91130aa8 Merge branch 'Stabrinai:master' into master 2023-04-20 20:38:12 +08:00
Sattera d25949fc3b 更新 2023-04-19 16:13:38 +08:00
HaHaWTH f63f00fade Update maven.yml 2023-04-06 21:43:55 +08:00
HaHaWTH 19c18987f6 Update maven.yml 2023-04-06 21:14:09 +08:00
HaHaWTH db1650c27f Update maven.yml 2023-04-06 20:59:28 +08:00
HaHaWTH f45696f82f Update maven.yml 2023-04-06 20:56:39 +08:00
HaHaWTH 1c1879ea01 Update maven.yml 2023-04-06 20:48:00 +08:00
HaHaWTH 812762db25 Merge branch 'Stabrinai:master' into master 2023-04-06 20:36:22 +08:00
Sattera a4bf7adb60 添加对 floodgate 的支持 2023-04-06 09:42:12 +08:00
Sattera 11c5237950 Merge remote-tracking branch 'origin/master'
# Conflicts:
#	src/main/java/fr/xephi/authme/listener/PlayerListener.java
2023-04-06 09:38:13 +08:00
Sattera bc43afe3d0 添加对 floodgate 的支持 2023-04-06 09:37:57 +08:00
HaHaWTH ced3d17537 Update README.md 2023-04-06 02:19:03 +08:00
HaHaWTH d9b3c59f30 Update maven.yml 2023-04-06 01:58:08 +08:00
HaHaWTH 8c286ceceb Update maven.yml 2023-04-06 01:54:54 +08:00
HaHaWTH 2ce6b066cc Update maven.yml 2023-04-06 01:52:50 +08:00
HaHaWTH 585b69ecd2 Update maven.yml 2023-04-06 01:50:33 +08:00
HaHaWTH 17187b05c1 Update maven.yml 2023-04-06 01:49:05 +08:00
HaHaWTH 6f193f05ce Update maven.yml 2023-04-06 01:47:55 +08:00
HaHaWTH a626265b09 Update maven.yml 2023-04-06 01:42:51 +08:00
HaHaWTH bda8613f93 Update .gitignore 2023-04-06 01:19:09 +08:00
HaHaWTH 44136bb91f Update maven.yml 2023-04-06 01:08:45 +08:00
HaHaWTH 69514738f7 Update maven.yml 2023-04-06 01:01:54 +08:00
HaHaWTH 220b31bb99 Update maven.yml 2023-04-06 00:59:20 +08:00
HaHaWTH 3b58a0acc9 Update maven.yml 2023-04-06 00:57:06 +08:00
HaHaWTH 5efa360cb2 Update README.md 2023-04-06 00:25:56 +08:00
HaHaWTH 2269c93dee Update maven.yml 2023-04-06 00:22:41 +08:00
HaHaWTH bf6233c024 Update maven.yml 2023-04-05 23:32:01 +08:00
HaHaWTH 3cc6f535a8 Update maven.yml 2023-04-05 22:01:32 +08:00
HaHaWTH 95d9edddeb Merge branch 'Stabrinai:master' into master 2023-04-05 21:05:10 +08:00
Sattera 4a559a7ccf Merge remote-tracking branch 'origin/master'
# Conflicts:
#	src/main/java/fr/xephi/authme/listener/PlayerListener.java
2023-04-05 20:25:10 +08:00
Sattera baaabb22d4 添加对 floodgate 的支持 2023-04-05 20:24:55 +08:00
HaHaWTH 9e39f4a186 Create maven-publish.yml 2023-04-05 18:56:36 +08:00
Sattera c2b7a693b2 添加对 floodgate 的支持 2023-04-04 09:08:07 +08:00
14 changed files with 76 additions and 194 deletions
+34
View File
@@ -0,0 +1,34 @@
# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path
name: Maven Package
on:
release:
types: [created]
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file
- name: Build with Maven
run: mvn -B package --file pom.xml
- name: Publish to GitHub Packages Apache Maven
run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml
env:
GITHUB_TOKEN: ${{ github.token }}
+4 -3
View File
@@ -7,11 +7,11 @@ on:
- master
jobs:
build_and_test:
Build:
strategy:
matrix:
jdkversion: [11]
runs-on: ubuntu-latest
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
@@ -19,5 +19,6 @@ jobs:
distribution: 'temurin'
java-version: ${{ matrix.jdkversion }}
cache: 'maven'
- name: Build with Maven
- name: 使用Maven构建
run: mvn -V -B clean package --file pom.xml
+1 -1
View File
@@ -24,7 +24,7 @@ hs_err_pid*
# Include the project's code style settings file
!.idea/codeStyleSettings.xml
/target/class/
# File-based project format:
*.ipr
*.iws
+4 -4
View File
@@ -1,12 +1,12 @@
# AuthMeReloaded
**"The best authentication plugin for the Bukkit modding API!"**
# AuthMeReReloaded
**"A Fork of Authme that contains many bug fixes!"**
**请前往Releases下载最新版本**
<img src="wallpaper.png?raw=true" alt="AuthMeLogo"/>
| Type | Badges |
|-------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **General:** | ![](https://tokei.rs/b1/github/AuthMe/AuthMeReloaded?category=code) ![](https://tokei.rs/b1/github/AuthMe/AuthMeReloaded?category=files) |
| **Code quality:** | [![Code Climate](https://codeclimate.com/github/AuthMe/AuthMeReloaded/badges/gpa.svg)](https://codeclimate.com/github/AuthMe/AuthMeReloaded) [![Coverage status](https://coveralls.io/repos/AuthMe-Team/AuthMeReloaded/badge.svg?branch=master&service=github)](https://coveralls.io/github/AuthMe-Team/AuthMeReloaded?branch=master) |
| **代码质量:** | [![Code Climate](https://codeclimate.com/github/AuthMe/AuthMeReloaded/badges/gpa.svg)](https://codeclimate.com/github/AuthMe/AuthMeReloaded) [![Coverage status](https://coveralls.io/repos/AuthMe-Team/AuthMeReloaded/badge.svg?branch=master&service=github)](https://coveralls.io/github/AuthMe-Team/AuthMeReloaded?branch=master) |
| **Jenkins CI:** | [![Jenkins Status](https://img.shields.io/website-up-down-green-red/http/shields.io.svg?label=ci.codemc.org)](https://ci.codemc.org/) [![Build Status](https://ci.codemc.org/buildStatus/icon?job=AuthMe/AuthMeReloaded)](https://ci.codemc.org/job/AuthMe/job/AuthMeReloaded) ![Build Tests](https://img.shields.io/jenkins/t/https/ci.codemc.org/job/AuthMe/job/AuthMeReloaded.svg) |
| **Other CIs:** | [![Build Status](https://www.travis-ci.com/AuthMe/AuthMeReloaded.svg?branch=master)](https://www.travis-ci.com/AuthMe/AuthMeReloaded) |
View File
+1
View File
@@ -0,0 +1 @@
423084f2a50c27f62d1b5c85a95e78b9bc3df49d5bd9cefd6fe1aa9227b856c1
+16 -1
View File
@@ -598,11 +598,26 @@
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>opencollab-snapshot</id>
<url>https://repo.opencollab.dev/maven-snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<dependencies>
<!-- Java Libraries -->
<dependency>
<groupId>org.geysermc.floodgate</groupId>
<artifactId>api</artifactId>
<version>2.2.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!-- Jalu Injector -->
<dependency>
<groupId>ch.jalu</groupId>
@@ -93,7 +93,6 @@ public class PlayerListener implements Listener {
private PermissionsManager permissionsManager;
@Inject
private QuickCommandsProtectionManager quickCommandsProtectionManager;
// Lowest priority to apply fast protection checks
@EventHandler(priority = EventPriority.LOWEST)
public void onAsyncPlayerPreLoginEventLowest(AsyncPlayerPreLoginEvent event) {
@@ -113,6 +112,9 @@ public class PlayerListener implements Listener {
return;
}
if (settings.getProperty(RestrictionSettings.HOOK_FLOODGATE_PLAYER) && org.geysermc.floodgate.api.FloodgateApi.getInstance().isFloodgateId(event.getUniqueId())){
return;
}
// Non-blocking checks
try {
onJoinVerifier.checkIsValidName(name);
@@ -120,6 +122,7 @@ public class PlayerListener implements Listener {
event.setKickMessage(messages.retrieveSingle(name, e.getReason(), e.getArgs()));
event.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_OTHER);
}
}
/*
@@ -47,37 +47,21 @@ public class GeoIpService {
private static final String DATABASE_NAME = "GeoLite2-Country";
private static final String DATABASE_FILE = DATABASE_NAME + ".mmdb";
private static final String DATABASE_TMP_FILE = DATABASE_NAME + ".mmdb.tmp";
private static final String ARCHIVE_FILE = DATABASE_NAME + ".mmdb.gz";
private static final String ARCHIVE_URL =
"https://updates.maxmind.com/geoip/databases/" + DATABASE_NAME + "/update";
private static final int UPDATE_INTERVAL_DAYS = 30;
private final ConsoleLogger logger = ConsoleLoggerFactory.get(GeoIpService.class);
private final Path dataFile;
private final BukkitService bukkitService;
private final Settings settings;
private GeoIp2Provider databaseReader;
private volatile boolean downloading;
@Inject
GeoIpService(@DataFolder File dataFolder, BukkitService bukkitService, Settings settings) {
this.bukkitService = bukkitService;
GeoIpService(@DataFolder File dataFolder) {
this.dataFile = dataFolder.toPath().resolve(DATABASE_FILE);
this.settings = settings;
// Fires download of recent data or the initialization of the look up service
isDataAvailable();
}
@VisibleForTesting
GeoIpService(@DataFolder File dataFolder, BukkitService bukkitService, Settings settings, GeoIp2Provider reader) {
this.bukkitService = bukkitService;
this.settings = settings;
GeoIpService(@DataFolder File dataFolder, GeoIp2Provider reader) {
this.dataFile = dataFolder.toPath().resolve(DATABASE_FILE);
this.databaseReader = reader;
@@ -101,73 +85,19 @@ public class GeoIpService {
if (Files.exists(dataFile)) {
try {
FileTime lastModifiedTime = Files.getLastModifiedTime(dataFile);
if (Duration.between(lastModifiedTime.toInstant(), Instant.now()).toDays() <= UPDATE_INTERVAL_DAYS) {
startReading();
// don't fire the update task - we are up to date
return true;
} else {
logger.debug("GEO IP database is older than " + UPDATE_INTERVAL_DAYS + " Days");
}
} catch (IOException ioEx) {
logger.logException("Failed to load GeoLiteAPI database", ioEx);
return false;
}
}
//set the downloading flag in order to fix race conditions outside
downloading = true;
// File is outdated or doesn't exist - let's try to download the data file!
// use bukkit's cached threads
bukkitService.runTaskAsynchronously(this::updateDatabase);
return false;
}
/**
* Tries to update the database by downloading a new version from the website.
*/
private void updateDatabase() {
logger.info("Downloading GEO IP database, because the old database is older than "
+ UPDATE_INTERVAL_DAYS + " days or doesn't exist");
Path downloadFile = null;
Path tempFile = null;
try {
// download database to temporarily location
downloadFile = Files.createTempFile(ARCHIVE_FILE, null);
tempFile = Files.createTempFile(DATABASE_TMP_FILE, null);
String expectedChecksum = downloadDatabaseArchive(downloadFile);
if (expectedChecksum == null) {
logger.info("There is no newer GEO IP database uploaded to MaxMind. Using the old one for now.");
startReading();
return;
}
// tar extract database and copy to target destination
extractDatabase(downloadFile, tempFile);
// MD5 checksum verification
verifyChecksum(Hashing.md5(), tempFile, expectedChecksum);
Files.copy(tempFile, dataFile, StandardCopyOption.REPLACE_EXISTING);
//only set this value to false on success otherwise errors could lead to endless download triggers
logger.info("Successfully downloaded new GEO IP database to " + dataFile);
startReading();
} catch (IOException ioEx) {
logger.logException("Could not download GeoLiteAPI database", ioEx);
} finally {
// clean up
if (downloadFile != null) {
FileUtils.delete(downloadFile.toFile());
}
if (tempFile != null) {
FileUtils.delete(tempFile.toFile());
}
}
}
private void startReading() throws IOException {
databaseReader = new Reader(dataFile.toFile(), FileMode.MEMORY, new CHMCache());
@@ -177,101 +107,6 @@ public class GeoIpService {
downloading = false;
}
/**
* Downloads the archive to the destination file if it's newer than the locally version.
*
* @param lastModified modification timestamp of the already present file
* @param destination save file
* @return null if no updates were found, the MD5 hash of the downloaded archive if successful
* @throws IOException if failed during downloading and writing to destination file
*/
private String downloadDatabaseArchive(Instant lastModified, Path destination) throws IOException {
String clientId = settings.getProperty(ProtectionSettings.MAXMIND_API_CLIENT_ID);
String licenseKey = settings.getProperty(ProtectionSettings.MAXMIND_API_LICENSE_KEY);
if (clientId.isEmpty() || licenseKey.isEmpty()) {
logger.warning("No MaxMind credentials found in the configuration file!"
+ " GeoIp protections will be disabled.");
return null;
}
HttpURLConnection connection = (HttpURLConnection) new URL(ARCHIVE_URL).openConnection();
String basicAuth = "Basic " + new String(Base64.getEncoder().encode((clientId + ":" + licenseKey).getBytes()));
connection.setRequestProperty("Authorization", basicAuth);
if (lastModified != null) {
// Only download if we actually need a newer version - this field is specified in GMT zone
ZonedDateTime zonedTime = lastModified.atZone(ZoneId.of("GMT"));
String timeFormat = DateTimeFormatter.RFC_1123_DATE_TIME.format(zonedTime);
connection.addRequestProperty("If-Modified-Since", timeFormat);
}
if (connection.getResponseCode() == HttpURLConnection.HTTP_NOT_MODIFIED) {
//we already have the newest version
connection.getInputStream().close();
return null;
}
String hash = connection.getHeaderField("X-Database-MD5");
String rawModifiedDate = connection.getHeaderField("Last-Modified");
Instant modifiedDate = Instant.from(DateTimeFormatter.RFC_1123_DATE_TIME.parse(rawModifiedDate));
Files.copy(connection.getInputStream(), destination, StandardCopyOption.REPLACE_EXISTING);
Files.setLastModifiedTime(destination, FileTime.from(modifiedDate));
return hash;
}
/**
* Downloads the archive to the destination file if it's newer than the locally version.
*
* @param destination save file
* @return null if no updates were found, the MD5 hash of the downloaded archive if successful
* @throws IOException if failed during downloading and writing to destination file
*/
private String downloadDatabaseArchive(Path destination) throws IOException {
Instant lastModified = null;
if (Files.exists(dataFile)) {
lastModified = Files.getLastModifiedTime(dataFile).toInstant();
}
return downloadDatabaseArchive(lastModified, destination);
}
/**
* Verify if the expected checksum is equal to the checksum of the given file.
*
* @param function the checksum function like MD5, SHA256 used to generate the checksum from the file
* @param file the file we want to calculate the checksum from
* @param expectedChecksum the expected checksum
* @throws IOException on I/O error reading the file or the checksum verification failed
*/
private void verifyChecksum(HashFunction function, Path file, String expectedChecksum) throws IOException {
HashCode actualHash = function.hashBytes(Files.readAllBytes(file));
HashCode expectedHash = HashCode.fromString(expectedChecksum);
if (!Objects.equals(actualHash, expectedHash)) {
throw new IOException("GEO IP Checksum verification failed. "
+ "Expected: " + expectedChecksum + "Actual:" + actualHash);
}
}
/**
* Extract the database from gzipped data. Existing outputFile will be replaced if it already exists.
*
* @param inputFile gzipped database input file
* @param outputFile destination file for the database
* @throws IOException on I/O error reading the archive, or writing the output
*/
private void extractDatabase(Path inputFile, Path outputFile) throws IOException {
// .gz -> gzipped file
try (BufferedInputStream in = new BufferedInputStream(Files.newInputStream(inputFile));
GZIPInputStream gzipIn = new GZIPInputStream(in)) {
// found the database file and copy file
Files.copy(gzipIn, outputFile, StandardCopyOption.REPLACE_EXISTING);
// update the last modification date to be same as in the archive
Files.setLastModifiedTime(outputFile, Files.getLastModifiedTime(inputFile));
}
}
/**
* Get the country code of the given IP address.
*
@@ -65,7 +65,7 @@ public final class EmailSettings implements SettingsHolder {
newProperty("Email.emailOauth2Token", "");
@Comment("Email notifications when the server shuts down")
public static final Property<Boolean> SHUTDOWN_MAIL =
newProperty("Email.shutDownEmail", true);
newProperty("Email.shutDownEmail", false);
@Comment("Email notification address when the server is shut down")
public static final Property<String> SHUTDOWN_MAIL_ADDRESS =
newProperty("Email.shutDownEmailAddress", "your@mail.com");
@@ -20,17 +20,6 @@ public final class ProtectionSettings implements SettingsHolder {
public static final Property<Boolean> ENABLE_PROTECTION_REGISTERED =
newProperty("Protection.enableProtectionRegistered", true);
@Comment({"The MaxMind clientId used to download the GeoIp database,",
"get one at https://www.maxmind.com/en/accounts/current/license-key",
"The EssentialsX project has a very useful tutorial on how to generate",
"the license key: https://github.com/EssentialsX/Wiki/blob/master/GeoIP.md"})
public static final Property<String> MAXMIND_API_CLIENT_ID =
newProperty("Protection.geoIpDatabase.clientId", "");
@Comment("The MaxMind licenseKey used to download the GeoIp database.")
public static final Property<String> MAXMIND_API_LICENSE_KEY =
newProperty("Protection.geoIpDatabase.licenseKey", "");
@Comment({
"Countries allowed to join the server and register. For country codes, see",
"https://dev.maxmind.com/geoip/legacy/codes/iso3166/",
@@ -125,6 +125,9 @@ public final class RestrictionSettings implements SettingsHolder {
public static final Property<String> ALLOWED_NICKNAME_CHARACTERS =
newProperty("settings.restrictions.allowedNicknameCharacters", "[a-zA-Z0-9_]*");
@Comment("Allow FloodGatePlayer Join Without checkIsValidName()")
public static final Property<Boolean> HOOK_FLOODGATE_PLAYER =
newProperty("settings.restrictions.hookFloodGatePlayer", false);
@Comment({
"How far can unregistered players walk?",
"Set to 0 for unlimited radius"
Binary file not shown.
+1
View File
@@ -15,6 +15,7 @@ softdepend:
- Essentials
- EssentialsSpawn
- ProtocolLib
- floodgate
commands:
authme:
description: AuthMe op commands