change code structure and github-linguist
28
.gitattributes
vendored
@@ -1,18 +1,18 @@
|
||||
worker/public/css/** linguist-vendored
|
||||
worker/public/fonts/* linguist-vendored
|
||||
worker/public/img/* linguist-vendored
|
||||
worker/public/js/* linguist-vendored
|
||||
worker/public/js/search.js -linguist-vendored
|
||||
worker/public/404.html linguist-vendored
|
||||
worker/public/resource.html linguist-vendored
|
||||
tools/worker/public/css/** linguist-vendored
|
||||
tools/worker/public/fonts/* linguist-vendored
|
||||
tools/worker/public/img/* linguist-vendored
|
||||
tools/worker/public/js/* linguist-vendored
|
||||
tools/worker/public/js/search.js -linguist-vendored
|
||||
tools/worker/public/404.html linguist-vendored
|
||||
tools/worker/public/resource.html linguist-vendored
|
||||
|
||||
web/css/** linguist-vendored
|
||||
web/fonts/* linguist-vendored
|
||||
web/img/* linguist-vendored
|
||||
web/js/* linguist-vendored
|
||||
web/404.html linguist-vendored
|
||||
web/resource.html linguist-vendored
|
||||
yyetsweb/css/** linguist-vendored
|
||||
yyetsweb/fonts/* linguist-vendored
|
||||
yyetsweb/img/* linguist-vendored
|
||||
yyetsweb/js/* linguist-vendored
|
||||
yyetsweb/404.html linguist-vendored
|
||||
yyetsweb/resource.html linguist-vendored
|
||||
|
||||
web/js/common.js -linguist-vendored
|
||||
yyetsweb/js/common.js -linguist-vendored
|
||||
|
||||
tests/data/* linguist-vendored
|
||||
|
||||
6
.gitignore
vendored
@@ -115,7 +115,7 @@ venv.bak/
|
||||
yyetsbot/data/
|
||||
health_check/client.session
|
||||
|
||||
/worker/.idea/
|
||||
/worker/workers-site/node_modules/*
|
||||
/worker/workers-site/worker/script.js
|
||||
/tools/worker/.idea/
|
||||
/tools/worker/workers-site/node_modules/*
|
||||
/tools/worker/workers-site/worker/script.js
|
||||
/health_check/client-hc.session
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* 参见 [这里](https://github.com/tgbot-collection/BotsRunner)
|
||||
* 本目录下的 `docker-compose.yml` 也可以作为参考
|
||||
* nginx reverse proxy可以[参考这里](https://github.com/BennyThink/WebsiteRunner)
|
||||
* [参考这里获取数据库](web/README.md)
|
||||
* [参考这里获取数据库](yyetsweb/README.md)
|
||||
|
||||
```shell
|
||||
# 启动数据库
|
||||
@@ -93,11 +93,7 @@ python /path/to/YYeTsBot/yyetsbot/bot.py
|
||||
|
||||
网站使用referer验证请求
|
||||
|
||||
### 2. 加密headers
|
||||
|
||||
使用headers `ne1` 进行加密验证,详细信息可以[参考这里](https://t.me/mikuri520/726)
|
||||
|
||||
### 3. rate limit
|
||||
### 2. rate limit
|
||||
|
||||
404的访问会被计数,超过10次会被拉入黑名单,持续3600秒,再次访问会持续叠加。
|
||||
|
||||
@@ -162,7 +158,7 @@ API 返回字符串,形如 `data:image/png;base64,iVBORw0KGgoAAA....`
|
||||
POST `/api/comments`
|
||||
只有登录用户才可以发表评论,检查cookie `username` 是否为空来判断是否为登录用户;未登录用户提示“请登录后发表评论”
|
||||
|
||||
body `resource_id` 从URL中获取,id是上一步验证码的那个id, `captcha` 是用户输入的验证码
|
||||
body `resource_id` 从URL中获取,id是上一步验证码的那个随机字符串id, `captcha` 是用户输入的验证码
|
||||
```json
|
||||
{
|
||||
"resource_id": 39301,
|
||||
@@ -178,4 +174,24 @@ body `resource_id` 从URL中获取,id是上一步验证码的那个id, `capt
|
||||
{
|
||||
"message": "评论成功/评论失败/etc"
|
||||
}
|
||||
```
|
||||
|
||||
# 获取备份数据库信息
|
||||
GET `http://127.0.0.1:8888/api/db_dump`
|
||||
```json
|
||||
{
|
||||
"yyets_mongo.gz": {
|
||||
"checksum": "b32e9d8e24c607a9f29889a926c15179d9179791",
|
||||
"date": "2021-04-15 22:11:08"
|
||||
},
|
||||
"yyets_mysql.zip": {
|
||||
"checksum": "6b24ae7cb7cef42951f7e2df183f0825512029e0",
|
||||
"date": "2021-04-15 22:11:08"
|
||||
},
|
||||
"yyets_sqlite.zip": {
|
||||
"checksum": "7e1659ab5cbc98b21155c3debce3015c39f1ec05",
|
||||
"date": "2021-04-15 22:11:08"
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
@@ -27,7 +27,7 @@ services:
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- mongo=mongo
|
||||
working_dir: /YYeTsBot/web/
|
||||
working_dir: /YYeTsBot/yyetsweb/
|
||||
command: [ "python3","server.py","-h=0.0.0.0" ]
|
||||
ports:
|
||||
- 0.0.0.0:8888:8888
|
||||
|
||||
|
Before Width: | Height: | Size: 123 KiB After Width: | Height: | Size: 123 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 44 KiB |
|
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
0
web/404.html → yyetsweb/404.html
vendored
|
Before Width: | Height: | Size: 123 KiB After Width: | Height: | Size: 123 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 44 KiB |
|
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 31 KiB |
0
web/img/afdian.png → yyetsweb/img/afdian.png
vendored
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 4.7 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
@@ -33,7 +33,6 @@ from tornado.concurrent import run_on_executor
|
||||
from passlib.hash import pbkdf2_sha256
|
||||
from captcha.image import ImageCaptcha
|
||||
|
||||
|
||||
enable_pretty_logging()
|
||||
|
||||
mongo_host = os.getenv("mongo") or "localhost"
|
||||
@@ -653,6 +652,29 @@ class HelpHandler(BaseHandler):
|
||||
self.render("help.html", data=self.file_info((live, mysql, sqlite)))
|
||||
|
||||
|
||||
class DBDumpHandler(HelpHandler):
|
||||
executor = ThreadPoolExecutor(10)
|
||||
|
||||
@run_on_executor()
|
||||
def get_hash(self):
|
||||
file_list = ["data/yyets_mongo.gz", "data/yyets_mysql.zip", "data/yyets_sqlite.zip"]
|
||||
result = {}
|
||||
data = self.file_info(file_list)
|
||||
for file, value in data.items():
|
||||
filename = os.path.basename(file)
|
||||
result[filename] = {
|
||||
"checksum": value[0],
|
||||
"date": value[1]
|
||||
}
|
||||
|
||||
return result
|
||||
|
||||
@gen.coroutine
|
||||
def get(self):
|
||||
resp = yield self.get_hash()
|
||||
self.write(resp)
|
||||
|
||||
|
||||
class RunServer:
|
||||
root_path = os.path.dirname(__file__)
|
||||
static_path = os.path.join(root_path, '')
|
||||
@@ -669,6 +691,7 @@ class RunServer:
|
||||
(r'/api/grafana/query', GrafanaQueryHandler),
|
||||
(r'/api/blacklist', BlacklistHandler),
|
||||
(r'/help.html', HelpHandler),
|
||||
(r'/api/db_dump', DBDumpHandler),
|
||||
(r'/', IndexHandler),
|
||||
(r'/(.*\.html|.*\.js|.*\.css|.*\.png|.*\.jpg|.*\.ico|.*\.gif|.*\.woff2|.*\.gz|.*\.zip)', web.StaticFileHandler,
|
||||
{'path': static_path}),
|
||||