Skip to content

Commit

Permalink
L78 2024-02-13-14:27
Browse files Browse the repository at this point in the history
  • Loading branch information
ludgerh committed Feb 13, 2024
1 parent bc95f51 commit 90ff6c6
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 22 deletions.
Binary file added camai/static/camai/nogit.zip
Binary file not shown.
18 changes: 16 additions & 2 deletions streams/c_camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,11 @@ def logger_init(logger):
init_log(logger)

def sortfunc(myinput):
return(myinput['address']['ip'])
return(ip_address(myinput['address']['ip']))

class search_executor(ThreadPoolExecutor):
def __init__(self, net, ip, ports, url, uname='', upass='', *args, **kwargs):
self.thread_count = 0
super().__init__(*args, **kwargs)
self.net = net
self.ip = ip
Expand All @@ -88,17 +89,28 @@ def __init__(self, net, ip, ports, url, uname='', upass='', *args, **kwargs):
if str(item) != self.ip:
f = self.submit(self.scan_one, item)
f.add_done_callback(self.callback)
#print('***** Shutdown')
self.shutdown()
#print('***** Shutdown done')
#>>> Probably not necessary, shutdown waits for callbacks
while True:
sleep(1.0)
count = self.thread_count
if not count:
break
#>>>
#print('***** Done')
self.all_results.sort(key = sortfunc)


def scan_one(self, my_ip):
self.thread_count += 1
my_ip = str(my_ip)
result = {}
socketdict = {}
for port in self.ports:
socketdict[port] = socket(AF_INET, SOCK_STREAM)
socketdict[port].settimeout(0.1)
socketdict[port].settimeout(1.0)
try:
socketdict[port].connect((my_ip, port))
socketdict[port].close()
Expand Down Expand Up @@ -224,6 +236,8 @@ def callback(self, f):
except:
pass
self.all_results.append(myresult)
self.thread_count -= 1
#print('***** Callback finished: ', self.thread_count)

class ptz_base():

Expand Down
43 changes: 23 additions & 20 deletions tools/templates/tools/scan_cams.html
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
{# Copyright (C) 2023 by the CAM-AI authors, info@cam-ai.de #}
{# More information and complete source: https://github.com/ludgerh/cam-ai #}
{# This program is free software; you can redistribute it and/or #}
{# modify it under the terms of the GNU General Public License #}
{# as published by the Free Software Foundation; either version 3 #}
{# of the License, or (at your option) any later version. #}
{# This program is distributed in the hope that it will be useful, #}
{# but WITHOUT ANY WARRANTY; without even the implied warranty of #}
{# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. #}
{# See the GNU General Public License for more details. #}
{# You should have received a copy of the GNU General Public License #}
{# along with this program; if not, write to the Free Software #}
{# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #}

{% extends 'main/basis.html' %}
{% comment %}
Copyright (C) 2024 by the CAM-AI team, info@cam-ai.de
More information and complete source: https://github.com/ludgerh/cam-ai
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 3
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
{% endcomment %}
{% block content %}
{% if mayadd %}
{% if emulatestatic %}
Expand Down Expand Up @@ -53,33 +54,33 @@
{% endif %}
</div>
</div>
<div class="h2 m-2">IPs scanned:</div>
<div class="h2 m-2">Ports scanned:</div>
<div class="form-check h2 m-2">
<input class="me-3 bool" type="checkbox" value="" id="checkbox80" port="80">
<input class="me-3 form-check-input bool" type="checkbox" value="" id="checkbox80" port="80">
<label class="form-check-label" for="flexCheckDefault">
80 (HTML, ISAPI, ONVIF)
</label>
</div>
<div class="form-check h2 m-2">
<input class="me-3 bool" type="checkbox" value="" id="checkbox443" port="443">
<input class="me-3 form-check-input bool" type="checkbox" value="" id="checkbox443" port="443">
<label class="form-check-label" for="flexCheckDefault">
443 (HTTPS)
</label>
</div>
<div class="form-check h2 m-2">
<input class="me-3 bool" type="checkbox" value="" id="checkbox554" port="554">
<input class="me-3 form-check-input bool" type="checkbox" value="" id="checkbox554" port="554">
<label class="form-check-label" for="flexCheckDefault">
554 (RTSP)
</label>
</div>
<div class="form-check h2 m-2">
<input class="me-3 bool" type="checkbox" value="" id="checkbox1935" port="1935">
<input class="me-3 form-check-input bool" type="checkbox" value="" id="checkbox1935" port="1935">
<label class="form-check-label" for="flexCheckDefault">
1935 (RTMP)
</label>
</div>
<div class="form-check h2 m-2">
<input class="me-3 bool" type="checkbox" value="" id="checkbox8000" port="8000">
<input class="me-3 form-check-input bool" type="checkbox" value="" id="checkbox8000" port="8000">
<label class="form-check-label" for="flexCheckDefault">
8000 (HTML, ONVIF)
</label>
Expand Down Expand Up @@ -122,11 +123,13 @@
}));
})
.then((result) => {
console.log(result);
mynetwork = result.mynet;
myip = result.myip;
$('#network').text(result.mynet);
$('#ipaddress').text(result.myip);
$('.form-check-input').each(function( index ) {
console.log(ports, parseInt($(this).attr('port')));
if (ports.includes(parseInt($(this).attr('port')))) {
$(this).prop("checked",true);
} else {
Expand Down

0 comments on commit 90ff6c6

Please sign in to comment.