Dedicated server API

Discussion in 'Community Workshop' started by J-F Chardon, Apr 23, 2018.

  1. ACX_Com

    ACX_Com New Member

    Joined:
    May 18, 2020
    Ratings:
    +2 / 0 / -0
    I think it's good that we are in agreement here and therefore everything is good.

    That's always my speech - the forums would be much less full if there were proper documentation - my recommendation is a well-maintained wiki.

    Regarding routers (with me FritzBox 7590) to reconnect via batch, I have a solution that works:

    curl -k -m 5 --anyauth --user USER:pASSWORD "http://ROUTER_IP:49000/igdupnp/control/WANIPConn1" -H "Content-Type: text/xml; charset="utf-8"" -H "SoapAction:urn:schemas-upnp-org:service:WANIPConnection:1#ForceTermination" -d "<?xml version='1.0' encoding='utf-8'?> <s:Envelope s:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/' xmlns:s='http://schemas.xmlsoap.org/soap/envelope/'> <s:Body> <u:ForceTermination xmlns:u='urn:schemas-upnp-org:service:WANIPConnection:1' /> </s:Body> </s:Envelope>" -s

    (Only change USER, PASSWORD and ROUTER_IP)
    ROUTER_IP ist the internal not the external WAN-IP! ;)

    ...is here in the forum no possibility to mark <code>? :oops:
     
  2. LaundroMat

    LaundroMat Member

    Joined:
    Nov 28, 2020
    Ratings:
    +14 / 0 / -0
    Cool, thanks for sharing! I'll add it to the wiki :)

    Yes, there is -- click on the + sign in the formatting menu.

    upload_2021-2-14_17-58-8.png
     
    • Like Like x 1
  3. ACX_Com

    ACX_Com New Member

    Joined:
    May 18, 2020
    Ratings:
    +2 / 0 / -0
    Great, you're getting started that fast! :)

    I'll also make my other scripts available to you as soon as I get around to it.

    Why did I not find the marking for codes myself!?!?!? o_O

    Beautiful evening :)
     
  4. LaundroMat

    LaundroMat Member

    Joined:
    Nov 28, 2020
    Ratings:
    +14 / 0 / -0
    Haha, yes, I told you I was an eager type of person :)

    Now, although Notion.so is a great tool to document stuff, it's only open to three editors in the free plan. It's good for the time being, but I'd like to set up a "real" wiki (with history & discussion) to make sure everyone can contribute and that we can see what changes over the course of time. I'll have a look around if there's anything suitable.
     
  5. ACX_Com

    ACX_Com New Member

    Joined:
    May 18, 2020
    Ratings:
    +2 / 0 / -0
    Yes you really are! ;)

    Sounds like a lot will improve in the future, I think it's great.

    So that you have good content, here are the PowerShell scripts as promised:

    RaceRoomDedicatedServer_DelAllSessions.ps1

    Code:
    CLS # nice to have, to clear screen if you use it in the PowerShell ISE
    "Löschen aller Server-Sessions..."
    $GameSettingsIDs = @()
    
    # User and Password only needed, if you use the file "access" in the folder...
    # C:\Program Files (x86)\Steam\steamapps\common\RaceRoom Dedicated Server
    # ...for protecting Dedicated Server Website
    $user = 'YOUR_USERNAME_IN_FILE_ACCESS'
    $pass = 'YOUR_USERNAME_IN_FILE_ACCESS'
    $pair = "$($user):$($pass)"
    $encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair))
    $basicAuthValue = "Basic $encodedCreds"
    
    # header only needed if you use upper Authentication
    $Headers = @{
        Authorization = $basicAuthValue
    }
    
    # it think (not tested), the header below is not needed if you do not use Authentication (filde "access" - see above)
    $GameSettingsIDs = (Invoke-RestMethod -Uri 'http://localhost:8088/dedi' -Headers $Headers).GameSetting.Id
    
    if($GameSettingsIDs.Count -lt 1)
    {
        "Es bestehen keine Server-Sessions!"
        exit
    }
    
    for($i=0; $i -lt $GameSettingsIDs.Count; $i++)
    {
    
    # If you do not use upper Authentication, you can delete Authorisation Part in the header...
    $Headers = @{
        Authorization = $basicAuthValue
        'Content-Type' = 'application/json; charset=utf-8'
        }
    
        [System.Environment]::NewLine + "Lösche Session " + $GameSettingsIDs[$i] + "... " +`
        (Invoke-WebRequest -Method 'DELETE' -Uri "http://localhost:8088/dedi/$($GameSettingsIDs[$i])" -Headers $Headers).StatusDescription
       
    }
    [System.Environment]::NewLine
    #pause

    RaceRoomDedicatedServer_StartSessions.ps1

    Code:
    CLS
    "Starten der Server-Sessions..."
    $GameSettingsIDs = @()
    
    # User and Password only needed, if you use the file "access" in the folder...
    # C:\Program Files (x86)\Steam\steamapps\common\RaceRoom Dedicated Server
    # ...for protecting Dedicated Server Website
    $user = 'YOUR_USERNAME_IN_FILE_ACCESS'
    $pass = 'YOUR_PASSWORD_IN_FILE_ACCESS'
    $pair = "$($user):$($pass)"
    $encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair))
    $basicAuthValue = "Basic $encodedCreds"
    
    # header only needed if you use upper Authentication
    $Headers = @{
        Authorization = $basicAuthValue
    }
    
    # it think (not tested), the header below is not needed if you do not use Authentication (filde "access" - see above)
    $GameSettingsIDs = (Invoke-RestMethod -Uri 'http://localhost:8088/dedi' -Headers $Headers).GameSetting.Id
    
    for($i=0; $i -lt $GameSettingsIDs.Count; $i++)
    {
    
        $Headers = @{
            Authorization = $basicAuthValue
            'Content-Type' = 'application/json; charset=utf-8'
            }
    
        #if($GameSettingsIDs[$i] -ne 152272) # lässt diese Session aus
        #if($i -lt 5) # nur die ersten 5 starten, da nicht mehr erlaubt sind
        if($i -ne 2) # lässt diese Session aus
        {
            [System.Environment]::NewLine + "Starte Session " + $GameSettingsIDs[$i] + "... " + `
            (Invoke-WebRequest -Method 'POST' -Uri 'http://localhost:8088/dedi/start' -Headers $Headers -Body "{""ProcessId"":$($GameSettingsIDs[$i])}").StatusDescription
        }
        else
        {
            [System.Environment]::NewLine + "Session " + $GameSettingsIDs[$i] + " wird nicht gestartet!"
        }
    }
    [System.Environment]::NewLine + [System.Environment]::NewLine
    #pause
    RaceRoomDedicatedServer_RestoreSettings.ps1

    Code:
    CLS # nice to have, to clear screen if you use it in the PowerShell ISE
    
    $Body = '{
      "BackupTime": 161...CONTENT_OF_YOUR_BACKUP_FILE...
    }'
    
    "Restore Server-Sessions..."
    
    # User and Password only needed, if you use the file "access" in the folder...
    # C:\Program Files (x86)\Steam\steamapps\common\RaceRoom Dedicated Server
    # ...for protecting Dedicated Server Website
    $user = 'YOUR_USERNAME_IN_FILE_ACCESS'
    $pass = 'YOUR_PASSWORD_IN_FILE_ACCESS'
    $pair = "$($user):$($pass)"
    $encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair))
    $basicAuthValue = "Basic $encodedCreds"
    
    
    # If you do not use upper Authentication, you can delete Authorisation Part in the header...
    $Headers = @{
        Authorization = $basicAuthValue
        'Content-Type' = 'application/json; charset=utf-8'
        }
    
    (Invoke-WebRequest -Method 'POST' -Uri 'http://localhost:8088/dedi' -Headers $Headers -Body $($Body)).Content
    
    [System.Environment]::NewLine + [System.Environment]::NewLine
    #pause # unkomment for controlling
     
    • Like Like x 1
  6. LaundroMat

    LaundroMat Member

    Joined:
    Nov 28, 2020
    Ratings:
    +14 / 0 / -0
    • Like Like x 1