ability to have a random string in the resource
This commit is contained in:
parent
2b1b461e90
commit
65362358a9
|
@ -325,7 +325,7 @@ class Config:
|
||||||
'client_cert_encrypted': [ opt_bool, False, '', False ],
|
'client_cert_encrypted': [ opt_bool, False, '', False ],
|
||||||
'savepass': [ opt_bool, False ],
|
'savepass': [ opt_bool, False ],
|
||||||
'password': [ opt_str, '' ],
|
'password': [ opt_str, '' ],
|
||||||
'resource': [ opt_str, 'gajim', '', True ],
|
'resource': [ opt_str, 'gajim.$rand', '', True ],
|
||||||
'priority': [ opt_int, 5, '', True ],
|
'priority': [ opt_int, 5, '', True ],
|
||||||
'adjust_priority_with_status': [ opt_bool, True, _('Priority will change automatically according to your status. Priorities are defined in autopriority_* options.') ],
|
'adjust_priority_with_status': [ opt_bool, True, _('Priority will change automatically according to your status. Priorities are defined in autopriority_* options.') ],
|
||||||
'autopriority_online': [ opt_int, 50],
|
'autopriority_online': [ opt_int, 50],
|
||||||
|
|
|
@ -36,7 +36,7 @@ import os
|
||||||
import random
|
import random
|
||||||
import socket
|
import socket
|
||||||
import operator
|
import operator
|
||||||
|
import string
|
||||||
import time
|
import time
|
||||||
import locale
|
import locale
|
||||||
import hmac
|
import hmac
|
||||||
|
@ -182,8 +182,10 @@ class CommonConnection:
|
||||||
resource = gajim.config.get_per('accounts', self.name, 'resource')
|
resource = gajim.config.get_per('accounts', self.name, 'resource')
|
||||||
# All valid resource substitution strings should be added to this hash.
|
# All valid resource substitution strings should be added to this hash.
|
||||||
if resource:
|
if resource:
|
||||||
|
rand = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(8))
|
||||||
resource = Template(resource).safe_substitute({
|
resource = Template(resource).safe_substitute({
|
||||||
'hostname': socket.gethostname()
|
'hostname': socket.gethostname(),
|
||||||
|
'rand': rand
|
||||||
})
|
})
|
||||||
return resource
|
return resource
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue