Taking #1838 one step further: when the client disables a feature completely (ie: clipboard) or when the client is not a UI client (ie: #2348) then we can generate a custom client class without those base classes.
get_client_connection_class needs to be made dynamic.
We'll need a map from flags to mixins, ie:
"clipboard" : ClipboardConnection, "webcam" : WebcamMixin, etc..
Preparatory work in r23081.
This will be much easier to implement after dropping python2 support. (v4)
implementation - causes server hangs on control-c
No idea why, but re-doing the change step by step no longer crashes and so the code has been merged in r24907. The only mixin we currently skip is the mmap mixin.
is_neededcheck to more mixins
is_neededcheck does not cost too much
Much improved in r24910, see commit message for details. With minor updates in r24911 + r24912 + r24913 + r24914.
Minimal backport to help the server figure out what the client is capable of: r24915.
With a regular client and
xpra top connected:
$ xpra info | grep ".modules" client.1.modules=('Client', 'ClientInfo', 'Clipboard', 'Audio', 'Webcam', 'FilePrint', 'MMAP', 'Input', 'DBUS', 'NetworkState', 'ClientDisplay', 'Windows', 'Encodings', 'AVSync', 'Idle') client.modules=('Client', 'ClientInfo', 'Webcam', 'Input', 'DBUS', 'NetworkState', 'ClientDisplay', 'Idle')
Apart from the stated goals of not loading code we don't need (reducing attack surface, reducing memory usage, etc), there are additional benefits: we are forced to remove cross-mixin dependencies and this reduces contention on shared resources. ie: a client which has disabled the clipboard will make it easier for other users.
Still TODO: test all possible combinations (one of the unit tests can do that - just disabled by default because it takes so long)
Unless needed skip those mixins:
This allows the "top" client to load only the bare minimum:
client.modules=('Client', 'ClientInfo', 'ClientDisplay')
This will do for v4.
this ticket has been moved to: https://github.com/Xpra-org/xpra/issues/2351