mirror of
https://github.com/schlagmichdoch/PairDrop.git
synced 2025-04-21 07:16:18 -04:00
generate unique peer names
use unique-names-generator to generate peer names instead of relying on UA. This prevents confusion when there are multiple clients on the network with same UA.
This commit is contained in:
parent
ff42ee1a3e
commit
0c7abfbf1d
4 changed files with 10 additions and 6 deletions
|
@ -111,11 +111,7 @@ class PeerUI {
|
||||||
}
|
}
|
||||||
|
|
||||||
_name() {
|
_name() {
|
||||||
if (this._peer.name.model) {
|
return this._peer.name.displayName;
|
||||||
return this._peer.name.os + ' ' + this._peer.name.model;
|
|
||||||
}
|
|
||||||
this._peer.name.os = this._peer.name.os.replace('Mac OS', 'Mac');
|
|
||||||
return this._peer.name.os + ' ' + this._peer.name.browser;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_icon() {
|
_icon() {
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
const parser = require('ua-parser-js');
|
const parser = require('ua-parser-js');
|
||||||
|
const { uniqueNamesGenerator } = require('unique-names-generator');
|
||||||
|
|
||||||
class SnapdropServer {
|
class SnapdropServer {
|
||||||
|
|
||||||
|
@ -187,7 +188,8 @@ class Peer {
|
||||||
model: ua.device.model,
|
model: ua.device.model,
|
||||||
os: ua.os.name,
|
os: ua.os.name,
|
||||||
browser: ua.browser.name,
|
browser: ua.browser.name,
|
||||||
type: ua.device.type
|
type: ua.device.type,
|
||||||
|
displayName: uniqueNamesGenerator({ length: 2 })
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
5
server/package-lock.json
generated
5
server/package-lock.json
generated
|
@ -14,6 +14,11 @@
|
||||||
"resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.18.tgz",
|
"resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.18.tgz",
|
||||||
"integrity": "sha512-LtzwHlVHwFGTptfNSgezHp7WUlwiqb0gA9AALRbKaERfxwJoiX0A73QbTToxteIAuIaFshhgIZfqK8s7clqgnA=="
|
"integrity": "sha512-LtzwHlVHwFGTptfNSgezHp7WUlwiqb0gA9AALRbKaERfxwJoiX0A73QbTToxteIAuIaFshhgIZfqK8s7clqgnA=="
|
||||||
},
|
},
|
||||||
|
"unique-names-generator": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/unique-names-generator/-/unique-names-generator-3.0.0.tgz",
|
||||||
|
"integrity": "sha512-5BQhANYUKPqFnFYL1OduL7FDPiV7u5K1Lm4Z89YL4uOLH/uCNTnHkW3roFUEiEptOKt8f3uhmWnZj9w0zBXppw=="
|
||||||
|
},
|
||||||
"ws": {
|
"ws": {
|
||||||
"version": "6.0.0",
|
"version": "6.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/ws/-/ws-6.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/ws/-/ws-6.0.0.tgz",
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"ua-parser-js": "^0.7.18",
|
"ua-parser-js": "^0.7.18",
|
||||||
|
"unique-names-generator": "^3.0.0",
|
||||||
"ws": "^6.0.0"
|
"ws": "^6.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue