]> jfr.im git - irc/quakenet/qwebirc.git/commitdiff
Add a new ident mode that passses in the nickname, and tidy up config file to get...
authorChris Porter <redacted>
Mon, 22 Jun 2009 01:36:26 +0000 (02:36 +0100)
committerChris Porter <redacted>
Mon, 22 Jun 2009 01:36:26 +0000 (02:36 +0100)
config.py.example
qwebirc/__init__.py
qwebirc/config_options.py [new file with mode: 0644]
qwebirc/engines/ajaxengine.py
qwebirc/ircclient.py
twisted/plugins/webirc.py

index e8c9a7beec0a1635db5c07a7d6088413c5fb1826..929bfa48eeacf40b16ac93fd4ac40f158a2473ff 100644 (file)
@@ -8,6 +8,9 @@
 # both!)
 # If in doubt always re-compile and restart.
 
+# The following line is required, don't remove it!
+from qwebirc.config_options import *
+
 # IRC OPTIONS
 # ---------------------------------------------------------------------
 #
@@ -22,9 +25,13 @@ IRCSERVER, IRCPORT = "irc.myserver.com", 6667
 REALNAME = "http://moo.com/"
 
 # OPTION: IDENT
-#        ident to use on irc, set to the literal value None to use a
-#        hexadecimal version of the IP address, e.g.:
-#        IDENT = None
+#        ident to use on irc, possible values include:
+#        - a string, e.g. IDENT = "webchat"
+#        - the literal value IDENT_HEX, this will set the ident to the
+#          a hexadecimal version of the users IP address, e.g
+#          IDENT = HEX_IDENT
+#        - the literal value IDENT_NICKNAME, this will use the users
+#          supplied nickname as their ident.
 IDENT = "webchat"
 
 # OPTION: WEBIRC_MODE
index 6e27e2a010c6a98839786a4ed3174f9641841c79..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1 +0,0 @@
-from root import RootSite
diff --git a/qwebirc/config_options.py b/qwebirc/config_options.py
new file mode 100644 (file)
index 0000000..8e3a662
--- /dev/null
@@ -0,0 +1,3 @@
+IDENT_HEX = object()\r
+IDENT_NICKNAME = object()\r
+WEBIRC_REALNAME = object()
\ No newline at end of file
index 0212e5a7f736d0212f6f23bda5add2cbd7f87530..0bf340465917b3a756d9dcfaf48caccae1ed3199 100644 (file)
@@ -2,7 +2,7 @@ from twisted.web import resource, server, static, error as http_error
 from twisted.names import client
 from twisted.internet import reactor, error
 from authgateengine import login_optional, getSessionData
-import simplejson, md5, sys, os, time, config, weakref, traceback, socket
+import simplejson, md5, sys, os, time, config, qwebirc.config_options as config_options, traceback, socket
 import qwebirc.ircclient as ircclient
 from adminengine import AdminEngineAction
 from qwebirc.util import HitCounter
@@ -208,8 +208,10 @@ class AJAXEngine(resource.Resource):
       perform = ["PRIVMSG %s :TICKETAUTH %s" % (msg_mask, qticket)]
 
     ident, realname = config.IDENT, config.REALNAME
-    if ident is None:
+    if ident is config_options.IDENT_HEX or ident is None: # latter is legacy
       ident = socket.inet_aton(ip).encode("hex")
+    elif ident is config_options.IDENT_NICKNAME:
+      ident = nick
 
     self.__connect_hit()
 
@@ -217,7 +219,9 @@ class AJAXEngine(resource.Resource):
       client = ircclient.createIRC(session, nick=nick, ident=ident, ip=ip, realname=realname, perform=perform, hostname=hostname)
       session.client = client
 
-    if config.WEBIRC_MODE != "hmac":
+    if not hasattr(config, "WEBIRC_MODE") or config.WEBIRC_MODE == "hmac":
+      proceed(None)
+    elif config.WEBIRC_MODE != "hmac":
       notice = lambda x: session.event(connect_notice(x))
       notice("Looking up your hostname...")
       def callback(hostname):
@@ -227,8 +231,6 @@ class AJAXEngine(resource.Resource):
         notice("Couldn't look up your hostname!")
         proceed(ip)
       qdns.lookupAndVerifyPTR(ip, timeout=[config.DNS_TIMEOUT]).addCallbacks(callback, errback)
-    else:
-      proceed(None) # hmac doesn't care
 
     Sessions[id] = session
     
index 8b9b3e59ef0731e586ebd93ee514ac7dccb28eb1..e473eccd889c5cced736b3e866d4122ca145c4f3 100644 (file)
@@ -4,10 +4,10 @@ from twisted.internet import reactor, protocol
 from twisted.web import resource, server
 from twisted.protocols import basic
 
-import hmac, time, config
+import hmac, time, config, qwebirc.config_options as config_options
 from config import HMACTEMPORAL
 
-if config.WEBIRC_MODE == "hmac":
+if hasattr(config, "WEBIRC_MODE") and config.WEBIRC_MODE == "hmac":
   HMACKEY = hmac.HMAC(key=config.HMACKEY)
 
 def hmacfn(*args):
@@ -75,7 +75,9 @@ class QWebIRCClient(basic.LineReceiver):
     self.__nickname = nick
     self.__perform = f.get("perform")
 
-    if config.WEBIRC_MODE == "hmac":
+    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":
@@ -84,7 +86,7 @@ class QWebIRCClient(basic.LineReceiver):
     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))
-    else:
+    elif config.WEBIRC_MODE == config_options.WEBIRC_REALNAME or config.WEBIRC_MODE is None: # last bit is legacy
       if ip == hostname:
         dispip = ip
       else:
index 5c50d605b59233d2c4ef874cf2460f0afa3f2c3d..d75c2836839526f8250945f3bde92627f079d714 100644 (file)
@@ -7,7 +7,7 @@ from twisted.application.service import IServiceMaker
 from twisted.application import internet, strports
 from twisted.web import static, server
 
-from qwebirc import RootSite
+from qwebirc.root import RootSite
 
 class Options(usage.Options):
   optParameters = [["port", "p", "9090","Port to start the server on."],