mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-19 06:32:59 +08:00
fix: 解决防火墙未显示具体应用占用情况的问题 (#2452)
This commit is contained in:
parent
b09c423bcc
commit
4c650af0e9
@ -647,7 +647,7 @@ func checkPortUsed(ports, proto string, apps []portOfApp) string {
|
|||||||
|
|
||||||
for _, app := range apps {
|
for _, app := range apps {
|
||||||
if app.HttpPort == ports || app.HttpsPort == ports {
|
if app.HttpPort == ports || app.HttpsPort == ports {
|
||||||
return fmt.Sprintf("%s (%s)", ports, app.AppName)
|
return fmt.Sprintf("(%s)", app.AppName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
port, err := strconv.Atoi(ports)
|
port, err := strconv.Atoi(ports)
|
||||||
@ -656,7 +656,7 @@ func checkPortUsed(ports, proto string, apps []portOfApp) string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
if common.ScanPortWithProto(port, proto) {
|
if common.ScanPortWithProto(port, proto) {
|
||||||
return ports
|
return "inUsed"
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
@ -102,6 +102,7 @@ func (u *SettingService) SystemScan() dto.CleanData {
|
|||||||
|
|
||||||
func (u *SettingService) SystemClean(req []dto.Clean) {
|
func (u *SettingService) SystemClean(req []dto.Clean) {
|
||||||
size := uint64(0)
|
size := uint64(0)
|
||||||
|
restart := false
|
||||||
for _, item := range req {
|
for _, item := range req {
|
||||||
size += item.Size
|
size += item.Size
|
||||||
switch item.TreeType {
|
switch item.TreeType {
|
||||||
@ -121,9 +122,7 @@ func (u *SettingService) SystemClean(req []dto.Clean) {
|
|||||||
|
|
||||||
case "cache":
|
case "cache":
|
||||||
dropFileOrDir(path.Join(global.CONF.System.BaseDir, "1panel/cache", item.Name))
|
dropFileOrDir(path.Join(global.CONF.System.BaseDir, "1panel/cache", item.Name))
|
||||||
defer func() {
|
restart = true
|
||||||
_, _ = cmd.Exec("systemctl restart 1panel.service")
|
|
||||||
}()
|
|
||||||
|
|
||||||
case "unused":
|
case "unused":
|
||||||
dropFileOrDir(path.Join(global.CONF.System.BaseDir, "original", item.Name))
|
dropFileOrDir(path.Join(global.CONF.System.BaseDir, "original", item.Name))
|
||||||
@ -207,6 +206,15 @@ func (u *SettingService) SystemClean(req []dto.Clean) {
|
|||||||
_ = settingRepo.Update("LastCleanTime", time.Now().Format("2006-01-02 15:04:05"))
|
_ = settingRepo.Update("LastCleanTime", time.Now().Format("2006-01-02 15:04:05"))
|
||||||
_ = settingRepo.Update("LastCleanSize", fmt.Sprintf("%v", size))
|
_ = settingRepo.Update("LastCleanSize", fmt.Sprintf("%v", size))
|
||||||
_ = settingRepo.Update("LastCleanData", fmt.Sprintf("%v", len(req)))
|
_ = settingRepo.Update("LastCleanData", fmt.Sprintf("%v", len(req)))
|
||||||
|
|
||||||
|
if restart {
|
||||||
|
go func() {
|
||||||
|
_, err := cmd.Exec("systemctl restart 1panel.service")
|
||||||
|
if err != nil {
|
||||||
|
global.LOG.Errorf("restart system port failed, err: %v", err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadSnapshotTree(fileOp fileUtils.FileOp) []dto.CleanTree {
|
func loadSnapshotTree(fileOp fileUtils.FileOp) []dto.CleanTree {
|
||||||
|
@ -7,7 +7,6 @@ type FireInfo struct {
|
|||||||
Protocol string `json:"protocol"` // tcp udp tcp/udp
|
Protocol string `json:"protocol"` // tcp udp tcp/udp
|
||||||
Strategy string `json:"strategy"` // accept drop
|
Strategy string `json:"strategy"` // accept drop
|
||||||
|
|
||||||
APPName string `json:"appName"`
|
|
||||||
UsedStatus string `json:"usedStatus"`
|
UsedStatus string `json:"usedStatus"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
}
|
}
|
||||||
|
@ -77,8 +77,8 @@ export namespace Host {
|
|||||||
port: string;
|
port: string;
|
||||||
protocol: string;
|
protocol: string;
|
||||||
strategy: string;
|
strategy: string;
|
||||||
appName: string;
|
|
||||||
isUsed: boolean;
|
usedStatus: string;
|
||||||
description: string;
|
description: string;
|
||||||
}
|
}
|
||||||
export interface UpdateDescription {
|
export interface UpdateDescription {
|
||||||
|
@ -1233,7 +1233,9 @@ const message = {
|
|||||||
'Temporary files generated during snapshots, upgrades, and obsolete file contents during version iterations',
|
'Temporary files generated during snapshots, upgrades, and obsolete file contents during version iterations',
|
||||||
panelOriginal: 'System snapshot recovery backup files',
|
panelOriginal: 'System snapshot recovery backup files',
|
||||||
upgrade: 'System upgrade backup files',
|
upgrade: 'System upgrade backup files',
|
||||||
|
upgradeHelper: '(Recommend keeping the latest upgrade backup for system rollback)',
|
||||||
cache: 'System cache files',
|
cache: 'System cache files',
|
||||||
|
cacheHelper: '(Proceed with caution, clearing requires a service restart)',
|
||||||
snapshot: 'System snapshot temporary files',
|
snapshot: 'System snapshot temporary files',
|
||||||
snapshotTmp: 'System snapshot upload temporary files',
|
snapshotTmp: 'System snapshot upload temporary files',
|
||||||
snapshotLocal: 'System snapshot creation temporary files',
|
snapshotLocal: 'System snapshot creation temporary files',
|
||||||
|
@ -1171,7 +1171,9 @@ const message = {
|
|||||||
systemHelper: '快照、升級等過程中產生的臨時文件以及版本叠代過程中廢棄的文件內容',
|
systemHelper: '快照、升級等過程中產生的臨時文件以及版本叠代過程中廢棄的文件內容',
|
||||||
panelOriginal: '系統快照恢復前備份文件',
|
panelOriginal: '系統快照恢復前備份文件',
|
||||||
upgrade: '系統升級備份文件',
|
upgrade: '系統升級備份文件',
|
||||||
|
upgradeHelper: '( 建議保留最新的升級備份用於系統回滾 )',
|
||||||
cache: '系統緩存文件',
|
cache: '系統緩存文件',
|
||||||
|
cacheHelper: '( 謹慎操作,清理需要重啟服務 )',
|
||||||
snapshot: '系統快照臨時文件',
|
snapshot: '系統快照臨時文件',
|
||||||
snapshotTmp: '系統快照上傳臨時文件',
|
snapshotTmp: '系統快照上傳臨時文件',
|
||||||
snapshotLocal: '系統快照製作臨時文件',
|
snapshotLocal: '系統快照製作臨時文件',
|
||||||
@ -1187,7 +1189,7 @@ const message = {
|
|||||||
website: '網站',
|
website: '網站',
|
||||||
app: '應用',
|
app: '應用',
|
||||||
database: '數據庫',
|
database: '數據庫',
|
||||||
directory: '應用',
|
directory: '文件夾',
|
||||||
|
|
||||||
systemLog: '系統日誌文件',
|
systemLog: '系統日誌文件',
|
||||||
systemLogHelper: '系統日誌信息、容器構建或鏡像拉取等日誌信息以及計劃任務中產生的日誌文件',
|
systemLogHelper: '系統日誌信息、容器構建或鏡像拉取等日誌信息以及計劃任務中產生的日誌文件',
|
||||||
|
@ -1170,7 +1170,9 @@ const message = {
|
|||||||
systemHelper: '快照、升级等过程中产生的临时文件以及版本迭代过程中废弃的文件内容',
|
systemHelper: '快照、升级等过程中产生的临时文件以及版本迭代过程中废弃的文件内容',
|
||||||
panelOriginal: '系统快照恢复前备份文件',
|
panelOriginal: '系统快照恢复前备份文件',
|
||||||
upgrade: '系统升级备份文件',
|
upgrade: '系统升级备份文件',
|
||||||
|
upgradeHelper: '( 建议保留最新的升级备份用于系统回滚 )',
|
||||||
cache: '系统缓存文件',
|
cache: '系统缓存文件',
|
||||||
|
cacheHelper: '( 谨慎操作,清理需要重启服务 )',
|
||||||
snapshot: '系统快照临时文件',
|
snapshot: '系统快照临时文件',
|
||||||
snapshotTmp: '系统快照上传临时文件',
|
snapshotTmp: '系统快照上传临时文件',
|
||||||
snapshotLocal: '系统快照制作临时文件',
|
snapshotLocal: '系统快照制作临时文件',
|
||||||
@ -1186,7 +1188,7 @@ const message = {
|
|||||||
website: '网站',
|
website: '网站',
|
||||||
app: '应用',
|
app: '应用',
|
||||||
database: '数据库',
|
database: '数据库',
|
||||||
directory: '应用',
|
directory: '文件夹',
|
||||||
|
|
||||||
systemLog: '系统日志文件',
|
systemLog: '系统日志文件',
|
||||||
systemLogHelper: '系统日志信息、容器构建或镜像拉取等日志信息以及计划任务中产生的日志文件',
|
systemLogHelper: '系统日志信息、容器构建或镜像拉取等日志信息以及计划任务中产生的日志文件',
|
||||||
|
@ -104,7 +104,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<el-tag type="info" v-if="row.usedStatus">
|
<el-tag type="info" v-if="row.usedStatus">
|
||||||
{{ $t('firewall.used') }}
|
<span v-if="row.usedStatus === 'inUsed'">{{ $t('firewall.used') }}</span>
|
||||||
|
<span v-else>{{ $t('firewall.used') + ' ' + row.usedStatus }}</span>
|
||||||
</el-tag>
|
</el-tag>
|
||||||
<el-tag type="success" v-else>{{ $t('firewall.unUsed') }}</el-tag>
|
<el-tag type="success" v-else>{{ $t('firewall.unUsed') }}</el-tag>
|
||||||
</div>
|
</div>
|
||||||
|
@ -240,6 +240,8 @@ import DrawerHeader from '@/components/drawer-header/index.vue';
|
|||||||
import { cleanSystem, scanSystem } from '@/api/modules/setting';
|
import { cleanSystem, scanSystem } from '@/api/modules/setting';
|
||||||
import i18n from '@/lang';
|
import i18n from '@/lang';
|
||||||
import { MsgSuccess } from '@/utils/message';
|
import { MsgSuccess } from '@/utils/message';
|
||||||
|
import { GlobalStore } from '@/store';
|
||||||
|
const globalStore = GlobalStore();
|
||||||
|
|
||||||
const emit = defineEmits<{ (e: 'search'): void }>();
|
const emit = defineEmits<{ (e: 'search'): void }>();
|
||||||
const drawerVisible = ref();
|
const drawerVisible = ref();
|
||||||
@ -284,7 +286,6 @@ interface DialogProps {
|
|||||||
const acceptParams = (params: DialogProps): void => {
|
const acceptParams = (params: DialogProps): void => {
|
||||||
scanStatus.value = 'beforeScan';
|
scanStatus.value = 'beforeScan';
|
||||||
form.lastCleanTime = params.lastCleanTime;
|
form.lastCleanTime = params.lastCleanTime;
|
||||||
console.log(form.lastCleanTime);
|
|
||||||
form.lastCleanSize = params.lastCleanSize;
|
form.lastCleanSize = params.lastCleanSize;
|
||||||
form.lastCleanData = params.lastCleanData;
|
form.lastCleanData = params.lastCleanData;
|
||||||
drawerVisible.value = true;
|
drawerVisible.value = true;
|
||||||
@ -332,10 +333,17 @@ const onSubmitClean = async () => {
|
|||||||
}).then(async () => {
|
}).then(async () => {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
submitCleans.value = [];
|
submitCleans.value = [];
|
||||||
|
let restart = false;
|
||||||
loadSubmitCheck(cleanData.systemClean);
|
loadSubmitCheck(cleanData.systemClean);
|
||||||
loadSubmitCheck(cleanData.uploadClean);
|
loadSubmitCheck(cleanData.uploadClean);
|
||||||
loadSubmitCheck(cleanData.downloadClean);
|
loadSubmitCheck(cleanData.downloadClean);
|
||||||
loadSubmitCheck(cleanData.systemLogClean);
|
loadSubmitCheck(cleanData.systemLogClean);
|
||||||
|
for (const item of submitCleans.value) {
|
||||||
|
if (item.treeType === 'cache') {
|
||||||
|
restart = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
await cleanSystem(submitCleans.value)
|
await cleanSystem(submitCleans.value)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
form.lastCleanSize = selectSize.value + '';
|
form.lastCleanSize = selectSize.value + '';
|
||||||
@ -343,6 +351,17 @@ const onSubmitClean = async () => {
|
|||||||
scanStatus.value = 'afterScan';
|
scanStatus.value = 'afterScan';
|
||||||
MsgSuccess(i18n.global.t('commons.msg.operationSuccess'));
|
MsgSuccess(i18n.global.t('commons.msg.operationSuccess'));
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
|
if (restart) {
|
||||||
|
let href = window.location.href;
|
||||||
|
globalStore.isLogin = false;
|
||||||
|
let address = href.split('://')[1];
|
||||||
|
if (globalStore.entrance) {
|
||||||
|
address = address.replaceAll('settings/panel', globalStore.entrance);
|
||||||
|
} else {
|
||||||
|
address = address.replaceAll('settings/panel', 'login');
|
||||||
|
}
|
||||||
|
window.open(`http://${address}`, '_self');
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
@ -437,6 +456,12 @@ function loadTag(node: any, data: any) {
|
|||||||
if (data.size === 0) {
|
if (data.size === 0) {
|
||||||
return i18n.global.t('clean.statusClean');
|
return i18n.global.t('clean.statusClean');
|
||||||
}
|
}
|
||||||
|
if (data.label === 'upgrade') {
|
||||||
|
return i18n.global.t('clean.upgradeHelper');
|
||||||
|
}
|
||||||
|
if (data.label === 'cache') {
|
||||||
|
return i18n.global.t('clean.cacheHelper');
|
||||||
|
}
|
||||||
return data.isRecommend ? i18n.global.t('clean.statusSuggest') : i18n.global.t('clean.statusWarning');
|
return data.isRecommend ? i18n.global.t('clean.statusSuggest') : i18n.global.t('clean.statusWarning');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user