changeset 411:6e2114f8e942

fixed version, surge protection configuration, merged CHANGES imported from: moin--main--1.5--patch-415
author Thomas Waldmann <tw@waldmann-edv.de>
date Fri, 03 Feb 2006 19:53:23 +0000
parents 1a2bd0457cf3
children 481c432b3d11
files ChangeLog MoinMoin/multiconfig.py MoinMoin/request.py MoinMoin/version.py docs/CHANGES docs/CHANGES.refactor
diffstat 6 files changed, 103 insertions(+), 109 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Feb 03 19:15:18 2006 +0000
+++ b/ChangeLog	Fri Feb 03 19:53:23 2006 +0000
@@ -2,6 +2,24 @@
 # arch-tag: automatic-ChangeLog--arch@arch.thinkmo.de--2003-archives/moin--main--1.5
 #
 
+2006-02-03 20:53:23 GMT	Thomas Waldmann <tw@waldmann-edv.de>	patch-415
+
+    Summary:
+      fixed version, surge protection configuration, merged CHANGES
+    Revision:
+      moin--main--1.5--patch-415
+
+    fixed version, surge protection configuration, merged CHANGES
+    
+
+    removed files:
+     docs/.arch-ids/CHANGES.refactor.id docs/CHANGES.refactor
+
+    modified files:
+     ChangeLog MoinMoin/multiconfig.py MoinMoin/request.py
+     MoinMoin/version.py docs/CHANGES
+
+
 2006-02-03 20:15:18 GMT	Thomas Waldmann <tw@waldmann-edv.de>	patch-414
 
     Summary:
--- a/MoinMoin/multiconfig.py	Fri Feb 03 19:15:18 2006 +0000
+++ b/MoinMoin/multiconfig.py	Fri Feb 03 19:53:23 2006 +0000
@@ -297,6 +297,17 @@
     siteid = 'default'
     stylesheets = [] # list of tuples (media, csshref) to insert after theme css, before user css
     superuser = [] # list of unicode user names that have super powers :)
+    
+    surge_action_limits = { # allow max. <count> <action> requests per <dt> secs
+        # action: (count, dt)
+        'show': (20, 60),
+        'fullsearch': (5, 60),
+        'edit': (10, 120),
+        'rss_rc': (1, 20),
+        'default': (60, 60),
+    }
+    surge_lockout_time = 3600 # secs you get locked out when you ignore warnings
+    
     theme_default = 'modern'
     theme_force = False
     trail_size = 5
--- a/MoinMoin/request.py	Fri Feb 03 19:15:18 2006 +0000
+++ b/MoinMoin/request.py	Fri Feb 03 19:53:23 2006 +0000
@@ -75,63 +75,6 @@
     moin_location = 'x-moin-location'
     proxy_host = 'x-forwarded-host'
     
-    def surge_protect(self):
-        limits = { # action: (count, dt)
-            'show': (20, 60),
-            'fullsearch': (5, 60),
-            'edit': (10, 120),
-            'rss_rc': (1, 20),
-        }
-        lockout_time = 3600 # secs
-        
-        validuser = self.user.valid
-        current_id = validuser and self.user.name or self.remote_addr
-        current_action = self.form.get('action', ['show'])[0]
-        if not validuser and current_id.startswith('127.'): # localnet
-            return False
-        
-        now = int(time.time())
-        surgedict = {}
-        surge_detected = False
-        
-        try:
-            cache = caching.CacheEntry(self, 'surgeprotect', 'surge-log')
-            data = cache.content()
-            data = data.split("\n")
-            for line in data:
-                try:
-                    id, t, action, surge_indicator = line.split("\t")
-                    t = int(t)
-                    maxnum, dt = limits.get(action, (60, 60))
-                    if t >= now - dt:
-                        events = surgedict.setdefault(id, copy.copy({}))
-                        timestamps = events.setdefault(action, copy.copy([]))
-                        timestamps.append((t, surge_indicator))
-                except:
-                    pass
-        
-            maxnum, dt = limits.get(current_action, (60, 60))
-            events = surgedict.setdefault(current_id, copy.copy({}))
-            timestamps = events.setdefault(current_action, copy.copy([]))
-            surge_detected = len(timestamps) > maxnum
-            surge_indicator = surge_detected and "!" or ""
-            timestamps.append((now, surge_indicator))
-            if surge_detected:
-                if len(timestamps) < maxnum*2:
-                    timestamps.append((now + lockout_time, surge_indicator)) # continue like that and get locked out
-        
-            data = []
-            for id, events in surgedict.items():
-                for action, timestamps in events.items():
-                    for t, surge_indicator in timestamps:
-                        data.append("%s\t%d\t%s\t%s" % (id, t, action, surge_indicator))
-            data = "\n".join(data)
-            cache.update(data)
-        except:
-            pass
-
-        return surge_detected   
-        
     def __init__(self, properties={}):
         # Decode values collected by sub classes
         self.path_info = self.decodePagename(self.path_info)
@@ -223,6 +166,59 @@
             self.opened_logs = 0
             self.reset()
         
