Commit 9964a729 authored by Leo P. Singer's avatar Leo P. Singer Committed by Alexander Pace
Browse files

Append UUID to resource name to guarantee that it is unique

Append a UUID to the Jabber resource name so that it is non-empty and
unique. Since Jabber uses resource names to identify distinct sessions
from the same user, this will make it so that connecting to an existing
resource name will not boot other clients off.

See <https://sympa.ligo.org/wws/arc/daswg/2016-05/msg00209.html

>.
Signed-off-by: default avatarAlexander Pace <alexander.pace@client-104-39-69-143.mobility.psu.edu>
parent 3c3ff9fb
......@@ -24,6 +24,7 @@ import select
import logging
import libxml2
import getpass
import uuid
from optparse import *
from M2Crypto.SSL import Context
......@@ -162,10 +163,6 @@ else:
class MyClient(Client):
def __init__(self, jid, password):
# if bare JID is provided add a resource -- it is required
if not jid.resource:
jid=JID(jid.node, jid.domain, "admin")
# we require a TLS connection
# Specify sslv3 to get around Sun Java SSL bug handling session ticket
# https://rt.phys.uwm.edu/Ticket/Display.html?id=1825
......@@ -256,7 +253,8 @@ else:
libxml2.debugMemory(1)
# set up the stream
myjid=JID(myusername+"@"+opts.server+"/"+opts.resource)
# append UUID to resource to guarantee that it is non-empty and unique
myjid=JID(myusername+"@"+opts.server+"/"+opts.resource+uuid.uuid4())
s=MyClient(jid=myjid,password=mypassword)
if opts.verbose:
......
......@@ -26,6 +26,7 @@ import select
import logging
import libxml2
import getpass
import uuid
import ConfigParser
from subprocess import Popen, PIPE
from optparse import *
......@@ -281,10 +282,6 @@ class LVAlertHandler(object):
class MyClient(Client):
def __init__(self, jid, password,actions, wait=True):
# if bare JID is provided add a resource -- it is required
if not jid.resource:
jid=JID(jid.node, jid.domain, "listener")
# we require a TLS connection
# Specify sslv3 to get around Sun Java SSL bug handling session ticket
# https://rt.phys.uwm.edu/Ticket/Display.html?id=1825
......@@ -336,7 +333,8 @@ if opts.config_file:
actions[node] = cp.get(node,'executable')
# set up the stream
myjid=JID(myusername+"@"+opts.server+"/"+opts.resource)
# append UUID to resource to guarantee that it is non-empty and unique
myjid=JID(myusername+"@"+opts.server+"/"+opts.resource+uuid.uuid4())
s=MyClient(myjid,mypassword,actions, wait=not opts.dont_wait)
if opts.verbose:
......
......@@ -23,6 +23,7 @@ import datetime
import logging
import libxml2
import getpass
import uuid
from optparse import OptionParser
from M2Crypto.SSL import Context
......@@ -243,11 +244,8 @@ if not opts.file:
libxml2.debugMemory(1)
# Instantiate the client
jid=JID(myusername+"@"+opts.server+"/"+opts.resource)
# if bare JID is provided add a resource -- it is required
if not jid.resource:
jid=JID(jid.node, jid.domain, "sender")
# append UUID to resource to guarantee that it is non-empty and unique
jid=JID(myusername+"@"+opts.server+"/"+opts.resource+uuid.uuid4())
client = MyClient(jid,mypassword,opts.max_attempts,onStart)
# Connect
......
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