Skip to content

Commit 36eaba3

Browse files
committed
Merge remote-tracking branch 'unpair/unpair-single-client' into nightly
2 parents 984344c + a390977 commit 36eaba3

9 files changed

Lines changed: 146 additions & 34 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# install dependencies for C++ analysis
2+
set -e
23

34
sudo apt-get update -y
45
sudo apt-get install -y \
@@ -54,3 +55,12 @@ sudo wget \
5455
sudo chmod a+x /root/cuda.run
5556
sudo /root/cuda.run --silent --toolkit --toolkitpath=/usr --no-opengl-libs --no-man-page --no-drm
5657
sudo rm /root/cuda.run
58+
59+
# build
60+
mkdir -p build
61+
cd build || exit 1
62+
cmake -G "Unix Makefiles" ..
63+
make -j"$(nproc)"
64+
65+
# skip autobuild
66+
echo "skip_autobuild=true" >> "$GITHUB_OUTPUT"

.codeql-prebuild-cpp-Windows.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# install dependencies for C++ analysis
2+
set -e
3+
4+
# update pacman
5+
pacman --noconfirm -Suy
6+
7+
# install dependencies
8+
pacman --noconfirm -S \
9+
base-devel \
10+
diffutils \
11+
gcc \
12+
git \
13+
make \
14+
mingw-w64-x86_64-binutils \
15+
mingw-w64-x86_64-boost \
16+
mingw-w64-x86_64-cmake \
17+
mingw-w64-x86_64-curl \
18+
mingw-w64-x86_64-miniupnpc \
19+
mingw-w64-x86_64-nlohmann-json \
20+
mingw-w64-x86_64-nodejs \
21+
mingw-w64-x86_64-onevpl \
22+
mingw-w64-x86_64-openssl \
23+
mingw-w64-x86_64-opus \
24+
mingw-w64-x86_64-rust \
25+
mingw-w64-x86_64-toolchain
26+
27+
# build
28+
mkdir -p build
29+
cd build || exit 1
30+
cmake -G "MinGW Makefiles" ..
31+
mingw32-make -j"$(nproc)"
32+
33+
# skip autobuild
34+
echo "skip_autobuild=true" >> "$GITHUB_OUTPUT"

.codeql-prebuild-cpp-macOS.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# install dependencies for C++ analysis
2+
set -e
3+
4+
# install dependencies
5+
brew install \
6+
boost \
7+
cmake \
8+
miniupnpc \
9+
node \
10+
opus \
11+
pkg-config
12+
13+
# build
14+
mkdir -p build
15+
cd build || exit 1
16+
cmake -G "Unix Makefiles" ..
17+
make -j"$(sysctl -n hw.logicalcpu)"
18+
19+
# skip autobuild
20+
echo "skip_autobuild=true" >> "$GITHUB_OUTPUT"

.github/workflows/codeql.yml

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ on:
1616
- cron: '00 12 * * 0' # every Sunday at 12:00 UTC
1717

1818
concurrency:
19-
group: ${{ github.workflow }}-${{ github.ref }}
19+
group: "${{ github.workflow }}-${{ github.ref }}"
2020
cancel-in-progress: true
2121

