thaliproject / Thali_CordovaPlugin

Thali p2p plugin
MIT License
226 stars 44 forks source link

ThaliCore 'disconnect' implementation bug #1875

Closed enricogior closed 7 years ago

enricogior commented 7 years ago

The disconnect API requires a peer uuid as input parameter (here and here), that is the peer id without the generation id.

But the disconnect API implementation assumes that the input parameter is a string that is formed by the peer uuid + the generation id and it passes it to ThaliCore.BrowserManager.disconnect that is correctly expecting just the uuid.

The result of passing the peer uuid or the peer uuid + the generation id is the same and it's a silent failure.

enricogior commented 7 years ago

The fix for https://github.com/thaliproject/Thali_CordovaPlugin/blob/411576925e169b8546762c74a75c4e750c5d125b/src/ios/AppContext.swift#L404

Change from:

    if let _ = try? Peer(stringValue: identifierString) {
      browserManager.disconnect(identifierString)
    }

to:

    if let _ = try? Peer(uuidIdentifier: identifierString, generation: 0) {
      browserManager.disconnect(identifierString)
    } else {
      throw AppContextError.badParameters
    }
enricogior commented 7 years ago

Fixed in https://github.com/thaliproject/thali-ios/commits/master-enrico-error-handling-tmp