diff options
author | Miklos Vajna <vmiklos@frugalware.org> | 2008-05-01 01:57:49 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@frugalware.org> | 2008-05-01 01:57:49 +0200 |
commit | b0d40f5b69100fa89498f0f6f496ce7171352261 (patch) | |
tree | 47a749b445a33d10738462cd35f66ee5d674e371 | |
parent | 4c340e907d611c13bee56393aa782aa954f758fc (diff) |
add python-gnutls support and make it default if available
- this change in general should be ok, since openssl has problems when
using it from gpl software which is distributed as a binary.
- anyway, i hope that this will solve that magic "Fatal Python error:
PyEval_RestoreThread: NULL tstate" error. at least it worth a try.
-rw-r--r-- | skype/README | 8 | ||||
-rw-r--r-- | skype/skyped.py | 24 |
2 files changed, 25 insertions, 7 deletions
diff --git a/skype/README b/skype/README index 60aa4081..bf6d98bf 100644 --- a/skype/README +++ b/skype/README @@ -34,6 +34,7 @@ not..) * Python >= 2.5. Skype4Py does not work with 2.4. * PyGObject >= 2.8.0. Older versions are part of PyGTK. (And you don't want to install GTK for nothing, right?) +* pyopenssl or python-gnutls. `bitlbee-skype` has been tested under Linux and Mac OS X. Skype and Skype4py is available under Windows, too, so it probably works, but this has not been tested. @@ -112,6 +113,13 @@ if you used the `--sysconfdir` switch when running bitlbee-skype's `configure`. NOTE: Maybe you want to adjust the permissions in the `/usr/local/etc/skyped` dir. For example make it readable by just your user. +- If both pyopenssl and python-gnutls are available, then python-gnutls + will be used. This behaviour can be overwritten by: + +---- +$ export SKYPED_NO_GNUTLS=1 +---- + - Start `skyped` (the tcp server): ---- diff --git a/skype/skyped.py b/skype/skyped.py index c9375596..ece745f1 100644 --- a/skype/skyped.py +++ b/skype/skyped.py @@ -73,13 +73,21 @@ def idle_handler(skype): def server(host, port): global options - - from OpenSSL import SSL - ctx = SSL.Context(SSL.TLSv1_METHOD) - ctx.use_privatekey_file(options.config.sslkey) - ctx.use_certificate_file(options.config.sslcert) - sock = SSL.Connection(ctx, socket.socket()) - + try: + if "SKYPED_NO_GNUTLS" in os.environ.keys(): + dprint("Warning, using OpenSSL instead of gnutls as requested (not recommended).") + raise ImportError + from gnutls import crypto, connection + cert = crypto.X509Certificate(open(options.config.sslcert).read()) + key = crypto.X509PrivateKey(open(options.config.sslkey).read()) + cred = connection.X509Credentials(cert, key) + sock = connection.ServerSessionFactory(socket.socket(), cred) + except ImportError: + from OpenSSL import SSL + ctx = SSL.Context(SSL.TLSv1_METHOD) + ctx.use_privatekey_file(options.config.sslkey) + ctx.use_certificate_file(options.config.sslcert) + sock = SSL.Connection(ctx, socket.socket()) sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) sock.bind((host, port)) sock.listen(1) @@ -88,6 +96,8 @@ def server(host, port): def listener(sock, *args): global options options.conn, addr = sock.accept() + if hasattr(options.conn, 'handshake'): + options.conn.handshake() ret = 0 line = options.conn.recv(1024) if line.startswith("USERNAME") and line.split(' ')[1].strip() == options.config.username: |