-
-
Notifications
You must be signed in to change notification settings - Fork 955
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Name and unpair individual clients #2042
Name and unpair individual clients #2042
Conversation
@TheElixZammuto any thoughts on using this over what were working on? |
Just two things:
|
@TheElixZammuto Easy enough. 👍 Regarding setting it as a "root element", do you mean the root of the JSON object or the |
My example idea
|
sunshine_state.json now follows the format outlined in LizardByte#2042 (comment)
@TheElixZammuto I've updated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my opinion the client list and the ability to remove them should be in the troubleshooting section, near the unpair all clients option.
The pin/pair page should be lightweight.
@ReenigneArcher Moved to Troubleshooting 👍 |
<form action="" class="form d-flex flex-column align-items-center" id="form"> | ||
<div class="card flex-column d-flex p-4 mb-4"> | ||
<input type="text" pattern="\d*" placeholder="PIN" id="pin-input" class="form-control my-4" /> | ||
<input type="number" pattern="\d*" placeholder="PIN" id="pin-input" class="form-control mt-2" /> | ||
<input type="text" placeholder="Name (optional)" id="name-input" class="form-control my-4" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be optional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your call. It wasn't required before, so I didn't want to enforce it. If it's going to be required, I think the field name should better indicate that they're coming up with a name for the device. Maybe "Name this device" or "Set device name"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's important to have an identifiable name as user's aren't going to be able to differentiate based on a uuid.
Ideally we could also get the client type during the pair process, but I'm not sure that's possible at the moment.
I think "Device Name" is okay to use as the name of the field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might also be nice to track/display when the client last connected and if there's an active session. But that seems like another PR for another day.
For now I'll make the field required and labeled "Device Name".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed!
I'd like to see these items tracked in the future.
- Last known IP address
- Last known network type (LAN or WAN)
- Moonlight Client (e.g. Android, QT, iOS, etc.)
- Last known moonlight version
- Device Name (provided by Moonlight, not sure if feasible... but e.g. Nvidia Shield)
- Last session start and end times
- Last session application launched
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't love the idea of making device name required. I'd much rather feed that info into the pairing process from the Moonlight side and allow the user to optionally adjust the name via this UI.
On the Moonlight side, it should be pretty easy to send the client's hostname across during the pairing process. We will run into some issues related to the privacy restrictions on iOS, but that's why we keep the optional field around as an override.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If Moonlight can send over enough details, then the name is probably not even necessary.
This is what Plex does. None of these fields can be modified, they are all collected from the client, and everything is pretty easy to identify.
The only issue I see is some of these can change after the pairing process. i.e. the client version (and IP address if we're going to track that somehow).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may still be helpful to optionally set a client name during pairing.
I suspect most users don't name their devices at the OS level, which can make the Moonlight-provided name somewhat meaningless without more info. Tracking clients this way could be especially difficult if you're using Sunshine to share your PC with someone else (remote "local" co-op, for example). Personally, I would rather set the client name myself than explain to a friend that they need to set a name in Moonlight (or worse, their device's hostname).
Also, I'd expect (well, "hope" lol) that this PR will get approved before the required additions to Moonlight are implemented. So a name field is still needed (optional or not) for now.
@xanderfrangos sorry for the delays. Do you have time to resume this? I think it will fix #2305 which is probably a side effect of using a static uniqueID. |
@ReenigneArcher I unfortunately won't be able to work on this much until later this month. But to my understanding, the only outstanding concern (#2042 (comment)) was something I wasn't sure how to help with anyway. |
@ReenigneArcher I've updated this branch to use the new localization library and (more importantly) utilize #2365. Individually unpaired devices can no longer start or resume a session. This should resolve #2042 (comment). Since active sessions aren't automatically disconnected, I've added language to make that clearer for users. Here's an updated screenshot from the Troubleshooting page (taken after unpairing a device): Also, the unpairing UI now consistently uses the word "device". I think that's a little more user-friendly than "client", but either is fine as long as it's consistent. |
@xanderfrangos sorry for the delays. This is the next one on our radar. Could you rebase it? |
@ReenigneArcher I've rebased locally, but need to test/check a few things first. Should have it up over the weekend. |
@xanderfrangos thank you! Also, FYI, in the last 24 hours we changed our default branch back to |
sunshine_state.json now follows the format outlined in LizardByte#2042 (comment)
commit d2e21f9 Merge: 52cb996 7fb8c76 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Wed May 1 21:39:04 2024 -0400 Merge branch 'nightly' into unpair-single-client commit 52cb996 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Thu Apr 18 22:19:53 2024 -0400 Rename unpair_all_desc to unpair_desc commit f5a0916 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Thu Apr 18 22:01:50 2024 -0400 Update src_assets/common/assets/web/troubleshooting.html Co-authored-by: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> commit e30ccb4 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Thu Apr 18 22:01:02 2024 -0400 Update src_assets/common/assets/web/public/assets/locale/en.json Co-authored-by: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> commit a64bfc4 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Thu Apr 18 09:31:38 2024 -0400 Re-use navbar.pin string commit a390977 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Wed Apr 17 21:35:07 2024 -0400 Additional variable reordering commit 63d5875 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Wed Apr 17 21:32:27 2024 -0400 Reordered Vue page vars LizardByte#2042 (review) commit 31c1f21 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Wed Apr 17 21:29:34 2024 -0400 Specify that only individual unpair requires force close commit bb3c0ba Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Wed Apr 17 21:21:35 2024 -0400 Sort client list alphabetically LizardByte#2042 (review) commit 2e82537 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Wed Apr 17 21:14:05 2024 -0400 Localize "PIN" input placeholder LizardByte#2042 (review) commit 1b6a828 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Wed Apr 17 21:13:02 2024 -0400 Close session when unpairing all clients LizardByte#2042 (review) commit 2700152 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Wed Apr 17 13:04:20 2024 -0400 Formatting commit 4e77854 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Wed Apr 17 12:45:22 2024 -0400 Rename unpair all button commit cef0b19 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Wed Apr 17 12:42:45 2024 -0400 Refresh client certs after unpairing a single client commit 5ef7b03 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Wed Apr 17 12:41:14 2024 -0400 Update web UI to use localization for single device pairing/unpairing commit da936b8 Merge: 2452665 9c68a62 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Wed Apr 17 11:01:42 2024 -0400 Merge branch 'nightly' into unpair-single-client commit 9c68a62 Merge: 2511bd0 ec8170c Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Wed Apr 17 10:43:49 2024 -0400 Merge branch 'nightly' of https://github.com/xanderfrangos/Sunshine into nightly commit 2452665 Merge: 735d788 65493d0 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Sat Feb 10 18:22:42 2024 -0500 Merge remote-tracking branch 'upstream/nightly' into unpair-single-client commit 735d788 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Sat Feb 10 18:09:49 2024 -0500 Update named_cert_t to better match sunshine_state.json commit 5ff80ad Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Sat Feb 10 17:53:05 2024 -0500 Remove uniqueID from client_t commit fbd26d0 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Sun Jan 28 11:10:17 2024 -0500 Rename device name field and mark fields as required LizardByte#2042 (review) commit b5d7da4 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Thu Jan 25 23:42:18 2024 -0500 Update src_assets/common/assets/web/troubleshooting.html Co-authored-by: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> commit 60e2da7 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Thu Jan 25 23:41:59 2024 -0500 Update src_assets/common/assets/web/troubleshooting.html Co-authored-by: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> commit a4a4125 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Thu Jan 25 23:41:46 2024 -0500 Update src/confighttp.cpp Co-authored-by: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> commit 805311b Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Thu Jan 25 23:41:36 2024 -0500 Update src/confighttp.cpp Co-authored-by: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> commit cb6846e Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Thu Jan 25 23:41:25 2024 -0500 Update src/confighttp.cpp Co-authored-by: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> commit 3a1c109 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Thu Jan 25 23:41:03 2024 -0500 Update src/confighttp.cpp Co-authored-by: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> commit dd6b597 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Thu Jan 25 23:18:51 2024 -0500 Update src_assets/common/assets/web/troubleshooting.html Co-authored-by: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> commit 36b8bab Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Thu Jan 25 23:18:38 2024 -0500 Update src_assets/common/assets/web/pin.html Co-authored-by: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> commit 3f4fc1c Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Thu Jan 25 21:36:25 2024 -0500 Move Paired Client UI to Troubleshooting page commit 0e1c02b Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Thu Jan 25 21:20:11 2024 -0500 Update API to use uuid instead of uniqueid for clients commit 5cc7fc0 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Wed Jan 24 17:17:10 2024 -0500 Rename named_certs to named_devices commit 541e341 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Wed Jan 24 17:11:26 2024 -0500 Refactor map_id_client into a single client_t commit d842e97 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Wed Jan 24 15:46:39 2024 -0500 Formatting commit 6c63992 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Wed Jan 24 15:37:47 2024 -0500 Formatting commit b6010a6 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Wed Jan 24 15:33:44 2024 -0500 Update sunshine_state.json format to no longer use root.devices sunshine_state.json now follows the format outlined in LizardByte#2042 (comment) commit 8c8dfcf Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Wed Jan 24 15:23:40 2024 -0500 Fixed "restart Sunshine" banner not hiding after clicking "apply" commit ced0122 Merge: 67988be 2511bd0 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Sat Jan 20 04:55:46 2024 -0500 Merge branch 'nightly' into unpair-single-client commit 2511bd0 Merge: b8f8b46 a10ec3a Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Sat Jan 20 04:54:59 2024 -0500 Merge branch 'LizardByte:nightly' into nightly commit 67988be Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Sat Jan 20 04:43:14 2024 -0500 Use lowercase property name for consistency commit bb3fd9a Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Sat Jan 20 04:16:48 2024 -0500 Comment typo commit 73bda36 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Sat Jan 20 04:05:45 2024 -0500 Formatting commit b8f8b46 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Sat Jan 20 02:59:37 2024 -0500 Added UI for unpairing individual clients commit 2e7655b Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Sat Jan 20 02:58:15 2024 -0500 During unpairing, also remove cert from client.certs commit c8d74f2 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Fri Jan 19 21:59:35 2024 -0500 API to unpair clients commit 4b9f9d0 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Fri Jan 19 21:57:41 2024 -0500 API to list paired clients commit 223fdfa Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Fri Jan 19 12:17:55 2024 -0500 Generate and track uniqueID for named certs commit 567725d Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Fri Jan 19 12:17:22 2024 -0500 Only read "certs" and "named_certs" if available commit ca6d1a2 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Fri Jan 19 12:16:25 2024 -0500 Don't prepare nodes for old format commit 9f6a485 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Fri Jan 19 09:41:09 2024 -0500 Assign name to certs when confirming PIN
0310e84
to
589c153
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2042 +/- ##
=========================================
- Coverage 7.02% 7.01% -0.02%
=========================================
Files 88 88
Lines 17900 17987 +87
Branches 8514 8579 +65
=========================================
+ Hits 1258 1261 +3
- Misses 13924 14091 +167
+ Partials 2718 2635 -83
Flags with carried forward coverage won't be shown. Click here to find out more.
|
@ReenigneArcher It got a little messy, so I squashed my changes and rebased onto |
On a side note: I know you're intentionally using "Pin", but "PIN" is what it should be. They have two different meanings. A "pin" is a small, narrow, sharp object (or the act of "pinning" something in place). A "PIN" is a "personal identification number". If you're trying to avoid "PIN" in all caps for some reason, you could use "pairing code"/"pairing" instead. But Moonlight already refers to it as a "PIN", so using any other language could confuse users. |
@xanderfrangos Thanks! This should get merged soon unless we find any last minute things. I find it easier to try to just have 1 commit and amend it when there are changes. It makes it a lot easier to rebase. Regarding the PIN, that sounds right. We should probably address that in a separate PR. |
I don't know if there's a way to handle this without changes to Moonlight, but I did face this small issue. When starting my testing initially, there was one unnamed device paired. I removed the Sunshine host from the client, and then repaired it. In Sunshine this showed 2 devices, one named and one unnamed. When I removed the named one, it still had access since it was also the unnamed one. Once, I removed the unnamed device on Sunshine's side, it was not able to connect. Otherwise this looks good. I guess we can just recommend that people unpair all if they have any unnamed devices. |
@@ -24,7 +25,7 @@ <h1 class="my-4">{{ $t('pin.pin_pairing') }}</h1> | |||
|
|||
<script type="module"> | |||
import { createApp } from 'vue' | |||
import i18n from './locale.js' | |||
import i18nLocale from './locale.js' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import i18nLocale from './locale.js' | |
import i18n from './locale.js' |
I'm confused why this was changed? I'm not seeing an i18nLocale in locale.js. Maybe it was just a bad copy pasta?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something changed with the localization library since I last worked on the PIN page months ago. The "success"/"failure" messages after pairing were throwing errors.
The i18n
import was previously an object with the function i18n.global.t
(see line 53 for example). However, that i18n
import is now itself an async function that returns the expected object (containing global.t
). So I needed to await the import to get the object. This meant that I either needed to rename the import or rename the returned object. I decided to rename the import (from i18n
to i18nLocale
) instead of having a new name for the returned object.
It technically works fine as-is. locale.js
uses the async function as the default export, so it doesn't matter what we call the imported variable. If you prefer the import still be called i18n
, we can rename the returned object instead of the import. Or if there's a better way to access the localization library, we can do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Hazer do you have any thoughts on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This way you're loading the locale twice, it does some API request behind, so it's not ideal.
When I created the initApp
method, I already provided the i18n
for injection, so you can inject it there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My suggestion rewriting like this:
<script type="module">
import { createApp } from 'vue'
import { initApp } from './init'
import Navbar from './Navbar.vue'
let app = createApp({
components: {
Navbar
},
inject: ['i18n'],
methods: {
registerDevice(e) {
let pin = document.querySelector("#pin-input").value;
let name = document.querySelector("#name-input").value;
document.querySelector("#status").innerHTML = "";
let b = JSON.stringify({pin: pin, name: name});
fetch("/api/pin", {method: "POST", body: b})
.then((response) => response.json())
.then((response) => {
if (response.status.toString().toLowerCase() === "true") {
document.querySelector(
"#status"
).innerHTML = `<div class="alert alert-success" role="alert">${this.i18n.t('pin.pair_success')}</div>`;
document.querySelector("#pin-input").value = "";
document.querySelector("#name-input").value = "";
} else {
document.querySelector(
"#status"
).innerHTML = `<div class="alert alert-danger" role="alert">${this.i18n.t('pin.pair_failure')}</div>`;
}
});
}
}
});
initApp(app);
</script>
This way you can inject i18n
easily, and also make a bit clearer what is this code, without changing much.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or, in case you're a bit adventurous, replace the whole pin.html
with:
<!DOCTYPE html>
<html lang="en" data-bs-theme="auto">
<head>
<%- header %>
</head>
<body id="app" v-cloak>
<Navbar></Navbar>
<div id="content" class="container">
<h1 class="my-4 text-center">{{ $t('pin.pin_pairing') }}</h1>
<pin-card></pin-card>
</div>
</body>
<script type="module">
import { createApp } from 'vue'
import { initApp } from './init'
import Navbar from './Navbar.vue'
import PinCard from './PinCard.vue'
let app = createApp({
components: {
Navbar,
PinCard
}
});
initApp(app);
</script>
and create a new file PinCard.vue
:
<script setup>
import { ref } from 'vue'
const inputPIN = ref('')
const inputName = ref('')
const status = ref()
function registerDevice() {
let b = JSON.stringify({pin: inputPIN.value, name: inputName.value});
console.log(b)
fetch("/api/pin", {method: "POST", body: b})
.then((response) => response.json())
.then((response) => {
if (response.status.toString().toLowerCase() === "true") {
status.value = true
inputPIN.value = ""
inputName.value = ""
} else {
status.value = false
}
});
}
</script>
<template>
<form class="form d-flex flex-column align-items-center" id="form" @submit.prevent="registerDevice">
<div class="card flex-column d-flex p-4 mb-4">
<input
type="text"
pattern="\d*"
v-model.trim="inputPIN"
:placeholder="`${$t('navbar.pin')}`"
id="pin-input"
class="form-control mt-2"
autofocus
required />
<input
type="text"
v-model.trim="inputName"
:placeholder="`${$t('pin.device_name')}`"
id="name-input"
class="form-control my-4"
required />
<button class="btn btn-primary">{{ $t('pin.send') }}</button>
</div>
<div class="alert alert-warning">
<b>{{ $t('_common.warning') }}</b> {{ $t('pin.warning_msg') }}
</div>
<div id="status" v-if="status !== undefined">
<div class="alert alert-success" role="alert" v-if="status === true">{{ $t('pin.pair_success') }}</div>
<div class="alert alert-danger" role="alert" v-else>{{ $t('pin.pair_failure') }}</div>
</div>
</form>
</template>
<style scoped>
</style>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ReenigneArcher I've updated it to @Hazer's code from the latest comment. 👍
Yeah, there's not much that can be done about unnamed devices. There's currently no way to figure out which clients/devices they're for and properly name them (or check if they were already paired). But I expect it to be a short-lived issue, since setting a device name for new pairings is now required. |
@@ -24,7 +25,7 @@ <h1 class="my-4">{{ $t('pin.pin_pairing') }}</h1> | |||
|
|||
<script type="module"> | |||
import { createApp } from 'vue' | |||
import i18n from './locale.js' | |||
import i18nLocale from './locale.js' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My suggestion rewriting like this:
<script type="module">
import { createApp } from 'vue'
import { initApp } from './init'
import Navbar from './Navbar.vue'
let app = createApp({
components: {
Navbar
},
inject: ['i18n'],
methods: {
registerDevice(e) {
let pin = document.querySelector("#pin-input").value;
let name = document.querySelector("#name-input").value;
document.querySelector("#status").innerHTML = "";
let b = JSON.stringify({pin: pin, name: name});
fetch("/api/pin", {method: "POST", body: b})
.then((response) => response.json())
.then((response) => {
if (response.status.toString().toLowerCase() === "true") {
document.querySelector(
"#status"
).innerHTML = `<div class="alert alert-success" role="alert">${this.i18n.t('pin.pair_success')}</div>`;
document.querySelector("#pin-input").value = "";
document.querySelector("#name-input").value = "";
} else {
document.querySelector(
"#status"
).innerHTML = `<div class="alert alert-danger" role="alert">${this.i18n.t('pin.pair_failure')}</div>`;
}
});
}
}
});
initApp(app);
</script>
This way you can inject i18n
easily, and also make a bit clearer what is this code, without changing much.
@@ -8,10 +8,11 @@ | |||
<body id="app" v-cloak> | |||
<Navbar></Navbar> | |||
<div id="content" class="container"> | |||
<h1 class="my-4">{{ $t('pin.pin_pairing') }}</h1> | |||
<h1 class="my-4 text-center">{{ $t('pin.pin_pairing') }}</h1> | |||
<form action="" class="form d-flex flex-column align-items-center" id="form"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the change proposed above, use this:
<form action="" class="form d-flex flex-column align-items-center" id="form"> | |
<form class="form d-flex flex-column align-items-center" id="form" @submit.prevent="registerDevice"> |
commit d2e21f9 Merge: 52cb996 7fb8c76 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Wed May 1 21:39:04 2024 -0400 Merge branch 'nightly' into unpair-single-client commit 52cb996 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Thu Apr 18 22:19:53 2024 -0400 Rename unpair_all_desc to unpair_desc commit f5a0916 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Thu Apr 18 22:01:50 2024 -0400 Update src_assets/common/assets/web/troubleshooting.html Co-authored-by: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> commit e30ccb4 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Thu Apr 18 22:01:02 2024 -0400 Update src_assets/common/assets/web/public/assets/locale/en.json Co-authored-by: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> commit a64bfc4 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Thu Apr 18 09:31:38 2024 -0400 Re-use navbar.pin string commit a390977 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Wed Apr 17 21:35:07 2024 -0400 Additional variable reordering commit 63d5875 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Wed Apr 17 21:32:27 2024 -0400 Reordered Vue page vars LizardByte#2042 (review) commit 31c1f21 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Wed Apr 17 21:29:34 2024 -0400 Specify that only individual unpair requires force close commit bb3c0ba Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Wed Apr 17 21:21:35 2024 -0400 Sort client list alphabetically LizardByte#2042 (review) commit 2e82537 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Wed Apr 17 21:14:05 2024 -0400 Localize "PIN" input placeholder LizardByte#2042 (review) commit 1b6a828 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Wed Apr 17 21:13:02 2024 -0400 Close session when unpairing all clients LizardByte#2042 (review) commit 2700152 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Wed Apr 17 13:04:20 2024 -0400 Formatting commit 4e77854 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Wed Apr 17 12:45:22 2024 -0400 Rename unpair all button commit cef0b19 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Wed Apr 17 12:42:45 2024 -0400 Refresh client certs after unpairing a single client commit 5ef7b03 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Wed Apr 17 12:41:14 2024 -0400 Update web UI to use localization for single device pairing/unpairing commit da936b8 Merge: 2452665 9c68a62 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Wed Apr 17 11:01:42 2024 -0400 Merge branch 'nightly' into unpair-single-client commit 9c68a62 Merge: 2511bd0 ec8170c Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Wed Apr 17 10:43:49 2024 -0400 Merge branch 'nightly' of https://github.com/xanderfrangos/Sunshine into nightly commit 2452665 Merge: 735d788 65493d0 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Sat Feb 10 18:22:42 2024 -0500 Merge remote-tracking branch 'upstream/nightly' into unpair-single-client commit 735d788 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Sat Feb 10 18:09:49 2024 -0500 Update named_cert_t to better match sunshine_state.json commit 5ff80ad Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Sat Feb 10 17:53:05 2024 -0500 Remove uniqueID from client_t commit fbd26d0 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Sun Jan 28 11:10:17 2024 -0500 Rename device name field and mark fields as required LizardByte#2042 (review) commit b5d7da4 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Thu Jan 25 23:42:18 2024 -0500 Update src_assets/common/assets/web/troubleshooting.html Co-authored-by: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> commit 60e2da7 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Thu Jan 25 23:41:59 2024 -0500 Update src_assets/common/assets/web/troubleshooting.html Co-authored-by: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> commit a4a4125 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Thu Jan 25 23:41:46 2024 -0500 Update src/confighttp.cpp Co-authored-by: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> commit 805311b Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Thu Jan 25 23:41:36 2024 -0500 Update src/confighttp.cpp Co-authored-by: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> commit cb6846e Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Thu Jan 25 23:41:25 2024 -0500 Update src/confighttp.cpp Co-authored-by: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> commit 3a1c109 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Thu Jan 25 23:41:03 2024 -0500 Update src/confighttp.cpp Co-authored-by: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> commit dd6b597 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Thu Jan 25 23:18:51 2024 -0500 Update src_assets/common/assets/web/troubleshooting.html Co-authored-by: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> commit 36b8bab Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Thu Jan 25 23:18:38 2024 -0500 Update src_assets/common/assets/web/pin.html Co-authored-by: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> commit 3f4fc1c Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Thu Jan 25 21:36:25 2024 -0500 Move Paired Client UI to Troubleshooting page commit 0e1c02b Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Thu Jan 25 21:20:11 2024 -0500 Update API to use uuid instead of uniqueid for clients commit 5cc7fc0 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Wed Jan 24 17:17:10 2024 -0500 Rename named_certs to named_devices commit 541e341 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Wed Jan 24 17:11:26 2024 -0500 Refactor map_id_client into a single client_t commit d842e97 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Wed Jan 24 15:46:39 2024 -0500 Formatting commit 6c63992 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Wed Jan 24 15:37:47 2024 -0500 Formatting commit b6010a6 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Wed Jan 24 15:33:44 2024 -0500 Update sunshine_state.json format to no longer use root.devices sunshine_state.json now follows the format outlined in LizardByte#2042 (comment) commit 8c8dfcf Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Wed Jan 24 15:23:40 2024 -0500 Fixed "restart Sunshine" banner not hiding after clicking "apply" commit ced0122 Merge: 67988be 2511bd0 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Sat Jan 20 04:55:46 2024 -0500 Merge branch 'nightly' into unpair-single-client commit 2511bd0 Merge: b8f8b46 a10ec3a Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Sat Jan 20 04:54:59 2024 -0500 Merge branch 'LizardByte:nightly' into nightly commit 67988be Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Sat Jan 20 04:43:14 2024 -0500 Use lowercase property name for consistency commit bb3fd9a Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Sat Jan 20 04:16:48 2024 -0500 Comment typo commit 73bda36 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Sat Jan 20 04:05:45 2024 -0500 Formatting commit b8f8b46 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Sat Jan 20 02:59:37 2024 -0500 Added UI for unpairing individual clients commit 2e7655b Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Sat Jan 20 02:58:15 2024 -0500 During unpairing, also remove cert from client.certs commit c8d74f2 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Fri Jan 19 21:59:35 2024 -0500 API to unpair clients commit 4b9f9d0 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Fri Jan 19 21:57:41 2024 -0500 API to list paired clients commit 223fdfa Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Fri Jan 19 12:17:55 2024 -0500 Generate and track uniqueID for named certs commit 567725d Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Fri Jan 19 12:17:22 2024 -0500 Only read "certs" and "named_certs" if available commit ca6d1a2 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Fri Jan 19 12:16:25 2024 -0500 Don't prepare nodes for old format commit 9f6a485 Author: Xander Frangos <33106561+xanderfrangos@users.noreply.github.com> Date: Fri Jan 19 09:41:09 2024 -0500 Assign name to certs when confirming PIN
fb8c11b
to
6edb4b0
Compare
Hi, Thanks for the dev :) Because I have a lot of unknown clients and I don't know which clients I'm using and which are old clients (potentially Android emulator, or old OS with the tests I've done) Thanks |
It's recommended to unpair all clients one time. Then you can name them as you pair them again. |
PR #2042 introduced another location for storing authorized clients but did not correctly consider how the load/store logic should differ for those places. One location (named_devices) could contain clients which had not completed pairing, while the other (certs) had only fully paired clients. Despite differences in trust level of clients in each list, the logic for loading/saving config treated them identically. The result is that clients that had not successfully completed pairing would be treated as fully paired after a state reload. Fix this state confusion by consolidating to a single location for authorized client state and ensuring it only contains information on fully paired clients.
PR LizardByte#2042 introduced another location for storing authorized clients but did not correctly consider how the load/store logic should differ for those places. One location (named_devices) could contain clients which had not completed pairing, while the other (certs) had only fully paired clients. Despite differences in trust level of clients in each list, the logic for loading/saving config treated them identically. The result is that clients that had not successfully completed pairing would be treated as fully paired after a state reload. Fix this state confusion by consolidating to a single location for authorized client state and ensuring it only contains information on fully paired clients.
Description
Introduces the option to name clients during PIN pairing, along with a UI to remove individual client certificates. The format of
sunshine_state.json
was updated to include anamed_certs
array instead of the previouscerts
array. The old array is used for migration to the new format on startup.Here's an example of the new format:
The
named_certs
array includes a user-defined name and a generated UUID. The UUID allows for the same name to be used multiple times. It also helps target the correct client over the API without exposing the certificate.The UI for managing clients has been added to the PIN page, under the PIN input. If a client wasn't named during the pairing process, or the certificate was imported from the old format, the client will be listed as "Unknown". After removing a paired client from the new UI, the user will be prompted to restart Sunshine in order to finish removing the certificate.
While working on this, I was made aware of the TheElixZammuto/Sunshine-1/state-revamp fork, which has a similar goal. However, it looks like it's still missing the UI, API, and server code to deal with "unpairing". It also hasn't been updated since September, so it can't merge cleanly as-is. I understand if you prefer to use what that fork over mine, but I figured I would clean up my code and submit it, in case it's useful
Screenshot
Issues Fixed or Closed
https://discord.com/channels/804382334370578482/1197647357030965328
Type of Change
.github/...
)Checklist
Branch Updates
LizardByte requires that branches be up-to-date before merging. This means that after any PR is merged, this branch
must be updated before it can be merged. You must also
Allow edits from maintainers.