]> www.vanbest.org Git - motioneye-debian/commitdiff
implemented image request flooding protection
authorCalin Crisan <ccrisan@gmail.com>
Sat, 23 Nov 2013 08:39:20 +0000 (10:39 +0200)
committerCalin Crisan <ccrisan@gmail.com>
Sat, 23 Nov 2013 08:39:20 +0000 (10:39 +0200)
README.md
raspicam/motion
static/js/main.js

index 6fa566d0645a0c2f401e90c44b6a9c4f2f97307a..a958d308eab3e4b30160e02fafb3b73a38a4c327 100644 (file)
--- a/README.md
+++ b/README.md
  * PIL
  * motion
  * ffmpeg
- * v4l2-utils
+ * v4l-utils
 
 On a debian-based system you could run:
 
-    apt-get install python-tornado python-jinja2 python-imaging motion ffmpeg v4l2-utils
+    apt-get install python-tornado python-jinja2 python-imaging motion ffmpeg v4l-utils
 
 ## Browser Compatibility ##
 
index de315557e16bd4734eace8c7a68f14cd7ef1d832..ef210460e6b245fcf516a93a4c246789fa42c340 100755 (executable)
@@ -6,6 +6,16 @@
 MOTION_BIN=/usr/bin/motion
 UV4L_BIN=/usr/bin/uv4l
 JPEG_QUALITY=85
+ARGS="$*"
+
+function config_full_path() {
+    dir="$1"
+    read file
+    if [ "${file:0:1}" != "/" ]; then
+        file="$dir/$file"
+    fi
+    echo "$file"
+}
 
 function list_config_files() {
     prev_arg=""
@@ -20,7 +30,7 @@ function list_config_files() {
 
     if [ -r "$config_file" ];then
         echo "$config_file"
-        cat motion.conf | grep thread | cut -d ' ' -f 2
+        cat motion.conf | grep thread | cut -d ' ' -f 2 | config_full_path $(dirname "$config_file")
     fi
 }
 
@@ -32,6 +42,9 @@ function find_resolution() {
         w=$(cat "$file" | grep width | cut -d ' ' -f 2)
         h=$(cat "$file" | grep height | cut -d ' ' -f 2)
         if [ -n "$w" ] && [ -n "$h" ]; then
+            width=$w
+            height=$h
+
             break
         fi
     done
@@ -50,3 +63,4 @@ ${UV4L_BIN} --driver raspicam --auto-video_nr --extension-presence 1 --sched-rr
 # start motion binary with preloaded .so
 export LD_PRELOAD=/usr/lib/uv4l/uv4lext/armv6l/libuv4lext.so
 exec ${MOTION_BIN} $*
+
index 23b8fcd19bf5f53d2553fb3ee1e1176e7eac7257..438c55ea44051ab0dceb7b6003c3cb4e1e97e7ba 100644 (file)
@@ -1657,12 +1657,16 @@ function addCameraFrameUi(cameraId, cameraName, framerate) {
     /* error and load handlers */
     cameraImg.error(function () {
         this.error = true;
+        this.loading = false;
+        
         cameraImg.addClass('error');
         cameraImg.height(Math.round(cameraImg.width() * 0.75));
         cameraPlaceholder.css('opacity', 1);
     });
     cameraImg.load(function () {
         this.error = false;
+        this.loading = false;
+        
         cameraImg.removeClass('error');
         cameraImg.css('height', '');
         cameraPlaceholder.css('opacity', 0);
@@ -1829,12 +1833,17 @@ function refreshCameraFrames() {
     }
     
     function refreshCameraFrame(cameraId, img, fast) {
+        if (img.loading) {
+            return; /* still loading the previous image */
+        }
+        
         var timestamp = new Date().getTime();
         if (!fast) {
             timestamp /= 500;
         }
         timestamp = Math.round(timestamp);
         img.src = '/picture/' + cameraId + '/current/?_=' + timestamp;
+        img.loading = true;
     }
     
     var cameraFrames;