2222
jobs:
@@ -57,10 +57,25 @@ jobs:
5757
console.log(`Remapping language: ${key} to ${remap_languages[key.toLowerCase()]}`)
5858
key = remap_languages[key.toLowerCase()]
5959
}
60-
if (supported_languages.includes(key.toLowerCase()) &&
61-
!matrix['include'].includes({"language": key.toLowerCase()})) {
60+
if (supported_languages.includes(key.toLowerCase())) {
6261
console.log(`Found supported language: ${key}`)
63-
matrix['include'].push({"language": key.toLowerCase()})
62+
let osList = ['ubuntu-latest'];
63+
if (key.toLowerCase() === 'swift') {
64+
osList = ['macos-latest'];
65+
} else if (key.toLowerCase() === 'cpp') {
66+
osList = ['macos-latest', 'ubuntu-latest', 'windows-latest'];
67+
}
68+
for (let os of osList) {
69+
// set name for matrix
70+
if (osList.length == 1) {
71+
name = key.toLowerCase()
72+
} else {
73+
name = `${key.toLowerCase()}, ${os}`
74+
}
75+
76+
// add to matrix
77+
matrix['include'].push({"language": key.toLowerCase(), "os": os, "name": name})
78+
}
6479
}
6580
}
6681
@@ -84,10 +99,15 @@ jobs:
8499
}
85100
86101
analyze:
87-
name: Analyze
102+
name: Analyze (${{ matrix.name }})
88103
if: ${{ needs.languages.outputs.continue == 'true' }}
104+
defaults:
105+
run:
106+
shell: ${{ matrix.os == 'windows-latest' && 'msys2 {0}' || 'bash' }}
107+
env:
108+
GITHUB_CODEQL_BUILD: true
89109
needs: [languages]
90-
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
110+
runs-on: ${{ matrix.os || 'ubuntu-latest' }}
91111
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
92112
permissions:
93113
actions: read
@@ -100,6 +120,7 @@ jobs:
100120

101121
steps:
102122
- name: Maximize build space
123+
if: runner.os == 'Linux'
103124
uses: easimon/maximize-build-space@v8
104125
with:
105126
root-reserve-mb: 20480
@@ -114,6 +135,12 @@ jobs:
114135
with:
115136
submodules: recursive
116137

138+
- name: Setup msys2
139+
if: runner.os == 'Windows'
140+
uses: msys2/setup-msys2@v2
141+
with:
142+
update: true
143+
117144
# Initializes the CodeQL tools for scanning.
118145
- name: Initialize CodeQL
119146
uses: github/codeql-action/init@v3
@@ -129,16 +156,20 @@ jobs:
129156

130157
# Pre autobuild
131158
# create a file named .codeql-prebuild-${{ matrix.language }}.sh in the root of your repository
159+
# create a file named .codeql-build-${{ matrix.language }}.sh in the root of your repository
132160
- name: Prebuild
161+
id: prebuild
133162
run: |
134-
# check if .qodeql-prebuild-${{ matrix.language }}.sh exists
135-
if [ -f "./.codeql-prebuild-${{ matrix.language }}.sh" ]; then
136-
echo "Running .codeql-prebuild-${{ matrix.language }}.sh"
137-
./.codeql-prebuild-${{ matrix.language }}.sh
163+
# check if prebuild script exists
164+
filename=".codeql-prebuild-${{ matrix.language }}-${{ runner.os }}.sh"
165+
if [ -f "./${filename}" ]; then
166+
echo "Running prebuild script: ${filename}"
167+
./${filename}
138168
fi
139169
140170
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
141171
- name: Autobuild
172+
if: steps.prebuild.outputs.skip_autobuild != 'true'
142173
uses: github/codeql-action/autobuild@v3
143174

144175
- name: Perform CodeQL Analysis

src/confighttp.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,7 @@ namespace confighttp {
753753
response->write(data.str());
754754
});
755755
nvhttp::erase_all_clients();
756+
proc::proc.terminate();
756757
outputTree.put("status", true);
757758
}
758759

src/nvhttp.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,16 @@ namespace nvhttp {
273273
client.certs.emplace_back(named_cert.cert);
274274
}
275275
}
276+
277+
// Empty certificate chain and import certs from file
278+
cert_chain.clear();
279+
for (auto &cert : client.certs) {
280+
cert_chain.add(crypto::x509(cert));
281+
}
282+
for (auto &named_cert : client.named_devices) {
283+
cert_chain.add(crypto::x509(named_cert.cert));
284+
}
285+
276286
client_root = client;
277287
}
278288