+    def surge_protect(self):
+        """ check if someone requesting too much from us """
+        validuser = self.user.valid
+        current_id = validuser and self.user.name or self.remote_addr
+        current_action = self.form.get('action', ['show'])[0]
+        if not validuser and current_id.startswith('127.'): # localnet
+            return False
+        
+        limits = self.cfg.surge_action_limits
+        default_limit = self.cfg.surge_action_limits.get('default', (60, 60))
+        
+        now = int(time.time())
+        surgedict = {}
+        surge_detected = False
+        
+        try:
+            cache = caching.CacheEntry(self, 'surgeprotect', 'surge-log')
+            data = cache.content()
+            data = data.split("\n")
+            for line in data:
+                try:
+                    id, t, action, surge_indicator = line.split("\t")
+                    t = int(t)
+                    maxnum, dt = limits.get(action, default_limit)
+                    if t >= now - dt:
+                        events = surgedict.setdefault(id, copy.copy({}))
+                        timestamps = events.setdefault(action, copy.copy([]))
+                        timestamps.append((t, surge_indicator))
+                except:
+                    pass
+        
+            maxnum, dt = limits.get(current_action, default_limit)
+            events = surgedict.setdefault(current_id, copy.copy({}))
+            timestamps = events.setdefault(current_action, copy.copy([]))
+            surge_detected = len(timestamps) > maxnum
+            surge_indicator = surge_detected and "!" or ""
+            timestamps.append((now, surge_indicator))
+            if surge_detected:
+                if len(timestamps) < maxnum*2:
+                    timestamps.append((now + self.cfg.surge_lockout_time, surge_indicator)) # continue like that and get locked out
+        
+            data = []
+            for id, events in surgedict.items():
+                for action, timestamps in events.items():
+                    for t, surge_indicator in timestamps:
+                        data.append("%s\t%d\t%s\t%s" % (id, t, action, surge_indicator))
+            data = "\n".join(data)
+            cache.update(data)
+        except:
+            pass
+
+        return surge_detected   
+        
     def getDicts(self):
         """ Lazy initialize the dicts on the first access """
         if self._dicts is None:
--- a/MoinMoin/version.py	Fri Feb 03 19:15:18 2006 +0000
+++ b/MoinMoin/version.py	Fri Feb 03 19:53:23 2006 +0000
@@ -13,7 +13,7 @@
     patchlevel = 'release'
 
 project = "MoinMoin"
-release  = '1.5.refactor'
+release  = '1.5.2pre'
 revision = patchlevel
 
 if __name__ == '__main__':
--- a/docs/CHANGES	Fri Feb 03 19:15:18 2006 +0000
+++ b/docs/CHANGES	Fri Feb 03 19:53:23 2006 +0000
@@ -7,11 +7,30 @@
     * added surge protection (TODO: configurability)
     * added "voyager" to bot useragent list
     * added locking for caching subsystem
+    * add new markup for bulletless lists: just use a "." instead of "*".
+    * deron meranda's formatter API cleanup
+    * added div and span to formatter API
+    * allow hex and symbolic entities
 
   Fixes:
    * fixed table attribute parsing
    * Fixed cookie handling wrt properties adherance.
-
+   * the new "." markup makes it possible to have a bulletless list with
+     elements on the same level. Before this change and only using indentation
+     with blanks, that would get merged into a single paragraph.
+   * it is possible now to have multiple paragraphs in the same list element
+   * fixed GAP processing for ordered lists
+   * fix text_gedit formatter's invalid list nesting
+   * fixed hr crash in blockquote (but needs more work)
+   * fixed FootNote's formatter usage
+   * fixed rst's headline levels
+   * fixed MoinMoinBugs/WikiParserThinksItIsInsidePreWhenItIsNot
+   * fixed MoinMoinBugs/ListItemGeneratedOutsideList
+   * fixed that macros were followed by a wrong <p>
+   * added <blockquote> to the block elements in the text_html formatter,
+     so it does not close it erratically when you close a inner <p>.
+   * GUI editor converter now also accept http: urls without // (relative or
+     same server urls)
 
 Version 1.5.1:
   Please completely read CHANGES text until you reach the version you were
--- a/docs/CHANGES.refactor	Fri Feb 03 19:15:18 2006 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-MoinMoin Version History
-========================
-
-Version moin--refactor--1.5:
-
-This was branched from moin--main--1.5--patch-399 (== release 1.5.1) to
-separately work on the following goals:
-
-  1. Make html output better (more valid).
-     Reduce problems the GUI editor converter has in 1.5.1.
-  2. Cleanup the formatter API
-
-While we are working on that goal, changes to moin--main--1.5 should be reduced
-to a minimum (security, critical bugs), due to following reasons:
-  * concentrate on goal (see above),
-    thus do not spend time on other features, neither here nor in "main" branch
-  * finish as soon as possible,
-    thus make merging "refactor" branch back to "main" branch easier
-
-Also please keep changes here as small as possible to reach the goal.
-Do not extend the goal without discussion and good reason.
-
-Please use THIS file for "refactor" branch CHANGES entries only, so we can
-easily integrate it when we merge back to "main".
-
-  Fixes:
-    * the new "." markup makes it possible to have a bulletless list with
-      elements on the same level. Before this change and only using indentation
-      with blanks, that would get merged into a single paragraph.
-    * it is possible now to have multiple paragraphs in the same list element
-    * fixed GAP processing for ordered lists
-    * fix text_gedit formatter's invalid list nesting
-    * fixed hr crash in blockquote (but needs more work)
-    * fixed FootNote's formatter usage
-    * fixed rst's headline levels
-    * fixed MoinMoinBugs/WikiParserThinksItIsInsidePreWhenItIsNot
-    * fixed MoinMoinBugs/ListItemGeneratedOutsideList
-    * fixed that macros were followed by a wrong <p>
-    * added <blockquote> to the block elements in the text_html formatter,
-      so it does not close it erratically when you close a inner <p>.
-    * GUI editor converter now also accept http: urls without // (relative or
-      same server urls)
-
-  Other changes:
-    * add new markup for bulletless lists: just use a "." instead of "*".
-    * deron meranda's formatter API cleanup
-    * added div and span to formatter API
-    * allow hex and symbolic entities
-
-