summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2012-04-19 10:46:46 -0300
committerSilvio Rhatto <rhatto@riseup.net>2012-04-19 10:46:46 -0300
commitabbf32872b917f8155bd6298d8f8d4315e85f82d (patch)
treeff8df45bf9b11b862d602d27850ee04d7ae40418
parent056838d484ed26523abc00f96e8ee59132e392bb (diff)
downloadpuppet-qwebirc-abbf32872b917f8155bd6298d8f8d4315e85f82d.tar.gz
puppet-qwebirc-abbf32872b917f8155bd6298d8f8d4315e85f82d.tar.bz2
Cleaning ssl patch dependencies
-rw-r--r--files/ircclient-ssl.py173
-rw-r--r--files/qwebirc-ssl.patch38
-rw-r--r--files/qwebirc-ssl.patch.orig38
-rw-r--r--manifests/init.pp21
4 files changed, 1 insertions, 269 deletions
diff --git a/files/ircclient-ssl.py b/files/ircclient-ssl.py
deleted file mode 100644
index 2fd09c0..0000000
--- a/files/ircclient-ssl.py
+++ /dev/null
@@ -1,173 +0,0 @@
-import twisted, sys, codecs, traceback
-from twisted.words.protocols import irc
-from twisted.internet import reactor, protocol, abstract, ssl
-from twisted.web import resource, server
-from twisted.protocols import basic
-from twisted.names.client import Resolver
-import hmac, time, config, random, qwebirc.config_options as config_options
-from config import HMACTEMPORAL
-
-if config.get("CONNECTION_RESOLVER"):
- CONNECTION_RESOLVER = Resolver(servers=config.get("CONNECTION_RESOLVER"))
-else:
- CONNECTION_RESOLVER = None
-
-if hasattr(config, "WEBIRC_MODE") and config.WEBIRC_MODE == "hmac":
- HMACKEY = hmac.HMAC(key=config.HMACKEY)
-
-def hmacfn(*args):
- h = HMACKEY.copy()
- h.update("%d %s" % (int(time.time() / HMACTEMPORAL), " ".join(args)))
- return h.hexdigest()
-
-def utf8_iso8859_1(data, table=dict((x, x.decode("iso-8859-1")) for x in map(chr, range(0, 256)))):
- return (table.get(data.object[data.start]), data.start+1)
-
-codecs.register_error("mixed-iso-8859-1", utf8_iso8859_1)
-
-def irc_decode(x):
- try:
- return x.decode("utf-8", "mixed-iso-8859-1")
- except UnicodeDecodeError:
- return x.decode("iso-8859-1", "ignore")
-
-class QWebIRCClient(basic.LineReceiver):
- delimiter = "\n"
- def __init__(self, *args, **kwargs):
- self.__nickname = "(unregistered)"
-
- def dataReceived(self, data):
- basic.LineReceiver.dataReceived(self, data.replace("\r", ""))
-
- def lineReceived(self, line):
- line = irc_decode(irc.lowDequote(line))
-
- try:
- prefix, command, params = irc.parsemsg(line)
- self.handleCommand(command, prefix, params)
- except irc.IRCBadMessage:
- # emit and ignore
- traceback.print_exc()
- return
-
- if command == "001":
- self.__nickname = params[0]
-
- if self.__perform is not None:
- for x in self.__perform:
- self.write(x)
- self.__perform = None
- elif command == "NICK":
- nick = prefix.split("!", 1)[0]
- if nick == self.__nickname:
- self.__nickname = params[0]
-
- def handleCommand(self, command, prefix, params):
- self("c", command, prefix, params)
-
- def __call__(self, *args):
- self.factory.publisher.event(args)
-
- def write(self, data):
- self.transport.write("%s\r\n" % irc.lowQuote(data.encode("utf-8")))
-
- def connectionMade(self):
- basic.LineReceiver.connectionMade(self)
-
- self.lastError = None
- f = self.factory.ircinit
- nick, ident, ip, realname, hostname, pass_ = f["nick"], f["ident"], f["ip"], f["realname"], f["hostname"], f.get("password")
- self.__nickname = nick
- self.__perform = f.get("perform")
-
- if not hasattr(config, "WEBIRC_MODE"):
- self.write("USER %s bleh bleh %s :%s" % (ident, ip, realname))
- elif config.WEBIRC_MODE == "hmac":
- hmac = hmacfn(ident, ip)
- self.write("USER %s bleh bleh %s %s :%s" % (ident, ip, hmac, realname))
- elif config.WEBIRC_MODE == "webirc":
- self.write("WEBIRC %s qwebirc %s %s" % (config.WEBIRC_PASSWORD, hostname, ip))
- self.write("USER %s bleh %s :%s" % (ident, ip, realname))
- elif config.WEBIRC_MODE == "cgiirc":
- self.write("PASS %s_%s_%s" % (config.CGIIRC_STRING, ip, hostname))
- self.write("USER %s bleh %s :%s" % (ident, ip, realname))
- elif config.WEBIRC_MODE == config_options.WEBIRC_REALNAME or config.WEBIRC_MODE is None: # last bit is legacy
- if ip == hostname:
- dispip = ip
- else:
- dispip = "%s/%s" % (hostname, ip)
-
- self.write("USER %s bleh bleh :%s - %s" % (ident, dispip, realname))
-
- if pass_ is not None:
- self.write("PASS :%s" % pass_)
- self.write("NICK %s" % nick)
-
- self.factory.client = self
- self("connect")
-
- def __str__(self):
- return "<QWebIRCClient: %s!%s@%s>" % (self.__nickname, self.factory.ircinit["ident"], self.factory.ircinit["ip"])
-
- def connectionLost(self, reason):
- if self.lastError:
- self.disconnect("Connection to IRC server lost: %s" % self.lastError)
- else:
- self.disconnect("Connection to IRC server lost.")
- self.factory.client = None
- basic.LineReceiver.connectionLost(self, reason)
-
- def error(self, message):
- self.lastError = message
- self.write("QUIT :qwebirc exception: %s" % message)
- self.transport.loseConnection()
-
- def disconnect(self, reason):
- self("disconnect", reason)
- self.factory.publisher.disconnect()
-
-class QWebIRCFactory(protocol.ClientFactory):
- protocol = QWebIRCClient
- def __init__(self, publisher, **kwargs):
- self.client = None
- self.publisher = publisher
- self.ircinit = kwargs
-
- def write(self, data):
- self.client.write(data)
-
- def error(self, reason):
- self.client.error(reason)
-
- def clientConnectionFailed(self, connector, reason):
- protocol.ClientFactory.clientConnectionFailed(self, connector, reason)
- self.publisher.event(["disconnect", "Connection to IRC server failed."])
- self.publisher.disconnect()
-
-def createIRC(*args, **kwargs):
- f = QWebIRCFactory(*args, **kwargs)
-
- tcpkwargs = {}
- if hasattr(config, "OUTGOING_IP"):
- tcpkwargs["bindAddress"] = (config.OUTGOING_IP, 0)
-
- if CONNECTION_RESOLVER is None:
- if hasattr(config, "SSLPORT"):
- reactor.connectSSL(config.IRCSERVER, config.SSLPORT, f, ssl.ClientContextFactory(), **tcpkwargs)
- else:
- reactor.connectTCP(config.IRCSERVER, config.IRCPORT, f, **tcpkwargs)
- return f
-
- def callback(result):
- name, port = random.choice(sorted((str(x.payload.target), x.payload.port) for x in result[0]))
- reactor.connectTCP(name, port, f, **tcpkwargs)
- def errback(err):
- f.clientConnectionFailed(None, err) # None?!
-
- d = CONNECTION_RESOLVER.lookupService(config.IRCSERVER, (1, 3, 11))
- d.addCallbacks(callback, errback)
- return f
-
-if __name__ == "__main__":
- e = createIRC(lambda x: 2, nick="slug__moo", ident="mooslug", ip="1.2.3.6", realname="mooooo", hostname="1.2.3.4")
- reactor.run()
diff --git a/files/qwebirc-ssl.patch b/files/qwebirc-ssl.patch
deleted file mode 100644
index 9c9e921..0000000
--- a/files/qwebirc-ssl.patch
+++ /dev/null
@@ -1,38 +0,0 @@
-diff -r 19d6068a1aa6 config.py.example
---- a/config.py.example Sun Apr 03 23:58:29 2011 +0100
-+++ b/config.py.example Sat Jan 28 13:31:49 2012 -0200
-@@ -20,6 +20,11 @@
- # Port of IRC server to connect to.
- IRCSERVER, IRCPORT = "irc.myserver.com", 6667
-
-+# OPTION: SSLPORT
-+# SSL port of IRC server to connect to.
-+# If this option is uncommented it will override IRCPORT.
-+#SSLPORT = 6697
-+
- # OPTION: REALNAME
- # The realname field of IRC clients will be set to this value.
- REALNAME = "http://moo.com/"
-diff -r 19d6068a1aa6 qwebirc/ircclient.py
---- a/qwebirc/ircclient.py Sun Apr 03 23:58:29 2011 +0100
-+++ b/qwebirc/ircclient.py Sat Jan 28 13:31:49 2012 -0200
-@@ -1,6 +1,6 @@
- import twisted, sys, codecs, traceback
- from twisted.words.protocols import irc
--from twisted.internet import reactor, protocol, abstract
-+from twisted.internet import reactor, protocol, abstract, ssl
- from twisted.web import resource, server
- from twisted.protocols import basic
- from twisted.names.client import Resolver
-@@ -152,7 +152,10 @@
- tcpkwargs["bindAddress"] = (config.OUTGOING_IP, 0)
-
- if CONNECTION_RESOLVER is None:
-- reactor.connectTCP(config.IRCSERVER, config.IRCPORT, f, **tcpkwargs)
-+ if hasattr(config, "SSLPORT"):
-+ reactor.connectSSL(config.IRCSERVER, config.SSLPORT, f, ssl.ClientContextFactory(), **tcpkwargs)
-+ else:
-+ reactor.connectTCP(config.IRCSERVER, config.IRCPORT, f, **tcpkwargs)
- return f
-
- def callback(result):
diff --git a/files/qwebirc-ssl.patch.orig b/files/qwebirc-ssl.patch.orig
deleted file mode 100644
index f0626f9..0000000
--- a/files/qwebirc-ssl.patch.orig
+++ /dev/null
@@ -1,38 +0,0 @@
-diff -r 19d6068a1aa6 config.py.example
---- a/config.py.example Sun Apr 03 23:58:29 2011 +0100
-+++ b/config.py.example Wed Oct 12 17:43:46 2011 -0400
-@@ -19,6 +19,11 @@
- # OPTION: IRCPORT
- # Port of IRC server to connect to.
- IRCSERVER, IRCPORT = "irc.myserver.com", 6667
-+
-+# OPTION: SSLPORT
-+# SSL port of IRC server to connect to.
-+# If this option is uncommented it will override IRCPORT.
-+#SSLPORT = 6697
-
- # OPTION: REALNAME
- # The realname field of IRC clients will be set to this value.
-diff -r 19d6068a1aa6 qwebirc/ircclient.py
---- a/qwebirc/ircclient.py Sun Apr 03 23:58:29 2011 +0100
-+++ b/qwebirc/ircclient.py Wed Oct 12 17:43:46 2011 -0400
-@@ -1,6 +1,6 @@
- import twisted, sys, codecs, traceback
- from twisted.words.protocols import irc
--from twisted.internet import reactor, protocol, abstract
-+from twisted.internet import reactor, protocol, abstract, ssl
- from twisted.web import resource, server
- from twisted.protocols import basic
- from twisted.names.client import Resolver
-@@ -152,7 +152,10 @@
- tcpkwargs["bindAddress"] = (config.OUTGOING_IP, 0)
-
- if CONNECTION_RESOLVER is None:
-- reactor.connectTCP(config.IRCSERVER, config.IRCPORT, f, **tcpkwargs)
-+ if hasattr(config, "SSLPORT"):
-+ reactor.connectSSL(config.IRCSERVER, config.SSLPORT, f, ssl.ClientContextFactory(), **tcpkwargs)
-+ else:
-+ reactor.connectTCP(config.IRCSERVER, config.IRCPORT, f, **tcpkwargs)
- return f
-
- def callback(result):
diff --git a/manifests/init.pp b/manifests/init.pp
index 78d82de..5c72eff 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -49,24 +49,6 @@ class qwebirc($ircserver = 'irc.myserver.com', $ircport = '6667', $realname = 'h
notify => Service['qwebirc'],
}
- # See http://hg.qwebirc.org/qwebirc/issue/152/ssl
- #file { '/var/lib/qwebirc/qwebirc/ircclient.py':
- # ensure => present,
- # owner => 'qwebirc',
- # group => 'qwebirc',
- # mode => 0640,
- # source => 'puppet:///modules/qwebirc/ircclient-ssl.py',
- # require => Vcsrepo['/var/lib/qwebirc'],
- # notify => Service['qwebirc'],
- #}
- #
- #exec { 'qwebirc-revert-ircclient.py':
- # command => 'hg revert qwebirc/ircclient.py'
- # cwd => '/var/lib/qwebirc',
- # user => 'qwebirc',
- # group => 'qwebirc',
- #}
-
exec { '/var/lib/qwebirc/compile.py':
cwd => '/var/lib/qwebirc',
creates => '/var/lib/qwebirc/.compiled',
@@ -83,8 +65,7 @@ class qwebirc($ircserver = 'irc.myserver.com', $ircport = '6667', $realname = 'h
hasrestart => true,
hasstatus => false,
pattern => 'python /var/lib/qwebirc/run.py',
- require => [ File['/etc/init.d/qwebirc', '/var/lib/qwebirc/config.py',
- '/var/lib/qwebirc/qwebirc/ircclient.py'],
+ require => [ File['/etc/init.d/qwebirc', '/var/lib/qwebirc/config.py' ],
Package['python-twisted'] ],
}
}