@@ -1137,15 +1147,6 @@ namespace nvhttp {
11371147
conf_intern.pkey = file_handler::read_file(config::nvhttp.pkey.c_str());
11381148
conf_intern.servercert = file_handler::read_file(config::nvhttp.cert.c_str());
11391149

1140-
crypto::cert_chain_t cert_chain;
1141-
client_t &client = client_root;
1142-
for (auto &cert : client.certs) {
1143-
cert_chain.add(crypto::x509(cert));
1144-
}
1145-
for (auto &named_cert : client.named_devices) {
1146-
cert_chain.add(crypto::x509(named_cert.cert));
1147-
}
1148-
11491150
auto add_cert = std::make_shared<safe::queue_t<crypto::x509_t>>(30);
11501151

11511152
// /resume doesn't always get the parameter "localAudioPlayMode"
@@ -1272,6 +1273,7 @@ namespace nvhttp {
12721273
erase_all_clients() {
12731274
client_t client;
12741275
client_root = client;
1276+
cert_chain.clear();
12751277
save_state();
12761278
}
12771279

@@ -1310,6 +1312,7 @@ namespace nvhttp {
13101312
}
13111313

13121314
save_state();
1315+
load_state();
13131316
return removed;
13141317
}
13151318
} // namespace nvhttp

src_assets/common/assets/web/pin.html

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88
<body id="app" v-cloak>
99
<Navbar></Navbar>
1010
<div id="content" class="container">
11-
<h1 class="my-4">{{ $t('pin.pin_pairing') }}</h1>
11+
<h1 class="my-4 text-center">{{ $t('pin.pin_pairing') }}</h1>
1212
<form action="" class="form d-flex flex-column align-items-center" id="form">
1313
<div class="card flex-column d-flex p-4 mb-4">
14-
<input type="number" pattern="\d*" placeholder="PIN" id="pin-input" class="form-control mt-2" required />
15-
<input type="text" placeholder="Device Name" id="name-input" class="form-control my-4" required />
14+
<input type="text" pattern="\d*" :placeholder="`${$t('pin.pin')}`" id="pin-input" class="form-control mt-2"
15+
required />
16+
<input type="text" :placeholder="`${$t('pin.device_name')}`" id="name-input" class="form-control my-4"
17+
required />
1618
<button class="btn btn-primary">{{ $t('pin.send') }}</button>
1719
</div>
1820
<div class="alert alert-warning">
@@ -26,22 +28,21 @@ <h1 class="my-4">{{ $t('pin.pin_pairing') }}</h1>
2628
<div class="card-body">
2729
<div class="p-2">
2830
<div class="d-flex justify-content-end align-items-center">
29-
<h2 id="unpair" class="text-center me-auto">Unpair Clients</h2>
31+
<h2 id="unpair" class="text-center me-auto">{{ $t('troubleshooting.unpair_title') }}</h2>
3032
<button class="btn btn-danger" :disabled="unpairAllPressed" @click="unpairAll">
31-
Unpair All
33+
{{ $t('troubleshooting.unpair_all') }}
3234
</button>
3335
</div>
3436
<div id="apply-alert" class="alert alert-success d-flex align-items-center mt-3"
3537
:style="{ 'display': (showApplyMessage ? 'flex !important': 'none !important') }">
36-
<div class="me-2"><b>Success!</b> Click 'Apply' to restart Sunshine and apply changes. This will terminate
37-
any running sessions.</div>
38-
<button class="btn btn-success ms-auto apply" @click="clickedApplyBanner">Apply</button>
38+
<div class="me-2"><b>{{ $t('_common.success') }}</b> {{ $t('troubleshooting.unpair_single_success') }}</div>
39+
<button class="btn btn-success ms-auto apply" @click="clickedApplyBanner">{{ $t('_common.dismiss') }}</button>
3940
</div>
4041
<div class="alert alert-success" v-if="unpairAllStatus === true">
41-
Unpair Successful!
42+
{{ $t('troubleshooting.unpair_all_success') }}
4243
</div>
4344
<div class="alert alert-danger" v-if="unpairAllStatus === false">
44-
Error while unpairing
45+
{{ $t('troubleshooting.unpair_all_error') }}
4546
</div>
4647
<br />
4748
<p class="mb-0">Remove your paired devices.</p>
@@ -92,7 +93,7 @@ <h2 id="unpair" class="text-center me-auto">Unpair Clients</h2>
9293
</table>
9394
</div>
9495
<div v-else class="list-group list-group-flush list-group-item-light">
95-
<div class="list-group-item p-3 text-center"><em>There are no paired clients.</em></div>
96+
<div class="list-group-item p-3 text-center"><em>{{ $t('troubleshooting.unpair_single_no_devices') }}</em></div>
9697
</div>
9798

