Class representing a connection to a Collaboration server
| 11 | |
| 12 | |
| 13 | class Remote: |
| 14 | """ |
| 15 | Class representing a connection to a Collaboration server |
| 16 | """ |
| 17 | def __init__(self, handle: core.BNRemoteHandle): |
| 18 | """ |
| 19 | :param handle: FFI handle for internal use |
| 20 | :raises: RuntimeError if there was an error |
| 21 | """ |
| 22 | |
| 23 | self._handle = ctypes.cast(handle, core.BNRemoteHandle) |
| 24 | |
| 25 | def __del__(self): |
| 26 | if core is not None: |
| 27 | core.BNFreeRemote(self._handle) |
| 28 | |
| 29 | def __eq__(self, other): |
| 30 | if not isinstance(other, Remote): |
| 31 | return False |
| 32 | if not self.has_loaded_metadata or not other.has_loaded_metadata: |
| 33 | # Don't pull metadata if we haven't yet |
| 34 | return self.address == other.address |
| 35 | return other.unique_id == self.unique_id |
| 36 | |
| 37 | def __str__(self): |
| 38 | return f'<remote: {self.name}>' |
| 39 | |
| 40 | def __repr__(self): |
| 41 | return f'<remote: {self.name}>' |
| 42 | |
| 43 | @staticmethod |
| 44 | def get_for_local_database(database: 'binaryninja.Database') -> Optional['Remote']: |
| 45 | """ |
| 46 | Get the Remote for a Database |
| 47 | |
| 48 | :param database: BN database, potentially with collaboration metadata |
| 49 | :return: Remote from one of the connected remotes, or None if not found |
| 50 | :rtype: Optional[Remote] |
| 51 | :raises RuntimeError: If there was an error |
| 52 | """ |
| 53 | return databasesync.get_remote_for_local_database(database) |
| 54 | |
| 55 | @staticmethod |
| 56 | def get_for_bv(bv: 'binaryninja.BinaryView') -> Optional['Remote']: |
| 57 | """ |
| 58 | Get the Remote for a Binary View |
| 59 | |
| 60 | :param bv: Binary view, potentially with collaboration metadata |
| 61 | :return: Remote from one of the connected remotes, or None if not found |
| 62 | :raises RuntimeError: If there was an error |
| 63 | """ |
| 64 | if not bv.file.has_database: |
| 65 | return None |
| 66 | db = bv.file.database |
| 67 | if db is None: |
| 68 | return None |
| 69 | return databasesync.get_remote_for_local_database(db) |
| 70 |
no outgoing calls
no test coverage detected