pg9182 / northstar-dedicated

Docker image for the Northstar dedicated server.
https://ghcr.io/pg9182/northstar-dedicated
zlib License
101 stars 18 forks source link

client crashes when the client connecting directly (insecure_enabled) #13

Closed L1ghtman2k closed 2 years ago

L1ghtman2k commented 2 years ago

I am now able to replicate the issue that was happening to my docker instance when I was running it in WSL2 (In DM with @pg9182: https://discord.com/channels/@me/924866340555218974/932860684465758249)

Core issue:

Connecting via server browser works fine, while direct connect (aka connect <IP-ADDRESS>:<PORT> in console crashes the client)

Some symptoms when connecting directly, instead of master server:

(Client crashes on game start) image image

(Lobby menu looks different than usual + crash): https://streamable.com/r0fsgo

Logs: (Client logs) nslog2022-02-11 02-57-13.txt

(Server Logs) electric-the-phantom.log.zip

How to replicate:

Run the following on a Linux server with docker (Downloads tf2 files, and starts up the server):

#!/bin/bash
export IMAGE=ghcr.io/pg9182/northstar-dedicated:1-tf2.0.11.0-ns1.4.0
export NS_AUTH_PORT="8081"
export NS_PORT="37015"
docker pull $IMAGE

apt update -y
apt install parallel jq unzip zip -y

echo "Downloading Titanfall2 Files"

curl -L "https://ghcr.io/v2/nsres/titanfall/manifests/2.0.11.0-dedicated-mp" -s -H "Accept: application/vnd.oci.image.manifest.v1+json" -H "Authorization: Bearer QQ==" | jq -r '.layers[]|[.digest, .annotations."org.opencontainers.image.title"] | @tsv' |
{
  paths=()
  uri=()
  while read -r line; do
    while IFS=$'\t' read -r digest path; do
      path="/titanfall2/$path"
      folder=${path%/*}
      mkdir -p "$folder"
      touch "$path"
      paths+=("$path")
      uri+=("https://ghcr.io/v2/nsres/titanfall/blobs/$digest")
    done <<< "$line" ;
  done
  parallel --link --jobs 8 'wget -O {1} {2} --header="Authorization: Bearer QQ==" -nv' ::: "${paths[@]}" ::: "${uri[@]}"
}

docker run -d --pull always --publish $NS_AUTH_PORT:$NS_AUTH_PORT/tcp --publish $NS_PORT:$NS_PORT/udp --mount "type=bind,source=/titanfall2,target=/mnt/titanfall,readonly"  --env NS_SERVER_NAME="[London]electric-the-phantom" --env NS_SERVER_DESC="Competitive LTS!! Yay!" --env NS_AUTH_PORT --env NS_PORT --env NS_SERVER_PASSWORD="1306" --env NS_INSECURE="1" --name "northstar-dedicated" $IMAGE

connect via: connect <IP-ADDRESS>:37015

For convenience, can be run via Northstar-bot in lighthouse discord via: /create_server region:new jersey insecure:True, which runs the above script in vultr.

L1ghtman2k commented 2 years ago

UDP: It seems like first connecting via master server, disconnecting, and connecting directly works.

I suspect there is some init step that is likely being performed on the server when the client first connects via the master server. I believe this issue exists only on docker containers, but I could be wrong since I tested this a while back

L1ghtman2k commented 2 years ago

same issue with 1.5.0 image

wolf109909 commented 2 years ago

Yep the same issue here

pg9182 commented 2 years ago

I have no clue what would be causing this...

L1ghtman2k commented 2 years ago

@pg9182, I was curious if were able to reproduce this one on your own. If you can't reproduce it, I am wondering how your setup could be different

faky1337 commented 2 years ago

RUN chown northstar:northstar /usr/lib/northstar/R2Northstar/placeholder_playerdata.pdata fixed the issue for me because the server needs to read the file when it did not receive pdata for a player by the master server (direct connect without server browser).

L1ghtman2k commented 2 years ago

certified brah moment, haven't tested it, but if it works, a very nice find!

pg9182 commented 2 years ago

It should be able to read it, but if it is trying to write to it, that might be it. I'll push a proper fix soon.

pg9182 commented 2 years ago

Yeah, that makes sense: https://github.com/R2Northstar/NorthstarLauncher/blob/90c123e6beabc833e8bbf0eae89653a522cc74bb/NorthstarDedicatedTest/serverauthentication.cpp#L251-L253

        std::fstream pdataStream(pdataPath, std::ios_base::in);
        if (pdataStream.fail()) // file doesn't exist, use placeholder
            pdataStream = std::fstream(GetNorthstarPrefix() + "/placeholder_playerdata.pdata");

That opens it read/write even though it only needs read.