提交 0b417d16 编辑于 作者: yuudi's avatar yuudi
浏览文件

fix: solve user-list blocking

上级 9eec0df9
{
"stable": {
"version": 3502,
"url": "http://download.yobot.win/yobot/yobot3502.zip"
"version": 3505,
"url": "http://download.yobot.win/yobot/yobot3505.zip"
}
}
\ No newline at end of file
......@@ -8,7 +8,7 @@
如果坚持在本地计算机运行,也可以使用内网穿透(不建议新手使用)
### 方法 1:直接连接
### 方法 1:直接连接(最简单)
在 yobot [配置文件](./configuration.md)中,将`host`字段恢复为`0.0.0.0`(即默认值,如果没有手动修改过就不用管)
......@@ -30,8 +30,6 @@ e.g. `http://10.10.10.10:9222/yobot/`
### 方法 2:使用 Nginx 代理(功能最强)
Windows 用户可以使用配置好的[Nginx 预配置包](./windows-nginx-package.md)
如果需要为网页添加日志记录、HTTPS支持、安全限制等,或者需要同时部署其他站点,可以使用 Nginx、Apache 之类的服务器软件
请根据服务器实际情况设定 Nginx 代理,这里给出一个示例,**不要直接复制**,如果不懂请用工具生成或请熟悉的人代劳
......@@ -42,11 +40,12 @@ Nginx 代理配置后,在机器人配置文件中`public_address`项替换为
server {
listen 80;
listen [::]:80;
listen 443 ssl http2;
listen [::]:443 ssl http2;
ssl_certificate /home/www/ssl/ssl_certificate.crt; # 你的证书路径
ssl_certificate_key /home/www/ssl/ssl_certificate.key; # 你的私钥路径
## 使用 https 加密通信,增加安全性(可选)
# listen 443 ssl http2;
# listen [::]:443 ssl http2;
# ssl_certificate /home/www/ssl/ssl_certificate.crt; # 你的证书路径
# ssl_certificate_key /home/www/ssl/ssl_certificate.key; # 你的私钥路径
server_name io.yobot.xyz; # 你的域名
......@@ -56,11 +55,6 @@ server {
proxy_set_header X-Real-IP $remote_addr; # 传递用户IP
}
## 强制使用https加密通信(可选,安全)
#if ($server_port != 443){
# return 301 https://$host$request_uri;
#}
## 静态文件直接访问(可选,性能)
#location /yobot/assets/ {
# alias /home/yobot/src/client/public/static/; # 你的静态文件目录,如果你修改了`public_basepath`,请同时修改这里的`location`
......
# -*- mode: python ; coding: utf-8 -*-
"""
打包文件说明(一般不建议对 python 项目打包)
pip 安装 `pyinstaller` 后,使用 `pyinstaller main.spec`,对项目打包。
"""
import os
import site
sitepackages = site.getsitepackages()
def sitepackages_location(package_name):
for sp in sitepackages:
if os.path.exists(os.path.join(sp,package_name)):
if os.path.exists(os.path.join(sp, package_name)):
return sp
raise RuntimeError(f"{package_name} not found")
block_cipher = None
......
import asyncio
import json
import os
from urllib.parse import urljoin
from playhouse.shortcuts import model_to_dict
from quart import Quart, jsonify, redirect, request, session, url_for
from .templating import render_template
from .ybdata import User, Clan_group
from .ybdata import Clan_group, User
class Setting:
......@@ -27,7 +29,7 @@ class Setting:
async def yobot_setting():
if 'yobot_user' not in session:
return redirect(url_for('yobot_login', callback=request.path))
user=User.get_by_id(session['yobot_user'])
user = User.get_by_id(session['yobot_user'])
if user.authority_group >= 10:
if not user.authority_group >= 100:
uathname = '公会战管理员'
......@@ -208,19 +210,27 @@ class Setting:
)
action = req['action']
if action == 'get_data':
users = []
for user in User.select().where(
User.deleted == False,
):
users.append({
'qqid': user.qqid,
'nickname': user.nickname,
'clan_group_id': user.clan_group_id,
'authority_group': user.authority_group,
'last_login_time': user.last_login_time,
'last_login_ipaddr': user.last_login_ipaddr,
# 暂时先用 run_in_executor 防止阻塞,稍后再改成分页
def _get_all_users():
users = User.select(
User.qqid,
User.nickname,
User.clan_group_id,
User.authority_group,
User.last_login_time,
User.last_login_ipaddr,
).where(
User.deleted == False,
)
return json.dumps({
'code': 0,
'data': [model_to_dict(u) for u in users],
})
return jsonify(code=0, data=users)
return await asyncio.get_running_loop().run_in_executor(
None,
_get_all_users,
)
elif action == 'modify_user':
data = req['data']
m_user: User = User.get_or_none(qqid=data['qqid'])
......
......@@ -33,8 +33,8 @@ else:
class Yobot:
Version = "[v3.6.4-beta.2]"
Version_id = 204
Version = "[v3.6.4-beta.3]"
Version_id = 205
# "git rev-list --count HEAD"
def __init__(self, *,
......@@ -100,8 +100,8 @@ class Yobot:
# initialize web path
if not self.glo_setting.get("public_address"):
try:
res = requests.get("http://ip-api.com/json/?fields=8192")
ipaddr = res.json()["query"]
res = requests.get("http://api.ipify.org/")
ipaddr = res.text
except:
with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as s:
s.connect(("8.8.8.8", 53))
......
Supports Markdown
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册