]> www.vanbest.org Git - motioneye-debian/commitdiff
rtsp network cameras: added support for basic authentication
authorCalin Crisan <ccrisan@gmail.com>
Sat, 2 Jul 2016 09:31:53 +0000 (12:31 +0300)
committerCalin Crisan <ccrisan@gmail.com>
Sat, 2 Jul 2016 09:31:53 +0000 (12:31 +0300)
motioneye/templates/main.html
motioneye/utils.py

index a920f3d784d48adaebe67cf7498440bf4d8f3cb1..19c7d431662463d4f21c241aa576f9cad02be108 100644 (file)
                                 <option value="digest">Digest</option>
                             </select>
                         </td>
-                        <td><span class="help-mark" title="the authentication mode to use when accessing the stream (use Basic instead of Digest if you encounter issues with third party apps)">?</span></td>
+                        <td><span class="help-mark" title="the authentication method used by the stream (choose Basic instead of Digest if you encounter issues with third party apps); surveillance credentials will be used">?</span></td>
                     </tr>
                     {% endif %}
                     <tr class="settings-item advanced-setting">
index bb7b995920f268f74e0343b0ec5f5d50c1341dc4..36ffbb0aa97be32c4820bd11b7263f2481470c45 100644 (file)
@@ -473,13 +473,22 @@ def test_rtsp_url(data, callback):
 
         logging.debug('connected to rtsp netcam')
         
-        stream.write('\r\n'.join([
+        lines = [
             'OPTIONS %s RTSP/1.0' % url.encode('utf8'),
             'CSeq: 1',
-            'User-Agent: motionEye',
+            'User-Agent: motionEye'
+        ]
+        
+        if data['username']:
+            auth_header = 'Authorization: ' + build_basic_header(data['username'], data['password'])
+            lines.append(auth_header)
+
+        lines += [
             '',
             ''
-        ]))
+        ]
+
+        stream.write('\r\n'.join(lines))
 
         seek_rtsp()
         
@@ -497,6 +506,9 @@ def test_rtsp_url(data, callback):
             if data.endswith('200 '):
                 seek_server()
     
+            elif data.endswith('401 '):
+                handle_error('authentication failed')
+
             else:
                 handle_error('rtsp netcam returned erroneous response: %s' % data)