diff --git a/backend/app/service/container.go b/backend/app/service/container.go index 4e583bf9e894..d598f3772070 100644 --- a/backend/app/service/container.go +++ b/backend/app/service/container.go @@ -407,6 +407,7 @@ func (u *ContainerService) ContainerInfo(req dto.OperationWithName) (*dto.Contai } } data.AutoRemove = oldContainer.HostConfig.AutoRemove + data.Privileged = oldContainer.HostConfig.Privileged data.PublishAllPorts = oldContainer.HostConfig.PublishAllPorts data.RestartPolicy = oldContainer.HostConfig.RestartPolicy.Name if oldContainer.HostConfig.NanoCPUs != 0 { @@ -440,7 +441,7 @@ func (u *ContainerService) ContainerUpdate(req dto.ContainerOperate) error { if !req.ForcePull { return err } - global.LOG.Errorf("force pull image %s failed, err: %v", req.Image, err) + return fmt.Errorf("pull image %s failed, err: %v", req.Image, err) } } @@ -483,7 +484,7 @@ func (u *ContainerService) ContainerUpgrade(req dto.ContainerUpgrade) error { if !req.ForcePull { return err } - global.LOG.Errorf("force pull image %s failed, err: %v", req.Image, err) + return fmt.Errorf("pull image %s failed, err: %v", req.Image, err) } } config := oldContainer.Config diff --git a/backend/app/service/firewall.go b/backend/app/service/firewall.go index fad43b2fb3c9..256d04dd2320 100644 --- a/backend/app/service/firewall.go +++ b/backend/app/service/firewall.go @@ -485,31 +485,20 @@ func (u *FirewallService) updatePingStatus(enable string) error { if err != nil { return err } - hasV4Line, hasV6Line := false, false - if _, err := os.Stat("/proc/sys/net/ipv6/icmp_echo_ignore_all"); err != nil { - hasV6Line = true - } files := strings.Split(string(lineBytes), "\n") var newFiles []string + hasLine := false for _, line := range files { - if strings.HasPrefix(strings.ReplaceAll(line, " ", ""), "net/ipv4/icmp_echo_ignore_all") && !hasV4Line { + if strings.Contains(line, "net/ipv4/icmp_echo_ignore_all") || strings.HasPrefix(line, "net/ipv4/icmp_echo_ignore_all") { newFiles = append(newFiles, "net/ipv4/icmp_echo_ignore_all="+enable) - hasV4Line = true - continue - } - if strings.HasPrefix(strings.ReplaceAll(line, " ", ""), "net/ipv6/icmp_echo_ignore_all") && !hasV6Line { - newFiles = append(newFiles, "net/ipv6/icmp_echo_ignore_all="+enable) - hasV6Line = true - continue + hasLine = true + } else { + newFiles = append(newFiles, line) } - newFiles = append(newFiles, line) } - if !hasV4Line { + if !hasLine { newFiles = append(newFiles, "net/ipv4/icmp_echo_ignore_all="+enable) } - if !hasV6Line { - newFiles = append(newFiles, "net/ipv6/icmp_echo_ignore_all="+enable) - } file, err := os.OpenFile(confPath, os.O_WRONLY|os.O_TRUNC, 0666) if err != nil { return err @@ -526,6 +515,11 @@ func (u *FirewallService) updatePingStatus(enable string) error { if err != nil { return fmt.Errorf("update ping status failed, err: %v", stdout) } + handle := "-A" + if enable == "1" { + handle = "-D" + } + _, _ = cmd.Execf("%s ip6tables %s INPUT -p icmpv6 --icmpv6-type echo-request -j DROP", cmd.SudoHandleCmd(), handle) return nil } diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index b2978033e54c..d69a91de2153 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -597,7 +597,7 @@ const message = { 'The upgrade operation requires rebuilding the container, and any non-persistent data will be lost. Do you want to continue?', oldImage: 'Current image', targetImage: 'Target image', - targetImageHelper: 'Please enter the target image version', + imageLoadErr: 'System did not detect the container image name, please manually enter the full image name:tag ', appHelper: 'This container is sourced from the application store. Upgrading it may cause the service to be unavailable.', diff --git a/frontend/src/lang/modules/tw.ts b/frontend/src/lang/modules/tw.ts index e3fffd5524d5..7e1ab4a5e3d4 100644 --- a/frontend/src/lang/modules/tw.ts +++ b/frontend/src/lang/modules/tw.ts @@ -578,7 +578,7 @@ const message = { upgradeWarning2: '升級操作需要重建容器,任何未持久化的數據將會丟失,是否繼續?', oldImage: '當前鏡像', targetImage: '目標鏡像', - targetImageHelper: '請輸入目標鏡像版本', + imageLoadErr: '系統未檢測到容器的鏡像名稱,請手動輸入完整的鏡像名稱:標籤', appHelper: '該容器來源於應用商店,升級可能導致該服務不可用', input: '手動輸入', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index c95dcd10ac78..143906d5bde0 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -579,7 +579,7 @@ const message = { upgradeWarning2: '升级操作需要重建容器,任何未持久化的数据将会丢失,是否继续?', oldImage: '当前镜像', targetImage: '目标镜像', - targetImageHelper: '请输入目标镜像版本', + imageLoadErr: '系统未检测到容器的镜像名称,请手动输入完整的镜像名称:标签', appHelper: '该容器来源于应用商店,升级可能导致该服务不可用', input: '手动输入', diff --git a/frontend/src/views/container/compose/create/index.vue b/frontend/src/views/container/compose/create/index.vue index 0e899f9d97a6..3d6c3c34798c 100644 --- a/frontend/src/views/container/compose/create/index.vue +++ b/frontend/src/views/container/compose/create/index.vue @@ -162,6 +162,7 @@ const acceptParams = (): void => { form.path = ''; form.file = ''; form.template = null; + onCreating.value = false; loadTemplates(); loadPath(); }; diff --git a/frontend/src/views/container/container/upgrade/index.vue b/frontend/src/views/container/container/upgrade/index.vue index 216882f5e5af..003f72dbcd80 100644 --- a/frontend/src/views/container/container/upgrade/index.vue +++ b/frontend/src/views/container/container/upgrade/index.vue @@ -15,27 +15,33 @@ /> - - {{ form.imageName.substring(0, 50) }}...:{{ form.oldTag }} + + {{ form.oldImageName.substring(0, 50) }}... - {{ form.imageName }}:{{ form.oldTag }} + {{ form.oldImageName }} - + - + {{ $t('container.upgradeHelper') }} @@ -79,9 +85,9 @@ const loading = ref(false); const form = reactive({ name: '', - imageName: '', - oldTag: '', - newTag: '', + oldImageName: '', + newImageName: '', + imageHelper: '', fromApp: false, forcePull: false, @@ -100,11 +106,16 @@ interface DialogProps { } const acceptParams = (props: DialogProps): void => { form.name = props.container; - form.imageName = props.image.indexOf(':') !== -1 ? props.image.split(':')[0] : props.image; - form.oldTag = props.image.indexOf(':') !== -1 ? props.image.split(':')[1] : 'latest'; - form.newTag = form.oldTag; + form.oldImageName = props.image; form.fromApp = props.fromApp; form.ignoreCompare = false; + + if (props.image.indexOf('sha256:') !== -1) { + form.imageHelper = i18n.global.t('container.imageLoadErr'); + drawerVisible.value = true; + return; + } + form.imageHelper = props.image.indexOf(':') !== -1 ? props.image.split(':')[0] : props.image; drawerVisible.value = true; }; const emit = defineEmits<{ (e: 'search'): void }>(); @@ -113,7 +124,7 @@ const onSubmit = async (formEl: FormInstance | undefined) => { if (!formEl) return; formEl.validate(async (valid) => { if (!valid) return; - if (!form.ignoreCompare && !compareVersion(form.newTag, form.oldTag)) { + if (!form.ignoreCompare && !compareVersion(form.newImageName, form.oldImageName)) { MsgWarning(i18n.global.t('container.upgradeWarning')); return; } @@ -122,7 +133,7 @@ const onSubmit = async (formEl: FormInstance | undefined) => { cancelButtonText: i18n.global.t('commons.button.cancel'), }).then(async () => { loading.value = true; - await upgradeContainer(form.name, form.imageName + ':' + form.newTag, form.forcePull) + await upgradeContainer(form.name, form.newImageName, form.forcePull) .then(() => { loading.value = false; emit('search'); @@ -141,14 +152,22 @@ const handleClose = async () => { }; function compareVersion(vNew, vOld) { - if (vNew === 'latest') { + let newImageName = vNew.indexOf(':') !== -1 ? vNew.split(':')[0] : vNew; + let oldImageName = vOld.indexOf(':') !== -1 ? vOld.split(':')[0] : vOld; + if (newImageName !== oldImageName) { + return true; + } + let newTag = vNew.indexOf(':') !== -1 ? vNew.split(':')[1] : 'latest'; + + if (newTag === 'latest') { return true; } - let v1 = vNew + let oldTag = vOld.indexOf(':') !== -1 ? vOld.split(':')[1] : 'latest'; + let v1 = newTag .replace('-', '.') .replace(/[^\d.]/g, '') .split('.'); - let v2 = vOld + let v2 = oldTag .replace('-', '.') .replace(/[^\d.]/g, '') .split('.'); diff --git a/frontend/src/views/container/network/create/index.vue b/frontend/src/views/container/network/create/index.vue index 401295612a54..7028cf89bfda 100644 --- a/frontend/src/views/container/network/create/index.vue +++ b/frontend/src/views/container/network/create/index.vue @@ -202,10 +202,10 @@ const handleClose = () => { const rules = reactive({ name: [Rules.requiredInput], driver: [Rules.requiredSelect], - subnet: [{ validator: checkCidr, trigger: 'blur' }], + subnet: [{ validator: checkCidr, trigger: 'blur' }, Rules.requiredInput], gateway: [{ validator: checkGateway, trigger: 'blur' }], scope: [{ validator: checkCidr, trigger: 'blur' }], - subnetV6: [{ validator: checkFixedCidrV6, trigger: 'blur' }], + subnetV6: [{ validator: checkFixedCidrV6, trigger: 'blur' }, Rules.requiredInput], gatewayV6: [{ validator: checkGatewayV6, trigger: 'blur' }], scopeV6: [{ validator: checkFixedCidrV6, trigger: 'blur' }], }); diff --git a/frontend/src/views/toolbox/fail2ban/ips/index.vue b/frontend/src/views/toolbox/fail2ban/ips/index.vue index 8ba8caca790f..59c20d541f84 100644 --- a/frontend/src/views/toolbox/fail2ban/ips/index.vue +++ b/frontend/src/views/toolbox/fail2ban/ips/index.vue @@ -1,5 +1,5 @@