mirror of
				https://github.com/1Panel-dev/1Panel.git
				synced 2025-10-31 03:07:34 +08:00 
			
		
		
		
	feat: 增加一个外部访问地址校验规则 (#4109)
Refs https://github.com/1Panel-dev/1Panel/issues/4091
This commit is contained in:
		
							parent
							
								
									cf4fcaa07f
								
							
						
					
					
						commit
						a6784772b9
					
				
					 5 changed files with 41 additions and 3 deletions
				
			
		|  | @ -487,6 +487,19 @@ const checkPHPExtensions = (rule, value, callback) => { | ||||||
|     } |     } | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | const checkHttpOrHttps = (rule, value, callback) => { | ||||||
|  |     if (value === '' || typeof value === 'undefined' || value == null) { | ||||||
|  |         callback(new Error(i18n.global.t('commons.rule.paramHttp'))); | ||||||
|  |     } else { | ||||||
|  |         const regHttpHttps = /^(http|https):\/\//; | ||||||
|  |         if (!regHttpHttps.test(value)) { | ||||||
|  |             callback(new Error(i18n.global.t('commons.rule.paramHttp'))); | ||||||
|  |         } else { | ||||||
|  |             callback(); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | }; | ||||||
|  | 
 | ||||||
| interface CommonRule { | interface CommonRule { | ||||||
|     requiredInput: FormItemRule; |     requiredInput: FormItemRule; | ||||||
|     requiredSelect: FormItemRule; |     requiredSelect: FormItemRule; | ||||||
|  | @ -527,6 +540,7 @@ interface CommonRule { | ||||||
|     paramPort: FormItemRule; |     paramPort: FormItemRule; | ||||||
|     paramExtUrl: FormItemRule; |     paramExtUrl: FormItemRule; | ||||||
|     paramSimple: FormItemRule; |     paramSimple: FormItemRule; | ||||||
|  |     paramHttp: FormItemRule; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export const Rules: CommonRule = { | export const Rules: CommonRule = { | ||||||
|  | @ -730,4 +744,9 @@ export const Rules: CommonRule = { | ||||||
|         validator: checkPHPExtensions, |         validator: checkPHPExtensions, | ||||||
|         trigger: 'blur', |         trigger: 'blur', | ||||||
|     }, |     }, | ||||||
|  |     paramHttp: { | ||||||
|  |         required: true, | ||||||
|  |         validator: checkHttpOrHttps, | ||||||
|  |         trigger: 'blur', | ||||||
|  |     }, | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | @ -195,6 +195,7 @@ const message = { | ||||||
|             filePermission: 'File Permission Error', |             filePermission: 'File Permission Error', | ||||||
|             formatErr: 'Format error, please check and retry', |             formatErr: 'Format error, please check and retry', | ||||||
|             phpExtension: 'Only supports , _ lowercase English and numbers', |             phpExtension: 'Only supports , _ lowercase English and numbers', | ||||||
|  |             paramHttp: 'Must start with http:// or https://', | ||||||
|         }, |         }, | ||||||
|         res: { |         res: { | ||||||
|             paramError: 'The request failed, please try again later!', |             paramError: 'The request failed, please try again later!', | ||||||
|  | @ -2206,6 +2207,11 @@ const message = { | ||||||
|                 httpHelper: 'Restrict the request method type of the website', |                 httpHelper: 'Restrict the request method type of the website', | ||||||
|                 geoRule: 'Regional access restrictions', |                 geoRule: 'Regional access restrictions', | ||||||
|                 geoHelper: 'Restrict access to your website from certain regions', |                 geoHelper: 'Restrict access to your website from certain regions', | ||||||
|  |                 ipLocation: 'IP home location', | ||||||
|  |                 action: 'action', | ||||||
|  |                 ruleType: 'attack type', | ||||||
|  |                 ipHelper: 'Please enter IP', | ||||||
|  |                 attackLog: 'Attack Log', | ||||||
|             }, |             }, | ||||||
|             monitor: { |             monitor: { | ||||||
|                 name: 'Website Monitoring', |                 name: 'Website Monitoring', | ||||||
|  |  | ||||||
|  | @ -193,6 +193,7 @@ const message = { | ||||||
|             filePermission: '權限錯誤', |             filePermission: '權限錯誤', | ||||||
|             formatErr: '格式錯誤,檢查後重試', |             formatErr: '格式錯誤,檢查後重試', | ||||||
|             phpExtension: '僅支持 , _ 小寫英文和數字', |             phpExtension: '僅支持 , _ 小寫英文和數字', | ||||||
|  |             paramHttp: '必須以 http:// 或 https:// 開頭', | ||||||
|         }, |         }, | ||||||
|         res: { |         res: { | ||||||
|             paramError: '請求失敗,請稍後重試!', |             paramError: '請求失敗,請稍後重試!', | ||||||
|  | @ -2061,6 +2062,11 @@ const message = { | ||||||
|                 httpHelper: '限制網站的請求方法類型', |                 httpHelper: '限制網站的請求方法類型', | ||||||
|                 geoRule: '地區存取限制', |                 geoRule: '地區存取限制', | ||||||
|                 geoHelper: '限制某些地區造訪你的網站', |                 geoHelper: '限制某些地區造訪你的網站', | ||||||
|  |                 ipLocation: 'IP 歸屬地', | ||||||
|  |                 action: '動作', | ||||||
|  |                 ruleType: '攻擊類型', | ||||||
|  |                 ipHelper: '請輸入 IP', | ||||||
|  |                 attackLog: '攻擊日誌', | ||||||
|             }, |             }, | ||||||
|             monitor: { |             monitor: { | ||||||
|                 name: '網站監控', |                 name: '網站監控', | ||||||
|  |  | ||||||
|  | @ -193,6 +193,7 @@ const message = { | ||||||
|             filePermission: '权限错误', |             filePermission: '权限错误', | ||||||
|             formatErr: '格式错误,检查后重试', |             formatErr: '格式错误,检查后重试', | ||||||
|             phpExtension: '仅支持 , _ 小写英文和数字', |             phpExtension: '仅支持 , _ 小写英文和数字', | ||||||
|  |             paramHttp: '必须以 http:// 或 https:// 开头', | ||||||
|         }, |         }, | ||||||
|         res: { |         res: { | ||||||
|             paramError: '请求失败,请稍后重试!', |             paramError: '请求失败,请稍后重试!', | ||||||
|  | @ -2062,6 +2063,11 @@ const message = { | ||||||
|             httpHelper: '限制网站的请求方法类型', |             httpHelper: '限制网站的请求方法类型', | ||||||
|             geoRule: '地区访问限制', |             geoRule: '地区访问限制', | ||||||
|             geoHelper: '限制某些地区访问你的网站', |             geoHelper: '限制某些地区访问你的网站', | ||||||
|  |             ipLocation: 'IP 归属地', | ||||||
|  |             action: '动作', | ||||||
|  |             ruleType: '攻击类型', | ||||||
|  |             ipHelper: '请输入 IP', | ||||||
|  |             attackLog: '攻击日志', | ||||||
|         }, |         }, | ||||||
|         monitor: { |         monitor: { | ||||||
|             name: '网站监控', |             name: '网站监控', | ||||||
|  |  | ||||||
|  | @ -25,7 +25,7 @@ | ||||||
|                 @change="updateParam" |                 @change="updateParam" | ||||||
|             ></el-input> |             ></el-input> | ||||||
|             <el-select |             <el-select | ||||||
|                 style="width: 100%" |                 class="p-w-200" | ||||||
|                 v-model="form[p.envKey]" |                 v-model="form[p.envKey]" | ||||||
|                 v-if="p.type == 'service'" |                 v-if="p.type == 'service'" | ||||||
|                 @change="changeService(form[p.envKey], p.services)" |                 @change="changeService(form[p.envKey], p.services)" | ||||||
|  | @ -42,7 +42,7 @@ | ||||||
|                     {{ $t('app.toInstall') }} |                     {{ $t('app.toInstall') }} | ||||||
|                 </el-link> |                 </el-link> | ||||||
|             </span> |             </span> | ||||||
|             <el-select v-model="form[p.envKey]" v-if="p.type == 'select'" :multiple="p.multiple"> |             <el-select v-model="form[p.envKey]" v-if="p.type == 'select'" :multiple="p.multiple" class="p-w-200"> | ||||||
|                 <el-option |                 <el-option | ||||||
|                     v-for="service in p.values" |                     v-for="service in p.values" | ||||||
|                     :key="service.label" |                     :key="service.label" | ||||||
|  | @ -56,7 +56,7 @@ | ||||||
|                         <el-select |                         <el-select | ||||||
|                             v-model="form[p.envKey]" |                             v-model="form[p.envKey]" | ||||||
|                             @change="getServices(p.child.envKey, form[p.envKey], p)" |                             @change="getServices(p.child.envKey, form[p.envKey], p)" | ||||||
|                             style="width: 100%" |                             class="p-w-200" | ||||||
|                         > |                         > | ||||||
|                             <el-option |                             <el-option | ||||||
|                                 v-for="service in p.values" |                                 v-for="service in p.values" | ||||||
|  | @ -73,6 +73,7 @@ | ||||||
|                             v-model="form[p.child.envKey]" |                             v-model="form[p.child.envKey]" | ||||||
|                             v-if="p.child.type == 'service'" |                             v-if="p.child.type == 'service'" | ||||||
|                             @change="changeService(form[p.child.envKey], p.services)" |                             @change="changeService(form[p.child.envKey], p.services)" | ||||||
|  |                             class="p-w-200" | ||||||
|                         > |                         > | ||||||
|                             <el-option |                             <el-option | ||||||
|                                 v-for="service in p.services" |                                 v-for="service in p.services" | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue