add patched version for twisted-12.3

This commit is contained in:
Manuel Friedli 2013-09-09 08:33:50 +00:00
parent c5d0a6f052
commit de4890c8a0
9 changed files with 371 additions and 0 deletions

View file

@ -0,0 +1,10 @@
--- pymsn-t/src/main.py 2008-09-19 10:53:30.000000000 +0200
+++ pymsn-t/src/main.py 2008-09-19 10:55:55.000000000 +0200
@@ -72,7 +72,6 @@
if config.reactor:
# They picked their own reactor. Lets install it.
- del sys.modules["twisted.internet.reactor"]
if config.reactor == "epoll":
from twisted.internet import epollreactor
epollreactor.install()

View file

@ -0,0 +1,12 @@
diff -a -u -d -r pymsnt.a/src/legacy/msn/msn.py pymsnt.b/src/legacy/msn/msn.py
--- pymsnt.a/src/legacy/msn/msn.py 2008-02-08 16:55:07.000000000 +0300
+++ pymsnt.b/src/legacy/msn/msn.py 2008-08-05 20:40:46.000000000 +0400
@@ -110,7 +110,7 @@
from urllib import quote, unquote
-MSN_PROTOCOL_VERSION = "MSNP11 CVR0" # protocol version
+MSN_PROTOCOL_VERSION = "MSNP11" # protocol version
MSN_PORT = 1863 # default dispatch server port
MSN_MAX_MESSAGE = 1664 # max message length
MSN_CVR_STR = "0x040c winnt 5.1 i386 MSNMSGR 7.0.0777 msmsgs"

View file

@ -0,0 +1,41 @@
--- pymsn-t/src/main.py 2008-04-04 17:45:43.000000000 +0400
+++ pymsn-t/src/main.py 2008-08-05 17:44:17.000000000 +0400
@@ -91,6 +91,7 @@
from twisted.words.xish.domish import Element
from twisted.words.protocols.jabber import component
from twisted.words.protocols.jabber.jid import internJID
+from twisted.python import log
from debug import LogEvent, INFO, WARN, ERROR
@@ -352,13 +353,29 @@
pf = open(config.pid, "w")
pf.write("%s\n" % pid)
pf.close()
+
+ def removePID(self, pidfile):
+ # Remove a PID file
+ if not pidfile:
+ return
+ try:
+ os.unlink(pidfile)
+ except OSError, e:
+ if e.errno == errno.EACCES or e.errno == errno.EPERM:
+ log.msg("Warning: No permission to delete pid file")
+ else:
+ log.msg("Failed to unlink PID file:")
+ log.deferr()
+ except:
+ log.msg("Failed to unlink PID file:")
+ log.deferr()
def shuttingDown(self):
self.transportSvc.removeMe()
# Keep the transport running for another 3 seconds
def cb(ignored=None):
if config.pid:
- twistd.removePID(config.pid)
+ self.removePID(config.pid)
d = Deferred()
d.addCallback(cb)
reactor.callLater(3.0, d.callback, None)

View file

@ -0,0 +1,11 @@
--- src/main.py~ 2008-02-08 14:55:07.000000000 +0100
+++ src/main.py 2013-09-09 10:29:35.003933282 +0200
@@ -328,7 +328,7 @@
# Daemonise the process and write the PID file
if config.background and os.name == "posix":
- twistd.daemonize()
+ twistd.daemonize(reactor, os)
if config.pid:
self.writePID()

View file

