Add support for gametag in OPS, MEMBERS and VISITORS (#610)
This commit is contained in:
2 files changed
+35
-6
No files matched your search
@@ -172,10 +172,15 @@ in the "LAN Games" part of the "Friends" tab, such as:
|
|||||||
|
|
||||||
## Permissions
|
## Permissions
|
||||||
|
|
||||||
The Bedrock Dedicated Server requires permissions be defined with XUIDs. There are various tools to look these up online, such as [MCProfile](https://mcprofile.io/). A player's XUID is also printed to the log when a player joins.
|
The Bedrock Dedicated Server requires permissions be defined with XUIDs or Xbox GamerTag. Each of `OPS`, `MEMBERS`, and `VISITORS` accepts a comma-separated list of identifiers. For each entry you can use:
|
||||||
|
|
||||||
|
- **XUID** — a 16+ digit number (e.g. `2535453759792258`). You can look these up with tools like [MCProfile](https://mcprofile.io/); the XUID is also printed in the server log when a player joins.
|
||||||
|
- **Xbox gamertag** — if the value is not a long numeric XUID, it is treated as a gamertag and resolved to an XUID at startup via the [MCProfile API](https://mcprofile.io/api/v1/bedrock/gamertag). This allows using names instead of numbers.
|
||||||
|
|
||||||
There are 3 levels of permissions and 3 options to configure each group:
|
There are 3 levels of permissions and 3 options to configure each group:
|
||||||
|
|
||||||
|
You can mix XUIDs and gamertags in the same list. The API base URL used for resolving gamertags can be overridden with `RESOLVE_XUID_API_URL` (default: `https://mcprofile.io/api/v1/bedrock/gamertag`).
|
||||||
|
|
||||||
- `OPS` is used to define operators on the server.
|
- `OPS` is used to define operators on the server.
|
||||||
```shell
|
```shell
|
||||||
-e OPS="1234567890,0987654321"
|
-e OPS="1234567890,0987654321"
|
||||||
|
|||||||
+29
-5
@@ -6,6 +6,7 @@ set -eo pipefail
|
|||||||
: "${PREVIEW:=false}"
|
: "${PREVIEW:=false}"
|
||||||
: "${DOWNLOAD_LINKS_URL:=https://net.web.minecraft-services.net/api/v1.0/download/links}"
|
: "${DOWNLOAD_LINKS_URL:=https://net.web.minecraft-services.net/api/v1.0/download/links}"
|
||||||
: "${DOWNLOAD_SECONDARY_LINKS_URL:=https://net-secondary.web.minecraft-services.net/api/v1.0/download/links}"
|
: "${DOWNLOAD_SECONDARY_LINKS_URL:=https://net-secondary.web.minecraft-services.net/api/v1.0/download/links}"
|
||||||
|
: "${RESOLVE_XUID_API_URL:=https://mcprofile.io/api/v1/bedrock/gamertag}"
|
||||||
: "${USE_BOX64:=true}"
|
: "${USE_BOX64:=true}"
|
||||||
: "${DEBUG_CURL:=false}"
|
: "${DEBUG_CURL:=false}"
|
||||||
: "${FORCE_PACK_COPY:=false}"
|
: "${FORCE_PACK_COPY:=false}"
|
||||||
@@ -28,6 +29,29 @@ function logError() {
|
|||||||
echo "ERROR $msg" >&2
|
echo "ERROR $msg" >&2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function resolveXuid() {
|
||||||
|
local value="${1?}"
|
||||||
|
|
||||||
|
if [[ $value =~ ^[0-9]+$ ]] && ((10#$value >= 10**15)); then
|
||||||
|
echo "$value"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
local encoded=$(jq -sRr @uri <<< "$value")
|
||||||
|
local xuid=$(curl "${debugCurlArgs[@]}" -fsSL -A "itzg/minecraft-bedrock-server" "$RESOLVE_XUID_API_URL/$encoded" 2>/dev/null | jq -r '.xuid // empty')
|
||||||
|
|
||||||
|
echo "${xuid:-$value}"
|
||||||
|
}
|
||||||
|
|
||||||
|
function resolvePermissionXuids() {
|
||||||
|
local list="$1" perm="$2"
|
||||||
|
IFS=',' read -ra a <<< "$list"
|
||||||
|
|
||||||
|
for v in "${a[@]}"; do
|
||||||
|
resolveXuid "$v" | jq -R --arg p "$perm" '{permission:$p,xuid:.}'
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
function replaceVersionInUrl() {
|
function replaceVersionInUrl() {
|
||||||
local original_url="${1?}"
|
local original_url="${1?}"
|
||||||
local new_version="${2?}"
|
local new_version="${2?}"
|
||||||
@@ -324,11 +348,11 @@ fi
|
|||||||
|
|
||||||
if [[ -n "$OPS" || -n "$MEMBERS" || -n "$VISITORS" ]]; then
|
if [[ -n "$OPS" || -n "$MEMBERS" || -n "$VISITORS" ]]; then
|
||||||
echo "Updating permissions"
|
echo "Updating permissions"
|
||||||
jq -n --arg ops "$OPS" --arg members "$MEMBERS" --arg visitors "$VISITORS" '[
|
{
|
||||||
[$ops | split(",") | map({permission: "operator", xuid:.})],
|
resolvePermissionXuids "$OPS" operator
|
||||||
[$members | split(",") | map({permission: "member", xuid:.})],
|
resolvePermissionXuids "$MEMBERS" member
|
||||||
[$visitors | split(",") | map({permission: "visitor", xuid:.})]
|
resolvePermissionXuids "$VISITORS" visitor
|
||||||
]| flatten' > permissions.json
|
} | jq -s '.' > permissions.json
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n "$ALLOW_LIST_USERS" || -n "$WHITE_LIST_USERS" ]]; then
|
if [[ -n "$ALLOW_LIST_USERS" || -n "$WHITE_LIST_USERS" ]]; then
|
||||||
|
|||||||
Reference in new issue
Block a user