-
Notifications
You must be signed in to change notification settings - Fork 822
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into 1.20.1/stable
- Loading branch information
Showing
22 changed files
with
699 additions
and
118 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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Used when a commit is tagged and pushed to the repository | ||
# This makes use of caching for faster builds and uploads the resulting artifacts | ||
name: build-tag | ||
|
||
on: | ||
push: | ||
tags: | ||
- '*' | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Extract current branch name | ||
shell: bash | ||
# bash pattern expansion to grab branch name without slashes | ||
run: ref="${GITHUB_REF#refs/heads/}" && echo "branch=${ref////-}" >> $GITHUB_OUTPUT | ||
id: ref | ||
- name: Checkout sources | ||
uses: actions/checkout@v3 | ||
- name: Set up JDK | ||
uses: actions/setup-java@v2 | ||
with: | ||
distribution: 'temurin' | ||
java-version: 17 | ||
- name: Initialize caches | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.gradle/caches | ||
~/.gradle/loom-cache | ||
~/.gradle/wrapper | ||
key: ${{ runner.os }}-build-tag-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }} | ||
restore-keys: | | ||
${{ runner.os }}-build-tag- | ||
- name: Build artifacts | ||
run: ./gradlew build -Pbuild.release=true | ||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: sodium-artifacts-${{ steps.ref.outputs.branch }} | ||
path: build/libs/*.jar |
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
3 changes: 2 additions & 1 deletion
3
src/desktop/java/net/caffeinemc/mods/sodium/desktop/utils/browse/GNOMEImpl.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
3 changes: 2 additions & 1 deletion
3
src/desktop/java/net/caffeinemc/mods/sodium/desktop/utils/browse/KDEImpl.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
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
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
3 changes: 2 additions & 1 deletion
3
...ysquid/mods/sodium/mixin/MixinConfig.java → ...odium/client/data/config/MixinConfig.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
68 changes: 68 additions & 0 deletions
68
src/main/java/me/jellysquid/mods/sodium/client/data/fingerprint/FingerprintMeasure.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,68 @@ | ||
package me.jellysquid.mods.sodium.client.data.fingerprint; | ||
|
||
import net.fabricmc.loader.api.FabricLoader; | ||
import net.minecraft.client.MinecraftClient; | ||
import org.apache.commons.codec.binary.Hex; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.nio.charset.StandardCharsets; | ||
import java.security.MessageDigest; | ||
import java.security.SecureRandom; | ||
import java.time.Instant; | ||
import java.util.Objects; | ||
|
||
public record FingerprintMeasure(@NotNull String uuid, @NotNull String path) { | ||
private static final int SALT_LENGTH = 64; | ||
|
||
public static @Nullable FingerprintMeasure create() { | ||
var uuid = MinecraftClient.getInstance().getSession().getUuidOrNull(); | ||
var path = FabricLoader.getInstance().getGameDir(); | ||
|
||
if (uuid == null || path == null) { | ||
return null; | ||
} | ||
|
||
return new FingerprintMeasure(uuid.toString(), path.toAbsolutePath().toString()); | ||
} | ||
|
||
public HashedFingerprint hashed() { | ||
var date = Instant.now(); | ||
var salt = createSalt(); | ||
|
||
var uuidHashHex = sha512(salt, this.uuid()); | ||
var pathHashHex = sha512(salt, this.path()); | ||
|
||
return new HashedFingerprint(HashedFingerprint.CURRENT_VERSION, salt, uuidHashHex, pathHashHex, date.getEpochSecond()); | ||
} | ||
|
||
public boolean looselyMatches(HashedFingerprint hashed) { | ||
var uuidHashHex = sha512(hashed.saltHex(), this.uuid()); | ||
var pathHashHex = sha512(hashed.saltHex(), this.path()); | ||
|
||
return Objects.equals(uuidHashHex, hashed.uuidHashHex()) || Objects.equals(pathHashHex, hashed.pathHashHex()); | ||
} | ||
|
||
private static String sha512(@NotNull String salt, @NotNull String message) { | ||
MessageDigest md; | ||
|
||
try { | ||
md = MessageDigest.getInstance("SHA-512"); | ||
md.update(Hex.decodeHex(salt)); | ||
md.update(message.getBytes(StandardCharsets.UTF_8)); | ||
} catch (Throwable t) { | ||
throw new RuntimeException("Failed to hash value", t); | ||
} | ||
|
||
return Hex.encodeHexString(md.digest()); | ||
} | ||
|
||
private static String createSalt() { | ||
var rng = new SecureRandom(); | ||
|
||
var salt = new byte[SALT_LENGTH]; | ||
rng.nextBytes(salt); | ||
|
||
return Hex.encodeHexString(salt); | ||
} | ||
} |
Oops, something went wrong.