@ -0,0 +1,44 @@
--- pymsn-t/src/legacy/glue.py 2008-09-19 10:53:30.000000000 +0200
+++ pymsn-t/src/legacy/glue.py 2008-09-19 10:52:38.000000000 +0200
@@ -379,7 +379,13 @@
self.session.removeMe()
def connectionLost(self, reason):
- LogEvent(INFO, self.jabberID)
+ LogEvent(INFO, self.jabberID)
+ # If we got a second referral, don't really log out but let the next NS
+ # try to log us in
+ if reason.type == error.ConnectionDone and self.gotadditionalXFR != 0:
+ LogEvent(INFO, self.ident)
+ self.gotadditionalXFR = 0
+ return
if reason.type != error.ConnectionDone:
text = lang.get(self.session.lang).msnDisconnected % reason
self.session.sendMessage(to=self.jabberID, fro=config.jid, body=text)
--- pymsn-t/src/legacy/msn/msn.py 2008-09-19 10:53:30.000000000 +0200
+++ pymsn-t/src/legacy/msn/msn.py 2008-09-19 10:52:38.000000000 +0200
@@ -1347,7 +1347,9 @@
port = MSN_PORT
if not self._fireCallback(id, host, int(port), params[4]):
- raise MSNProtocolError, "Got XFR (referral) that I didn't ask for .. should this happen?" # debug
+ #raise MSNProtocolError, "Got XFR (referral) that I didn't ask for .. should this happen?" # debug
+ self.factory.msncon.gotadditionalXFR = 1
+ self.factory.msncon.connectors.append(reactor.connectTCP(host, int(port), self.factory, bindAddress=(self.factory.msncon.BINDADDRESS, 0)))
def handle_RNG(self, params):
checkParamLen(len(params), 6, 'RNG')
--- pymsn-t/src/legacy/msn/msnw.py 2008-09-19 10:53:30.000000000 +0200
+++ pymsn-t/src/legacy/msn/msnw.py 2008-09-19 10:52:38.000000000 +0200
@@ -67,8 +67,9 @@
LogEvent(INFO, self.ident)
def _gotNotificationReferral(self, (host, port)):
- self.timeout.cancel()
- self.timeout = None
+ if self.timeout != None:
+ self.timeout.cancel()
+ self.timeout = None
# Create the NotificationClient
self.notificationFactory = msn.NotificationFactory()
self.notificationFactory.userHandle = self.username

View file

