Skip to content

Commit

Permalink
release v1.6.19
Browse files Browse the repository at this point in the history
  • Loading branch information
mouday committed Mar 27, 2024
1 parent 4ff20a7 commit 800d800
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
- v1.6.19(2024-03-27)
-

- v1.6.18(2024-03-26)
- 修复 手动编辑域名或证书到期时间,天数筛选不匹配的问题

Expand Down
18 changes: 18 additions & 0 deletions domain_admin/enums/source_enum.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
"""
@File : role_enum.py
@Date : 2022-10-30
@Author : Peng Shiyu
"""
from __future__ import print_function, unicode_literals, absolute_import, division


class SourceEnum(object):
"""
数据来源枚举值
"""
# 0 自动
AUTO = 0

# 1 手动
MANUAL = 1
3 changes: 2 additions & 1 deletion domain_admin/model/address_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from peewee import CharField, IntegerField, DateTimeField, BooleanField, AutoField, TextField

from domain_admin.enums.source_enum import SourceEnum
from domain_admin.model.base_model import BaseModel
from domain_admin.utils import datetime_util, time_util

Expand Down Expand Up @@ -32,7 +33,7 @@ class AddressModel(BaseModel):

# 添加方式 0 自动 1 手动
# @since v1.6.8
source = IntegerField(default=0, null=False)
source = IntegerField(default=SourceEnum.AUTO, null=False)

# 备注说明
# @since v1.6.8
Expand Down
37 changes: 33 additions & 4 deletions domain_admin/service/domain_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
from __future__ import print_function, unicode_literals, absolute_import, division

import io
import time
import traceback
from datetime import datetime, timedelta

from peewee import chunked, fn
from playhouse.shortcuts import model_to_dict

from domain_admin.enums.role_enum import RoleEnum
from domain_admin.enums.source_enum import SourceEnum
from domain_admin.log import logger
from domain_admin.model import domain_model
from domain_admin.model.address_model import AddressModel
Expand Down Expand Up @@ -71,18 +73,45 @@ def update_domain_address_list_cert(domain_row):

err = ''
for address_row in lst:
err = update_address_row_info(address_row, domain_row)
err = update_address_row_info_wrap(address_row, domain_row)

sync_address_info_to_domain_info(domain_row)
return err


def update_address_row_info_wrap(address_row, domain_row):
"""
更新单个地址信息 的代理方法 增加重试次数
:param address_row:
:param domain_row:
:return: error
"""
# 最大重试次数
MAX_RETRY_COUNT = 3
retry_count = 0
err = ''

while True:
retry_count += 1
logger.info("retry_count: %s", retry_count)

err = update_address_row_info(address_row, domain_row)

if not err or retry_count >= MAX_RETRY_COUNT:
break

# sleep
time.sleep(0.5)

return err


def update_address_row_info(address_row, domain_row):
"""
更新单个地址信息
:param domain_row:
:param address_row:
:return:
:return: error
"""

# 获取证书信息
Expand Down Expand Up @@ -129,7 +158,7 @@ def update_address_row_info_with_sync_domain_row(address_id):

domain_row = DomainModel.get_by_id(address_row.domain_id)

update_address_row_info(address_row, domain_row)
update_address_row_info_wrap(address_row, domain_row)

sync_address_info_to_domain_info(domain_row)

Expand Down Expand Up @@ -188,7 +217,7 @@ def update_domain_row(domain_row):
# 移除动态主机行为,都清空自动添加的数据再获取
AddressModel.delete().where(
AddressModel.domain_id == domain_row.id,
AddressModel.source == 0
AddressModel.source == SourceEnum.AUTO
).execute()

# 主机ip信息
Expand Down
2 changes: 1 addition & 1 deletion domain_admin/utils/domain_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def verify_cert_common_name(common_name, domain):
:param domain:
:return:
"""
logger.debug("%s <=> %s", common_name, domain)
# logger.debug("%s <=> %s", common_name, domain)

if '*' in common_name:
# 通配符 SSL 证书
Expand Down
2 changes: 1 addition & 1 deletion domain_admin/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
"""
from __future__ import print_function, unicode_literals, absolute_import, division

VERSION = '1.6.18'
VERSION = '1.6.19'

0 comments on commit 800d800

Please sign in to comment.