Defer the creation of XTLS until it's first time used.

This will make Gajim start a bit faster and more entropy can be
generated for key generation.
This commit is contained in:
Fedor Brunner 2014-04-15 14:01:55 +02:00
parent 7e183d4515
commit 0a704d05d9
2 changed files with 9 additions and 7 deletions

View File

@ -30,7 +30,6 @@ import stat
from common import gajim from common import gajim
from common import logger from common import logger
from common import jingle_xtls
# DO NOT MOVE ABOVE OF import gajim # DO NOT MOVE ABOVE OF import gajim
import sqlite3 as sqlite import sqlite3 as sqlite
@ -350,12 +349,6 @@ def check_and_possibly_create_paths():
create_path(XTLS_CERTS) create_path(XTLS_CERTS)
if not os.path.exists(LOCAL_XTLS_CERTS): if not os.path.exists(LOCAL_XTLS_CERTS):
create_path(LOCAL_XTLS_CERTS) create_path(LOCAL_XTLS_CERTS)
cert_name = os.path.join(LOCAL_XTLS_CERTS,
jingle_xtls.SELF_SIGNED_CERTIFICATE)
if gajim.HAVE_PYOPENSSL and not (os.path.exists(cert_name + '.cert') and \
os.path.exists(cert_name + '.pkey')):
jingle_xtls.make_certs(cert_name, 'gajim')
def create_path(directory): def create_path(directory):
head, tail = os.path.split(directory) head, tail = os.path.split(directory)

View File

@ -19,9 +19,11 @@
Handles Jingle File Transfer (XEP 0234) Handles Jingle File Transfer (XEP 0234)
""" """
import os
import hashlib import hashlib
from common import gajim from common import gajim
import nbxmpp import nbxmpp
from common import configpaths
from . import jingle_xtls from . import jingle_xtls
from common.jingle_content import contents, JingleContent from common.jingle_content import contents, JingleContent
from common.jingle_transport import * from common.jingle_transport import *
@ -108,6 +110,13 @@ class JingleFileTransfer(JingleContent):
STATE_TRANSPORT_REPLACE : StateTransportReplace(self), STATE_TRANSPORT_REPLACE : StateTransportReplace(self),
STATE_CAND_SENT_AND_RECEIVED : StateCandSentAndRecv(self) STATE_CAND_SENT_AND_RECEIVED : StateCandSentAndRecv(self)
} }
if jingle_xtls.PYOPENSSL_PRESENT:
cert_name = os.path.join(configpaths.gajimpaths['MY_CERT'],
jingle_xtls.SELF_SIGNED_CERTIFICATE)
if not (os.path.exists(cert_name + '.cert')
and os.path.exists(cert_name + '.pkey')):
jingle_xtls.make_certs(cert_name, 'gajim')
def __state_changed(self, nextstate, args=None): def __state_changed(self, nextstate, args=None):
# Executes the next state action and sets the next state # Executes the next state action and sets the next state