@ -0,0 +1,142 @@
diff -Naur pymsnt-0.11.3/src/avatar.py pymsnt-0.11.3-1/src/avatar.py
--- pymsnt-0.11.3/src/avatar.py 2008-02-08 14:55:07.000000000 +0100
+++ pymsnt-0.11.3-1/src/avatar.py 2011-09-04 13:40:02.350321866 +0200
@@ -6,7 +6,12 @@
from twisted.internet import reactor
from twisted.words.xish.domish import Element
-import sha, base64, os, os.path
+import base64, os, os.path
+
+try:
+ from hashlib import sha1
+except ImportError:
+ from sha import sha as sha1
import utils
import config
@@ -34,7 +39,7 @@
class Avatar:
""" Represents an Avatar. Does not store the image in memory. """
def __init__(self, imageData, avatarCache):
- self.__imageHash = sha.sha(imageData).hexdigest()
+ self.__imageHash = sha1(imageData).hexdigest()
self.__avatarCache = avatarCache
def getImageHash(self):
diff -Naur pymsnt-0.11.3/src/legacy/msn/msnp11chl.py pymsnt-0.11.3-1/src/legacy/msn/msnp11chl.py
--- pymsnt-0.11.3/src/legacy/msn/msnp11chl.py 2008-02-08 14:55:07.000000000 +0100
+++ pymsnt-0.11.3-1/src/legacy/msn/msnp11chl.py 2011-09-04 13:40:02.351321854 +0200
@@ -1,16 +1,20 @@
# Copyright 2005 James Bunton <james@delx.cjb.net>
# Licensed for distribution under the GPL version 2, check COPYING for details
-import md5
import struct
+try:
+ from hashlib import md5
+except ImportError:
+ from md5 import md5
+
MSNP11_PRODUCT_ID = "PROD0090YUAUV{2B"
MSNP11_PRODUCT_KEY = "YMM8C_H7KCQ2S_KL"
MSNP11_MAGIC_NUM = 0x0E79A9C1
def doChallenge(chlData):
- md5digest = md5.md5(chlData + MSNP11_PRODUCT_KEY).digest()
+ md5digest = md5(chlData + MSNP11_PRODUCT_KEY).digest()
# Make array of md5 string ints
md5Ints = struct.unpack("<llll", md5digest)
diff -Naur pymsnt-0.11.3/src/legacy/msn/msn.py pymsnt-0.11.3-1/src/legacy/msn/msn.py
--- pymsnt-0.11.3/src/legacy/msn/msn.py 2008-02-08 14:55:07.000000000 +0100
+++ pymsnt-0.11.3-1/src/legacy/msn/msn.py 2011-09-04 13:40:02.351321854 +0200
@@ -106,9 +106,12 @@
# System imports
-import types, operator, os, sys, base64, random, struct, random, sha, base64, StringIO, array, codecs, binascii
+import types, operator, os, sys, base64, random, struct, random, base64, StringIO, array, codecs, binascii
from urllib import quote, unquote
-
+try:
+ from hashlib import sha1
+except ImportError:
+ from sha import sha as sha1
MSN_PROTOCOL_VERSION = "MSNP11 CVR0" # protocol version
MSN_PORT = 1863 # default dispatch server port
@@ -490,7 +493,7 @@
self.type = 3
self.location = "TMP" + str(random.randint(1000,9999))
self.friendly = "AAA="
- self.sha1d = b64enc(sha.sha(imageData).digest())
+ self.sha1d = b64enc(sha1(imageData).digest())
self.makeText()
def setNull(self):
@@ -518,7 +521,7 @@
h.append(self.friendly)
h.append("SHA1D")
h.append(self.sha1d)
- sha1c = b64enc(sha.sha("".join(h)).digest())
+ sha1c = b64enc(sha1("".join(h)).digest())
self.text = '<msnobj Creator="%s" Size="%s" Type="%s" Location="%s" Friendly="%s" SHA1D="%s" SHA1C="%s"/>' % (self.creator, str(self.size), str(self.type), self.location, self.friendly, self.sha1d, sha1c)
def parse(self, s):
diff -Naur pymsnt-0.11.3/src/utils.py pymsnt-0.11.3-1/src/utils.py
--- pymsnt-0.11.3/src/utils.py 2008-02-08 14:55:07.000000000 +0100
+++ pymsnt-0.11.3-1/src/utils.py 2011-09-04 13:40:02.351321854 +0200
@@ -1,17 +1,17 @@
# Copyright 2004-2005 James Bunton <james@delx.cjb.net>
# Licensed for distribution under the GPL version 2, check COPYING for details
+try:
+ from hashlib import sha1
+except ImportError:
+ from sha import sha as sha1
+def socks5Hash(sid, initiator, target):
+ return sha1("%s%s%s" % (sid, initiator, target)).hexdigest()
def getLang(el):
return el.getAttribute((u'http://www.w3.org/XML/1998/namespace', u'lang'))
-
-import sha
-def socks5Hash(sid, initiator, target):
- return sha.new("%s%s%s" % (sid, initiator, target)).hexdigest()
-
-
import urllib
import os.path
def getURLBits(url, assumedType=None):
diff -Naur pymsnt-0.11.3/src/xdb.py pymsnt-0.11.3-1/src/xdb.py
--- pymsnt-0.11.3/src/xdb.py 2008-02-08 14:55:07.000000000 +0100
+++ pymsnt-0.11.3-1/src/xdb.py 2011-09-04 13:40:02.351321854 +0200
@@ -6,9 +6,13 @@
import os
import os.path
import shutil
-import md5
import config
+try:
+ from hashlib import md5
+except ImportError:
+ from md5 import md5
+
X = os.path.sep
SPOOL_UMASK = 0077
@@ -23,7 +27,7 @@
return file.replace("@", "%")
def makeHash(file):
- return md5.md5(file).hexdigest()[0:3]
+ return md5(file).hexdigest()[0:3]
class XDB:

View file

@ -0,0 +1,23 @@
#!/sbin/runscript
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-im/pymsn-t/files/pymsn-t-initd,v 1.1 2011/09/04 10:26:35 hanno Exp $
depend() {
need net
use jabber-server
}
start() {
ebegin "Starting MSN Jabber Transport"
start-stop-daemon --start --pidfile /var/run/jabber/pymsn-t.pid -u jabber -g jabber \
--exec /usr/bin/python INSPATH/pymsn-t.py -- \
-b -c /etc/jabber/pymsn-t.xml -l /var/log/jabber/pymsn-t.log
eend $?
}
stop() {
ebegin "Stopping MSN Jabber Transport"
start-stop-daemon --stop --quiet --pidfile /var/run/jabber/pymsn-t.pid
eend $?
}