9899
</div>
@@ -101,7 +102,7 @@ <h2 id="unpair" class="text-center me-auto">Unpair Clients</h2>
101102
</body>
102103

103104
<script type="module">
104-
import { createApp, ref } from 'vue'
105+
import {createApp, ref} from 'vue'
105106
import i18n from './locale.js'
106107
import Navbar from './Navbar.vue'
107108

@@ -236,4 +237,4 @@ <h2 id="unpair" class="text-center me-auto">Unpair Clients</h2>
236237
app.use(i18n);
237238
app.mount('#app');
238239
});
239-
</script>
240+
</script>

src_assets/common/assets/web/public/assets/locale/en.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"cancel": "Cancel",
77
"disabled": "Disabled",
88
"disabled_def": "Disabled (default)",
9+
"dismiss": "Dismiss",
910
"do_cmd": "Do Command",
1011
"elevated": "Elevated",
1112
"enabled": "Enabled",
@@ -367,8 +368,10 @@
367368
"success_msg": "Password has been changed successfully! This page will reload soon, your browser will ask you for the new credentials."
368369
},
369370
"pin": {
371+
"device_name": "Device Name",
370372
"pair_failure": "Pairing Failed: Check if the PIN is typed correctly",
371373
"pair_success": "Success! Please check Moonlight to continue",
374+
"pin": "PIN",
372375
"pin_pairing": "PIN Pairing",
373376
"send": "Send",
374377
"warning_msg": "Make sure you have access to the client you are pairing with. This software can give total control to your computer, so be careful!"
@@ -400,9 +403,13 @@
400403
"restart_sunshine_success": "Sunshine is restarting",
401404
"troubleshooting": "Troubleshooting",
402405
"unpair_all": "Unpair All",
403-
"unpair_all_desc": "Remove all your paired devices",
406+
"unpair_all_desc": "Remove your paired devices. Individually unpaired devices with an active session will remain connected, but cannot start or resume a session.",
404407
"unpair_all_error": "Error while unpairing",
405-
"unpair_all_success": "Unpair Successful!"
408+
"unpair_all_success": "All devices unpaired.",
409+
"unpair_single_no_devices": "There are no paired devices.",
410+
"unpair_single_success": "However, the device(s) may still be in an active session. Use the 'Force Close' button above to end any open sessions.",
411+
"unpair_single_unknown": "Unknown Client",
412+
"unpair_title": "Unpair Devices"
406413
},
407414
"welcome": {
408415
"confirm_password": "Confirm password",

src_assets/common/assets/web/troubleshooting.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ <h2 id="logs">{{ $t('troubleshooting.logs') }}</h2>
132132
logs: 'Loading...',
133133
logFilter: null,
134134
logInterval: null,
135+
restartPressed: false,
136+
showApplyMessage: false,
137+
unpairAllPressed: false,
138+
unpairAllStatus: null,
135139
};
136140
},
137141
computed: {
@@ -187,6 +191,7 @@ <h2 id="logs">{{ $t('troubleshooting.logs') }}</h2>
187191
setTimeout(() => {
188192
this.resetDisplayDeviceStatus = null;
189193
}, 5000);
194+
this.refreshClients();
190195
});
191196
},
192197
copyLogs() {

0 commit comments

Comments
 (0)