diff --git a/dockerfile b/dockerfile index abd5ba62c5e1b79a2d4a86c055ec7929599263c1..d9cb5fba63ec13e0a1256ef90408ea8380d77a6b 100644 --- a/dockerfile +++ b/dockerfile @@ -56,7 +56,7 @@ EXPOSE 5705 9001 # docker build -f dockerfile -t hjdhnx/drpy_mini . 构建命令,非此文件内命令 # docker push hjdhnx/drpy_mini # docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -f dockerfile -t hjdhnx/drpy:mini_arm64 . -# docker buildx build --platform linux/arm/v7 -f dockerfile -t hjdhnx/drpy_mini:armv7 . +# docker buildx build --platform linux/arm/v7 -f dockerfile -t hjdhnx/drpy:armv7 . # docker buildx build --platform linux/arm/v7 -f dockerfile -t hjdhnx/drpy:armv7 --push . # 启动命令,非此文件内命令 # docker run -it -p 5705:5705 -p 9001:9001 -v /home/pywork/dr_py:/root/sd/pywork/dr_py --restart=always --name drpy -d hjdhnx/drpy:mini diff --git a/dockerfile_arm64.txt b/dockerfile_arm64.txt index b958177bc20430c0f4d373d2bf3a81fbed46c4ad..4499204a22cc946bf97593e91cb3f875ad672f3d 100644 --- a/dockerfile_arm64.txt +++ b/dockerfile_arm64.txt @@ -29,9 +29,11 @@ ADD sources.list /etc/apt/ ADD app.sh /etc/autostart/ # RUN sed -i s@/archive.ubuntu.com/@/mirrors.aliyun.com/@g /etc/apt/sources.list -# armv7安装gcc -# RUN apt-get install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf -y RUN chmod +x /etc/autostart/app.sh && apt-get clean && apt-get update +# arm64安装gcc +# RUN apt-get install gcc-9-aarch64-linux-gnu gcc-aarch64-linux-gnu -y +RUN apt install build-essential -y + # 执行指令,换源并安装依赖 设置默认pip源 RUN pip install -i https://mirrors.cloud.tencent.com/pypi/simple --upgrade pip \ && pip config set global.index-url https://mirrors.cloud.tencent.com/pypi/simple @@ -56,7 +58,7 @@ EXPOSE 5705 9001 # docker push hjdhnx/drpy_mini # docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -f dockerfile -t hjdhnx/drpy:mini_arm64 . # docker buildx build --platform linux/arm64 -f dockerfile -t hjdhnx/drpy_mini:armv7 . -# docker buildx build --platform linux/arm64 -f dockerfile_arm64.txt -t hjdhnx/drpy_mini:arm64 . +# docker buildx build --platform linux/arm64 -f dockerfile_arm64.txt -t hjdhnx/drpy:arm64 . # docker buildx build --platform linux/arm64 -f dockerfile_arm64.txt -t hjdhnx/drpy:arm64 --push . # 启动命令,非此文件内命令 # docker run -it -p 5705:5705 -p 9001:9001 -v /home/pywork/dr_py:/root/sd/pywork/dr_py --restart=always --name drpy -d hjdhnx/drpy:mini diff --git a/readme.md b/readme.md index 2e78280ab0b896db6ce7f84ef9d4b2918fa098c9..2ea3a14e77b4d090c9574a21e4e4d9fe9eb8aabd 100644 --- a/readme.md +++ b/readme.md @@ -41,6 +41,8 @@ [参考T4](https://github.com/sec-an/TV_Spider/blob/main/spider/sp360.py) [golang最好的js引擎-otto](https://github.com/robertkrimen/otto) [dockerfile教程](https://blog.csdn.net/qq_46158060/article/details/125718218) +[获取本地设备信息](https://blog.csdn.net/cui_yonghua/article/details/125508991) +[获取本地设备信息](https://m.jb51.net/article/140716.htm) ###### 2022/09/04 - [X] 1.增加了dockerfile diff --git a/requirements.txt b/requirements.txt index 21fcf78b48c7e284d2f52545f3d50474e72ee0ed..287795ae806b2f20b705f008e2586ca6e41dee40 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,7 +4,8 @@ flask flask_migrate flask-sqlalchemy requests -netifaces +psutil +# netifaces # gevent==1.1.2 ; sys_platform != 'win32' and python_version < '3.7' # gevent==1.3.4 ; sys_platform != 'win32' and python_version >= '3.7' and python_version < '3.9' # gevent==21.12.0 ; sys_platform == 'win32' diff --git a/utils/web.py b/utils/web.py index 232595d2322fc8d4bc181b3211ec9b846bb8ed11..cd1ad85bec19f8d24837bbd7c74a779d2003665e 100644 --- a/utils/web.py +++ b/utils/web.py @@ -7,7 +7,7 @@ import socket import hashlib from werkzeug.utils import import_string -from netifaces import interfaces, ifaddresses, AF_INET +import psutil from flask import request from utils.log import logger MOBILE_UA = 'Mozilla/5.0 (Linux; Android 11; M2007J3SC Build/RKQ1.200826.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045714 Mobile Safari/537.36' @@ -31,7 +31,8 @@ def get_host_ip2(): # 获取局域网ip s.close() return ip -def get_host_ip(): # 获取局域网ip +def get_host_ip_old(): # 获取局域网ip + from netifaces import interfaces, ifaddresses, AF_INET ips = [] for ifaceName in interfaces(): addresses = ''.join([i['addr'] for i in ifaddresses(ifaceName).setdefault(AF_INET, [{'addr': ''}])]) @@ -41,6 +42,21 @@ def get_host_ip(): # 获取局域网ip jyw = list(filter(lambda x:str(x).startswith('192.168'),real_ips)) return real_ips[-1] if len(jyw) < 1 else jyw[0] +def get_host_ip(): # 获取局域网ip + info = psutil.net_if_addrs() + # print(info) + netcard_info = [] + ips = [] + for k, v in info.items(): + for item in v: + if item[0] == 2: + netcard_info.append((k, item[1])) + ips.append(item[1]) + print(netcard_info) + real_ips = list(filter(lambda x: x and x != '127.0.0.1', ips)) + jyw = list(filter(lambda x: str(x).startswith('192.168'), real_ips)) + return real_ips[-1] if len(jyw) < 1 else jyw[0] + def getHost(mode=0,port=None): port = port or request.environ.get('SERVER_PORT') # hostname = socket.gethostname()