mirror of
https://github.com/schlagmichdoch/PairDrop.git
synced 2025-04-20 07:05:05 -04:00
readd persistent peerId via sessionStorage
This commit is contained in:
parent
8dc0f1cb0c
commit
621c525d11
2 changed files with 16 additions and 5 deletions
14
index.js
14
index.js
|
@ -102,7 +102,8 @@ class SnapdropServer {
|
|||
type: 'display-name',
|
||||
message: {
|
||||
displayName: peer.name.displayName,
|
||||
deviceName: peer.name.deviceName
|
||||
deviceName: peer.name.deviceName,
|
||||
peerId: peer.id
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -230,7 +231,7 @@ class Peer {
|
|||
this._setIP(request);
|
||||
|
||||
// set peer id
|
||||
this._setPeerId()
|
||||
this._setPeerId(request)
|
||||
|
||||
// is WebRTC supported ?
|
||||
this.rtcSupported = request.url.indexOf('webrtc') > -1;
|
||||
|
@ -297,8 +298,13 @@ class Peer {
|
|||
return false;
|
||||
}
|
||||
|
||||
_setPeerId() {
|
||||
this.id = Peer.uuid();
|
||||
_setPeerId(request) {
|
||||
let peer_id = new URL(request.url, "http://server").searchParams.get("peer_id");
|
||||
if (peer_id && /^([0-9]|[a-f]){8}-(([0-9]|[a-f]){4}-){3}([0-9]|[a-f]){12}$/.test(peer_id)) {
|
||||
this.id = peer_id;
|
||||
} else {
|
||||
this.id = Peer.uuid();
|
||||
}
|
||||
}
|
||||
|
||||
toString() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue