1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-01-31 14:08:06 +08:00

fix: 优化主机测试连接逻辑 (#3211)

This commit is contained in:
ssongliu 2023-12-07 10:18:07 +08:00 committed by GitHub
parent 2fdca95255
commit 02f41ba45d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 40 additions and 31 deletions

View File

@ -86,6 +86,7 @@ func Start() {
panic(err)
}
} else {
global.LOG.Infof("listen at http://%s:%s [%s]", global.CONF.System.BindAddress, global.CONF.System.Port, tcpItem)
if err := server.Serve(tcpKeepAliveListener{ln.(*net.TCPListener)}); err != nil {
panic(err)
}

View File

@ -11,13 +11,13 @@
<span v-if="dialogData.rowData!.addr === '127.0.0.1' && dialogData.title === 'edit'">
{{ dialogData.rowData!.addr }}
</span>
<el-input v-else clearable v-model.trim="dialogData.rowData!.addr" />
<el-input @change="isOK = false" v-else clearable v-model.trim="dialogData.rowData!.addr" />
</el-form-item>
<el-form-item :label="$t('commons.login.username')" prop="user">
<el-input clearable v-model="dialogData.rowData!.user" />
<el-input @change="isOK = false" clearable v-model="dialogData.rowData!.user" />
</el-form-item>
<el-form-item :label="$t('terminal.authMode')" prop="authMode">
<el-radio-group v-model="dialogData.rowData!.authMode">
<el-radio-group @change="isOK = false" v-model="dialogData.rowData!.authMode">
<el-radio label="password">{{ $t('terminal.passwordMode') }}</el-radio>
<el-radio label="key">{{ $t('terminal.keyMode') }}</el-radio>
</el-radio-group>
@ -27,14 +27,25 @@
v-if="dialogData.rowData!.authMode === 'password'"
prop="password"
>
<el-input clearable show-password type="password" v-model="dialogData.rowData!.password" />
<el-input
@change="isOK = false"
clearable
show-password
type="password"
v-model="dialogData.rowData!.password"
/>
</el-form-item>
<el-form-item
:label="$t('terminal.key')"
v-if="dialogData.rowData!.authMode === 'key'"
prop="privateKey"
>
<el-input clearable type="textarea" v-model="dialogData.rowData!.privateKey" />
<el-input
@change="isOK = false"
clearable
type="textarea"
v-model="dialogData.rowData!.privateKey"
/>
</el-form-item>
<el-form-item
:label="$t('terminal.keyPassword')"
@ -42,6 +53,7 @@
prop="passPhrase"
>
<el-input
@change="isOK = false"
type="password"
show-password
clearable
@ -52,7 +64,7 @@
{{ $t('terminal.rememberPassword') }}
</el-checkbox>
<el-form-item style="margin-top: 10px" :label="$t('commons.table.port')" prop="port">
<el-input clearable v-model.number="dialogData.rowData!.port" />
<el-input @change="isOK = false" clearable v-model.number="dialogData.rowData!.port" />
</el-form-item>
<el-form-item :label="$t('commons.table.group')" prop="groupID">
<el-select filterable v-model="dialogData.rowData!.groupID" clearable style="width: 100%">
@ -89,7 +101,7 @@
</template>
<script lang="ts" setup>
import { ref, reactive, watch } from 'vue';
import { ref, reactive } from 'vue';
import type { ElForm } from 'element-plus';
import { Rules } from '@/global/form-rules';
import { addHost, editHost, testByInfo } from '@/api/modules/host';
@ -111,14 +123,6 @@ const dialogData = ref<DialogProps>({
title: '',
});
watch(
() => dialogData.value.rowData,
() => {
isOK.value = false;
},
{ deep: true },
);
const groupList = ref();
const acceptParams = (params: DialogProps): void => {
dialogData.value = params;

View File

@ -16,16 +16,16 @@
type="warning"
/>
<el-form-item :label="$t('terminal.ip')" prop="addr">
<el-input v-if="!isLocal" clearable v-model.trim="hostInfo.addr" />
<el-input @change="isOK = false" v-if="!isLocal" clearable v-model.trim="hostInfo.addr" />
<div style="margin-left: 12px">
<span v-if="isLocal">{{ hostInfo.addr }}</span>
</div>
</el-form-item>
<el-form-item :label="$t('commons.login.username')" prop="user">
<el-input clearable v-model="hostInfo.user" />
<el-input @change="isOK = false" clearable v-model="hostInfo.user" />
</el-form-item>
<el-form-item :label="$t('terminal.authMode')" prop="authMode">
<el-radio-group v-model="hostInfo.authMode">
<el-radio-group @change="isOK = false" v-model="hostInfo.authMode">
<el-radio label="password">{{ $t('terminal.passwordMode') }}</el-radio>
<el-radio label="key">{{ $t('terminal.keyMode') }}</el-radio>
</el-radio-group>
@ -35,23 +35,35 @@
v-if="hostInfo.authMode === 'password'"
prop="password"
>
<el-input clearable show-password type="password" v-model="hostInfo.password" />
<el-input
@change="isOK = false"
clearable
show-password
type="password"
v-model="hostInfo.password"
/>
</el-form-item>
<el-form-item :label="$t('terminal.key')" v-if="hostInfo.authMode === 'key'" prop="privateKey">
<el-input clearable type="textarea" v-model="hostInfo.privateKey" />
<el-input @change="isOK = false" clearable type="textarea" v-model="hostInfo.privateKey" />
</el-form-item>
<el-form-item
:label="$t('terminal.keyPassword')"
v-if="hostInfo.authMode === 'key'"
prop="passPhrase"
>
<el-input type="password" show-password clearable v-model="hostInfo.passPhrase" />
<el-input
@change="isOK = false"
type="password"
show-password
clearable
v-model="hostInfo.passPhrase"
/>
</el-form-item>
<el-checkbox clearable v-model.number="hostInfo.rememberPassword">
{{ $t('terminal.rememberPassword') }}
</el-checkbox>
<el-form-item style="margin-top: 10px" :label="$t('commons.table.port')" prop="port">
<el-input clearable v-model.number="hostInfo.port" />
<el-input @change="isOK = false" clearable v-model.number="hostInfo.port" />
</el-form-item>
<el-form-item :label="$t('commons.table.title')" prop="name">
<el-input clearable v-model="hostInfo.name" />
@ -84,7 +96,7 @@ import { Rules } from '@/global/form-rules';
import { addHost, testByInfo } from '@/api/modules/host';
import DrawerHeader from '@/components/drawer-header/index.vue';
import i18n from '@/lang';
import { reactive, ref, watch } from 'vue';
import { reactive, ref } from 'vue';
import { MsgError, MsgSuccess } from '@/utils/message';
const dialogVisible = ref();
@ -107,14 +119,6 @@ let hostInfo = reactive<Host.HostOperate>({
description: '',
});
watch(
() => hostInfo,
() => {
isOK.value = false;
},
{ deep: true },
);
const rules = reactive({
addr: [Rules.ipV4V6OrDomain],
port: [Rules.requiredInput, Rules.port],