diff --git a/xmcl-runtime/peer/PeerService.ts b/xmcl-runtime/peer/PeerService.ts index 691128ef1..c0875d0a6 100644 --- a/xmcl-runtime/peer/PeerService.ts +++ b/xmcl-runtime/peer/PeerService.ts @@ -280,6 +280,7 @@ export class PeerService extends StatefulService implements IPeerServ if (ip && port) { const state = await natService.getNatState() await mapLocalPort(natService, state.localIp, privatePort, Number(port), this).catch((e) => { + if (e.name === 'Error') { e.name = 'MapNatError' } this.error(e) }) } diff --git a/xmcl-runtime/peer/mapAndGetPortCanidate.ts b/xmcl-runtime/peer/mapAndGetPortCanidate.ts index 42f99c925..d783d9835 100644 --- a/xmcl-runtime/peer/mapAndGetPortCanidate.ts +++ b/xmcl-runtime/peer/mapAndGetPortCanidate.ts @@ -48,15 +48,13 @@ export async function mapLocalPort(natService: NatService, ip: string, priv: num if (err.detail?.UPnPError && err.detail?.UPnPError.errorCode === 501) { // Table is full const candidates = getUnmapCandidates(currentMappings, mappings) - console.log(candidates) for (const c of candidates) { await natService.unmap(c).catch(() => {}) } await Promise.all(mappings.map(n => natService.map(n))) - } else if (err.detail.UPnPError && err.detail.UPnPError.errorCode === 718) { + } else if (err.detail?.UPnPError && err.detail.UPnPError.errorCode === 718) { // Conflict const candidates = getUnmapCandidates(currentMappings, mappings) - console.log(candidates) for (const c of candidates) { await natService.unmap(c).catch(() => {}) }