Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/gajim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYann Leboulanger <asterix@lagaule.org>2017-01-04 15:13:55 +0300
committerYann Leboulanger <asterix@lagaule.org>2017-01-04 15:14:21 +0300
commit65362358a9e0a4097d88761c65bf6a64c63838fe (patch)
treef86a340586f45263bead204fc5e1a008b8a99f2a
parent2b1b461e90f1a2d26c7a8a1ecf0ac80aa40b2445 (diff)
ability to have a random string in the resource
-rw-r--r--src/common/config.py2
-rw-r--r--src/common/connection.py6
2 files changed, 5 insertions, 3 deletions
diff --git a/src/common/config.py b/src/common/config.py
index 79368347a..c9e308a42 100644
--- a/src/common/config.py
+++ b/src/common/config.py
@@ -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],
diff --git a/src/common/connection.py b/src/common/connection.py
index 3e943b02d..644574423 100644
--- a/src/common/connection.py
+++ b/src/common/connection.py
@@ -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