Custom endpoints

- minor change to customise textures & session server host for custom yggdrasil server
This commit is contained in:
Gilles Lazures 2025-12-08 21:02:48 +01:00
parent d6293cc73d
commit 41690f84c7
3 changed files with 8 additions and 4 deletions

View File

@ -60,6 +60,10 @@ var config = {
sidebar: process.env.SPONSOR_SIDE, sidebar: process.env.SPONSOR_SIDE,
top_right: process.env.SPONSOR_TOP_RIGHT top_right: process.env.SPONSOR_TOP_RIGHT
}, },
endpoints: {
textures_url: "https://textures.minecraft.net/texture/",
session_url: "https://sessionserver.mojang.com/session/minecraft/profile/"
}
}; };
module.exports = config; module.exports = config;

View File

@ -5,8 +5,8 @@ var skins = require("./skins");
var http = require("http"); var http = require("http");
require("./object-patch"); require("./object-patch");
var session_url = "https://sessionserver.mojang.com/session/minecraft/profile/"; var session_url = config.endpoints.session_url;
var textures_url = "https://textures.minecraft.net/texture/"; var textures_url = config.endpoints.textures_url;
// count requests made to session_url in the last 1000ms // count requests made to session_url in the last 1000ms
var session_requests = []; var session_requests = [];

View File

@ -158,7 +158,7 @@ describe("Crafatar", function() {
it("should time out on skin download", function(done) { it("should time out on skin download", function(done) {
var original_timeout = config.http_timeout; var original_timeout = config.http_timeout;
config.server.http_timeout = 1; config.server.http_timeout = 1;
networking.get_from(rid(), "http://textures.minecraft.net/texture/477be35554684c28bdeee4cf11c591d3c88afb77e0b98da893fd7bc318c65184", function(body, res, error) { networking.get_from(rid(), config.endpoints.textures_url + "477be35554684c28bdeee4cf11c591d3c88afb77e0b98da893fd7bc318c65184", function(body, res, error) {
assert.notStrictEqual(["ETIMEDOUT", "ESOCKETTIMEDOUT"].indexOf(error.code), -1); assert.notStrictEqual(["ETIMEDOUT", "ESOCKETTIMEDOUT"].indexOf(error.code), -1);
config.server.http_timeout = original_timeout; config.server.http_timeout = original_timeout;
done(); done();
@ -166,7 +166,7 @@ describe("Crafatar", function() {
}); });
it("should not find the skin", function(done) { it("should not find the skin", function(done) {
assert.doesNotThrow(function() { assert.doesNotThrow(function() {
networking.get_from(rid(), "http://textures.minecraft.net/texture/this-does-not-exist", function(img, response, err) { networking.get_from(rid(), config.endpoints.textures_url + "this-does-not-exist", function(img, response, err) {
assert.strictEqual(err, null); // no error here, but it shouldn't throw exceptions assert.strictEqual(err, null); // no error here, but it shouldn't throw exceptions
done(); done();
}); });