Commit 65362358 authored by Yann Leboulanger's avatar Yann Leboulanger
Browse files

ability to have a random string in the resource

parent 2b1b461e
......@@ -325,7 +325,7 @@ class Config:
'client_cert_encrypted': [ opt_bool, False, '', False ],
'savepass': [ opt_bool, False ],
'password': [ opt_str, '' ],
'resource': [ opt_str, 'gajim', '', True ],
'resource': [ opt_str, 'gajim.$rand', '', 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.') ],
'autopriority_online': [ opt_int, 50],
......
......@@ -36,7 +36,7 @@ import os
import random
import socket
import operator
import string
import time
import locale
import hmac
......@@ -182,8 +182,10 @@ class CommonConnection:
resource = gajim.config.get_per('accounts', self.name, 'resource')
# All valid resource substitution strings should be added to this hash.
if resource:
rand = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(8))
resource = Template(resource).safe_substitute({
'hostname': socket.gethostname()
'hostname': socket.gethostname(),
'rand': rand
})
return resource
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment