Merge pull request #32 from thsrite/main

This commit is contained in:
jxxghp 2023-08-05 22:27:53 +08:00 committed by GitHub
commit 8d01630d03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 282 additions and 280 deletions

View File

@ -40,6 +40,7 @@ RUN apt-get update \
procps \ procps \
gosu \ gosu \
bash \ bash \
wget \
&& mkdir -p /etc/nginx ${HOME} \ && mkdir -p /etc/nginx ${HOME} \
&& cp -f nginx.conf /etc/nginx/nginx.template.conf \ && cp -f nginx.conf /etc/nginx/nginx.template.conf \
&& mv ./public / \ && mv ./public / \

View File

@ -11,7 +11,7 @@ from python_hosts import Hosts, HostsEntry
from app.core.config import settings from app.core.config import settings
from app.log import logger from app.log import logger
from app.plugins import _PluginBase from app.plugins import _PluginBase
from app.schemas.types import EventType from app.schemas.types import EventType, NotificationType
from app.utils.http import RequestUtils from app.utils.http import RequestUtils
from app.utils.ip import IpUtils from app.utils.ip import IpUtils
from app.utils.system import SystemUtils from app.utils.system import SystemUtils
@ -192,7 +192,8 @@ class CloudflareSpeedTest(_PluginBase):
"plugin_id": "CustomHosts" "plugin_id": "CustomHosts"
}) })
if self._notify: if self._notify:
logger.send_message( self.post_message(
mtype=NotificationType.SiteMessage,
title="【Cloudflare优选任务完成】", title="【Cloudflare优选任务完成】",
text=f"原ip{old_ip}\n" text=f"原ip{old_ip}\n"
f"新ip{best_ip}" f"新ip{best_ip}"
@ -403,207 +404,207 @@ class CloudflareSpeedTest(_PluginBase):
拼装插件配置页面需要返回两块数据1页面配置2数据结构 拼装插件配置页面需要返回两块数据1页面配置2数据结构
""" """
return [ return [
{ {
'component': 'VForm', 'component': 'VForm',
'content': [ 'content': [
{ {
'component': 'VRow', 'component': 'VRow',
'content': [ 'content': [
{ {
'component': 'VCol', 'component': 'VCol',
'props': { 'props': {
'cols': 12, 'cols': 12,
'md': 4 'md': 4
}, },
'content': [ 'content': [
{ {
'component': 'VTextField', 'component': 'VTextField',
'props': { 'props': {
'model': 'cf_ip', 'model': 'cf_ip',
'label': '优选IP', 'label': '优选IP',
'placeholder': '121.121.121.121' 'placeholder': '121.121.121.121'
} }
} }
] ]
}, },
{ {
'component': 'VCol', 'component': 'VCol',
'props': { 'props': {
'cols': 12, 'cols': 12,
'md': 4 'md': 4
}, },
'content': [ 'content': [
{ {
'component': 'VTextField', 'component': 'VTextField',
'props': { 'props': {
'model': 'cron', 'model': 'cron',
'label': '优选周期', 'label': '优选周期',
'placeholder': '0 0 0 ? *' 'placeholder': '0 0 0 ? *'
} }
} }
] ]
}, },
{ {
'component': 'VCol', 'component': 'VCol',
'props': { 'props': {
'cols': 12, 'cols': 12,
'md': 4 'md': 4
}, },
'content': [ 'content': [
{ {
'component': 'VTextField', 'component': 'VTextField',
'props': { 'props': {
'model': 'version', 'model': 'version',
'readonly': True, 'readonly': True,
'label': 'CloudflareSpeedTest版本', 'label': 'CloudflareSpeedTest版本',
'placeholder': '暂未安装' 'placeholder': '暂未安装'
} }
} }
] ]
} }
] ]
}, },
{ {
'component': 'VRow', 'component': 'VRow',
'content': [ 'content': [
{ {
'component': 'VCol', 'component': 'VCol',
'props': { 'props': {
'cols': 12, 'cols': 12,
'md': 4 'md': 4
}, },
'content': [ 'content': [
{ {
'component': 'VSwitch', 'component': 'VSwitch',
'props': { 'props': {
'model': 'ipv4', 'model': 'ipv4',
'label': 'IPv4', 'label': 'IPv4',
} }
} }
] ]
}, },
{ {
'component': 'VCol', 'component': 'VCol',
'props': { 'props': {
'cols': 12, 'cols': 12,
'md': 4 'md': 4
}, },
'content': [ 'content': [
{ {
'component': 'VSwitch', 'component': 'VSwitch',
'props': { 'props': {
'model': 'ipv6', 'model': 'ipv6',
'label': 'IPv6', 'label': 'IPv6',
} }
} }
] ]
}, },
{ {
'component': 'VCol', 'component': 'VCol',
'props': { 'props': {
'cols': 12, 'cols': 12,
'md': 4 'md': 4
}, },
'content': [ 'content': [
{ {
'component': 'VSwitch', 'component': 'VSwitch',
'props': { 'props': {
'model': 'check', 'model': 'check',
'label': '自动校准', 'label': '自动校准',
} }
} }
] ]
} }
] ]
}, },
{ {
'component': 'VRow', 'component': 'VRow',
'content': [ 'content': [
{ {
'component': 'VCol', 'component': 'VCol',
'props': { 'props': {
'cols': 12, 'cols': 12,
'md': 4 'md': 4
}, },
'content': [ 'content': [
{ {
'component': 'VSwitch', 'component': 'VSwitch',
'props': { 'props': {
'model': 'onlyonce', 'model': 'onlyonce',
'label': '立即运行一次', 'label': '立即运行一次',
} }
} }
] ]
}, },
{ {
'component': 'VCol', 'component': 'VCol',
'props': { 'props': {
'cols': 12, 'cols': 12,
'md': 4 'md': 4
}, },
'content': [ 'content': [
{ {
'component': 'VSwitch', 'component': 'VSwitch',
'props': { 'props': {
'model': 're_install', 'model': 're_install',
'label': '重装后运行', 'label': '重装后运行',
} }
} }
] ]
}, },
{ {
'component': 'VCol', 'component': 'VCol',
'props': { 'props': {
'cols': 12, 'cols': 12,
'md': 4 'md': 4
}, },
'content': [ 'content': [
{ {
'component': 'VSwitch', 'component': 'VSwitch',
'props': { 'props': {
'model': 'notify', 'model': 'notify',
'label': '运行时通知', 'label': '运行时通知',
} }
} }
] ]
} }
] ]
}, },
{ {
'component': 'VRow', 'component': 'VRow',
'content': [ 'content': [
{ {
'component': 'VCol', 'component': 'VCol',
'props': { 'props': {
'cols': 12 'cols': 12
}, },
'content': [ 'content': [
{ {
'component': 'VTextField', 'component': 'VTextField',
'props': { 'props': {
'model': 'additional_args', 'model': 'additional_args',
'label': '高级参数', 'label': '高级参数',
'placeholder': '-dd' 'placeholder': '-dd'
} }
} }
] ]
} }
] ]
} }
] ]
} }
], { ], {
"cf_ip": "", "cf_ip": "",
"cron": "", "cron": "",
"version": "", "version": "",
"ipv4": True, "ipv4": True,
"ipv6": False, "ipv6": False,
"check": False, "check": False,
"onlyonce": False, "onlyonce": False,
"re_install": False, "re_install": False,
"notify": True, "notify": True,
"additional_args": "" "additional_args": ""
} }
def get_page(self) -> List[dict]: def get_page(self) -> List[dict]:
pass pass

View File

@ -54,7 +54,7 @@ class CustomHosts(_PluginBase):
# 更新错误Hosts # 更新错误Hosts
self.update_config({ self.update_config({
"hosts": self._hosts, "hosts": ''.join(self._hosts),
"err_hosts": error_hosts, "err_hosts": error_hosts,
"enabled": self._enabled "enabled": self._enabled
}) })
@ -74,82 +74,82 @@ class CustomHosts(_PluginBase):
拼装插件配置页面需要返回两块数据1页面配置2数据结构 拼装插件配置页面需要返回两块数据1页面配置2数据结构
""" """
return [ return [
{ {
'component': 'VForm', 'component': 'VForm',
'content': [ 'content': [
{ {
'component': 'VRow', 'component': 'VRow',
'content': [ 'content': [
{ {
'component': 'VCol', 'component': 'VCol',
'props': { 'props': {
'cols': 12, 'cols': 12,
'md': 6 'md': 6
}, },
'content': [ 'content': [
{ {
'component': 'VSwitch', 'component': 'VSwitch',
'props': { 'props': {
'model': 'enabled', 'model': 'enabled',
'label': '启用插件', 'label': '启用插件',
} }
} }
] ]
} }
] ]
}, },
{ {
'component': 'VRow', 'component': 'VRow',
'content': [ 'content': [
{ {
'component': 'VCol', 'component': 'VCol',
'props': { 'props': {
'cols': 12 'cols': 12
}, },
'content': [ 'content': [
{ {
'component': 'VTextarea', 'component': 'VTextarea',
'props': { 'props': {
'model': 'hosts', 'model': 'hosts',
'label': '自定义hosts', 'label': '自定义hosts',
'rows': 10, 'rows': 10,
'placeholder': '每行一个配置格式为ip host1 host2 ...' 'placeholder': '每行一个配置格式为ip host1 host2 ...'
} }
} }
] ]
} }
] ]
}, },
{ {
'component': 'VRow', 'component': 'VRow',
'content': [ 'content': [
{ {
'component': 'VCol', 'component': 'VCol',
'props': { 'props': {
'cols': 12 'cols': 12
}, },
'content': [ 'content': [
{ {
'component': 'VTextarea', 'component': 'VTextarea',
'props': { 'props': {
'model': 'err_hosts', 'model': 'err_hosts',
'readonly': True, 'readonly': True,
'label': '错误hosts', 'label': '错误hosts',
'rows': 2, 'rows': 2,
'placeholder': '错误的hosts配置会展示在此处请修改上方hosts重新提交错误的hosts不会写入系统hosts文件' 'placeholder': '错误的hosts配置会展示在此处请修改上方hosts重新提交错误的hosts不会写入系统hosts文件'
} }
} }
] ]
} }
] ]
} }
] ]
} }
], { ], {
"enabled": False, "enabled": False,
"hosts": "", "hosts": "",
"err_hosts": "" "err_hosts": ""
} }
def get_page(self) -> List[dict]: def get_page(self) -> List[dict]:
pass pass