@decentnetwork/lan 0.1.222 → 0.1.223

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1978,7 +1978,10 @@ function useRtcFileController(selfId, onReceivedText) {
1978
1978
  let sess = peersRef.current.get(fileId);
1979
1979
  try {
1980
1980
  if (env.type === "offer") {
1981
- if (sess) cleanup(fileId);
1981
+ if (sess && sess.pc && sess.pc.signalingState !== "closed") {
1982
+ console.warn("[file-rtc] duplicate offer ignored for " + fileId);
1983
+ return;
1984
+ }
1982
1985
  const pc = new RTCPeerConnection({ iceServers: CALL_ICE_SERVERS });
1983
1986
  pc.oniceconnectionstatechange = () => console.warn("[file-rtc] receiver ice=" + pc.iceConnectionState + " conn=" + pc.connectionState);
1984
1987
  pc.onconnectionstatechange = () => console.warn("[file-rtc] receiver conn=" + pc.connectionState + " ice=" + pc.iceConnectionState);
@@ -2002,6 +2005,10 @@ function useRtcFileController(selfId, onReceivedText) {
2002
2005
  await pc.setLocalDescription(answer);
2003
2006
  await sendSignal(peerId, fileId, "answer", { sdp: answer.sdp });
2004
2007
  } else if (env.type === "answer" && sess) {
2008
+ if (sess.pc.signalingState !== "have-local-offer") {
2009
+ console.warn("[file-rtc] stale answer ignored for " + fileId + " state=" + sess.pc.signalingState);
2010
+ return;
2011
+ }
2005
2012
  await sess.pc.setRemoteDescription({ type: "answer", sdp: env.sdp });
2006
2013
  if (sess.pendingCandidates) {
2007
2014
  for (const c of sess.pendingCandidates.splice(0)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decentnetwork/lan",
3
- "version": "0.1.222",
3
+ "version": "0.1.223",
4
4
  "description": "Private virtual LAN for self-hosted services and AI agents, built on Elastos Carrier. NAT-traversal, name service, ACL, all over a peer-to-peer mesh — no public IP required.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",