This commit is contained in:
C
2022-12-01 12:41:24 +05:00
parent 1513aac2a8
commit 880d0345a2
111 changed files with 14389 additions and 0 deletions
@@ -0,0 +1,35 @@
#!/bin/bash
# Copyright Epic Games, Inc. All Rights Reserved.
FROM node:latest
# Copy the signalling server source code to the Docker build context
COPY . /opt/SignallingWebServer
# Install the dependencies for the signalling server
WORKDIR /opt/SignallingWebServer
RUN npm install .
# Expose TCP port 80 for player WebSocket connections and web server HTTP access
EXPOSE 80
# Expose TCP port 8888 for streamer WebSocket connections
EXPOSE 8888
EXPOSE 8888/udp
# Expose port for SFU connections
EXPOSE 8889
# Google stun
EXPOSE 19302
# Matchmaker
EXPOSE 9999
# Turn coturn
EXPOSE 3478
EXPOSE 3479
# Set the signalling server as the container's entrypoint
ENTRYPOINT ["/usr/local/bin/node", "/opt/SignallingWebServer/cirrus.js"]
@@ -0,0 +1,12 @@
How to use files in this directory:
- Make sure that all of your dependencies are installed. Use ./setup.sh what will install whatever is missing as long as you are on a supported operating system. Please note that setup.sh is called from every script designed to run
- Run a local instance of the Cirrus server by using the ./run_local.sh script
- Use the following scripts to run locally or in your cloud instance:
- Start_SignallingServer.sh - Start only the Signalling (STUN) server
- Start_TURNServer.sh - Start only the TURN server
- Start_WithTURN_SignallingServer.sh - Start a TURN server and the Cirrus server together
- Please note that scripts intended to run need to be executable: $ chmod +x *.sh will do that job.
- The local/cloud Start_*.sh shell scripts can be invoked with the --help command line option to see how those can be configured. The following options can be supplied: --publicip, --turn, --stun. Please read the --help
@@ -0,0 +1,33 @@
#!/bin/bash
# Copyright Epic Games, Inc. All Rights Reserved.
BASH_LOCATION=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
pushd "${BASH_LOCATION}" > /dev/null
source common_utils.sh
set_start_default_values "n" "y" # Set STUN server defaults only
use_args "$@"
call_setup_sh
print_parameters
peerconnectionoptions='{\"iceServers\":[{\"urls\":[\"stun:${stunserver}\"]}]}'
process="${BASH_LOCATION}/node/lib/node_modules/npm/bin/npm-cli.js run start:default --"
arguments=""
if [ ! -z $IS_DEBUG ]; then
arguments+=" --inspect"
fi
arguments+=" --peerConnectionOptions=\"${peerconnectionoptions}\" --PublicIp=${publicip}"
# Add arguments passed to script to arguments for executable
arguments+=" ${cirruscmd}"
pushd ../..
echo "Running: $process $arguments"
PATH="${BASH_LOCATION}/node/bin:$PATH"
start_process $process $arguments
popd
popd
@@ -0,0 +1,40 @@
#!/bin/bash
# Copyright Epic Games, Inc. All Rights Reserved.
BASH_LOCATION=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
pushd "${BASH_LOCATION}" > /dev/null
source turn_user_pwd.sh
source common_utils.sh
set_start_default_values "y" "n" # TURN server defaults only
use_args "$@"
call_setup_sh
print_parameters
localip=$(hostname -I | awk '{print $1}')
echo "Private IP: $localip"
turnport="${turnserver##*:}"
if [ -z "${turnport}" ]; then
turnport=3478
fi
echo "TURN port: ${turnport}"
echo ""
# Hmm, plain text
realm="PixelStreaming"
process="turnserver"
arguments="-p ${turnport} -r $realm -X $publicip -E $localip -L $localip --no-cli --no-tls --no-dtls --pidfile /var/run/turnserver.pid -f -a -v -n -u ${turnusername}:${turnpassword}"
# Add arguments passed to script to arguments for executable
arguments+=" ${cirruscmd}"
pushd ../.. >/dev/null
echo "Running: $process $arguments"
# pause
start_process $process $arguments &
popd >/dev/null # ../..
popd >/dev/null # BASH_SOURCE
@@ -0,0 +1,35 @@
#!/bin/bash
# Copyright Epic Games, Inc. All Rights Reserved.
BASH_LOCATION=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
pushd "${BASH_LOCATION}" > /dev/null
source common_utils.sh
set_start_default_values "y" "y" # Set both TURN and STUN server defaults
use_args "$@"
call_setup_sh
print_parameters
bash Start_TURNServer.sh --turn "${turnserver}"
peerconnectionoptions='{\"iceServers\":[{\"urls\":[\"stun:$stunserver\",\"turn:$turnserver\"],\"username\":\"PixelStreamingUser\",\"credential\":\"AnotherTURNintheroad\"}]}'
process="${BASH_LOCATION}/node/lib/node_modules/npm/bin/npm-cli.js run start:default --"
arguments=""
if [ ! -z $IS_DEBUG ]; then
arguments+=" --inspect"
fi
arguments+=" --peerConnectionOptions=\"$peerconnectionoptions\" --PublicIp=$publicip"
# Add arguments passed to script to arguments for executable
arguments+=" ${cirruscmd}"
pushd ../..
echo "Running: $process $arguments"
PATH="${BASH_LOCATION}/node/bin:$PATH"
start_process $process $arguments
popd
popd
@@ -0,0 +1,96 @@
#!/bin/bash
# Copyright Epic Games, Inc. All Rights Reserved.
function log_msg() { #message
if [ ! -z $VERBOSE ]; then
echo $1
fi
}
function print_usage() {
echo "
Usage:
${0} [--help] [--publicip <IP Address>] [--turn <turn server>] [--stun <stun server>] [cirrus options...]
Where:
--help will print this message and stop this script.
--debug will run all scripts with --inspect
--nosudo will run all scripts without \`sudo\` command useful for when run in containers.
--verbose will enable additional logging
--package-manager <package manager name> specify an alternative package manager to apt-get
--publicip is used to define public ip address (using default port) for turn server, syntax: --publicip ; it is used for
default value: Retrieved from 'curl https://api.ipify.org' or if unsuccessful then set to 127.0.0.1. It is the IP address of the Cirrus server and the default IP address of the TURN server
--turn defines what TURN server to be used, syntax: --turn 127.0.0.1:19303
default value: as above, IP address downloaded from https://api.ipify.org; in case if download failure it is set to 127.0.0.1
--stun defined what STUN server to be used, syntax: --stun stun.l.google.com:19302
default value as above
Other options: stored and passed to the Cirrus server. All parameters printed once the script values are set.
Command line options might be omitted to run with defaults and it is a good practice to omit specific ones when just starting the TURN or the STUN server alone, not the whole set of scripts.
"
exit 1
}
function print_parameters() {
echo ""
echo "${0} is running with the following parameters:"
echo "--------------------------------------"
if [[ -n "${stunserver}" ]]; then echo "STUN server : ${stunserver}" ; fi
if [[ -n "${turnserver}" ]]; then echo "TURN server : ${turnserver}" ; fi
echo "Public IP address : ${publicip}"
echo "Cirrus server command line arguments: ${cirruscmd}"
echo ""
}
function set_start_default_values() {
# publicip and cirruscmd are always needed
publicip=$(curl -s https://api.ipify.org)
if [[ -z $publicip ]]; then
publicip="127.0.0.1"
fi
cirruscmd=""
if [ "$1" = "y" ]; then
turnserver="${publicip}:19303"
fi
if [ "$2" = "y" ]; then
stunserver="stun.l.google.com:19302"
fi
}
function use_args() {
while(($#)) ; do
case "$1" in
--debug ) IS_DEBUG=1; shift;;
--nosudo ) NO_SUDO=1; shift;;
--verbose ) VERBOSE=1; shift;;
--stun ) stunserver="$2"; shift 2;;
--turn ) turnserver="$2"; shift 2;;
--publicip ) publicip="$2"; turnserver="${publicip}:19303"; shift 2;;
--help ) print_usage;;
* ) echo "Unknown command, adding to cirrus command line: $1"; cirruscmd+=" $1"; shift;;
esac
done
}
function call_setup_sh() {
bash "setup.sh"
}
function start_process() {
if [ ! -z $NO_SUDO ]; then
log_msg "running with sudo removed"
eval $(echo "$@" | sed 's/sudo//g')
else
eval $@
fi
}
function get_version() {
local version=$1
if command -v $version; then
version=$($@)
fi
echo $version | sed -E 's/[^0-9.]//g'
}
@@ -0,0 +1,7 @@
#!/bin/bash
# Copyright Epic Games, Inc. All Rights Reserved.
# When run from SignallingWebServer/platform_scripts/bash, this uses the SignallingWebServer directory
# as the build context so the Cirrus files can be successfully copied into the container image
docker build --network=host -t 'cirrus-webserver:latest' -f ./Dockerfile ../..
@@ -0,0 +1,8 @@
#!/bin/bash
# Copyright Epic Games, Inc. All Rights Reserved.
# Start docker container by name using host networking
docker run --name cirrus_latest --network host --rm cirrus-webserver
# Interactive start example
#docker run --name cirrus_latest --network host --rm -it --entrypoint /bin/bash cirrus-webserver
@@ -0,0 +1,15 @@
#!/bin/bash
# Copyright Epic Games, Inc. All Rights Reserved.
# Suppress printing of directory stack
pushd () {
command pushd "$@" > /dev/null
}
popd () {
command popd "$@" > /dev/null
}
# Stop both stun and turn
pushd "$(dirname ${BASH_SOURCE[0]})"
./docker-start-cirrus.sh --with-turn &
popd
@@ -0,0 +1,31 @@
#!/bin/bash
# Copyright Epic Games, Inc. All Rights Reserved.
source turn_user_pwd.sh
USETURN="false"
for arg do
shift
[ "${arg}" = "--with-turn" ] && USETURN="true" && continue
set -- "$@" "${arg}"
done
# Get stun server data for passing to the container
source common_utils.sh
if [ "${USETURN}" = "true" ]; then
set_start_default_values "y" "y" # Both TURN and STUN server defaults
else
set_start_default_values "n" "y" # Only STUN server defaults
fi
use_args "$@"
# Start docker container by name using host networking
if [ "${USETURN}" = "true" ]; then
peerConnectionOptions="{\""iceServers\"":[{\""urls\"":[\""stun:"${stunserver}"\"",\""turn":"${turnserver}\""],\""username\"":\""${turnusername}\"",\""credential\"":\""${turnpassword}\""}]}"
else
peerConnectionOptions="{\""iceServers\"":[{\""urls\"":[\""stun:"${stunserver}"\""]}]}"
fi
docker run --name cirrus_latest --network host --rm --entrypoint /usr/local/bin/node cirrus-webserver /opt/SignallingWebServer/cirrus.js --peerConnectionOptions="${peerConnectionOptions}" --publicIp="${publicip}"
@@ -0,0 +1,42 @@
#!/bin/bash
# Copyright Epic Games, Inc. All Rights Reserved.
# Get stun server data for passing to the container
source common_utils.sh
set_start_default_values "n" "y" # Only STUN server defaults
use_args "$@"
localip=$(hostname -I | awk '{print $1}')
echo "Private IP: $localip"
turnport="${turnserver##*:}"
if [ -z "${turnport}" ]; then
turnport=3478
fi
echo "TURN port: ${turnport}"
echo ""
turnusername="PixelStreamingUser"
turnpassword="AnotherTURNintheroad"
realm="PixelStreaming"
process="turnserver"
arguments="-p ${turnport} -r $realm -X $publicip -E $localip -L $localip --no-cli --no-tls --no-dtls --pidfile /var/run/turnserver.pid -f -a -v -n -u ${turnusername}:${turnpassword}"
# Add arguments passed to script to arguments for executable
arguments+=" ${cirruscmd}"
# Start docker container by name using host networking
echo "Running: ${process} ${arguments}"
# Get the docker image
docker pull coturn/coturn
# Start the TURN server
#docker run --name coturn_latest --network host -it --entrypoint /bin/bash coturn/coturn
#docker run --name coturn_latest --network host --rm -a stdin -a stdout -a stderr --entrypoint "sudo mkdir -p /var/run" coturn/coturn ""
#docker run --name coturn_latest --network host --rm -a stdin -a stdout -a stderr --entrypoint "/bin/ls" coturn/coturn "/var/"
docker run --name coturn_latest --network host --rm -a stdin -a stdout -a stderr --entrypoint "${process}" coturn/coturn "${arguments}"
#docker run --name coturn_latest --network host --rm -a stdin -a stdout -a stderr --entrypoint "/bin/bash" coturn/coturn "ls -latr /var/run/"
#docker run --name coturn_latest --network host --rm -a stdin -a stdout -a stderr --entrypoint "sudo chown ubuntu:ubuntu /var/run/turnserver.pid | sudo chmod +x /var/run/turnserver.pid | ${process}" coturn/coturn "${arguments}"
@@ -0,0 +1,16 @@
#!/bin/bash
# Copyright Epic Games, Inc. All Rights Reserved.
# Suppress printing of directory stack
pushd () {
command pushd "$@" > /dev/null
}
popd () {
command popd "$@" > /dev/null
}
# Stop both stun and turn
pushd "$(dirname ${BASH_SOURCE[0]})"
./docker-stop-cirrus.sh
./docker-stop-turn.sh
popd
@@ -0,0 +1,12 @@
#!/bin/bash
# Copyright Epic Games, Inc. All Rights Reserved.
# Stop the docker container
PSID=$(docker ps -a -q --filter="name=cirrus_latest")
if [ -z "$PSID" ]; then
echo "Docker stun is not running, no stopping will be done"
exit 1;
fi
echo "Stopping stun server ..."
docker stop cirrus_latest
@@ -0,0 +1,12 @@
#!/bin/bash
# Copyright Epic Games, Inc. All Rights Reserved.
# Stop the docker container
PSID=$(docker ps -a -q --filter="name=coturn_latest")
if [ -z "$PSID" ]; then
echo "Docker turn is not running, no stopping will be done"
exit 1;
fi
echo "Stopping turn server..."
docker stop coturn_latest
@@ -0,0 +1,36 @@
#!/bin/bash
# Copyright Epic Games, Inc. All Rights Reserved.
BASH_LOCATION=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
pushd "${BASH_LOCATION}" > /dev/null
source common_utils.sh
set_start_default_values "n" "n" # No server specific defaults
use_args "$@"
call_setup_sh
print_parameters
process="${BASH_LOCATION}/node/lib/node_modules/npm/bin/npm-cli.js run start:default --"
arguments=""
if [ ! -z $IS_DEBUG ]; then
arguments+=" --inspect"
fi
arguments+=" --publicIp=${publicip}"
arguments+=" ${cirruscmd}"
pushd ../.. > /dev/null
echo ""
echo "Starting Cirrus server use ctrl-c to exit"
echo "-----------------------------------------"
echo ""
PATH="${BASH_LOCATION}/node/bin:$PATH"
start_process $process $arguments
popd > /dev/null # ../..
popd > /dev/null # BASH_SOURCE
@@ -0,0 +1,129 @@
#!/bin/bash
# Copyright Epic Games, Inc. All Rights Reserved.
BASH_LOCATION=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
pushd "${BASH_LOCATION}" > /dev/null
source common_utils.sh
use_args $@
# Azure specific fix to allow installing NodeJS from NodeSource
if test -f "/etc/apt/sources.list.d/azure-cli.list"; then
sudo touch /etc/apt/sources.list.d/nodesource.list
sudo touch /usr/share/keyrings/nodesource.gpg
sudo chmod 644 /etc/apt/sources.list.d/nodesource.list
sudo chmod 644 /usr/share/keyrings/nodesource.gpg
sudo chmod 644 /etc/apt/sources.list.d/azure-cli.list
fi
function check_version() { #current_version #min_version
#check if same string
if [ -z "$2" ] || [ "$1" = "$2" ]; then
return 0
fi
local i current minimum
IFS="." read -r -a current <<< $1
IFS="." read -r -a minimum <<< $2
# fill empty fields in current with zeros
for ((i=${#current[@]}; i<${#minimum[@]}; i++))
do
current[i]=0
done
for ((i=0; i<${#current[@]}; i++))
do
if [[ -z ${minimum[i]} ]]; then
# fill empty fields in minimum with zeros
minimum[i]=0
fi
if ((10#${current[i]} > 10#${minimum[i]})); then
return 1
fi
if ((10#${current[i]} < 10#${minimum[i]})); then
return 2
fi
done
# if got this far string is the same once we added missing 0
return 0
}
function check_and_install() { #dep_name #get_version_string #version_min #install_command
local is_installed=0
log_msg "Checking for required $1 install"
local current=$(echo $2 | sed -E 's/[^0-9.]//g')
local minimum=$(echo $3 | sed -E 's/[^0-9.]//g')
if [ $# -ne 4 ]; then
log_msg "check_and_install expects 4 args (dep_name get_version_string version_min install_command) got $#"
return -1
fi
if [ ! -z $current ]; then
log_msg "Current version: $current checking >= $minimum"
check_version "$current" "$minimum"
if [ "$?" -lt 2 ]; then
log_msg "$1 is installed."
return 0
else
log_msg "Required install of $1 not found installing"
fi
fi
if [ $is_installed -ne 1 ]; then
echo "$1 installation not found installing..."
start_process $4
if [ $? -ge 1 ]; then
echo "Installation of $1 failed try running `export VERBOSE=1` then run this script again for more details"
fi
fi
}
echo "Checking Pixel Streaming Server dependencies."
# navigate to SignallingWebServer root
pushd ../.. > /dev/null
node_version=""
if [[ -f "${BASH_LOCATION}/node/bin/node" ]]; then
node_version=$("${BASH_LOCATION}/node/bin/node" --version)
fi
check_and_install "node" "$node_version" "v16.4.2" "curl https://nodejs.org/dist/v16.14.2/node-v16.14.2-linux-x64.tar.gz --output node.tar.xz
&& tar -xf node.tar.xz
&& rm node.tar.xz
&& mv node-v*-linux-x64 \"${BASH_LOCATION}/node\""
PATH="${BASH_LOCATION}/node/bin:$PATH"
"${BASH_LOCATION}/node/lib/node_modules/npm/bin/npm-cli.js" install
popd > /dev/null # SignallingWebServer
popd > /dev/null # BASH_SOURCE
#command #dep_name #get_version_string #version_min #install command
coturn_version=$(if command -v turnserver &> /dev/null; then echo 1; else echo 0; fi)
if [ $coturn_version -eq 0 ]; then
if ! command -v apt-get &> /dev/null; then
echo "Setup for the scripts is designed for use with distros that use the apt-get package manager" \
"if you are seeing this message you will have to update \"${BASH_LOCATION}/setup.sh\" with\n" \
"a package manger and the equivalent packages for your distribution. Please follow the\n" \
"instructions found at https://pkgs.org/search/?q=coturn to install Coturn for your specific distribution"
exit 1
else
if [ `id -u` -eq 0 ]; then
check_and_install "coturn" "$coturn_version" "1" "apt-get install -y coturn"
else
check_and_install "coturn" "$coturn_version" "1" "sudo apt-get install -y coturn"
fi
fi
fi
@@ -0,0 +1,7 @@
#!/bin/bash
# Copyright Epic Games, Inc. All Rights Reserved.
# Plain text TURN setup
turnusername="PixelStreamingUser"
turnpassword="AnotherTURNintheroad"
@@ -0,0 +1,13 @@
How to use files in this directory:
- Files with .ps1 extension can be run with PowerShell[.exe] in Windows. Powershell needs to be started as Administrator to run setup.ps1 so it can run installation / installation check steps
- Make sure that all of your dependencies are installed. Use .\setup.ps1 what will install whatever is missing as long as you are on a supported operating system
- Run a local instance of the Cirrus server by using the .\run_local.ps1 script
- Use the following scripts to run locally or in your cloud instance:
- Start_SignallingServer.ps1 - Start only the Signalling (STUN) server
- Start_TURNServer.ps1 - Start only the TURN server
- Start_WithTURN_SignallingServer.ps1 - Start a TURN server and the Cirrus server together
- The Start_Common.ps1 file contains shared functions for other Start_*.ps1 scripts and it is not supposed to run alone
- The local/cloud Start_*.ps1 powershell scripts can be invoked with the --help command line option to see how those can be configured. The following options can be supplied: --publicip, --turn, --stun. Please read the --help
@@ -0,0 +1,77 @@
# Copyright Epic Games, Inc. All Rights Reserved.
# Do setup as a common task, it is smart and will not reinstall if not required.
Start-Process -FilePath "$PSScriptRoot\setup.bat" -Wait -NoNewWindow
$global:ScriptName = $MyInvocation.MyCommand.Name
$global:PublicIP = $null
$global:StunServer = $null
$global:TurnServer = $null
$global:CirrusCmd = $null
function print_usage {
echo "
Usage (in MS Windows Power Shell):
$global:ScriptName [--help] [--publicip <IP Address>] [--turn <turn server>] [--stun <stun server>] [cirrus options...]
Where:
--help will print this message and stop this script.
--publicip is used to define public ip address (using default port) for turn server, syntax: --publicip ; it is used for
default value: Retrieved from 'curl https://api.ipify.org' or if unsuccessful then set to 127.0.0.1. It is the IP address of the Cirrus server and the default IP address of the TURN server
--turn defines what TURN server to be used, syntax: --turn 127.0.0.1:19303
default value: as above, IP address downloaded from https://api.ipify.org; in case if download failure it is set to 127.0.0.1
--stun defined what STUN server to be used, syntax: --stun stun.l.google.com:19302
default value as above
Other options: stored and passed to the Cirrus server. All parameters printed once the script values are set.
Command line options might be omitted to run with defaults and it is a good practice to omit specific ones when just starting the TURN or the STUN server alone, not the whole set of scripts.
"
exit 1
}
function print_parameters {
echo ""
echo "$scriptname is running with the following parameters:"
echo "--------------------------------------"
if ($global:StunServer -ne $null) { echo "STUN server : $global:StunServer" }
if ($global:TurnServer -ne $null) { echo "TURN server : $global:TurnServer" }
echo "Public IP address : $global:PublicIP"
echo "Cirrus server command line arguments: $global:CirrusCmd"
echo ""
}
function set_start_default_values($SetTurnServerVar, $SetStunServerVar) {
# publicip and cirruscmd are always needed
$global:PublicIP = Invoke-WebRequest -Uri "https://api.ipify.org" -UseBasicParsing
if ($global:PublicIP -eq $null -Or $global:PublicIP.length -eq 0) {
$global:PublicIP = "127.0.0.1"
} else {
$global:PublicIP = ($global:PublicIP).Content
}
$global:cirruscmd = ""
if ($SetTurnServerVar -eq "y") {
$global:TurnServer = $global:PublicIP + ":19303"
}
if ($SetStunServerVar -eq "y") {
$global:StunServer = "stun.l.google.com:19302"
}
}
function use_args($arg) {
$CmdArgs = $arg -split (" ")
while($CmdArgs.count -gt 0) {
$Cmd, $CmdArgs = $CmdArgs
if ($Cmd -eq "--stun") {
$global:StunServer, $CmdArgs = $CmdArgs
} elseif ($Cmd -eq "--turn") {
$global:TurnServer, $CmdArgs = $CmdArgs
} elseif ($Cmd -eq "--publicip") {
$global:PublicIP, $CmdArgs = $CmdArgs
$global:TurnServer = $global:publicip + ":19303"
} elseif ($Cmd -eq "--help") {
print_usage
} else {
echo "Unknown command, adding to cirrus command line: $Cmd"
$global:CirrusCmd += " $Cmd"
}
}
}
@@ -0,0 +1,19 @@
# Copyright Epic Games, Inc. All Rights Reserved.
. "$PSScriptRoot\Start_Common.ps1"
set_start_default_values "n" "y" # Set both TURN and STUN server defaults
use_args($args)
print_parameters
$peerConnectionOptions = "{ \""iceServers\"": [{\""urls\"": [\""stun:" + $global:StunServer + "\""]}] }"
$ProcessExe = "platform_scripts\cmd\node\node.exe"
$Arguments = @("cirrus", "--peerConnectionOptions=""$peerConnectionOptions""", "--PublicIp=$global:PublicIp")
# Add arguments passed to script to Arguments for executable
$Arguments += $global:CirrusCmd
Push-Location $PSScriptRoot\..\..\
Write-Output "Running: $ProcessExe $Arguments"
Start-Process -FilePath $ProcessExe -ArgumentList "$Arguments" -Wait -NoNewWindow
Pop-Location
@@ -0,0 +1,38 @@
# Copyright Epic Games, Inc. All Rights Reserved.
. "$PSScriptRoot\Start_Common.ps1"
set_start_default_values "y" "n" # Set both TURN and STUN server defaults
use_args($args)
print_parameters
#$LocalIp = Invoke-WebRequest -Uri "http://169.254.169.254/latest/meta-data/local-ipv4"
$LocalIP = (Test-Connection -ComputerName (hostname) -Count 1 | Select IPV4Address).IPV4Address.IPAddressToString
Write-Output "Private IP: $LocalIp"
$TurnPort="19303"
$Pos = $global:TurnServer.LastIndexOf(":")
if ($Pos -ne -1) {
$TurnPort = $global:TurnServer.Substring($Pos+ 1)
}
echo "TURN port: ${turnport}"
echo ""
Push-Location $PSScriptRoot
$TurnUsername = "PixelStreamingUser"
$TurnPassword = "AnotherTURNintheroad"
$Realm = "PixelStreaming"
$ProcessExe = ".\turnserver.exe"
$Arguments = "-p $TurnPort -r $Realm -X $PublicIP -E $LocalIP -L $LocalIP --no-cli --no-tls --no-dtls --pidfile `"C:\coturn.pid`" -f -a -v -n -u $TurnUsername`:$TurnPassword"
# Add arguments passed to script to Arguments for executable
$Arguments += $args
Push-Location $PSScriptRoot\coturn\
Write-Output "Running: $ProcessExe $Arguments"
# pause
Start-Process -FilePath $ProcessExe -ArgumentList $Arguments -NoNewWindow
Pop-Location
Pop-Location
@@ -0,0 +1,25 @@
# Copyright Epic Games, Inc. All Rights Reserved.
. "$PSScriptRoot\Start_Common.ps1"
set_start_default_values "y" "y" # Set both TURN and STUN server defaults
use_args($args)
print_parameters
Push-Location $PSScriptRoot
Start-Process -FilePath "PowerShell" -ArgumentList ".\Start_TURNServer.ps1" -WorkingDirectory "$PSScriptRoot"
$peerConnectionOptions = "{ \""iceServers\"": [{\""urls\"": [\""stun:" + $global:StunServer + "\"",\""turn:" + $global:TurnServer + "\""], \""username\"": \""PixelStreamingUser\"", \""credential\"": \""AnotherTURNintheroad\""}] }"
$ProcessExe = "platform_scripts\cmd\node\node.exe"
$Arguments = @("cirrus", "--peerConnectionOptions=""$peerConnectionOptions""", "--PublicIp=$global:PublicIp")
# Add arguments passed to script to Arguments for executable
$Arguments += $args
Push-Location $PSScriptRoot\..\..\
Write-Output "Running: $ProcessExe $Arguments"
Start-Process -FilePath $ProcessExe -ArgumentList $Arguments -Wait -NoNewWindow
Pop-Location
Pop-Location
@@ -0,0 +1,39 @@
@Rem Copyright Epic Games, Inc. All Rights Reserved.
@echo off
@Rem Set script directory as working directory.
pushd "%~dp0"
title Building Cirrus.exe
@Rem Run setup to ensure we have node and cirrus installed.
call setup.bat
@Rem Look for a `nexe` directory next to this script
if exist nexe\ (
echo nexe directory found...skipping install.
) else (
echo nexe directory not found...beginning nexe install.
@Rem Make `nexe directory`
mkdir nexe
@Rem npm init and install nexe
pushd nexe
call ..\node\npm init -y
call ..\node\npm install nexe --save
popd
)
@Rem Move to cirrus directory.
pushd ..\..
@Rem Build cirrus.exe using `nexe` using node 14.5.0 (as that is one of the latest prebuilts node versions in the nexe repo)
call platform_scripts\cmd\node\npx nexe cirrus.js --target "x64-14.15.3" -r "Public/*" -r "scripts/*" -r "images/*" -r "config.json"
@Rem Pop cirrus directory.
popd ..\..
@Rem Pop working directory
popd
@@ -0,0 +1,25 @@
@Rem Copyright Epic Games, Inc. All Rights Reserved.
@echo off
@Rem Set script directory as working directory.
pushd "%~dp0"
title Cirrus
@Rem Run setup to ensure we have node and cirrus installed.
call setup.bat
@Rem Move to cirrus directory.
pushd ..\..
@Rem Run node server and pass any argument along.
platform_scripts\cmd\node\node.exe cirrus %*
@Rem Pop cirrus directory.
popd
@Rem Pop script directory.
popd
pause
@@ -0,0 +1,20 @@
@Rem Copyright Epic Games, Inc. All Rights Reserved.
@echo off
@Rem Set script location as working directory for commands.
pushd "%~dp0"
@Rem Ensure we have NodeJs available for calling.
call setup_node.bat
@Rem Ensure we have CoTURN available for calling.
call setup_coturn.bat
@Rem Move to cirrus.js directory and install its package.json
pushd %~dp0\..\..\
call platform_scripts\cmd\node\npm install --no-save
popd
@Rem Pop working directory
popd
@@ -0,0 +1,25 @@
@Rem Copyright Epic Games, Inc. All Rights Reserved.
@echo off
@Rem Set script location as working directory for commands.
pushd "%~dp0"
@Rem Look for CoTURN directory next to this script
if exist coturn\ (
echo CoTURN directory found...skipping install.
) else (
echo CoTURN directory not found...beginning CoTURN download for Windows.
@Rem Download nodejs and follow redirects.
curl -L -o ./turnserver.zip "https://github.com/mcottontensor/coturn/releases/download/v4.5.2-windows/turnserver.zip"
@Rem Unarchive the .zip to a directory called "turnserver"
mkdir coturn & tar -xf turnserver.zip -C coturn
@Rem Delete the downloaded turnserver.zip
del turnserver.zip
)
@Rem Pop working directory
popd
@@ -0,0 +1,35 @@
@Rem Copyright Epic Games, Inc. All Rights Reserved.
@echo off
@Rem Set script location as working directory for commands.
pushd "%~dp0"
@Rem Name and version of node that we are downloading
SET NodeVersion=v16.4.2
SET NodeName=node-%NodeVersion%-win-x64
@Rem Look for a node directory next to this script
if exist node\ (
echo Node directory found...skipping install.
) else (
echo Node directory not found...beginning NodeJS download for Windows.
@Rem Download nodejs and follow redirects.
curl -L -o ./node.zip "https://nodejs.org/dist/%NodeVersion%/%NodeName%.zip"
@Rem Unarchive the .zip
tar -xf node.zip
@Rem Rename the extracted, versioned, directory that contains the NodeJS binaries to simply "node".
ren "%NodeName%\" "node"
@Rem Delete the downloaded node.zip
del node.zip
)
@Rem Print node version
echo Node version: & node\node.exe -v
@Rem Pop working directory
popd