mirror of
https://github.com/matrix-org/pantalaimon.git
synced 2025-01-07 21:58:14 -05:00
ui: Allow devices to be blackliksted and unblacklisted.
This commit is contained in:
parent
694903e8bd
commit
48f94851d2
@ -112,7 +112,35 @@ class ProxyDaemon:
|
|||||||
await self.send_update_devcies()
|
await self.send_update_devcies()
|
||||||
else:
|
else:
|
||||||
msg = (f"Device {device.id} of user "
|
msg = (f"Device {device.id} of user "
|
||||||
f"{device.user_id} already unverified")
|
f"{device.user_id} already unverified.")
|
||||||
|
|
||||||
|
logger.info(msg)
|
||||||
|
await self.send_response(message_id, client.user_id, "m.ok", msg)
|
||||||
|
|
||||||
|
async def _blacklist_device(self, message_id, client, device):
|
||||||
|
ret = client.blacklist_device(device)
|
||||||
|
|
||||||
|
if ret:
|
||||||
|
msg = (f"Device {device.id} of user "
|
||||||
|
f"{device.user_id} succesfully blacklisted.")
|
||||||
|
await self.send_update_devcies()
|
||||||
|
else:
|
||||||
|
msg = (f"Device {device.id} of user "
|
||||||
|
f"{device.user_id} already blacklisted.")
|
||||||
|
|
||||||
|
logger.info(msg)
|
||||||
|
await self.send_response(message_id, client.user_id, "m.ok", msg)
|
||||||
|
|
||||||
|
async def _unblacklist_device(self, message_id, client, device):
|
||||||
|
ret = client.unblacklist_device(device)
|
||||||
|
|
||||||
|
if ret:
|
||||||
|
msg = (f"Device {device.id} of user "
|
||||||
|
f"{device.user_id} succesfully unblacklisted.")
|
||||||
|
await self.send_update_devcies()
|
||||||
|
else:
|
||||||
|
msg = (f"Device {device.id} of user "
|
||||||
|
f"{device.user_id} already unblacklisted.")
|
||||||
|
|
||||||
logger.info(msg)
|
logger.info(msg)
|
||||||
await self.send_response(message_id, client.user_id, "m.ok", msg)
|
await self.send_response(message_id, client.user_id, "m.ok", msg)
|
||||||
@ -131,7 +159,8 @@ class ProxyDaemon:
|
|||||||
|
|
||||||
if isinstance(
|
if isinstance(
|
||||||
message,
|
message,
|
||||||
(DeviceVerifyMessage, DeviceUnverifyMessage, StartSasMessage)
|
(DeviceVerifyMessage, DeviceUnverifyMessage, StartSasMessage,
|
||||||
|
DeviceBlacklistMessage, DeviceUnblacklistMessage)
|
||||||
):
|
):
|
||||||
|
|
||||||
device = client.device_store[message.user_id].get(
|
device = client.device_store[message.user_id].get(
|
||||||
@ -155,6 +184,12 @@ class ProxyDaemon:
|
|||||||
await self._verify_device(message.message_id, client, device)
|
await self._verify_device(message.message_id, client, device)
|
||||||
elif isinstance(message, DeviceUnverifyMessage):
|
elif isinstance(message, DeviceUnverifyMessage):
|
||||||
await self._unverify_device(message.message_id, client, device)
|
await self._unverify_device(message.message_id, client, device)
|
||||||
|
elif isinstance(message, DeviceBlacklistMessage):
|
||||||
|
await self._blacklist_device(message.message_id, client,
|
||||||
|
device)
|
||||||
|
elif isinstance(message, DeviceUnblacklistMessage):
|
||||||
|
await self._unblacklist_device(message.message_id, client,
|
||||||
|
device)
|
||||||
elif isinstance(message, StartSasMessage):
|
elif isinstance(message, StartSasMessage):
|
||||||
await client.start_sas(message, device)
|
await client.start_sas(message, device)
|
||||||
|
|
||||||
|
@ -75,6 +75,16 @@ class PanctlParser():
|
|||||||
unverify.add_argument("user_id", type=str)
|
unverify.add_argument("user_id", type=str)
|
||||||
unverify.add_argument("device_id", type=str)
|
unverify.add_argument("device_id", type=str)
|
||||||
|
|
||||||
|
blacklist = subparsers.add_parser("blacklist-device")
|
||||||
|
blacklist.add_argument("pan_user", type=str)
|
||||||
|
blacklist.add_argument("user_id", type=str)
|
||||||
|
blacklist.add_argument("device_id", type=str)
|
||||||
|
|
||||||
|
unblacklist = subparsers.add_parser("unblacklist-device")
|
||||||
|
unblacklist.add_argument("pan_user", type=str)
|
||||||
|
unblacklist.add_argument("user_id", type=str)
|
||||||
|
unblacklist.add_argument("device_id", type=str)
|
||||||
|
|
||||||
import_keys = subparsers.add_parser("import-keys")
|
import_keys = subparsers.add_parser("import-keys")
|
||||||
import_keys.add_argument("pan_user", type=str)
|
import_keys.add_argument("pan_user", type=str)
|
||||||
import_keys.add_argument("path", type=str)
|
import_keys.add_argument("path", type=str)
|
||||||
@ -202,6 +212,8 @@ class PanCompleter(Completer):
|
|||||||
"cancel-verification",
|
"cancel-verification",
|
||||||
"verify-device",
|
"verify-device",
|
||||||
"unverify-device",
|
"unverify-device",
|
||||||
|
"blacklist-device",
|
||||||
|
"unblacklist-device",
|
||||||
]:
|
]:
|
||||||
return self.complete_verification(command, last_word, words)
|
return self.complete_verification(command, last_word, words)
|
||||||
|
|
||||||
@ -267,6 +279,8 @@ class PanCtl:
|
|||||||
"import-keys",
|
"import-keys",
|
||||||
"verify-device",
|
"verify-device",
|
||||||
"unverify-device",
|
"unverify-device",
|
||||||
|
"blacklist-device",
|
||||||
|
"unblacklist-device",
|
||||||
"start-verification",
|
"start-verification",
|
||||||
"cancel-verification",
|
"cancel-verification",
|
||||||
"accept-verification",
|
"accept-verification",
|
||||||
@ -443,6 +457,38 @@ class PanCtl:
|
|||||||
elif command == "list-devices":
|
elif command == "list-devices":
|
||||||
self.list_devices(args)
|
self.list_devices(args)
|
||||||
|
|
||||||
|
elif command == "verify-device":
|
||||||
|
self.own_message_ids.append(
|
||||||
|
self.devices.Verify(
|
||||||
|
args.pan_user,
|
||||||
|
args.user_id,
|
||||||
|
args.device_id
|
||||||
|
))
|
||||||
|
|
||||||
|
elif command == "unverify-device":
|
||||||
|
self.own_message_ids.append(
|
||||||
|
self.devices.Unverify(
|
||||||
|
args.pan_user,
|
||||||
|
args.user_id,
|
||||||
|
args.device_id
|
||||||
|
))
|
||||||
|
|
||||||
|
elif command == "blacklist-device":
|
||||||
|
self.own_message_ids.append(
|
||||||
|
self.devices.Blacklist(
|
||||||
|
args.pan_user,
|
||||||
|
args.user_id,
|
||||||
|
args.device_id
|
||||||
|
))
|
||||||
|
|
||||||
|
elif command == "unblacklist-device":
|
||||||
|
self.own_message_ids.append(
|
||||||
|
self.devices.Unblacklist(
|
||||||
|
args.pan_user,
|
||||||
|
args.user_id,
|
||||||
|
args.device_id
|
||||||
|
))
|
||||||
|
|
||||||
elif command == "start-verification":
|
elif command == "start-verification":
|
||||||
self.own_message_ids.append(
|
self.own_message_ids.append(
|
||||||
self.devices.StartKeyVerification(
|
self.devices.StartKeyVerification(
|
||||||
|
@ -60,6 +60,16 @@ class DeviceUnverifyMessage(_VerificationMessage):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@attr.s
|
||||||
|
class DeviceBlacklistMessage(_VerificationMessage):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@attr.s
|
||||||
|
class DeviceUnblacklistMessage(_VerificationMessage):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
@attr.s
|
@attr.s
|
||||||
class SasMessage(_VerificationMessage):
|
class SasMessage(_VerificationMessage):
|
||||||
pass
|
pass
|
||||||
|
@ -124,6 +124,34 @@ class Devices:
|
|||||||
<arg type='aa{ss}' name='devices' direction='out'/>
|
<arg type='aa{ss}' name='devices' direction='out'/>
|
||||||
</method>
|
</method>
|
||||||
|
|
||||||
|
<method name='Verify'>
|
||||||
|
<arg type='s' name='pan_user' direction='in'/>
|
||||||
|
<arg type='s' name='user_id' direction='in'/>
|
||||||
|
<arg type='s' name='device_id' direction='in'/>
|
||||||
|
<arg type='u' name='id' direction='out'/>
|
||||||
|
</method>
|
||||||
|
|
||||||
|
<method name='Unverify'>
|
||||||
|
<arg type='s' name='pan_user' direction='in'/>
|
||||||
|
<arg type='s' name='user_id' direction='in'/>
|
||||||
|
<arg type='s' name='device_id' direction='in'/>
|
||||||
|
<arg type='u' name='id' direction='out'/>
|
||||||
|
</method>
|
||||||
|
|
||||||
|
<method name='Blacklist'>
|
||||||
|
<arg type='s' name='pan_user' direction='in'/>
|
||||||
|
<arg type='s' name='user_id' direction='in'/>
|
||||||
|
<arg type='s' name='device_id' direction='in'/>
|
||||||
|
<arg type='u' name='id' direction='out'/>
|
||||||
|
</method>
|
||||||
|
|
||||||
|
<method name='Unblacklist'>
|
||||||
|
<arg type='s' name='pan_user' direction='in'/>
|
||||||
|
<arg type='s' name='user_id' direction='in'/>
|
||||||
|
<arg type='s' name='device_id' direction='in'/>
|
||||||
|
<arg type='u' name='id' direction='out'/>
|
||||||
|
</method>
|
||||||
|
|
||||||
<method name='StartKeyVerification'>
|
<method name='StartKeyVerification'>
|
||||||
<arg type='s' name='pan_user' direction='in'/>
|
<arg type='s' name='pan_user' direction='in'/>
|
||||||
<arg type='s' name='user_id' direction='in'/>
|
<arg type='s' name='user_id' direction='in'/>
|
||||||
@ -249,6 +277,26 @@ class Devices:
|
|||||||
self.queue.put(message)
|
self.queue.put(message)
|
||||||
return message.message_id
|
return message.message_id
|
||||||
|
|
||||||
|
def Blacklist(self, pan_user, user_id, device_id):
|
||||||
|
message = DeviceBlacklistMessage(
|
||||||
|
self.message_id,
|
||||||
|
pan_user,
|
||||||
|
user_id,
|
||||||
|
device_id
|
||||||
|
)
|
||||||
|
self.queue.put(message)
|
||||||
|
return message.message_id
|
||||||
|
|
||||||
|
def Unblacklist(self, pan_user, user_id, device_id):
|
||||||
|
message = DeviceUnblacklistMessage(
|
||||||
|
self.message_id,
|
||||||
|
pan_user,
|
||||||
|
user_id,
|
||||||
|
device_id
|
||||||
|
)
|
||||||
|
self.queue.put(message)
|
||||||
|
return message.message_id
|
||||||
|
|
||||||
def StartKeyVerification(self, pan_user, user_id, device_id):
|
def StartKeyVerification(self, pan_user, user_id, device_id):
|
||||||
message = StartSasMessage(
|
message = StartSasMessage(
|
||||||
self.message_id,
|
self.message_id,
|
||||||
|
Loading…
Reference in New Issue
Block a user