Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions agent/app/dto/alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ type AlertConfigTest struct {
Host string `json:"host"`
Port int `json:"port"`
Sender string `json:"sender"`
UserName string `json:"userName"`
Password string `json:"password"`
DisplayName string `json:"displayName"`
Encryption string `json:"encryption"` // "ssl" / "tls" / "none"
Expand Down Expand Up @@ -323,6 +324,7 @@ type AlertEmailConfig struct {
Host string `json:"host"`
Port int `json:"port"`
Sender string `json:"sender"`
UserName string `json:"userName"`
Password string `json:"password"`
DisplayName string `json:"displayName"`
Encryption string `json:"encryption"` // "ssl" / "tls" / "none"
Expand Down
6 changes: 5 additions & 1 deletion agent/app/service/alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -479,10 +479,14 @@ func (a AlertService) DeleteAlertConfig(id uint) error {
}

func (a AlertService) TestAlertConfig(req dto.AlertConfigTest) (bool, error) {
username := req.UserName
if username == "" {
username = req.Sender
}
cfg := email.SMTPConfig{
Host: req.Host,
Port: req.Port,
Username: req.Sender,
Username: username,
Password: req.Password,
From: fmt.Sprintf("%s <%s>", req.DisplayName, req.Sender),
Encryption: req.Encryption,
Expand Down
6 changes: 5 additions & 1 deletion agent/utils/alert/alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,14 @@ func CreateEmailAlertLog(create dto.AlertLogCreate, alert dto.AlertDTO, params [
if err != nil {
return err
}
username := emailInfo.UserName
if username == "" {
username = emailInfo.Sender
}
smtpConfig := email.SMTPConfig{
Host: emailInfo.Host,
Port: emailInfo.Port,
Username: emailInfo.Sender,
Username: username,
Password: emailInfo.Password,
From: fmt.Sprintf("%s <%s>", emailInfo.DisplayName, emailInfo.Sender),
Encryption: emailInfo.Encryption,
Expand Down
1 change: 1 addition & 0 deletions frontend/src/api/interface/alert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ export namespace Alert {
port: number;
host: string;
sender: string;
userName: string;
password: string;
displayName: string;
encryption: string;
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lang/modules/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3899,6 +3899,7 @@ const message = {
licenseExceptionRule: 'License exception alert, sent {0} times per day',
panelLoginRule: 'Panel login alert, sent {0} times per day',
sshLoginRule: 'SSH login alert, sent {0} times per day',
userNameHelper: 'Username is empty, the sender address will be used by default',
},
theme: {
lingXiaGold: 'Ling Xia Gold',
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lang/modules/es-es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3836,6 +3836,7 @@ const message = {
licenseExceptionRule: 'Alerta de licencia anómala, {0} envíos/día',
panelLoginRule: 'Alerta de login en panel, {0} envíos/día',
sshLoginRule: 'Alerta de login SSH, {0} envíos/día',
userNameHelper: 'El nombre de usuario está vacío, se usará la dirección del remitente por defecto',
},
theme: {
lingXiaGold: 'Ling Xia Gold',
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lang/modules/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3779,6 +3779,7 @@ const message = {
licenseExceptionRule: 'ライセンス異常アラートは、1日あたり{0}回送信',
panelLoginRule: 'パネルログインアラートは、1日あたり{0}回送信',
sshLoginRule: 'SSHログインアラートは、1日あたり{0}回送信',
userNameHelper: 'ユーザー名が空の場合、送信者のアドレスがデフォルトで使用されます',
},
theme: {
lingXiaGold: '凌霞金',
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lang/modules/ko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3709,6 +3709,7 @@ const message = {
licenseExceptionRule: '라이선스 이상 알림은 하루 {0}회 전송',
panelLoginRule: '패널 로그인 알림은 하루 {0}회 전송',
sshLoginRule: 'SSH 로그인 알림은 하루 {0}회 전송',
userNameHelper: '사용자 이름이 비어 있으면 기본적으로 발신자 주소가 사용됩니다',
},
theme: {
lingXiaGold: '링샤 골드',
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lang/modules/ms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3857,6 +3857,7 @@ const message = {
licenseExceptionRule: 'Amaran kerosakan lesen, dihantar {0} kali sehari',
panelLoginRule: 'Amaran log masuk panel, dihantar {0} kali sehari',
sshLoginRule: 'Amaran log masuk SSH, dihantar {0} kali sehari',
userNameHelper: 'Nama pengguna kosong, alamat penghantar akan digunakan secara lalai',
},
theme: {
lingXiaGold: 'Ling Xia Emas',
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lang/modules/pt-br.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3875,6 +3875,7 @@ const message = {
licenseExceptionRule: 'Alerta de exceção de licença, enviado {0} vezes por dia',
panelLoginRule: 'Alerta de login no painel, enviado {0} vezes por dia',
sshLoginRule: 'Alerta de login SSH, enviado {0} vezes por dia',
userNameHelper: 'O nome de usuário está vazio, o endereço do remetente será usado por padrão',
},
theme: {
lingXiaGold: 'Ling Xia Gold',
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lang/modules/ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3870,6 +3870,7 @@ const message = {
licenseExceptionRule: 'Оповещение о сбое лицензии, отправляется {0} раз в день',
panelLoginRule: 'Оповещение о входе в панель, отправляется {0} раз в день',
sshLoginRule: 'Оповещение о входе по SSH, отправляется {0} раз в день',
userNameHelper: 'Имя пользователя не указано, по умолчанию будет использоваться адрес отправителя',
},
theme: {
lingXiaGold: 'Лин Ся Золотой',
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lang/modules/tr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3945,6 +3945,7 @@ const message = {
licenseExceptionRule: 'Lisans hatası uyarısı, günde {0} kez gönderilir',
panelLoginRule: 'Panel girişi uyarısı, günde {0} kez gönderilir',
sshLoginRule: 'SSH girişi uyarısı, günde {0} kez gönderilir',
userNameHelper: 'Kullanıcı adı boşsa, varsayılan olarak gönderici adresi kullanılacaktır',
},
theme: {
lingXiaGold: 'Ling Xia Altın',
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lang/modules/zh-Hant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3627,6 +3627,7 @@ const message = {
licenseExceptionRule: '許可證異常告警,每天發送 {0} 次',
panelLoginRule: '面板登入告警,每天發送 {0} 次',
sshLoginRule: 'SSH 登入告警,每天發送 {0} 次',
userNameHelper: '使用者名稱為空時,將預設使用寄件者地址',
},
theme: {
lingXiaGold: '凌霞金',
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lang/modules/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3595,6 +3595,7 @@ const message = {
licenseExceptionRule: '许可证异常告警,每天发送 {0} 次',
panelLoginRule: '面板登录告警,每天发送 {0} 次',
sshLoginRule: 'SSH 登录告警告警,每天发送 {0} 次',
userNameHelper: '用户名为空会默认使用发件箱地址',
},
theme: {
lingXiaGold: '凌霞金',
Expand Down
9 changes: 9 additions & 0 deletions frontend/src/views/setting/alert/setting/email/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@
{{ $t('xpack.alert.senderHelper') }}
</span>
</el-form-item>
<el-form-item :label="$t('commons.login.username')" prop="userName">
<el-input v-model.trim="form.config.userName" />
<span class="input-help">
{{ $t('xpack.alert.userNameHelper') }}
</span>
</el-form-item>
<el-form-item :label="$t('xpack.alert.password')" prop="password">
<el-input v-model.trim="form.config.password" type="password" show-password />
<span class="input-help">
Expand Down Expand Up @@ -103,6 +109,7 @@ interface Config {
status: string;
displayName: string;
sender: string;
userName: string;
password: string;
host: string;
port: number;
Expand All @@ -122,6 +129,7 @@ const form = reactive({
displayName: '',
sender: '',
password: '',
userName: '',
host: '',
port: 465,
encryption: 'NONE',
Expand Down Expand Up @@ -170,6 +178,7 @@ const onTest = async (formEl: FormInstance | undefined) => {
if (!valid) return;
loading.value = true;
try {
debugger;
await TestAlertConfig(form.config)
.then((res) => {
loading.value = false;
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/views/setting/alert/setting/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@
<el-form-item :label="$t('xpack.alert.sender')" prop="sender">
{{ emailConfig.config.sender }}
</el-form-item>
<el-form-item :label="$t('commons.login.username')" prop="userName">
{{ emailConfig.config.userName || emailConfig.config.sender }}
</el-form-item>
<el-form-item :label="$t('xpack.alert.host')" prop="host">
{{ emailConfig.config.host }}
</el-form-item>
Expand Down Expand Up @@ -186,6 +189,7 @@ export interface EmailConfig {
config: {
status?: string;
sender?: string;
userName?: string;
password?: string;
displayName?: string;
host?: string;
Expand All @@ -202,6 +206,7 @@ const defaultEmailConfig: EmailConfig = {
config: {
displayName: '',
sender: '',
userName: '',
password: '',
host: '',
port: 25,
Expand Down
Loading