-
-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into dependabot/maven/org.bouncycastle-bcprov-jdk…
…18on-1.75
- Loading branch information
Showing
5 changed files
with
122 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,7 @@ jobs: | |
# Environment image - always use the newest OS | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
contents: write | ||
|
||
# Run steps | ||
steps: | ||
|
@@ -33,11 +33,15 @@ jobs: | |
uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'temurin' | ||
java-version: 19 | ||
java-version-file: '.java-version' | ||
cache: 'maven' | ||
|
||
# Build and test (included in package) | ||
- name: Build with Maven and test | ||
# Run non-interactive, package (with compile+test), | ||
# ignore snapshot updates, because they are likely to have breaking changes, enforce checksums | ||
run: mvn test --batch-mode --threads 2.0C --no-snapshot-updates --strict-checksums --file pom.xml | ||
|
||
- name: Update dependency graph | ||
if: ${{ github.event_name == 'push' }} | ||
uses: advanced-security/[email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
17 |
63 changes: 63 additions & 0 deletions
63
bukkit/src/main/java/com/github/games647/fastlogin/bukkit/InetUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* SPDX-License-Identifier: MIT | ||
* | ||
* The MIT License (MIT) | ||
* | ||
* Copyright (c) 2015-2023 games647 and contributors | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
package com.github.games647.fastlogin.bukkit; | ||
|
||
import java.net.InetAddress; | ||
|
||
public final class InetUtils { | ||
|
||
private InetUtils() { | ||
// Utility | ||
} | ||
|
||
/** | ||
* Verifies if the given IP address is from the local network | ||
* | ||
* @param address IP address | ||
* @return true if address is from local network or even from the device itself (loopback) | ||
*/ | ||
public static boolean isLocalAddress(InetAddress address) { | ||
// Loopback addresses like 127.0.* (IPv4) or [::1] (IPv6) | ||
return address.isLoopbackAddress() | ||
// Example: 10.0.0.0, 172.16.0.0, 192.168.0.0, fec0::/10 (deprecated) | ||
// Ref: https://en.wikipedia.org/wiki/IP_address#Private_addresses | ||
|| address.isSiteLocalAddress() | ||
// Example: 169.254.0.0/16, fe80::/10 | ||
// Ref: https://en.wikipedia.org/wiki/IP_address#Address_autoconfiguration | ||
|| address.isLinkLocalAddress() | ||
// non deprecated unique site-local that java doesn't check yet -> fc00::/7 | ||
|| isIPv6UniqueSiteLocal(address); | ||
} | ||
|
||
private static boolean isIPv6UniqueSiteLocal(InetAddress address) { | ||
// ref: https://en.wikipedia.org/wiki/Unique_local_address | ||
|
||
// currently undefined but could be used in the near future fc00::/8 | ||
return (address.getAddress()[0] & 0xFF) == 0xFC | ||
// in use for unique site-local fd00::/8 | ||
|| (address.getAddress()[0] & 0xFF) == 0xFD; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters