signalling server update
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user