From 5a17ae9d798c4a98d4787a7f2a02db5e5f00b67a Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Sat, 27 Jul 2024 14:15:25 +0800 Subject: [PATCH] v1.4.1 --- build/build.sh | 31 +- cmd/edge-api/main.go | 7 +- cmd/edge-instance-installer/main.go | 7 +- cmd/installer-dns-helper/main.go | 5 +- cmd/installer-helper/main.go | 5 +- cmd/sql-dump/main.go | 5 +- cmd/tt/main.go | 7 +- go.mod | 44 +- go.sum | 100 +-- internal/acme/acme_test.go | 7 +- internal/acme/dns_provider.go | 9 +- internal/acme/providers_ext.go | 2 +- internal/acme/request.go | 5 +- internal/acme/request_test.go | 3 +- internal/acme/user.go | 1 + internal/apps/app_cmd.go | 11 +- internal/apps/log_writer.go | 11 +- internal/configs/api_config.go | 5 +- internal/configs/api_config_test.go | 3 +- internal/configs/db_config.go | 5 +- internal/configs/simple_db_config.go | 9 +- internal/const/const.go | 4 +- internal/const/const_community.go | 2 +- internal/const/vars.go | 5 +- internal/db/db_test.go | 5 +- internal/db/models/acme/acme_task_dao.go | 234 ++++++- internal/db/models/acme/acme_task_model.go | 4 + .../db/models/acme/acme_task_model_ext.go | 1 + internal/db/models/acme/acme_user_dao.go | 15 + internal/db/models/api_access_token_dao.go | 3 +- internal/db/models/api_node_dao.go | 7 +- internal/db/models/api_node_dao_test.go | 5 +- internal/db/models/api_node_model_ext.go | 1 + .../db/models/authority/authority_node_dao.go | 1 + .../clients/client_agent_ip_dao_test.go | 3 +- .../db/models/clients/client_browser_dao.go | 3 +- .../models/clients/client_browser_dao_test.go | 3 +- .../db/models/clients/client_system_dao.go | 3 +- .../models/clients/client_system_dao_test.go | 3 +- internal/db/models/db_node_dao.go | 3 +- internal/db/models/db_node_dao_test.go | 3 +- internal/db/models/db_node_initializer.go | 7 +- internal/db/models/db_node_initializer_ext.go | 2 +- internal/db/models/db_node_model_ext.go | 1 + internal/db/models/dns/dns_domain_dao.go | 5 +- internal/db/models/dns/dns_domain_dao_test.go | 3 +- .../db/models/dns/dns_domain_model_ext.go | 1 + internal/db/models/dns/dns_provider_dao.go | 3 +- .../db/models/dns/dns_provider_model_ext.go | 1 + internal/db/models/dns/dns_task_dao.go | 3 +- internal/db/models/dns/dns_task_dao_test.go | 5 +- internal/db/models/dns/dnsutils/dns_utils.go | 1 + .../db/models/dns/dnsutils/dns_utils_test.go | 3 +- internal/db/models/file_chunk_dao.go | 1 + .../db/models/formal_client_browser_dao.go | 7 +- .../models/formal_client_browser_model_ext.go | 1 + .../models/formal_client_system_model_ext.go | 1 + internal/db/models/http_access_log_dao.go | 17 +- .../db/models/http_access_log_manager_test.go | 5 +- .../db/models/http_access_log_model_ext.go | 1 + internal/db/models/http_auth_policy_dao.go | 1 + internal/db/models/http_cache_policy_dao.go | 1 + internal/db/models/http_cache_task_dao.go | 3 +- .../db/models/http_cache_task_key_dao_test.go | 3 +- internal/db/models/http_fastcgi_dao.go | 1 + .../db/models/http_firewall_policy_dao.go | 1 + .../models/http_firewall_policy_dao_test.go | 3 +- .../db/models/http_firewall_rule_group_dao.go | 1 + .../http_firewall_rule_group_dao_test.go | 3 +- .../db/models/http_firewall_rule_set_dao.go | 1 + .../models/http_firewall_rule_set_dao_test.go | 5 +- internal/db/models/http_gzip_dao.go | 1 + internal/db/models/http_gzip_model_ext.go | 1 + internal/db/models/http_header_dao.go | 1 + .../db/models/http_header_policy_dao_test.go | 3 +- internal/db/models/http_location_dao.go | 1 + internal/db/models/http_page_dao.go | 1 + internal/db/models/http_rewrite_rule_dao.go | 1 + internal/db/models/http_web_dao.go | 1 + internal/db/models/http_web_dao_test.go | 3 +- internal/db/models/http_websocket_dao.go | 1 + internal/db/models/ip_item_dao.go | 7 +- internal/db/models/ip_item_dao_test.go | 5 +- internal/db/models/ip_library_file_dao.go | 9 +- .../db/models/ip_library_file_dao_test.go | 3 +- internal/db/models/ip_list_dao.go | 3 +- internal/db/models/ip_list_dao_test.go | 5 +- internal/db/models/latest_item_dao.go | 3 +- internal/db/models/log_dao.go | 7 +- internal/db/models/log_dao_test.go | 3 +- internal/db/models/login_session_dao.go | 3 +- internal/db/models/login_ticket_dao.go | 5 +- internal/db/models/message_dao.go | 3 +- internal/db/models/message_dao_test.go | 5 +- .../db/models/message_media_instance_dao.go | 1 + internal/db/models/message_receiver_dao.go | 1 + internal/db/models/message_recipient_dao.go | 3 +- .../db/models/message_recipient_dao_test.go | 3 +- .../db/models/message_recipient_model_ext.go | 1 + internal/db/models/message_task_dao.go | 3 +- internal/db/models/message_task_dao_ext.go | 2 +- internal/db/models/message_task_dao_test.go | 3 +- internal/db/models/message_task_log_dao.go | 3 +- internal/db/models/metric_chart_dao.go | 1 + internal/db/models/metric_item_dao.go | 7 +- internal/db/models/metric_item_dao_test.go | 3 +- internal/db/models/metric_stat_dao.go | 15 +- internal/db/models/metric_stat_dao_test.go | 5 +- internal/db/models/metric_sum_stat_dao.go | 5 +- .../db/models/metric_sum_stat_dao_test.go | 3 +- .../models/nameservers/ns_domain_model_ext.go | 1 + .../models/nameservers/ns_record_model_ext.go | 1 + internal/db/models/node_cluster_dao.go | 3 +- internal/db/models/node_cluster_dao_test.go | 3 +- .../node_cluster_firewall_action_model_ext.go | 1 + internal/db/models/node_dao.go | 25 +- internal/db/models/node_dao_limit.go | 3 +- internal/db/models/node_dao_test.go | 5 +- internal/db/models/node_grant_dao.go | 1 + internal/db/models/node_ip_address_dao.go | 1 + .../db/models/node_ip_address_dao_test.go | 3 +- .../db/models/node_ip_address_log_dao_test.go | 3 +- .../db/models/node_ip_address_model_ext.go | 1 + .../models/node_ip_address_threshold_dao.go | 1 + .../node_ip_address_threshold_model_ext.go | 1 + internal/db/models/node_log_dao.go | 7 +- internal/db/models/node_log_dao_ext.go | 6 +- internal/db/models/node_login_dao.go | 1 + internal/db/models/node_login_dao_ext.go | 2 +- internal/db/models/node_login_dao_test.go | 3 +- internal/db/models/node_model.go | 2 + internal/db/models/node_model_ext.go | 5 +- internal/db/models/node_model_ext_schdule.go | 4 +- internal/db/models/node_region_dao.go | 1 + internal/db/models/node_task_dao.go | 5 +- internal/db/models/node_task_dao_ext.go | 2 +- internal/db/models/node_task_dao_test.go | 5 +- internal/db/models/node_threshold_dao_ext.go | 2 +- .../db/models/node_traffic_daily_stat_dao.go | 3 +- .../models/node_traffic_daily_stat_dao_ext.go | 2 +- internal/db/models/node_value_dao.go | 5 +- internal/db/models/node_value_dao_ext.go | 2 +- internal/db/models/node_value_dao_test.go | 5 +- internal/db/models/node_value_model_ext.go | 1 + internal/db/models/ns_cluster_dao.go | 5 +- internal/db/models/ns_cluster_dao_test.go | 3 +- internal/db/models/ns_cluster_model_ext.go | 1 + internal/db/models/ns_node_dao.go | 1 + internal/db/models/origin_dao.go | 1 + internal/db/models/origin_dao_test.go | 3 +- internal/db/models/origin_model_ext.go | 1 + internal/db/models/plan_dao.go | 1 + internal/db/models/regions/region_city_dao.go | 5 +- .../models/regions/region_city_model_ext.go | 1 + .../db/models/regions/region_country_dao.go | 7 +- .../models/regions/region_country_dao_test.go | 3 +- .../regions/region_country_model_ext.go | 1 + .../db/models/regions/region_provider_dao.go | 5 +- .../regions/region_provider_model_ext.go | 1 + .../db/models/regions/region_province_dao.go | 7 +- .../regions/region_province_dao_test.go | 3 +- .../regions/region_province_model_ext.go | 1 + internal/db/models/regions/region_town_dao.go | 5 +- .../models/regions/region_town_model_ext.go | 1 + internal/db/models/report_node_dao.go | 1 + internal/db/models/report_result_dao.go | 3 +- internal/db/models/reverse_proxy_dao.go | 1 + .../db/models/server_bandwidth_stat_dao.go | 11 +- .../models/server_bandwidth_stat_dao_test.go | 5 +- internal/db/models/server_bill_dao.go | 5 +- internal/db/models/server_bill_dao_test.go | 3 +- .../db/models/server_daily_stat_dao_test.go | 5 +- internal/db/models/server_dao.go | 21 +- internal/db/models/server_dao_copy_ext.go | 3 +- internal/db/models/server_dao_ext.go | 2 +- internal/db/models/server_dao_test.go | 5 +- internal/db/models/server_group_dao.go | 1 + internal/db/models/server_model_ext.go | 1 + internal/db/models/ssl_cert_dao.go | 7 +- internal/db/models/ssl_cert_dao_test.go | 3 +- internal/db/models/ssl_policy_dao.go | 1 + internal/db/models/ssl_policy_model_ext.go | 1 + .../node_cluster_traffic_daily_stat_dao.go | 3 +- .../stats/node_traffic_hourly_stat_dao.go | 3 +- .../server_client_browser_monthly_stat_dao.go | 3 +- ...er_client_browser_monthly_stat_dao_test.go | 3 +- .../server_client_system_monthly_stat_dao.go | 3 +- ...ver_client_system_monthly_stat_dao_test.go | 3 +- .../stats/server_domain_hourly_stat_dao.go | 9 +- .../server_domain_hourly_stat_dao_test.go | 5 +- .../server_http_firewall_daily_stat_dao.go | 3 +- .../server_http_firewall_hourly_stat_dao.go | 3 +- .../server_region_city_monthly_stat_dao.go | 3 +- ...erver_region_city_monthly_stat_dao_test.go | 3 +- .../server_region_country_daily_stat_dao.go | 3 +- ...rver_region_country_daily_stat_dao_test.go | 3 +- .../server_region_country_monthly_stat_dao.go | 3 +- ...server_region_provider_monthly_stat_dao.go | 3 +- ...r_region_provider_monthly_stat_dao_test.go | 3 +- ...server_region_province_monthly_stat_dao.go | 3 +- .../db/models/stats/traffic_daily_stat_dao.go | 3 +- .../stats/traffic_daily_stat_dao_test.go | 5 +- .../models/stats/traffic_hourly_stat_dao.go | 3 +- .../stats/traffic_hourly_stat_dao_test.go | 5 +- internal/db/models/sys_event_dao.go | 1 + internal/db/models/sys_event_dao_test.go | 3 +- internal/db/models/sys_locker_dao.go | 5 +- internal/db/models/sys_locker_dao_test.go | 7 +- internal/db/models/sys_locker_increment.go | 2 +- .../db/models/sys_locker_increment_test.go | 5 +- internal/db/models/sys_setting_dao.go | 5 +- internal/db/models/sys_setting_dao_test.go | 3 +- .../db/models/updating_server_list_dao.go | 5 +- .../models/updating_server_list_model_ext.go | 1 + internal/db/models/user_access_key_dao.go | 3 +- .../db/models/user_bandwidth_stat_dao_test.go | 5 +- internal/db/models/user_dao.go | 1 + internal/db/models/user_dao_ext.go | 2 +- internal/db/models/user_dao_test.go | 3 +- internal/db/models/user_identity_dao.go | 3 +- internal/db/models/user_model_ext.go | 1 + internal/db/models/user_node_dao.go | 5 +- internal/db/models/user_node_model_ext.go | 1 + .../db/models/user_plan_bandwidth_stat_dao.go | 7 +- .../user_plan_bandwidth_stat_dao_test.go | 3 +- .../db/models/user_plan_stat_dao_community.go | 2 +- internal/db/models/utils.go | 5 +- internal/db/models/utils_test.go | 5 +- internal/db/utils/disk.go | 5 +- internal/db/utils/disk_test.go | 5 +- internal/db/utils/utils.go | 13 +- internal/db/utils/utils_test.go | 3 +- .../dnspod/response_custom_line_group_list.go | 2 +- .../dnsclients/dnspod/response_domain_info.go | 2 +- .../dnsclients/dnspod/response_domain_list.go | 2 +- .../dnspod/response_record_create.go | 2 +- .../dnsclients/dnspod/response_record_line.go | 2 +- .../dnsclients/dnspod/response_record_list.go | 2 +- .../dnspod/response_record_modify.go | 2 +- .../dnspod/response_record_remove.go | 2 +- internal/dnsclients/domain_records_cache.go | 7 +- .../dnsclients/domain_records_cahce_test.go | 7 +- internal/dnsclients/edgeapi/response_base.go | 3 +- .../edgeapi/response_create_ns_record.go | 2 +- .../edgeapi/response_find_all_ns_routes.go | 2 +- .../response_find_ns_domain_with_name.go | 2 +- ...ponse_find_ns_record_with_name_and_type.go | 2 +- ...onse_find_ns_records_with_name_and_type.go | 2 +- .../edgeapi/response_get_api_access_token.go | 2 +- .../dnsclients/edgeapi/response_interface.go | 2 +- .../edgeapi/response_list_ns_domains.go | 2 +- .../edgeapi/response_list_ns_records.go | 2 +- .../dnsclients/edgeapi/response_success.go | 2 +- .../edgeapi/response_update_ns_record.go | 2 +- internal/dnsclients/provider_alidns.go | 3 +- internal/dnsclients/provider_alidns_test.go | 3 +- internal/dnsclients/provider_base.go | 1 + internal/dnsclients/provider_base_test.go | 3 +- internal/dnsclients/provider_cloud_flare.go | 13 +- .../dnsclients/provider_cloud_flare_test.go | 3 +- internal/dnsclients/provider_custom_http.go | 9 +- .../dnsclients/provider_custom_http_test.go | 3 +- internal/dnsclients/provider_dns_la.go | 605 ++++++++++++++++++ internal/dnsclients/provider_dns_la_test.go | 217 +++++++ internal/dnsclients/provider_dnspod.go | 11 +- internal/dnsclients/provider_dnspod_test.go | 3 +- internal/dnsclients/provider_edge_dns_api.go | 11 +- .../dnsclients/provider_edge_dns_api_test.go | 3 +- internal/dnsclients/provider_huawei_dns.go | 11 +- .../dnsclients/provider_huawei_dns_test.go | 3 +- internal/dnsclients/provider_tencent_dns.go | 5 +- internal/dnsclients/types.go | 8 +- internal/dnsclients/types_ext.go | 4 + internal/dnsclients/utils.go | 5 +- internal/dnsclients/utils_test.go | 5 +- internal/errors/error.go | 3 +- internal/installers/deploy_manager.go | 5 +- internal/installers/errors.go | 2 +- internal/installers/helpers/unzip_test.go | 3 +- internal/installers/installer_base.go | 11 +- internal/installers/installer_base_test.go | 3 +- internal/installers/installer_node.go | 5 +- internal/installers/installer_node_test.go | 3 +- internal/installers/queue_node.go | 3 +- internal/installers/ssh_client.go | 5 +- internal/installers/ssh_client_test.go | 3 +- internal/installers/upgrade_limiter.go | 7 +- internal/installers/upgrade_limiter_test.go | 7 +- internal/instances/api_config.go | 2 +- internal/instances/instance.go | 19 +- internal/instances/instance_test.go | 5 +- internal/instances/options.go | 2 +- internal/nodes/api_node.go | 25 +- internal/nodes/api_node_ext.go | 4 +- internal/nodes/api_node_services.go | 5 +- internal/nodes/ip_library_updater.go | 9 +- internal/nodes/node_status_executor.go | 9 +- internal/nodes/node_status_executor_test.go | 3 +- internal/nodes/node_status_executor_unix.go | 5 +- .../nodes/node_status_executor_windows.go | 5 +- internal/nodes/rest_server.go | 11 +- internal/nodes/start_issue.go | 2 +- internal/remotelogs/utils.go | 3 +- .../services/clients/service_client_agent.go | 3 +- .../clients/service_client_agent_ip.go | 3 +- .../clients/service_formal_client_browser.go | 3 +- .../clients/service_formal_client_system.go | 3 +- internal/rpc/services/reporters/utils.go | 3 +- .../services/service_acme_authentication.go | 1 + .../rpc/services/service_acme_provider.go | 1 + .../services/service_acme_provider_account.go | 1 + internal/rpc/services/service_acme_task.go | 3 +- internal/rpc/services/service_acme_user.go | 1 + internal/rpc/services/service_admin.go | 3 +- internal/rpc/services/service_admin_ext.go | 3 +- internal/rpc/services/service_admin_test.go | 5 +- .../rpc/services/service_api_access_token.go | 1 + .../rpc/services/service_api_method_stat.go | 1 + internal/rpc/services/service_api_node.go | 9 +- internal/rpc/services/service_api_token.go | 1 + .../rpc/services/service_authority_node.go | 3 +- internal/rpc/services/service_base.go | 1 + internal/rpc/services/service_db.go | 3 +- internal/rpc/services/service_db_node.go | 3 +- internal/rpc/services/service_db_test.go | 3 +- internal/rpc/services/service_dns.go | 1 + internal/rpc/services/service_dns_domain.go | 3 +- internal/rpc/services/service_dns_provider.go | 1 + internal/rpc/services/service_dns_task.go | 1 + internal/rpc/services/service_file.go | 1 + internal/rpc/services/service_file_chunk.go | 1 + internal/rpc/services/service_firewall.go | 7 +- .../rpc/services/service_http_access_log.go | 3 +- .../services/service_http_access_log_ext.go | 2 +- .../rpc/services/service_http_auth_policy.go | 1 + .../rpc/services/service_http_cache_policy.go | 1 + .../rpc/services/service_http_cache_task.go | 5 +- .../services/service_http_cache_task_key.go | 3 +- .../services/service_http_cache_task_test.go | 5 +- internal/rpc/services/service_http_fastcgi.go | 1 + .../services/service_http_firewall_policy.go | 3 +- .../service_http_firewall_policy_test.go | 3 +- .../service_http_firewall_rule_group.go | 1 + .../service_http_firewall_rule_set.go | 1 + internal/rpc/services/service_http_header.go | 1 + .../services/service_http_header_policy.go | 1 + .../rpc/services/service_http_location.go | 1 + internal/rpc/services/service_http_page.go | 1 + .../rpc/services/service_http_rewrite_rule.go | 1 + internal/rpc/services/service_http_web.go | 3 +- .../services/service_http_web_community.go | 3 +- .../rpc/services/service_http_websocket.go | 1 + internal/rpc/services/service_ip_item.go | 5 +- internal/rpc/services/service_ip_library.go | 1 + .../services/service_ip_library_artifact.go | 3 +- .../rpc/services/service_ip_library_file.go | 3 +- internal/rpc/services/service_ip_list.go | 1 + internal/rpc/services/service_latest_item.go | 1 + internal/rpc/services/service_log.go | 1 + internal/rpc/services/service_login.go | 1 + .../rpc/services/service_login_session.go | 3 +- internal/rpc/services/service_login_ticket.go | 3 +- internal/rpc/services/service_message.go | 1 + internal/rpc/services/service_metric_chart.go | 1 + internal/rpc/services/service_metric_item.go | 1 + internal/rpc/services/service_metric_stat.go | 7 +- internal/rpc/services/service_node.go | 30 +- internal/rpc/services/service_node_cluster.go | 3 +- .../rpc/services/service_node_cluster_ext.go | 3 +- .../service_node_cluster_firewall_action.go | 1 + .../service_node_cluster_metric_item.go | 1 + internal/rpc/services/service_node_ext.go | 3 +- internal/rpc/services/service_node_grant.go | 9 +- internal/rpc/services/service_node_group.go | 1 + .../rpc/services/service_node_ip_address.go | 1 + .../services/service_node_ip_address_log.go | 1 + .../service_node_ip_address_threshold.go | 1 + internal/rpc/services/service_node_log.go | 1 + internal/rpc/services/service_node_login.go | 7 +- internal/rpc/services/service_node_region.go | 1 + internal/rpc/services/service_node_stream.go | 9 +- internal/rpc/services/service_node_task.go | 3 +- .../rpc/services/service_node_threshold.go | 1 + internal/rpc/services/service_node_value.go | 1 + internal/rpc/services/service_origin.go | 1 + internal/rpc/services/service_ping.go | 3 +- .../rpc/services/service_plan_community.go | 1 + internal/rpc/services/service_region_city.go | 1 + .../rpc/services/service_region_country.go | 1 + .../rpc/services/service_region_provider.go | 1 + .../rpc/services/service_region_province.go | 1 + internal/rpc/services/service_region_town.go | 1 + .../rpc/services/service_reverse_proxy.go | 1 + internal/rpc/services/service_server.go | 9 +- internal/rpc/services/service_server_.go | 7 +- .../services/service_server_bandwidth_stat.go | 13 +- ...vice_server_client_browser_monthly_stat.go | 1 + ...rvice_server_client_system_monthly_stat.go | 1 + .../rpc/services/service_server_community.go | 1 + .../rpc/services/service_server_daily_stat.go | 7 +- .../service_server_domain_hourly_stat.go | 1 + internal/rpc/services/service_server_group.go | 1 + ...service_server_http_firewall_daily_stat.go | 5 +- ...ce_server_http_firewall_daily_stat_test.go | 3 +- ...service_server_region_city_monthly_stat.go | 1 + ...vice_server_region_country_monthly_stat.go | 1 + ...ice_server_region_provider_monthly_stat.go | 1 + ...ice_server_region_province_monthly_stat.go | 1 + .../rpc/services/service_server_stat_board.go | 3 +- .../service_server_stat_board_chart.go | 1 + internal/rpc/services/service_server_test.go | 3 +- internal/rpc/services/service_ssl_cert.go | 1 + internal/rpc/services/service_ssl_policy.go | 1 + internal/rpc/services/service_sys_locker.go | 1 + internal/rpc/services/service_sys_setting.go | 1 + .../services/service_traffic_daily_stat.go | 3 +- .../services/service_updating_server_list.go | 3 +- .../rpc/services/service_user_access_key.go | 1 + .../rpc/services/service_user_identity.go | 3 +- .../services/service_user_plan_community.go | 1 + internal/rpc/services/sevice_http_gzip.go | 1 + internal/rpc/services/users/service_user.go | 5 +- .../rpc/services/users/service_user_ext.go | 3 +- internal/rpc/tasks/cache_task_manager.go | 5 +- internal/rpc/utils/utils_ext.go | 1 + internal/setup/setup.go | 7 +- internal/setup/setup_test.go | 3 +- internal/setup/sql.json | 20 +- internal/setup/sql_dump.go | 11 +- internal/setup/sql_dump_test.go | 3 +- internal/setup/sql_executor.go | 7 +- internal/setup/sql_executor_ext.go | 2 +- internal/setup/sql_executor_test.go | 3 +- internal/setup/sql_upgrade.go | 5 +- internal/setup/sql_upgrade_ext.go | 5 +- internal/setup/sql_upgrade_ext_test.go | 8 +- internal/setup/sql_upgrade_test.go | 3 +- internal/setup/utils.go | 3 +- internal/setup/utils_test.go | 3 +- internal/tasks/dns_task_executor.go | 7 +- internal/tasks/dns_task_executor_test.go | 5 +- internal/tasks/event_looper.go | 3 +- internal/tasks/health_check_cluster_task.go | 5 +- .../tasks/health_check_cluster_task_test.go | 3 +- internal/tasks/health_check_executor.go | 13 +- internal/tasks/health_check_executor_ext.go | 2 +- internal/tasks/health_check_executor_test.go | 3 +- internal/tasks/health_check_task.go | 3 +- internal/tasks/health_check_task_test.go | 5 +- internal/tasks/log_task.go | 3 +- internal/tasks/log_task_test.go | 5 +- internal/tasks/message_task.go | 3 +- internal/tasks/monitor_item_value_task.go | 3 +- .../tasks/monitor_item_value_task_test.go | 5 +- internal/tasks/node_log_cleaner_task.go | 3 +- internal/tasks/node_log_cleaner_task_test.go | 5 +- internal/tasks/node_monitor_task.go | 5 +- internal/tasks/node_monitor_task_test.go | 5 +- internal/tasks/node_task_extractor.go | 3 +- internal/tasks/server_access_log_cleaner.go | 7 +- .../tasks/server_access_log_cleaner_test.go | 5 +- .../tasks/ssl_cert_expire_check_executor.go | 7 +- .../ssl_cert_expire_check_executor_test.go | 5 +- internal/tasks/ssl_cert_issue_executor.go | 121 ++++ internal/tasks/ssl_cert_update_ocsp_task.go | 7 +- .../tasks/ssl_cert_update_ocsp_task_test.go | 5 +- internal/tasks/task_base.go | 2 +- internal/tasks/task_interface.go | 2 +- internal/utils/cache_map.go | 3 +- internal/utils/cache_map_test.go | 3 +- internal/utils/compare.go | 2 +- internal/utils/compare_test.go | 5 +- internal/utils/domain.go | 2 +- internal/utils/domainutils/utils.go | 4 +- internal/utils/email.go | 2 +- internal/utils/email_test.go | 5 +- internal/utils/exec/cmd.go | 2 +- internal/utils/exec/cmd_test.go | 5 +- internal/utils/exec/look_linux.go | 6 +- internal/utils/exec/look_others.go | 2 +- internal/utils/expires/id_key_map_test.go | 3 +- internal/utils/expires/list.go | 3 +- internal/utils/expires/list_test.go | 9 +- internal/utils/expires/manager.go | 5 +- internal/utils/firewall.go | 7 +- internal/utils/json.go | 2 +- internal/utils/json_test.go | 5 +- internal/utils/lookup.go | 3 +- internal/utils/lookup_test.go | 3 +- internal/utils/maps/fixed_map.go | 2 +- internal/utils/maps/fixed_map_test.go | 5 +- internal/utils/mobile.go | 2 +- internal/utils/mobile_test.go | 5 +- internal/utils/numberutils/utils.go | 3 +- internal/utils/numberutils/utils_test.go | 5 +- internal/utils/progress.go | 2 +- internal/utils/regexputils/expr.go | 2 +- internal/utils/regexputils/expr_test.go | 5 +- internal/utils/service.go | 7 +- internal/utils/service_linux.go | 7 +- internal/utils/service_test.go | 3 +- internal/utils/service_windows.go | 3 +- internal/utils/sha1.go | 7 +- internal/utils/sha1_test.go | 5 +- internal/utils/sizes/sizes_test.go | 3 +- internal/utils/strings.go | 10 + internal/utils/strings_test.go | 3 +- internal/utils/system_test.go | 3 +- internal/utils/taskutils/concurrent.go | 2 +- internal/utils/taskutils/concurrent_test.go | 5 +- internal/utils/testutils/memory.go | 3 +- internal/utils/time.go | 5 +- internal/utils/time_test.go | 3 +- internal/utils/ttlcache/cache.go | 3 +- internal/utils/ttlcache/cache_test.go | 11 +- internal/utils/ttlcache/manager.go | 5 +- internal/utils/ttlcache/piece.go | 5 +- internal/utils/ttlcache/piece_test.go | 3 +- internal/utils/unix_time.go | 3 +- internal/utils/unzip_test.go | 3 +- 520 files changed, 2515 insertions(+), 762 deletions(-) create mode 100644 internal/dnsclients/provider_dns_la.go create mode 100644 internal/dnsclients/provider_dns_la_test.go create mode 100644 internal/tasks/ssl_cert_issue_executor.go diff --git a/build/build.sh b/build/build.sh index c352b405..92d5eddb 100755 --- a/build/build.sh +++ b/build/build.sh @@ -76,10 +76,10 @@ function build() { fi # build sql - if [ $TAG = "plus" ]; then - echo "building sql ..." - "${ROOT}"/sql.sh - fi + # if [ $TAG = "plus" ]; then + # echo "building sql ..." + # "${ROOT}"/sql.sh + # fi # copy files echo "copying ..." @@ -101,7 +101,7 @@ function build() { architects=("amd64" "arm64") for arch in "${architects[@]}"; do # TODO support arm, mips ... - env GOOS=linux GOARCH="${arch}" go build -trimpath -tags $TAG --ldflags="-s -w" -o "$ROOT"/installers/edge-installer-helper-linux-"${arch}" "$ROOT"/../cmd/installer-helper/main.go + env GOOS=linux GOARCH="${arch}" CGO_ENABLED=0 go build -trimpath -tags $TAG --ldflags="-s -w" -o "$ROOT"/installers/edge-installer-helper-linux-"${arch}" "$ROOT"/../cmd/installer-helper/main.go done # building edge dns installer @@ -110,12 +110,29 @@ function build() { architects=("amd64" "arm64") for arch in "${architects[@]}"; do # TODO support arm, mips ... - env GOOS=linux GOARCH="${arch}" go build -trimpath -tags $TAG --ldflags="-s -w" -o "$ROOT"/installers/edge-installer-dns-helper-linux-"${arch}" "$ROOT"/../cmd/installer-dns-helper/main.go + env GOOS=linux GOARCH="${arch}" CGO_ENABLED=0 go build -trimpath -tags $TAG --ldflags="-s -w" -o "$ROOT"/installers/edge-installer-dns-helper-linux-"${arch}" "$ROOT"/../cmd/installer-dns-helper/main.go done fi + CC_PATH="" + CXX_PATH="" + if [[ "${OS}" == "linux" ]]; then + if [ "${ARCH}" == "amd64" ]; then + CC_PATH=$(command -v x86_64-linux-musl-gcc) + CXX_PATH=$(command -v x86_64-linux-musl-g++) + fi + if [ "${ARCH}" == "arm64" ]; then + CC_PATH=$(command -v aarch64-linux-musl-gcc) + CXX_PATH=$(command -v aarch64-linux-musl-g++) + fi + fi # building api node - env GOOS="$OS" GOARCH="$ARCH" go build -trimpath -tags $TAG --ldflags="-s -w" -o "$DIST/bin/$NAME" "$ROOT"/../cmd/edge-api/main.go + if [ -f $CC_PATH ]; then + env CC=$CC_PATH CXX=$CXX_PATH CGO_ENABLED=1 GOOS="$OS" GOARCH="$ARCH" go build -trimpath -tags $TAG --ldflags="-linkmode external -extldflags -static -s -w" -o "$DIST/bin/$NAME" "$ROOT"/../cmd/edge-api/main.go + else + env GOOS="$OS" GOARCH="$ARCH" go build -trimpath -tags $TAG --ldflags="-s -w" -o "$DIST/bin/$NAME" "$ROOT"/../cmd/edge-api/main.go + fi + if [ ! -f "${DIST}/bin/${NAME}" ]; then echo "build failed!" exit diff --git a/cmd/edge-api/main.go b/cmd/edge-api/main.go index 92db6b57..d98db1f7 100644 --- a/cmd/edge-api/main.go +++ b/cmd/edge-api/main.go @@ -4,6 +4,10 @@ import ( "encoding/json" "flag" "fmt" + "log" + "os" + "strings" + "github.com/TeaOSLab/EdgeAPI/internal/apps" "github.com/TeaOSLab/EdgeAPI/internal/configs" teaconst "github.com/TeaOSLab/EdgeAPI/internal/const" @@ -15,9 +19,6 @@ import ( "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/types" "github.com/iwind/gosock/pkg/gosock" - "log" - "os" - "strings" ) func main() { diff --git a/cmd/edge-instance-installer/main.go b/cmd/edge-instance-installer/main.go index 572a8fa3..c60bb793 100644 --- a/cmd/edge-instance-installer/main.go +++ b/cmd/edge-instance-installer/main.go @@ -1,14 +1,15 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package main import ( "fmt" + "log" + "os" + "github.com/TeaOSLab/EdgeAPI/internal/instances" _ "github.com/iwind/TeaGo/bootstrap" "github.com/iwind/TeaGo/lists" - "log" - "os" ) func main() { diff --git a/cmd/installer-dns-helper/main.go b/cmd/installer-dns-helper/main.go index d7472f3c..54ab5f25 100644 --- a/cmd/installer-dns-helper/main.go +++ b/cmd/installer-dns-helper/main.go @@ -2,10 +2,11 @@ package main import ( "flag" - "github.com/TeaOSLab/EdgeAPI/internal/installers/helpers" - "github.com/iwind/gosock/pkg/gosock" "os" "os/exec" + + "github.com/TeaOSLab/EdgeAPI/internal/installers/helpers" + "github.com/iwind/gosock/pkg/gosock" ) func main() { diff --git a/cmd/installer-helper/main.go b/cmd/installer-helper/main.go index 1f7dfac7..7db6f43c 100644 --- a/cmd/installer-helper/main.go +++ b/cmd/installer-helper/main.go @@ -3,10 +3,11 @@ package main // 注意这里的依赖文件应该最小化,从而使编译后的文件最小化 import ( "flag" - "github.com/TeaOSLab/EdgeAPI/internal/installers/helpers" - "github.com/iwind/gosock/pkg/gosock" "os" "os/exec" + + "github.com/TeaOSLab/EdgeAPI/internal/installers/helpers" + "github.com/iwind/gosock/pkg/gosock" ) func main() { diff --git a/cmd/sql-dump/main.go b/cmd/sql-dump/main.go index d201b439..654e0327 100644 --- a/cmd/sql-dump/main.go +++ b/cmd/sql-dump/main.go @@ -3,12 +3,13 @@ package main import ( "encoding/json" "fmt" + "os" + "path/filepath" + "github.com/TeaOSLab/EdgeAPI/internal/setup" "github.com/iwind/TeaGo/Tea" _ "github.com/iwind/TeaGo/bootstrap" "github.com/iwind/TeaGo/dbs" - "os" - "path/filepath" ) func main() { diff --git a/cmd/tt/main.go b/cmd/tt/main.go index 2890ac56..5d2d18c5 100644 --- a/cmd/tt/main.go +++ b/cmd/tt/main.go @@ -4,13 +4,14 @@ import ( "bufio" "bytes" "fmt" + "os" + "path/filepath" + "time" + "github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/cmd" _ "github.com/iwind/TeaGo/dbs/commands" "github.com/iwind/TeaGo/lists" - "os" - "path/filepath" - "time" ) // TeaTool工具 diff --git a/go.mod b/go.mod index f34ba081..ca38bda0 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/TeaOSLab/EdgeAPI -go 1.21 +go 1.22 replace github.com/TeaOSLab/EdgeCommon => ../EdgeCommon @@ -8,43 +8,45 @@ require ( github.com/Azure/azure-sdk-for-go/sdk/azcore v1.11.1 github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.5.2 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns v1.2.0 - github.com/TeaOSLab/EdgeCommon v0.0.0-00010101000000-000000000000 github.com/aliyun/alibaba-cloud-sdk-go v1.62.712 - github.com/andybalholm/brotli v1.0.4 - github.com/aws/aws-sdk-go v1.40.45 + github.com/andybalholm/brotli v1.0.5 + github.com/aws/aws-sdk-go v1.44.279 github.com/cespare/xxhash v1.1.0 github.com/fsnotify/fsnotify v1.7.0 - github.com/go-acme/lego/v4 v4.15.0 - github.com/go-sql-driver/mysql v1.7.0 + github.com/go-acme/lego/v4 v4.17.3 + github.com/go-sql-driver/mysql v1.8.1 github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible github.com/iwind/TeaGo v0.0.0-20240508072741-7647e70b7070 github.com/iwind/gosock v0.0.0-20220505115348-f88412125a62 - github.com/miekg/dns v1.1.58 + github.com/miekg/dns v1.1.59 github.com/mozillazg/go-pinyin v0.18.0 github.com/pkg/sftp v1.12.0 - github.com/shirou/gopsutil/v3 v3.22.2 + github.com/shirou/gopsutil/v3 v3.24.2 github.com/smartwalle/alipay/v3 v3.2.20 - github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.898 + github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.918 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dnspod v1.0.898 + github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/sms v1.0.918 github.com/volcengine/volc-sdk-golang v1.0.124 - golang.org/x/crypto v0.22.0 - golang.org/x/net v0.24.0 - golang.org/x/sys v0.19.0 - google.golang.org/grpc v1.63.1 + golang.org/x/crypto v0.23.0 + golang.org/x/net v0.25.0 + golang.org/x/sys v0.20.0 + google.golang.org/grpc v1.63.2 gopkg.in/yaml.v3 v3.0.1 ) require ( + filippo.io/edwards25519 v1.1.0 // indirect github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.2 // indirect github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect github.com/cenkalti/backoff/v4 v4.3.0 // indirect - github.com/go-jose/go-jose/v3 v3.0.1 // indirect + github.com/go-jose/go-jose/v4 v4.0.1 // indirect github.com/go-ole/go-ole v1.2.6 // indirect github.com/golang-jwt/jwt/v5 v5.2.1 // indirect github.com/google/uuid v1.6.0 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/kr/fs v0.1.0 // indirect + github.com/kr/pretty v0.3.1 // indirect github.com/kylelemons/godebug v1.1.0 // indirect github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect @@ -53,18 +55,20 @@ require ( github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect github.com/pkg/errors v0.9.1 // indirect github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect + github.com/rogpeppe/go-internal v1.12.0 // indirect + github.com/shoenig/go-m1cpu v0.1.6 // indirect github.com/smartwalle/ncrypto v1.0.4 // indirect github.com/smartwalle/ngx v1.0.9 // indirect github.com/smartwalle/nsign v1.0.9 // indirect github.com/technoweenie/multipartstreamer v1.0.1 // indirect - github.com/tklauser/go-sysconf v0.3.9 // indirect - github.com/tklauser/numcpus v0.3.0 // indirect - github.com/yusufpapurcu/wmi v1.2.2 // indirect + github.com/tklauser/go-sysconf v0.3.13 // indirect + github.com/tklauser/numcpus v0.7.0 // indirect + github.com/yusufpapurcu/wmi v1.2.4 // indirect golang.org/x/mod v0.17.0 // indirect golang.org/x/sync v0.7.0 // indirect - golang.org/x/text v0.14.0 // indirect - golang.org/x/tools v0.20.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 // indirect + golang.org/x/text v0.15.0 // indirect + golang.org/x/tools v0.21.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240415180920-8c6c420018be // indirect google.golang.org/protobuf v1.33.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect ) diff --git a/go.sum b/go.sum index 9ded94e5..00367311 100644 --- a/go.sum +++ b/go.sum @@ -31,6 +31,8 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= +filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= +filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.11.1 h1:E+OJmp2tPvt1W+amx48v1eqbjDYsgN+RzP4q16yV5eM= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.11.1/go.mod h1:a6xsAQUZg+VsS3TJ05SRp524Hs4pZ/AeFSr5ENf0Yjo= github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.5.2 h1:FDif4R1+UUR+00q6wquyX90K7A8dN+R5E8GEadoP7sU= @@ -67,8 +69,8 @@ github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRF github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= github.com/aliyun/alibaba-cloud-sdk-go v1.62.712 h1:lM7JnA9dEdDFH9XOgRNQMDTQnOjlLkDTNA7c0aWTQ30= github.com/aliyun/alibaba-cloud-sdk-go v1.62.712/go.mod h1:SOSDHfe1kX91v3W5QiBsWSLqeLxImobbMX1mxrFHsVQ= -github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY= -github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= +github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs= +github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= @@ -77,8 +79,9 @@ github.com/armon/go-metrics v0.3.9/go.mod h1:4O98XIr/9W0sxpJ8UaYkvjk10Iff7SnFrb4 github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/avast/retry-go v3.0.0+incompatible/go.mod h1:XtSnn+n/sHqQIpZ10K1qAevBhOOCWBLXXy3hyiqqBrY= -github.com/aws/aws-sdk-go v1.40.45 h1:QN1nsY27ssD/JmW4s83qmSb+uL6DG4GmCDzjmJB4xUI= github.com/aws/aws-sdk-go v1.40.45/go.mod h1:585smgzpB/KqRA+K3y/NL/oYRqQvpNJYvLm+LY1U59Q= +github.com/aws/aws-sdk-go v1.44.279 h1:g23dxnYjIiPlQo0gIKNR0zVPsSvo1bj5frWln+5sfhk= +github.com/aws/aws-sdk-go v1.44.279/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v1.9.1/go.mod h1:cK/D0BBs0b/oWPIcX/Z/obahJK1TT7IPVjy53i/mX/4= github.com/aws/aws-sdk-go-v2/service/cloudwatch v1.8.1/go.mod h1:CM+19rL1+4dFWnOQKwDc7H1KwXTz+h61oUSHyhV0b3o= github.com/aws/smithy-go v1.8.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAmR5n+E= @@ -146,13 +149,13 @@ github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4 github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/go-acme/lego/v4 v4.15.0 h1:A7MHEU3b+TDFqhC/HmzMJnzPbyeaYvMZQBbqgvbThhU= -github.com/go-acme/lego/v4 v4.15.0/go.mod h1:eeGhjW4zWT7Ccqa3sY7ayEqFLCAICx+mXgkMHKIkLxg= +github.com/go-acme/lego/v4 v4.17.3 h1:5our7Qdyik0abag40abdmQuytq97iweaNHFMT4pYDnQ= +github.com/go-acme/lego/v4 v4.17.3/go.mod h1:Ol6l04hnmavqVHKYS/ByhXXqE64x8yVYhomha82uAUk= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-jose/go-jose/v3 v3.0.1 h1:pWmKFVtt+Jl0vBZTIpz/eAKwsm6LkIxDVVbFHKkchhA= -github.com/go-jose/go-jose/v3 v3.0.1/go.mod h1:RNkWWRld676jZEYoV3+XK8L2ZnNSvIsxFMht0mSX+u8= +github.com/go-jose/go-jose/v4 v4.0.1 h1:QVEPDE3OluqXBQZDcnNvQrInro2h0e4eqNbnZSWqS6U= +github.com/go-jose/go-jose/v4 v4.0.1/go.mod h1:WVf9LFMHh/QVrmqrOfqun0C45tMe3RoiKJMPvgWwLfY= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.12.0/go.mod h1:lHd+EkCZPIwYItmGDDRdhinkzX2A1sj+M9biaEaizzs= @@ -164,8 +167,8 @@ github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= -github.com/go-sql-driver/mysql v1.7.0 h1:ueSltNNllEqE3qcWBTD0iQd3IpL/6U+mJxLkazJ7YPc= -github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= +github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y= +github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible h1:2cauKuaELYAEARXRkq2LrJ0yDDv1rW7+wrTEdVL3uaU= @@ -224,7 +227,7 @@ github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= @@ -332,8 +335,8 @@ github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= -github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -356,8 +359,8 @@ github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5 github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= github.com/miekg/dns v1.1.43/go.mod h1:+evo5L0630/F6ca/Z9+GAqzhjGyn8/c+TBaOyfEl0V4= -github.com/miekg/dns v1.1.58 h1:ca2Hdkz+cDg/7eNF6V56jjzuZ4aCAE+DbVkILdQWG/4= -github.com/miekg/dns v1.1.58/go.mod h1:Ypv+3b/KadlvW9vJfXOTf300O4UqaHFzFCuHz+rPkBY= +github.com/miekg/dns v1.1.59 h1:C9EXc/UToRwKLhK5wKU/I4QVsBUc8kE6MkHBkeypWZs= +github.com/miekg/dns v1.1.59/go.mod h1:nZpewl5p6IvctfgrckopVx2OlSEHPRO/U4SYkRklrEk= github.com/minio/highwayhash v1.0.1/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY= github.com/minio/highwayhash v1.0.2/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY= github.com/mitchellh/cli v1.1.0/go.mod h1:xcISNoH86gajksDmfB23e/pu+B+GeFRMYmoHXxx3xhI= @@ -446,12 +449,17 @@ github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqn github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= -github.com/shirou/gopsutil/v3 v3.22.2 h1:wCrArWFkHYIdDxx/FSfF5RB4dpJYW6t7rcp3+zL8uks= -github.com/shirou/gopsutil/v3 v3.22.2/go.mod h1:WapW1AOOPlHyXr+yOyw3uYx36enocrtSoSBy0L5vUHY= +github.com/shirou/gopsutil/v3 v3.24.2 h1:kcR0erMbLg5/3LcInpw0X/rrPSqq4CDPyI6A6ZRC18Y= +github.com/shirou/gopsutil/v3 v3.24.2/go.mod h1:tSg/594BcA+8UdQU2XcW803GWYgdtauFFPgJCJKZlVk= +github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM= +github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ= +github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU= +github.com/shoenig/test v0.6.4/go.mod h1:byHiCGXqrVaflBLAMq/srcZIHynQPQgeyvkvXnjqq0k= github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= @@ -477,24 +485,34 @@ github.com/streadway/amqp v1.0.0/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1Sd github.com/streadway/handy v0.0.0-20200128134331-0f66f006fb2e/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/technoweenie/multipartstreamer v1.0.1 h1:XRztA5MXiR1TIRHxH2uNxXxaIkKQDeX7m2XsSOlQEnM= github.com/technoweenie/multipartstreamer v1.0.1/go.mod h1:jNVxdtShOxzAsukZwTSw6MDx5eUJoiEBsSvzDU9uzog= -github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.898 h1:ERwcXqhc94L9cFxtiI0pvt7IJtlHl/p/Jayl3mLw+ms= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.898/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0= +github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.918 h1:ufylziLaOLyvMzQRq9BqF59OCC6tyPNuRvEUfBcmf00= +github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.918/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dnspod v1.0.898 h1:LoYv5u+gUoFpU/AmIuTRG/2KiEkdm9gCC0dTvk8WITQ= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dnspod v1.0.898/go.mod h1:c1j6YQ+vCbeA8kJ59Im4UnMd1GxovlpPBDhGZoewfn8= -github.com/tklauser/go-sysconf v0.3.9 h1:JeUVdAOWhhxVcU6Eqr/ATFHgXk/mmiItdKeJPev3vTo= -github.com/tklauser/go-sysconf v0.3.9/go.mod h1:11DU/5sG7UexIrp/O6g35hrWzu0JxlwQ3LSFUzyeuhs= -github.com/tklauser/numcpus v0.3.0 h1:ILuRUQBtssgnxw0XXIjKUC56fgnOrFoQQ/4+DeU2biQ= -github.com/tklauser/numcpus v0.3.0/go.mod h1:yFGUr7TUHQRAhyqBcEg0Ge34zDBAsIvJJcyE6boqnA8= +github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/sms v1.0.918 h1:XNjdcqnZWhWRMuxdYpMnMCdVf1lICgEo1qvZS21e4vU= +github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/sms v1.0.918/go.mod h1:/RdYOqS//MZNeusaTAdsjycZlwtO/sWhLLBEBEuF7Jk= +github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= +github.com/tklauser/go-sysconf v0.3.13 h1:GBUpcahXSpR2xN01jhkNAbTLRk2Yzgggk8IM08lq3r4= +github.com/tklauser/go-sysconf v0.3.13/go.mod h1:zwleP4Q4OehZHGn4CYZDipCgg9usW5IJePewFCGVEa0= +github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= +github.com/tklauser/numcpus v0.7.0 h1:yjuerZP127QG9m5Zh/mSO4wqurYil27tHrqwRoRjpr4= +github.com/tklauser/numcpus v0.7.0/go.mod h1:bb6dMVcj8A42tSE7i32fsIUCbQNllK5iDguyOZRUzAY= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/uber/jaeger-client-go v2.30.0+incompatible h1:D6wyKGCecFaSRUpo8lCVbaOOb6ThwMmTEbhRwtKR97o= github.com/uber/jaeger-client-go v2.30.0+incompatible/go.mod h1:WVhlPFC8FDjOFMMWRy2pZqQJSXxYSwNYOkTr/Z6d3Kk= @@ -514,8 +532,8 @@ github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg= -github.com/yusufpapurcu/wmi v1.2.2/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= +github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0= +github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs= go.etcd.io/etcd/client/pkg/v3 v3.5.0/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g= go.etcd.io/etcd/client/v2 v2.305.0/go.mod h1:h9puh54ZTgAKtEbut2oe9P4L/oqKCVB6xsXlzd7alYQ= @@ -540,7 +558,6 @@ golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnf golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= @@ -554,8 +571,8 @@ golang.org/x/crypto v0.0.0-20210920023735-84f357641f63/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio= -golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= -golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= +golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI= +golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -638,13 +655,14 @@ golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qx golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210917221730-978cfadd31cf/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/net v0.3.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= -golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= -golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= +golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac= +golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -725,9 +743,7 @@ golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210816074244-15123e1e1f71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210917161153-d61c044b1678/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220111092808-5a964db01320/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -736,17 +752,19 @@ golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= -golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= +golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/term v0.3.0/go.mod h1:q750SLmJuPmVoN1blW3UFBPREJfb1KmY3vwxfr+nFDA= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= golang.org/x/term v0.10.0/go.mod h1:lpqdcUyK/oCiQxvxVrppt5ggO2KCZ5QblwqPnfZ6d5o= -golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q= -golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk= +golang.org/x/term v0.20.0 h1:VnkxpohqXaOBYJtBmEppKUG6mXpi+4O6purfc2+sMhw= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -760,8 +778,8 @@ golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= +golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -819,8 +837,8 @@ golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.4.0/go.mod h1:UE5sM2OK9E/d67R0ANs2xJizIymRP5gJU295PvKXxjQ= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.20.0 h1:hz/CVckiOxybQvFw6h7b/q80NTr9IUQb4s1IIzW7KNY= -golang.org/x/tools v0.20.0/go.mod h1:WvitBU7JJf6A4jOdg4S1tviW9bhUxkgeCui/0JHctQg= +golang.org/x/tools v0.21.0 h1:qc0xYgIbsSDt9EyWz05J5wfa7LOVW0YTLOXrqdLAWIw= +golang.org/x/tools v0.21.0/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -883,8 +901,8 @@ google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= google.golang.org/genproto v0.0.0-20210917145530-b395a37504d4/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 h1:NnYq6UN9ReLM9/Y01KWNOWyI5xQ9kbIms5GGJVwS/Yc= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240415180920-8c6c420018be h1:LG9vZxsWGOmUKieR8wPAUR3u3MpnYFQZROPIMaXh7/A= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240415180920-8c6c420018be/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= @@ -902,8 +920,8 @@ google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= -google.golang.org/grpc v1.63.1 h1:pNClQmvdlyNUiwFETOux/PYqfhmA7BrswEdGRnib1fA= -google.golang.org/grpc v1.63.1/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA= +google.golang.org/grpc v1.63.2 h1:MUeiw1B2maTVZthpU5xvASfTh3LDbxHd6IJ6QQVU+xM= +google.golang.org/grpc v1.63.2/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= diff --git a/internal/acme/acme_test.go b/internal/acme/acme_test.go index 6d0c103c..8e3caad9 100644 --- a/internal/acme/acme_test.go +++ b/internal/acme/acme_test.go @@ -5,14 +5,15 @@ import ( "crypto/ecdsa" "crypto/elliptic" "crypto/rand" + "io" + "log" + "testing" + "github.com/go-acme/lego/v4/certcrypto" "github.com/go-acme/lego/v4/certificate" "github.com/go-acme/lego/v4/challenge/dns01" "github.com/go-acme/lego/v4/lego" acmelog "github.com/go-acme/lego/v4/log" - "io" - "log" - "testing" "github.com/go-acme/lego/v4/registration" ) diff --git a/internal/acme/dns_provider.go b/internal/acme/dns_provider.go index 33ceb248..c6357b1a 100644 --- a/internal/acme/dns_provider.go +++ b/internal/acme/dns_provider.go @@ -2,15 +2,16 @@ package acme import ( "fmt" + "os" + "strings" + "sync" + "time" + "github.com/TeaOSLab/EdgeAPI/internal/dnsclients" "github.com/TeaOSLab/EdgeAPI/internal/dnsclients/dnstypes" "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/go-acme/lego/v4/challenge/dns01" "github.com/iwind/TeaGo/lists" - "os" - "strings" - "sync" - "time" ) type DNSProvider struct { diff --git a/internal/acme/providers_ext.go b/internal/acme/providers_ext.go index 1f0815d2..56aca031 100644 --- a/internal/acme/providers_ext.go +++ b/internal/acme/providers_ext.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . //go:build !plus package acme diff --git a/internal/acme/request.go b/internal/acme/request.go index 121aec19..c55a24bb 100644 --- a/internal/acme/request.go +++ b/internal/acme/request.go @@ -2,6 +2,9 @@ package acme import ( "fmt" + "io" + "log" + teaconst "github.com/TeaOSLab/EdgeAPI/internal/const" "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/go-acme/lego/v4/certcrypto" @@ -10,8 +13,6 @@ import ( acmelog "github.com/go-acme/lego/v4/log" "github.com/go-acme/lego/v4/registration" "github.com/iwind/TeaGo/Tea" - "io" - "log" ) type Request struct { diff --git a/internal/acme/request_test.go b/internal/acme/request_test.go index b6592e41..98f9d3c0 100644 --- a/internal/acme/request_test.go +++ b/internal/acme/request_test.go @@ -2,13 +2,14 @@ package acme import ( "encoding/json" + "testing" + "github.com/TeaOSLab/EdgeAPI/internal/dnsclients" "github.com/go-acme/lego/v4/registration" _ "github.com/go-sql-driver/mysql" _ "github.com/iwind/TeaGo/bootstrap" "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/maps" - "testing" ) func TestRequest_Run_DNS(t *testing.T) { diff --git a/internal/acme/user.go b/internal/acme/user.go index 38f429c0..78624556 100644 --- a/internal/acme/user.go +++ b/internal/acme/user.go @@ -3,6 +3,7 @@ package acme import ( "crypto" "encoding/json" + "github.com/go-acme/lego/v4/registration" ) diff --git a/internal/apps/app_cmd.go b/internal/apps/app_cmd.go index da1d55c0..4a3b6278 100644 --- a/internal/apps/app_cmd.go +++ b/internal/apps/app_cmd.go @@ -3,11 +3,6 @@ package apps import ( "errors" "fmt" - teaconst "github.com/TeaOSLab/EdgeAPI/internal/const" - "github.com/iwind/TeaGo/logs" - "github.com/iwind/TeaGo/maps" - "github.com/iwind/TeaGo/types" - "github.com/iwind/gosock/pkg/gosock" "os" "os/exec" "path/filepath" @@ -15,6 +10,12 @@ import ( "strconv" "strings" "time" + + teaconst "github.com/TeaOSLab/EdgeAPI/internal/const" + "github.com/iwind/TeaGo/logs" + "github.com/iwind/TeaGo/maps" + "github.com/iwind/TeaGo/types" + "github.com/iwind/gosock/pkg/gosock" ) // AppCmd App命令帮助 diff --git a/internal/apps/log_writer.go b/internal/apps/log_writer.go index 0c23588f..4e0a4c08 100644 --- a/internal/apps/log_writer.go +++ b/internal/apps/log_writer.go @@ -1,16 +1,17 @@ package apps import ( - "github.com/TeaOSLab/EdgeAPI/internal/goman" - "github.com/TeaOSLab/EdgeAPI/internal/utils/sizes" - "github.com/iwind/TeaGo/Tea" - "github.com/iwind/TeaGo/files" - timeutil "github.com/iwind/TeaGo/utils/time" "log" "os" "runtime" "strconv" "strings" + + "github.com/TeaOSLab/EdgeAPI/internal/goman" + "github.com/TeaOSLab/EdgeAPI/internal/utils/sizes" + "github.com/iwind/TeaGo/Tea" + "github.com/iwind/TeaGo/files" + timeutil "github.com/iwind/TeaGo/utils/time" ) type LogWriter struct { diff --git a/internal/configs/api_config.go b/internal/configs/api_config.go index 286eaf6d..ed97234c 100644 --- a/internal/configs/api_config.go +++ b/internal/configs/api_config.go @@ -1,11 +1,12 @@ package configs import ( + "os" + "path/filepath" + teaconst "github.com/TeaOSLab/EdgeAPI/internal/const" "github.com/iwind/TeaGo/Tea" "gopkg.in/yaml.v3" - "os" - "path/filepath" ) var sharedAPIConfig *APIConfig = nil diff --git a/internal/configs/api_config_test.go b/internal/configs/api_config_test.go index 74fe515a..d9cee5b8 100644 --- a/internal/configs/api_config_test.go +++ b/internal/configs/api_config_test.go @@ -1,8 +1,9 @@ package configs import ( - _ "github.com/iwind/TeaGo/bootstrap" "testing" + + _ "github.com/iwind/TeaGo/bootstrap" ) func TestSharedAPIConfig(t *testing.T) { diff --git a/internal/configs/db_config.go b/internal/configs/db_config.go index e113e7a9..fd446247 100644 --- a/internal/configs/db_config.go +++ b/internal/configs/db_config.go @@ -1,13 +1,14 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package configs import ( "errors" + "os" + "github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/dbs" "gopkg.in/yaml.v3" - "os" ) func LoadDBConfig() (*dbs.Config, error) { diff --git a/internal/configs/simple_db_config.go b/internal/configs/simple_db_config.go index cbc66c21..07591f68 100644 --- a/internal/configs/simple_db_config.go +++ b/internal/configs/simple_db_config.go @@ -1,14 +1,15 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package configs import ( "fmt" + "net/url" + "os" + "github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/dbs" "gopkg.in/yaml.v3" - "net/url" - "os" ) type SimpleDBConfig struct { @@ -28,7 +29,7 @@ func ParseSimpleDBConfig(data []byte) (*SimpleDBConfig, error) { func (this *SimpleDBConfig) GenerateOldConfig() error { var dbConfig = &dbs.DBConfig{ Driver: "mysql", - Dsn: url.QueryEscape(this.User) + ":" + url.QueryEscape(this.Password) + "@tcp(" + this.Host + ")/" + url.PathEscape(this.Database) + "?charset=utf8mb4&timeout=30s&multiStatements=true", + Dsn: url.QueryEscape(this.User) + ":" + this.Password + "@tcp(" + this.Host + ")/" + url.PathEscape(this.Database) + "?charset=utf8mb4&timeout=30s&multiStatements=true", Prefix: "edge", } dbConfig.Models.Package = "internal/db/models" diff --git a/internal/const/const.go b/internal/const/const.go index 79f60fa2..fb8fafa9 100644 --- a/internal/const/const.go +++ b/internal/const/const.go @@ -1,7 +1,7 @@ package teaconst const ( - Version = "1.3.9" + Version = "1.4.1" ProductName = "Edge API" ProcessName = "edge-api" @@ -17,5 +17,5 @@ const ( // 其他节点版本号,用来检测是否有需要升级的节点 - NodeVersion = "1.3.9" + NodeVersion = "1.4.0" ) diff --git a/internal/const/const_community.go b/internal/const/const_community.go index efadd2ba..dffaa80b 100644 --- a/internal/const/const_community.go +++ b/internal/const/const_community.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . //go:build !plus package teaconst diff --git a/internal/const/vars.go b/internal/const/vars.go index 832bda6a..eb5aa524 100644 --- a/internal/const/vars.go +++ b/internal/const/vars.go @@ -5,11 +5,12 @@ package teaconst import ( "crypto/sha1" "fmt" - "github.com/iwind/TeaGo/rands" - "github.com/iwind/TeaGo/types" "os" "strings" "time" + + "github.com/iwind/TeaGo/rands" + "github.com/iwind/TeaGo/types" ) var ( diff --git a/internal/db/db_test.go b/internal/db/db_test.go index 662f45af..794f35c4 100644 --- a/internal/db/db_test.go +++ b/internal/db/db_test.go @@ -3,13 +3,14 @@ package db import ( "database/sql" "database/sql/driver" + "testing" + "time" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" _ "github.com/go-sql-driver/mysql" "github.com/iwind/TeaGo/Tea" _ "github.com/iwind/TeaGo/bootstrap" "github.com/iwind/TeaGo/dbs" - "testing" - "time" ) func TestDB_Env(t *testing.T) { diff --git a/internal/db/models/acme/acme_task_dao.go b/internal/db/models/acme/acme_task_dao.go index 17f50a99..ab6b44b2 100644 --- a/internal/db/models/acme/acme_task_dao.go +++ b/internal/db/models/acme/acme_task_dao.go @@ -4,6 +4,13 @@ import ( "bytes" "context" "encoding/json" + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" + "net/http" + "strconv" + "strings" + "sync" + "time" + acmeutils "github.com/TeaOSLab/EdgeAPI/internal/acme" teaconst "github.com/TeaOSLab/EdgeAPI/internal/const" "github.com/TeaOSLab/EdgeAPI/internal/db/models" @@ -21,15 +28,21 @@ import ( "github.com/iwind/TeaGo/logs" "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/types" - "net/http" - "time" ) const ( ACMETaskStateEnabled = 1 // 已启用 ACMETaskStateDisabled = 0 // 已禁用 + + ACMETaskStatusPending = 0 + ACMETaskStatusDone = 1 + ACMETaskStatusRunning = 2 + ACMETaskStatusIssueFailed = 3 ) +var runningTaskMap sync.Map +var serverBindMutex = &sync.Mutex{} + type ACMETaskDAO dbs.DAO func NewACMETaskDAO() *ACMETaskDAO { @@ -187,7 +200,7 @@ func (this *ACMETaskDAO) ListEnabledACMETasks(tx *dbs.Tx, userId int64, isAvaila } // CreateACMETask 创建任务 -func (this *ACMETaskDAO) CreateACMETask(tx *dbs.Tx, adminId int64, userId int64, authType acmeutils.AuthType, acmeUserId int64, dnsProviderId int64, dnsDomain string, domains []string, autoRenew bool, authURL string) (int64, error) { +func (this *ACMETaskDAO) CreateACMETask(tx *dbs.Tx, adminId int64, userId int64, authType acmeutils.AuthType, acmeUserId int64, dnsProviderId int64, dnsDomain string, domains []string, autoRenew bool, authURL string, async bool) (int64, error) { var op = NewACMETaskOperator() op.AdminId = adminId op.UserId = userId @@ -210,6 +223,7 @@ func (this *ACMETaskDAO) CreateACMETask(tx *dbs.Tx, adminId int64, userId int64, op.AuthURL = authURL op.IsOn = true op.State = ACMETaskStateEnabled + op.Async = async err := this.Save(tx, op) if err != nil { return 0, err @@ -281,7 +295,7 @@ func (this *ACMETaskDAO) UpdateACMETaskCert(tx *dbs.Tx, taskId int64, certId int // RunTask 执行任务并记录日志 func (this *ACMETaskDAO) RunTask(tx *dbs.Tx, taskId int64) (isOk bool, errMsg string, resultCertId int64) { - isOk, errMsg, resultCertId = this.runTaskWithoutLog(tx, taskId) + isOk, errMsg, resultCertId = this.runTaskWithoutLog(tx, taskId, false) // 记录日志 err := SharedACMETaskLogDAO.CreateACMETaskLog(tx, taskId, isOk, errMsg) @@ -293,7 +307,7 @@ func (this *ACMETaskDAO) RunTask(tx *dbs.Tx, taskId int64) (isOk bool, errMsg st } // 执行任务但并不记录日志 -func (this *ACMETaskDAO) runTaskWithoutLog(tx *dbs.Tx, taskId int64) (isOk bool, errMsg string, resultCertId int64) { +func (this *ACMETaskDAO) runTaskWithoutLog(tx *dbs.Tx, taskId int64, randomAcmeAccount bool) (isOk bool, errMsg string, resultCertId int64) { task, err := this.FindEnabledACMETask(tx, taskId) if err != nil { errMsg = "查询任务信息时出错:" + err.Error() @@ -308,6 +322,17 @@ func (this *ACMETaskDAO) runTaskWithoutLog(tx *dbs.Tx, taskId int64) (isOk bool, return } + if task.Status == ACMETaskStatusDone { + errMsg = "任务已完成" + return + } + + // 设置执行中 + err = this.UpdateStatus(tx, taskId, ACMETaskStatusRunning) + if err != nil { + logs.Error(err) + } + // ACME用户 user, err := SharedACMEUserDAO.FindEnabledACMEUser(tx, int64(task.AcmeUserId)) if err != nil { @@ -323,6 +348,15 @@ func (this *ACMETaskDAO) runTaskWithoutLog(tx *dbs.Tx, taskId int64) (isOk bool, if len(user.ProviderCode) == 0 { user.ProviderCode = acmeutils.DefaultProviderCode } + + if randomAcmeAccount { + user, err = SharedACMEUserDAO.FindRandomACMEUserWithSameProvider(tx, user.ProviderCode) + if user == nil { + errMsg = "找不到ACME用户" + return + } + } + var acmeProvider = acmeutils.FindProviderWithCode(user.ProviderCode) if acmeProvider == nil { errMsg = "服务商已不可用" @@ -515,3 +549,193 @@ func (this *ACMETaskDAO) runTaskWithoutLog(tx *dbs.Tx, taskId int64) (isOk bool, isOk = true return } + +// FindIssueACMETask 查找N小时内未执行的AcmeTask +func (this *ACMETaskDAO) FindIssueACMETask(tx *dbs.Tx, hour int, limit int64, excludeTasks []int64) (result []*ACMETask, err error) { + if len(excludeTasks) == 0 { + excludeTasks = append(excludeTasks, 0) + } + var strIDs []string + for _, id := range excludeTasks { + strIDs = append(strIDs, strconv.FormatInt(id, 10)) + } + _, err = this.Query(tx). + Attr("isOn", true). + Attr("async", true). + State(ACMETaskStateEnabled). + Where("FROM_UNIXTIME(createdAt, '%Y-%m-%d %H:%i')>:hoursAgo AND certId=0 and id NOT IN ("+strings.Join(strIDs, ",")+")"). + Param("hoursAgo", time.Now().UTC().Add(-time.Duration(hour)*time.Hour).Format("2006-01-02 15:04")). + Param("now", time.Now().Unix()). + Slice(&result). + AscPk(). + Limit(limit). + FindAll() + return +} + +// UpdateStatus 更新状态 +func (this *ACMETaskDAO) UpdateStatus(tx *dbs.Tx, id int64, status int64) error { + _, err := this.Query(tx). + Pk(id). + Set("status", status). + Update() + return err +} + +// RunTaskAndAutoBindServer 证书签发并绑定Server,记录日志 +func (this *ACMETaskDAO) RunTaskAndAutoBindServer(tx *dbs.Tx, taskId int64, domains []string) (isOk bool, errMsg string) { + _, ok := runningTaskMap.Load(taskId) + if ok { + return true, "" // 返回ok,异步任务无需继续执行 + } + + isOk, errMsg, resultCertId := this.runTaskWithoutLog(tx, taskId, true) + + // 记录日志 + err := SharedACMETaskLogDAO.CreateACMETaskLog(tx, taskId, isOk, errMsg) + if err != nil { + logs.Error(err) + } + if !isOk { + // 设置签发失败 + err = this.UpdateStatus(tx, taskId, ACMETaskStatusIssueFailed) + if err != nil { + logs.Error(err) + } + return + } + + // 签发成功 + err = this.UpdateStatus(tx, taskId, ACMETaskStatusDone) + if err != nil { + logs.Error(err) + } + + newCert, err := models.SharedSSLCertDAO.FindEnabledSSLCert(tx, resultCertId) + if err != nil { + logs.Error(err) + return + } + + type ServerInfo struct { + SSLPolicyId int64 + CertIds []int64 + UserId int64 + TlsConfig *serverconfigs.HTTPSProtocolConfig + } + serverMap := map[int64]ServerInfo{} + domainChecked := map[string]bool{} + + // 以下绑定cert到Server的逻辑加互斥锁,避免大量证书绑定到同一个Server时sslCertIds数据覆盖;以下绑定流程耗时不长 + serverBindMutex.Lock() + defer serverBindMutex.Unlock() + + // 获取域名需要绑定的SSLPolicy + for _, domain := range domains { + if _, ok := domainChecked[domain]; ok { + continue + } + servers, err := models.SharedServerDAO.FindUserServerByServerName(tx, domain) + if err != nil { + continue + } + for _, server := range servers { + var serverNames []string + err = json.Unmarshal(server.PlainServerNames, &serverNames) + if err != nil { + continue + } + for _, sn := range serverNames { + domainChecked[sn] = true + } + tlsConfig := server.DecodeHTTPS() + if tlsConfig == nil { + continue // 跳过,其他有HTTPS的正常执行 + } + if tlsConfig.SSLPolicyRef != nil { + sslPolicyConfig, err := models.SharedSSLPolicyDAO.ComposePolicyConfig(tx, tlsConfig.SSLPolicyRef.SSLPolicyId, false, nil, nil) + if err != nil { + continue + } + if sslPolicyConfig != nil { + var certIds []int64 + for _, cert := range sslPolicyConfig.Certs { + // 新签发的证书如果包含所有旧证书的域名则不再绑定旧证书,并禁用旧证书避免触发续签 + if utils.ListIsGreaterEqualThanOther(domains, cert.DNSNames) && cert.TimeEndAt < int64(newCert.TimeEndAt) { + err = models.SharedSSLCertDAO.DisableSSLCert(tx, cert.Id) + if err != nil { + logs.Error(err) + } + continue + } + certIds = append(certIds, cert.Id) + } + certIds = append(certIds, resultCertId) + serverMap[int64(server.Id)] = ServerInfo{ + UserId: int64(server.UserId), + SSLPolicyId: sslPolicyConfig.Id, + CertIds: certIds, + TlsConfig: tlsConfig} + continue + } + } + serverMap[int64(server.Id)] = ServerInfo{CertIds: []int64{resultCertId}, TlsConfig: tlsConfig, UserId: int64(server.UserId)} + } + } + + for serverId, serverInfo := range serverMap { + var certRefs []*sslconfigs.SSLCertRef + certExists := make(map[int64]bool) + for _, certId := range serverInfo.CertIds { + if !certExists[certId] { + certRefs = append(certRefs, &sslconfigs.SSLCertRef{ + IsOn: true, + CertId: certId, + }) + certExists[certId] = true + } + } + + certRefsJSON, err := json.Marshal(certRefs) + if err != nil { + logs.Errorf("解析证书错误:%s", err.Error()) + continue + } + if serverInfo.SSLPolicyId == 0 { + policyId, err := models.SharedSSLPolicyDAO.CreatePolicy(tx, + 0, serverInfo.UserId, false, false, + "TLS 1.1", certRefsJSON, + nil, false, 0, + nil, false, nil) + if err != nil { + logs.Errorf("创建SSL策略错误:%s", err.Error()) + continue + } + httpsConfig := serverInfo.TlsConfig + httpsConfig.SSLPolicyRef = &sslconfigs.SSLPolicyRef{ + IsOn: true, + SSLPolicyId: policyId, + } + httpsJSON, err := json.Marshal(httpsConfig) + if err != nil { + logs.Errorf("获取https信息错误:%s", err.Error()) + continue + } + err = models.SharedServerDAO.UpdateServerHTTPS(tx, serverId, httpsJSON) + } else { + policy, err := models.SharedSSLPolicyDAO.FindEnabledSSLPolicy(tx, serverInfo.SSLPolicyId) + if err != nil { + logs.Errorf("获取SSL策略错误:%s", err.Error()) + continue + } + err = models.SharedSSLPolicyDAO.UpdatePolicy(tx, serverInfo.SSLPolicyId, policy.Http2Enabled, policy.Http3Enabled, + policy.MinVersion, certRefsJSON, policy.Hsts, policy.OcspIsOn == 1, int32(policy.ClientAuthType), policy.ClientCACerts, policy.CipherSuitesIsOn == 1, nil) + if err != nil { + logs.Errorf("更新SSL策略错误:%s", err.Error()) + continue + } + + } + } + return +} diff --git a/internal/db/models/acme/acme_task_model.go b/internal/db/models/acme/acme_task_model.go index b298cb7b..df986007 100644 --- a/internal/db/models/acme/acme_task_model.go +++ b/internal/db/models/acme/acme_task_model.go @@ -18,6 +18,8 @@ type ACMETask struct { AutoRenew uint8 `field:"autoRenew"` // 是否自动更新 AuthType string `field:"authType"` // 认证类型 AuthURL string `field:"authURL"` // 认证URL + Async bool `field:"async"` // 是否异步 + Status uint32 `field:"status"` // 任务状态 } type ACMETaskOperator struct { @@ -35,6 +37,8 @@ type ACMETaskOperator struct { AutoRenew interface{} // 是否自动更新 AuthType interface{} // 认证类型 AuthURL interface{} // 认证URL + Async interface{} //是否异步 + Status interface{} // 任务状态 } func NewACMETaskOperator() *ACMETaskOperator { diff --git a/internal/db/models/acme/acme_task_model_ext.go b/internal/db/models/acme/acme_task_model_ext.go index fc708133..ef3eba70 100644 --- a/internal/db/models/acme/acme_task_model_ext.go +++ b/internal/db/models/acme/acme_task_model_ext.go @@ -2,6 +2,7 @@ package acme import ( "encoding/json" + "github.com/iwind/TeaGo/logs" ) diff --git a/internal/db/models/acme/acme_user_dao.go b/internal/db/models/acme/acme_user_dao.go index 67fc0274..a0a57265 100644 --- a/internal/db/models/acme/acme_user_dao.go +++ b/internal/db/models/acme/acme_user_dao.go @@ -11,6 +11,7 @@ import ( "github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/types" + mrand "math/rand" ) const ( @@ -209,3 +210,17 @@ func (this *ACMEUserDAO) CheckACMEUser(tx *dbs.Tx, acmeUserId int64, adminId int State(ACMEUserStateEnabled). Exist() } +func (this *ACMEUserDAO) FindRandomACMEUserWithSameProvider(tx *dbs.Tx, providerCode string) (*ACMEUser, error) { + results, err := this.Query(tx). + Attr("providerCode", providerCode). + Attr("userId", 0). + FindAll() + if results == nil { + return nil, err + } + if len(results) == 0 { + return nil, errors.New("no acme user found") + } + idx := mrand.Intn(len(results)) + return results[idx].(*ACMEUser), err +} diff --git a/internal/db/models/api_access_token_dao.go b/internal/db/models/api_access_token_dao.go index 8c3f0a93..acfb4249 100644 --- a/internal/db/models/api_access_token_dao.go +++ b/internal/db/models/api_access_token_dao.go @@ -1,12 +1,13 @@ package models import ( + "time" + "github.com/TeaOSLab/EdgeAPI/internal/errors" _ "github.com/go-sql-driver/mysql" "github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/rands" - "time" ) type APIAccessTokenDAO dbs.DAO diff --git a/internal/db/models/api_node_dao.go b/internal/db/models/api_node_dao.go index a3947fde..3e5c4ee2 100644 --- a/internal/db/models/api_node_dao.go +++ b/internal/db/models/api_node_dao.go @@ -3,6 +3,10 @@ package models import ( "encoding/json" "errors" + "net" + "strconv" + "strings" + "github.com/TeaOSLab/EdgeAPI/internal/configs" "github.com/TeaOSLab/EdgeAPI/internal/remotelogs" "github.com/TeaOSLab/EdgeAPI/internal/utils" @@ -14,9 +18,6 @@ import ( "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/rands" "github.com/iwind/TeaGo/types" - "net" - "strconv" - "strings" ) const ( diff --git a/internal/db/models/api_node_dao_test.go b/internal/db/models/api_node_dao_test.go index 6cbf2c7a..1904530e 100644 --- a/internal/db/models/api_node_dao_test.go +++ b/internal/db/models/api_node_dao_test.go @@ -1,11 +1,12 @@ package models import ( + "runtime" + "testing" + "github.com/TeaOSLab/EdgeAPI/internal/utils" _ "github.com/go-sql-driver/mysql" "github.com/iwind/TeaGo/dbs" - "runtime" - "testing" ) func TestAPINodeDAO_FindEnabledAPINodeIdWithAddr(t *testing.T) { diff --git a/internal/db/models/api_node_model_ext.go b/internal/db/models/api_node_model_ext.go index df5c657d..bea6f35d 100644 --- a/internal/db/models/api_node_model_ext.go +++ b/internal/db/models/api_node_model_ext.go @@ -3,6 +3,7 @@ package models import ( "context" "encoding/json" + "github.com/TeaOSLab/EdgeAPI/internal/utils" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" "github.com/iwind/TeaGo/dbs" diff --git a/internal/db/models/authority/authority_node_dao.go b/internal/db/models/authority/authority_node_dao.go index bf314ea8..f1e65cb5 100644 --- a/internal/db/models/authority/authority_node_dao.go +++ b/internal/db/models/authority/authority_node_dao.go @@ -2,6 +2,7 @@ package authority import ( "encoding/json" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeAPI/internal/utils" diff --git a/internal/db/models/clients/client_agent_ip_dao_test.go b/internal/db/models/clients/client_agent_ip_dao_test.go index ec709514..e8078e9b 100644 --- a/internal/db/models/clients/client_agent_ip_dao_test.go +++ b/internal/db/models/clients/client_agent_ip_dao_test.go @@ -1,10 +1,11 @@ package clients_test import ( + "testing" + "github.com/TeaOSLab/EdgeAPI/internal/db/models/clients" _ "github.com/go-sql-driver/mysql" _ "github.com/iwind/TeaGo/bootstrap" - "testing" ) func TestClientAgentIPDAO_CreateIP(t *testing.T) { diff --git a/internal/db/models/clients/client_browser_dao.go b/internal/db/models/clients/client_browser_dao.go index 4b2fff82..79446793 100644 --- a/internal/db/models/clients/client_browser_dao.go +++ b/internal/db/models/clients/client_browser_dao.go @@ -1,6 +1,8 @@ package clients import ( + "time" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/goman" "github.com/TeaOSLab/EdgeAPI/internal/remotelogs" @@ -10,7 +12,6 @@ import ( "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/rands" timeutil "github.com/iwind/TeaGo/utils/time" - "time" ) const ( diff --git a/internal/db/models/clients/client_browser_dao_test.go b/internal/db/models/clients/client_browser_dao_test.go index 7a30f679..596b9480 100644 --- a/internal/db/models/clients/client_browser_dao_test.go +++ b/internal/db/models/clients/client_browser_dao_test.go @@ -1,9 +1,10 @@ package clients_test import ( + "testing" + "github.com/TeaOSLab/EdgeAPI/internal/db/models/clients" _ "github.com/go-sql-driver/mysql" - "testing" ) func TestClientBrowserDAO_CreateBrowser(t *testing.T) { diff --git a/internal/db/models/clients/client_system_dao.go b/internal/db/models/clients/client_system_dao.go index 0ebd808e..d964b518 100644 --- a/internal/db/models/clients/client_system_dao.go +++ b/internal/db/models/clients/client_system_dao.go @@ -1,6 +1,8 @@ package clients import ( + "time" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/goman" "github.com/TeaOSLab/EdgeAPI/internal/remotelogs" @@ -10,7 +12,6 @@ import ( "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/rands" timeutil "github.com/iwind/TeaGo/utils/time" - "time" ) const ( diff --git a/internal/db/models/clients/client_system_dao_test.go b/internal/db/models/clients/client_system_dao_test.go index 5f7c6482..192cf103 100644 --- a/internal/db/models/clients/client_system_dao_test.go +++ b/internal/db/models/clients/client_system_dao_test.go @@ -1,9 +1,10 @@ package clients_test import ( + "testing" + "github.com/TeaOSLab/EdgeAPI/internal/db/models/clients" _ "github.com/go-sql-driver/mysql" - "testing" ) func TestClientSystemDAO_CreateSystemIfNotExists(t *testing.T) { diff --git a/internal/db/models/db_node_dao.go b/internal/db/models/db_node_dao.go index fc4f0c85..0bad4289 100644 --- a/internal/db/models/db_node_dao.go +++ b/internal/db/models/db_node_dao.go @@ -2,6 +2,8 @@ package models import ( "encoding/base64" + "strings" + "github.com/TeaOSLab/EdgeAPI/internal/encrypt" "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" @@ -9,7 +11,6 @@ import ( "github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/types" - "strings" ) const ( diff --git a/internal/db/models/db_node_dao_test.go b/internal/db/models/db_node_dao_test.go index a39114ff..0c56b6dc 100644 --- a/internal/db/models/db_node_dao_test.go +++ b/internal/db/models/db_node_dao_test.go @@ -1,8 +1,9 @@ package models import ( - _ "github.com/go-sql-driver/mysql" "testing" + + _ "github.com/go-sql-driver/mysql" ) func TestDBNodeDAO_EncodePassword(t *testing.T) { diff --git a/internal/db/models/db_node_initializer.go b/internal/db/models/db_node_initializer.go index 5ed9939e..56318716 100644 --- a/internal/db/models/db_node_initializer.go +++ b/internal/db/models/db_node_initializer.go @@ -2,6 +2,10 @@ package models import ( "fmt" + "strconv" + "sync" + "time" + dbutils "github.com/TeaOSLab/EdgeAPI/internal/db/utils" "github.com/TeaOSLab/EdgeAPI/internal/goman" "github.com/TeaOSLab/EdgeAPI/internal/remotelogs" @@ -10,9 +14,6 @@ import ( "github.com/iwind/TeaGo/lists" "github.com/iwind/TeaGo/rands" timeutil "github.com/iwind/TeaGo/utils/time" - "strconv" - "sync" - "time" ) var accessLogDBMapping = map[int64]*dbs.DB{} // dbNodeId => DB diff --git a/internal/db/models/db_node_initializer_ext.go b/internal/db/models/db_node_initializer_ext.go index 2152b8e7..0e24491b 100644 --- a/internal/db/models/db_node_initializer_ext.go +++ b/internal/db/models/db_node_initializer_ext.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . //go:build !plus package models diff --git a/internal/db/models/db_node_model_ext.go b/internal/db/models/db_node_model_ext.go index fe24e31c..312bd3df 100644 --- a/internal/db/models/db_node_model_ext.go +++ b/internal/db/models/db_node_model_ext.go @@ -2,6 +2,7 @@ package models import ( "fmt" + "github.com/iwind/TeaGo/dbs" ) diff --git a/internal/db/models/dns/dns_domain_dao.go b/internal/db/models/dns/dns_domain_dao.go index 3ea25ece..dd0e4aaa 100644 --- a/internal/db/models/dns/dns_domain_dao.go +++ b/internal/db/models/dns/dns_domain_dao.go @@ -2,6 +2,9 @@ package dns import ( "encoding/json" + "strings" + "time" + "github.com/TeaOSLab/EdgeAPI/internal/dnsclients/dnstypes" "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeAPI/internal/utils" @@ -10,8 +13,6 @@ import ( "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/types" - "strings" - "time" ) const ( diff --git a/internal/db/models/dns/dns_domain_dao_test.go b/internal/db/models/dns/dns_domain_dao_test.go index fe5b526e..a362f9e7 100644 --- a/internal/db/models/dns/dns_domain_dao_test.go +++ b/internal/db/models/dns/dns_domain_dao_test.go @@ -1,9 +1,10 @@ package dns import ( + "testing" + _ "github.com/go-sql-driver/mysql" "github.com/iwind/TeaGo/dbs" - "testing" ) func TestDNSDomainDAO_ExistDomainRecord(t *testing.T) { diff --git a/internal/db/models/dns/dns_domain_model_ext.go b/internal/db/models/dns/dns_domain_model_ext.go index c3c60097..f1eff273 100644 --- a/internal/db/models/dns/dns_domain_model_ext.go +++ b/internal/db/models/dns/dns_domain_model_ext.go @@ -2,6 +2,7 @@ package dns import ( "encoding/json" + "github.com/TeaOSLab/EdgeAPI/internal/dnsclients/dnstypes" ) diff --git a/internal/db/models/dns/dns_provider_dao.go b/internal/db/models/dns/dns_provider_dao.go index 7a507bb1..9bb8d61c 100644 --- a/internal/db/models/dns/dns_provider_dao.go +++ b/internal/db/models/dns/dns_provider_dao.go @@ -1,13 +1,14 @@ package dns import ( + "time" + dbutils "github.com/TeaOSLab/EdgeAPI/internal/db/utils" "github.com/TeaOSLab/EdgeAPI/internal/errors" _ "github.com/go-sql-driver/mysql" "github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/types" - "time" ) const ( diff --git a/internal/db/models/dns/dns_provider_model_ext.go b/internal/db/models/dns/dns_provider_model_ext.go index 8d92975d..7485dc21 100644 --- a/internal/db/models/dns/dns_provider_model_ext.go +++ b/internal/db/models/dns/dns_provider_model_ext.go @@ -2,6 +2,7 @@ package dns import ( "encoding/json" + "github.com/iwind/TeaGo/maps" ) diff --git a/internal/db/models/dns/dns_task_dao.go b/internal/db/models/dns/dns_task_dao.go index 0ba83088..64a3a4cc 100644 --- a/internal/db/models/dns/dns_task_dao.go +++ b/internal/db/models/dns/dns_task_dao.go @@ -1,12 +1,13 @@ package dns import ( + "time" + "github.com/TeaOSLab/EdgeAPI/internal/errors" _ "github.com/go-sql-driver/mysql" "github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/maps" - "time" ) type DNSTaskType = string diff --git a/internal/db/models/dns/dns_task_dao_test.go b/internal/db/models/dns/dns_task_dao_test.go index 5c8fcdee..6f4c2e0a 100644 --- a/internal/db/models/dns/dns_task_dao_test.go +++ b/internal/db/models/dns/dns_task_dao_test.go @@ -1,12 +1,13 @@ package dns_test import ( + "testing" + "time" + "github.com/TeaOSLab/EdgeAPI/internal/db/models/dns" _ "github.com/go-sql-driver/mysql" _ "github.com/iwind/TeaGo/bootstrap" "github.com/iwind/TeaGo/dbs" - "testing" - "time" ) func TestDNSTaskDAO_CreateDNSTask(t *testing.T) { diff --git a/internal/db/models/dns/dnsutils/dns_utils.go b/internal/db/models/dns/dnsutils/dns_utils.go index f9730616..5eb9a6cb 100644 --- a/internal/db/models/dns/dnsutils/dns_utils.go +++ b/internal/db/models/dns/dnsutils/dns_utils.go @@ -4,6 +4,7 @@ package dnsutils import ( "fmt" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/db/models/dns" "github.com/TeaOSLab/EdgeAPI/internal/dnsclients" diff --git a/internal/db/models/dns/dnsutils/dns_utils_test.go b/internal/db/models/dns/dnsutils/dns_utils_test.go index 1b0707f1..fd7606cf 100644 --- a/internal/db/models/dns/dnsutils/dns_utils_test.go +++ b/internal/db/models/dns/dnsutils/dns_utils_test.go @@ -3,10 +3,11 @@ package dnsutils import ( + "testing" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/logs" - "testing" ) func TestNodeClusterDAO_CheckClusterDNS(t *testing.T) { diff --git a/internal/db/models/file_chunk_dao.go b/internal/db/models/file_chunk_dao.go index da8484c8..a5fdf2c8 100644 --- a/internal/db/models/file_chunk_dao.go +++ b/internal/db/models/file_chunk_dao.go @@ -2,6 +2,7 @@ package models import ( "errors" + _ "github.com/go-sql-driver/mysql" "github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/dbs" diff --git a/internal/db/models/formal_client_browser_dao.go b/internal/db/models/formal_client_browser_dao.go index a86b4181..5a37ae84 100644 --- a/internal/db/models/formal_client_browser_dao.go +++ b/internal/db/models/formal_client_browser_dao.go @@ -2,6 +2,10 @@ package models import ( "encoding/json" + "strconv" + "strings" + "time" + dbutils "github.com/TeaOSLab/EdgeAPI/internal/db/utils" "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeAPI/internal/utils/ttlcache" @@ -9,9 +13,6 @@ import ( "github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/types" - "strconv" - "strings" - "time" ) const ( diff --git a/internal/db/models/formal_client_browser_model_ext.go b/internal/db/models/formal_client_browser_model_ext.go index 506ed4fe..4be8e7eb 100644 --- a/internal/db/models/formal_client_browser_model_ext.go +++ b/internal/db/models/formal_client_browser_model_ext.go @@ -2,6 +2,7 @@ package models import ( "encoding/json" + "github.com/TeaOSLab/EdgeAPI/internal/remotelogs" ) diff --git a/internal/db/models/formal_client_system_model_ext.go b/internal/db/models/formal_client_system_model_ext.go index c0484696..8e4866d7 100644 --- a/internal/db/models/formal_client_system_model_ext.go +++ b/internal/db/models/formal_client_system_model_ext.go @@ -2,6 +2,7 @@ package models import ( "encoding/json" + "github.com/TeaOSLab/EdgeAPI/internal/remotelogs" ) diff --git a/internal/db/models/http_access_log_dao.go b/internal/db/models/http_access_log_dao.go index bd9a068b..820fec7c 100644 --- a/internal/db/models/http_access_log_dao.go +++ b/internal/db/models/http_access_log_dao.go @@ -3,6 +3,15 @@ package models import ( "bytes" "encoding/json" + "net" + "net/http" + "net/url" + "regexp" + "sort" + "strings" + "sync" + "time" + dbutils "github.com/TeaOSLab/EdgeAPI/internal/db/utils" "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeAPI/internal/goman" @@ -22,14 +31,6 @@ import ( "github.com/iwind/TeaGo/types" timeutil "github.com/iwind/TeaGo/utils/time" "golang.org/x/net/idna" - "net" - "net/http" - "net/url" - "regexp" - "sort" - "strings" - "sync" - "time" ) type HTTPAccessLogDAO dbs.DAO diff --git a/internal/db/models/http_access_log_manager_test.go b/internal/db/models/http_access_log_manager_test.go index a0449612..babaa611 100644 --- a/internal/db/models/http_access_log_manager_test.go +++ b/internal/db/models/http_access_log_manager_test.go @@ -4,11 +4,12 @@ package models_test import ( "encoding/json" + "testing" + "time" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/iwind/TeaGo/dbs" timeutil "github.com/iwind/TeaGo/utils/time" - "testing" - "time" ) func TestNewHTTPAccessLogManager(t *testing.T) { diff --git a/internal/db/models/http_access_log_model_ext.go b/internal/db/models/http_access_log_model_ext.go index 153b57f2..f20129fb 100644 --- a/internal/db/models/http_access_log_model_ext.go +++ b/internal/db/models/http_access_log_model_ext.go @@ -2,6 +2,7 @@ package models import ( "encoding/json" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" ) diff --git a/internal/db/models/http_auth_policy_dao.go b/internal/db/models/http_auth_policy_dao.go index 93b712e6..f0f15858 100644 --- a/internal/db/models/http_auth_policy_dao.go +++ b/internal/db/models/http_auth_policy_dao.go @@ -2,6 +2,7 @@ package models import ( "encoding/json" + "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeAPI/internal/utils" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" diff --git a/internal/db/models/http_cache_policy_dao.go b/internal/db/models/http_cache_policy_dao.go index 6ffaacd2..3b0086ed 100644 --- a/internal/db/models/http_cache_policy_dao.go +++ b/internal/db/models/http_cache_policy_dao.go @@ -2,6 +2,7 @@ package models import ( "encoding/json" + dbutils "github.com/TeaOSLab/EdgeAPI/internal/db/utils" "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeAPI/internal/utils" diff --git a/internal/db/models/http_cache_task_dao.go b/internal/db/models/http_cache_task_dao.go index 588db509..88e28f93 100644 --- a/internal/db/models/http_cache_task_dao.go +++ b/internal/db/models/http_cache_task_dao.go @@ -1,6 +1,8 @@ package models import ( + "time" + "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeAPI/internal/goman" "github.com/TeaOSLab/EdgeAPI/internal/remotelogs" @@ -10,7 +12,6 @@ import ( "github.com/iwind/TeaGo/rands" "github.com/iwind/TeaGo/types" timeutil "github.com/iwind/TeaGo/utils/time" - "time" ) const ( diff --git a/internal/db/models/http_cache_task_key_dao_test.go b/internal/db/models/http_cache_task_key_dao_test.go index 66ff3d8e..f93b6072 100644 --- a/internal/db/models/http_cache_task_key_dao_test.go +++ b/internal/db/models/http_cache_task_key_dao_test.go @@ -1,12 +1,13 @@ package models_test import ( + "testing" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" _ "github.com/go-sql-driver/mysql" _ "github.com/iwind/TeaGo/bootstrap" "github.com/iwind/TeaGo/dbs" timeutil "github.com/iwind/TeaGo/utils/time" - "testing" ) func TestHTTPCacheTaskKeyDAO_CreateKey(t *testing.T) { diff --git a/internal/db/models/http_fastcgi_dao.go b/internal/db/models/http_fastcgi_dao.go index 5b0bf0f4..e86e3407 100644 --- a/internal/db/models/http_fastcgi_dao.go +++ b/internal/db/models/http_fastcgi_dao.go @@ -2,6 +2,7 @@ package models import ( "encoding/json" + "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared" diff --git a/internal/db/models/http_firewall_policy_dao.go b/internal/db/models/http_firewall_policy_dao.go index 97fef162..146cdb80 100644 --- a/internal/db/models/http_firewall_policy_dao.go +++ b/internal/db/models/http_firewall_policy_dao.go @@ -2,6 +2,7 @@ package models import ( "encoding/json" + dbutils "github.com/TeaOSLab/EdgeAPI/internal/db/utils" "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeAPI/internal/utils" diff --git a/internal/db/models/http_firewall_policy_dao_test.go b/internal/db/models/http_firewall_policy_dao_test.go index 5d78bd2a..ffa80076 100644 --- a/internal/db/models/http_firewall_policy_dao_test.go +++ b/internal/db/models/http_firewall_policy_dao_test.go @@ -1,9 +1,10 @@ package models import ( + "testing" + _ "github.com/go-sql-driver/mysql" "github.com/iwind/TeaGo/dbs" - "testing" ) func TestHTTPFirewallPolicyDAO_FindFirewallPolicyIdsContainsIPList(t *testing.T) { diff --git a/internal/db/models/http_firewall_rule_group_dao.go b/internal/db/models/http_firewall_rule_group_dao.go index b7d122c7..0eff2ab4 100644 --- a/internal/db/models/http_firewall_rule_group_dao.go +++ b/internal/db/models/http_firewall_rule_group_dao.go @@ -2,6 +2,7 @@ package models import ( "encoding/json" + "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs" _ "github.com/go-sql-driver/mysql" diff --git a/internal/db/models/http_firewall_rule_group_dao_test.go b/internal/db/models/http_firewall_rule_group_dao_test.go index 16e8dfe7..b010fc54 100644 --- a/internal/db/models/http_firewall_rule_group_dao_test.go +++ b/internal/db/models/http_firewall_rule_group_dao_test.go @@ -1,9 +1,10 @@ package models import ( + "testing" + _ "github.com/go-sql-driver/mysql" "github.com/iwind/TeaGo/dbs" - "testing" ) func TestHTTPFirewallRuleGroupDAO_FindRuleGroupIdWithRuleSetId(t *testing.T) { diff --git a/internal/db/models/http_firewall_rule_set_dao.go b/internal/db/models/http_firewall_rule_set_dao.go index d6d068b6..44f488ee 100644 --- a/internal/db/models/http_firewall_rule_set_dao.go +++ b/internal/db/models/http_firewall_rule_set_dao.go @@ -2,6 +2,7 @@ package models import ( "encoding/json" + "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs" _ "github.com/go-sql-driver/mysql" diff --git a/internal/db/models/http_firewall_rule_set_dao_test.go b/internal/db/models/http_firewall_rule_set_dao_test.go index f2a7dee7..9b324a7b 100644 --- a/internal/db/models/http_firewall_rule_set_dao_test.go +++ b/internal/db/models/http_firewall_rule_set_dao_test.go @@ -1,10 +1,11 @@ package models import ( - _ "github.com/go-sql-driver/mysql" - "github.com/iwind/TeaGo/dbs" "testing" "time" + + _ "github.com/go-sql-driver/mysql" + "github.com/iwind/TeaGo/dbs" ) func TestHTTPFirewallRuleSetDAO_FindRuleSetIdWithRuleId(t *testing.T) { diff --git a/internal/db/models/http_gzip_dao.go b/internal/db/models/http_gzip_dao.go index 34e06e76..94f06406 100644 --- a/internal/db/models/http_gzip_dao.go +++ b/internal/db/models/http_gzip_dao.go @@ -3,6 +3,7 @@ package models import ( "encoding/json" "errors" + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared" _ "github.com/go-sql-driver/mysql" diff --git a/internal/db/models/http_gzip_model_ext.go b/internal/db/models/http_gzip_model_ext.go index 9e1a507a..a8df6ccd 100644 --- a/internal/db/models/http_gzip_model_ext.go +++ b/internal/db/models/http_gzip_model_ext.go @@ -2,6 +2,7 @@ package models import ( "encoding/json" + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared" ) diff --git a/internal/db/models/http_header_dao.go b/internal/db/models/http_header_dao.go index cc6ee017..f87a0739 100644 --- a/internal/db/models/http_header_dao.go +++ b/internal/db/models/http_header_dao.go @@ -2,6 +2,7 @@ package models import ( "encoding/json" + "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared" _ "github.com/go-sql-driver/mysql" diff --git a/internal/db/models/http_header_policy_dao_test.go b/internal/db/models/http_header_policy_dao_test.go index ada06162..1c6c9e99 100644 --- a/internal/db/models/http_header_policy_dao_test.go +++ b/internal/db/models/http_header_policy_dao_test.go @@ -1,9 +1,10 @@ package models import ( + "testing" + _ "github.com/go-sql-driver/mysql" "github.com/iwind/TeaGo/dbs" - "testing" ) func TestHTTPHeaderPolicyDAO_FindHeaderPolicyIdWithHeaderId(t *testing.T) { diff --git a/internal/db/models/http_location_dao.go b/internal/db/models/http_location_dao.go index d77fb27f..20b57f38 100644 --- a/internal/db/models/http_location_dao.go +++ b/internal/db/models/http_location_dao.go @@ -3,6 +3,7 @@ package models import ( "encoding/json" "errors" + "github.com/TeaOSLab/EdgeAPI/internal/utils" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared" diff --git a/internal/db/models/http_page_dao.go b/internal/db/models/http_page_dao.go index c54402c2..d1271cc7 100644 --- a/internal/db/models/http_page_dao.go +++ b/internal/db/models/http_page_dao.go @@ -3,6 +3,7 @@ package models import ( "encoding/json" "errors" + "github.com/TeaOSLab/EdgeAPI/internal/utils" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared" diff --git a/internal/db/models/http_rewrite_rule_dao.go b/internal/db/models/http_rewrite_rule_dao.go index 487b6f72..b9195e37 100644 --- a/internal/db/models/http_rewrite_rule_dao.go +++ b/internal/db/models/http_rewrite_rule_dao.go @@ -3,6 +3,7 @@ package models import ( "encoding/json" "errors" + "github.com/TeaOSLab/EdgeAPI/internal/utils" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared" diff --git a/internal/db/models/http_web_dao.go b/internal/db/models/http_web_dao.go index 066d9441..b2e9d1f4 100644 --- a/internal/db/models/http_web_dao.go +++ b/internal/db/models/http_web_dao.go @@ -3,6 +3,7 @@ package models import ( "encoding/json" "errors" + teaconst "github.com/TeaOSLab/EdgeAPI/internal/const" "github.com/TeaOSLab/EdgeAPI/internal/utils" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" diff --git a/internal/db/models/http_web_dao_test.go b/internal/db/models/http_web_dao_test.go index fb340dfd..58bff4db 100644 --- a/internal/db/models/http_web_dao_test.go +++ b/internal/db/models/http_web_dao_test.go @@ -1,9 +1,10 @@ package models import ( + "testing" + _ "github.com/go-sql-driver/mysql" "github.com/iwind/TeaGo/dbs" - "testing" ) func TestHTTPWebDAO_UpdateWebShutdown(t *testing.T) { diff --git a/internal/db/models/http_websocket_dao.go b/internal/db/models/http_websocket_dao.go index 76ca0a2d..cf940f69 100644 --- a/internal/db/models/http_websocket_dao.go +++ b/internal/db/models/http_websocket_dao.go @@ -3,6 +3,7 @@ package models import ( "encoding/json" "errors" + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared" _ "github.com/go-sql-driver/mysql" diff --git a/internal/db/models/ip_item_dao.go b/internal/db/models/ip_item_dao.go index f0b96c03..a1f75134 100644 --- a/internal/db/models/ip_item_dao.go +++ b/internal/db/models/ip_item_dao.go @@ -1,6 +1,10 @@ package models import ( + "net" + "strings" + "time" + dbutils "github.com/TeaOSLab/EdgeAPI/internal/db/utils" "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeAPI/internal/goman" @@ -13,9 +17,6 @@ import ( "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/lists" "github.com/iwind/TeaGo/types" - "net" - "strings" - "time" ) const ( diff --git a/internal/db/models/ip_item_dao_test.go b/internal/db/models/ip_item_dao_test.go index cdfe37be..e7d24c98 100644 --- a/internal/db/models/ip_item_dao_test.go +++ b/internal/db/models/ip_item_dao_test.go @@ -1,14 +1,15 @@ package models_test import ( + "testing" + "time" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs" _ "github.com/go-sql-driver/mysql" "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/rands" "github.com/iwind/TeaGo/types" - "testing" - "time" ) func TestIPItemDAO_NotifyClustersUpdate(t *testing.T) { diff --git a/internal/db/models/ip_library_file_dao.go b/internal/db/models/ip_library_file_dao.go index 0d7f3627..2f304076 100644 --- a/internal/db/models/ip_library_file_dao.go +++ b/internal/db/models/ip_library_file_dao.go @@ -4,6 +4,11 @@ import ( "encoding/json" "errors" "fmt" + "io" + "os" + "strings" + "time" + "github.com/TeaOSLab/EdgeAPI/internal/db/models/regions" "github.com/TeaOSLab/EdgeAPI/internal/utils" "github.com/TeaOSLab/EdgeCommon/pkg/iplibrary" @@ -11,10 +16,6 @@ import ( "github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/types" - "io" - "os" - "strings" - "time" ) const ( diff --git a/internal/db/models/ip_library_file_dao_test.go b/internal/db/models/ip_library_file_dao_test.go index 080a99c9..8ae3f8fc 100644 --- a/internal/db/models/ip_library_file_dao_test.go +++ b/internal/db/models/ip_library_file_dao_test.go @@ -1,11 +1,12 @@ package models_test import ( + "testing" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" _ "github.com/go-sql-driver/mysql" _ "github.com/iwind/TeaGo/bootstrap" "github.com/iwind/TeaGo/dbs" - "testing" ) func TestIPLibraryFileDAO_GenerateIPLibrary(t *testing.T) { diff --git a/internal/db/models/ip_list_dao.go b/internal/db/models/ip_list_dao.go index f6e6f654..9790095f 100644 --- a/internal/db/models/ip_list_dao.go +++ b/internal/db/models/ip_list_dao.go @@ -1,6 +1,8 @@ package models import ( + "regexp" + dbutils "github.com/TeaOSLab/EdgeAPI/internal/db/utils" "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeAPI/internal/utils" @@ -13,7 +15,6 @@ import ( "github.com/iwind/TeaGo/lists" "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/types" - "regexp" ) const ( diff --git a/internal/db/models/ip_list_dao_test.go b/internal/db/models/ip_list_dao_test.go index 159ba72c..a22c29bb 100644 --- a/internal/db/models/ip_list_dao_test.go +++ b/internal/db/models/ip_list_dao_test.go @@ -2,10 +2,11 @@ package models import ( "errors" - _ "github.com/go-sql-driver/mysql" - "github.com/iwind/TeaGo/dbs" "runtime" "testing" + + _ "github.com/go-sql-driver/mysql" + "github.com/iwind/TeaGo/dbs" ) func TestIPListDAO_IncreaseVersion(t *testing.T) { diff --git a/internal/db/models/latest_item_dao.go b/internal/db/models/latest_item_dao.go index 31ca3770..8271917a 100644 --- a/internal/db/models/latest_item_dao.go +++ b/internal/db/models/latest_item_dao.go @@ -1,11 +1,12 @@ package models import ( + "time" + _ "github.com/go-sql-driver/mysql" "github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/maps" - "time" ) type LatestItemType = string diff --git a/internal/db/models/log_dao.go b/internal/db/models/log_dao.go index 6d084026..555f44ce 100644 --- a/internal/db/models/log_dao.go +++ b/internal/db/models/log_dao.go @@ -2,6 +2,10 @@ package models import ( "encoding/json" + "regexp" + "strings" + "time" + dbutils "github.com/TeaOSLab/EdgeAPI/internal/db/utils" "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeAPI/internal/utils" @@ -11,9 +15,6 @@ import ( "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/types" timeutil "github.com/iwind/TeaGo/utils/time" - "regexp" - "strings" - "time" ) type LogDAO dbs.DAO diff --git a/internal/db/models/log_dao_test.go b/internal/db/models/log_dao_test.go index 7ed61979..84a2dcb0 100644 --- a/internal/db/models/log_dao_test.go +++ b/internal/db/models/log_dao_test.go @@ -1,9 +1,10 @@ package models import ( + "testing" + _ "github.com/go-sql-driver/mysql" "github.com/iwind/TeaGo/dbs" - "testing" ) func TestLogDAO_SumLogsSize(t *testing.T) { diff --git a/internal/db/models/login_session_dao.go b/internal/db/models/login_session_dao.go index 208c2c5d..32dcb7a6 100644 --- a/internal/db/models/login_session_dao.go +++ b/internal/db/models/login_session_dao.go @@ -3,12 +3,13 @@ package models import ( "encoding/json" "errors" + "time" + _ "github.com/go-sql-driver/mysql" "github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/types" - "time" ) // TODO 定时清理过期的SESSION diff --git a/internal/db/models/login_ticket_dao.go b/internal/db/models/login_ticket_dao.go index a55b1e30..1c0d2882 100644 --- a/internal/db/models/login_ticket_dao.go +++ b/internal/db/models/login_ticket_dao.go @@ -2,6 +2,9 @@ package models import ( "errors" + "math/rand" + "time" + teaconst "github.com/TeaOSLab/EdgeAPI/internal/const" "github.com/TeaOSLab/EdgeAPI/internal/goman" "github.com/TeaOSLab/EdgeAPI/internal/remotelogs" @@ -12,8 +15,6 @@ import ( "github.com/iwind/TeaGo/rands" "github.com/iwind/TeaGo/types" stringutil "github.com/iwind/TeaGo/utils/string" - "math/rand" - "time" ) func init() { diff --git a/internal/db/models/message_dao.go b/internal/db/models/message_dao.go index 1e5a7bb3..8b6ea3f6 100644 --- a/internal/db/models/message_dao.go +++ b/internal/db/models/message_dao.go @@ -3,6 +3,8 @@ package models import ( "crypto/md5" "fmt" + "time" + "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeAPI/internal/utils" "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" @@ -11,7 +13,6 @@ import ( "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/types" timeutil "github.com/iwind/TeaGo/utils/time" - "time" ) const ( diff --git a/internal/db/models/message_dao_test.go b/internal/db/models/message_dao_test.go index ceb19a67..1d9e2197 100644 --- a/internal/db/models/message_dao_test.go +++ b/internal/db/models/message_dao_test.go @@ -1,11 +1,12 @@ package models import ( + "testing" + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" _ "github.com/go-sql-driver/mysql" "github.com/iwind/TeaGo/dbs" - "testing" - "time" ) func TestMessageDAO_CreateClusterMessage(t *testing.T) { diff --git a/internal/db/models/message_media_instance_dao.go b/internal/db/models/message_media_instance_dao.go index a429dbb3..07de4590 100644 --- a/internal/db/models/message_media_instance_dao.go +++ b/internal/db/models/message_media_instance_dao.go @@ -2,6 +2,7 @@ package models import ( "encoding/json" + dbutils "github.com/TeaOSLab/EdgeAPI/internal/db/utils" "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeAPI/internal/utils" diff --git a/internal/db/models/message_receiver_dao.go b/internal/db/models/message_receiver_dao.go index 3665c6b3..c458f302 100644 --- a/internal/db/models/message_receiver_dao.go +++ b/internal/db/models/message_receiver_dao.go @@ -2,6 +2,7 @@ package models import ( "encoding/json" + _ "github.com/go-sql-driver/mysql" "github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/dbs" diff --git a/internal/db/models/message_recipient_dao.go b/internal/db/models/message_recipient_dao.go index 4a9b7f23..d612ca1f 100644 --- a/internal/db/models/message_recipient_dao.go +++ b/internal/db/models/message_recipient_dao.go @@ -2,6 +2,8 @@ package models import ( "encoding/json" + "regexp" + dbutils "github.com/TeaOSLab/EdgeAPI/internal/db/utils" "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeAPI/internal/utils" @@ -10,7 +12,6 @@ import ( "github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/types" - "regexp" ) const ( diff --git a/internal/db/models/message_recipient_dao_test.go b/internal/db/models/message_recipient_dao_test.go index 2c56ac48..85553dbc 100644 --- a/internal/db/models/message_recipient_dao_test.go +++ b/internal/db/models/message_recipient_dao_test.go @@ -1,10 +1,11 @@ package models import ( + "testing" + _ "github.com/go-sql-driver/mysql" _ "github.com/iwind/TeaGo/bootstrap" "github.com/iwind/TeaGo/dbs" - "testing" ) func TestMessageRecipientDAO_FindAllEnabledAndOnRecipientIdsWithGroup(t *testing.T) { diff --git a/internal/db/models/message_recipient_model_ext.go b/internal/db/models/message_recipient_model_ext.go index 46f68b6b..5e8d56ca 100644 --- a/internal/db/models/message_recipient_model_ext.go +++ b/internal/db/models/message_recipient_model_ext.go @@ -2,6 +2,7 @@ package models import ( "encoding/json" + "github.com/iwind/TeaGo/logs" ) diff --git a/internal/db/models/message_task_dao.go b/internal/db/models/message_task_dao.go index 67a05c6d..583b6405 100644 --- a/internal/db/models/message_task_dao.go +++ b/internal/db/models/message_task_dao.go @@ -1,6 +1,8 @@ package models import ( + "time" + "github.com/TeaOSLab/EdgeAPI/internal/goman" "github.com/TeaOSLab/EdgeAPI/internal/remotelogs" _ "github.com/go-sql-driver/mysql" @@ -8,7 +10,6 @@ import ( "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/rands" timeutil "github.com/iwind/TeaGo/utils/time" - "time" ) const ( diff --git a/internal/db/models/message_task_dao_ext.go b/internal/db/models/message_task_dao_ext.go index fcae45a2..aace03b4 100644 --- a/internal/db/models/message_task_dao_ext.go +++ b/internal/db/models/message_task_dao_ext.go @@ -1,4 +1,4 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . //go:build !plus package models diff --git a/internal/db/models/message_task_dao_test.go b/internal/db/models/message_task_dao_test.go index db9c37f6..57ead439 100644 --- a/internal/db/models/message_task_dao_test.go +++ b/internal/db/models/message_task_dao_test.go @@ -1,11 +1,12 @@ package models_test import ( + "testing" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" _ "github.com/go-sql-driver/mysql" _ "github.com/iwind/TeaGo/bootstrap" "github.com/iwind/TeaGo/dbs" - "testing" ) func TestMessageTaskDAO_CleanExpiredMessageTasks(t *testing.T) { diff --git a/internal/db/models/message_task_log_dao.go b/internal/db/models/message_task_log_dao.go index 389407ab..98fd32eb 100644 --- a/internal/db/models/message_task_log_dao.go +++ b/internal/db/models/message_task_log_dao.go @@ -1,6 +1,8 @@ package models import ( + "time" + "github.com/TeaOSLab/EdgeAPI/internal/goman" "github.com/TeaOSLab/EdgeAPI/internal/remotelogs" _ "github.com/go-sql-driver/mysql" @@ -8,7 +10,6 @@ import ( "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/rands" timeutil "github.com/iwind/TeaGo/utils/time" - "time" ) type MessageTaskLogDAO dbs.DAO diff --git a/internal/db/models/metric_chart_dao.go b/internal/db/models/metric_chart_dao.go index 897da760..da36ba09 100644 --- a/internal/db/models/metric_chart_dao.go +++ b/internal/db/models/metric_chart_dao.go @@ -2,6 +2,7 @@ package models import ( "encoding/json" + "github.com/TeaOSLab/EdgeAPI/internal/errors" _ "github.com/go-sql-driver/mysql" "github.com/iwind/TeaGo/Tea" diff --git a/internal/db/models/metric_item_dao.go b/internal/db/models/metric_item_dao.go index efe1e430..7cf1acd5 100644 --- a/internal/db/models/metric_item_dao.go +++ b/internal/db/models/metric_item_dao.go @@ -2,6 +2,10 @@ package models import ( "encoding/json" + "sort" + "strings" + "sync" + "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeAPI/internal/utils" "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" @@ -10,9 +14,6 @@ import ( "github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/types" - "sort" - "strings" - "sync" ) const ( diff --git a/internal/db/models/metric_item_dao_test.go b/internal/db/models/metric_item_dao_test.go index a3c2d5ad..3447886c 100644 --- a/internal/db/models/metric_item_dao_test.go +++ b/internal/db/models/metric_item_dao_test.go @@ -1,10 +1,11 @@ package models_test import ( + "testing" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" _ "github.com/go-sql-driver/mysql" _ "github.com/iwind/TeaGo/bootstrap" - "testing" ) func TestMetricStatDAO_Clean(t *testing.T) { diff --git a/internal/db/models/metric_stat_dao.go b/internal/db/models/metric_stat_dao.go index 97c6d6d9..c1796a26 100644 --- a/internal/db/models/metric_stat_dao.go +++ b/internal/db/models/metric_stat_dao.go @@ -2,6 +2,14 @@ package models import ( "encoding/json" + "regexp" + "sort" + "strconv" + "strings" + "sync" + "sync/atomic" + "time" + "github.com/TeaOSLab/EdgeAPI/internal/goman" "github.com/TeaOSLab/EdgeAPI/internal/remotelogs" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" @@ -13,13 +21,6 @@ import ( "github.com/iwind/TeaGo/rands" "github.com/iwind/TeaGo/types" timeutil "github.com/iwind/TeaGo/utils/time" - "regexp" - "sort" - "strconv" - "strings" - "sync" - "sync/atomic" - "time" ) type MetricStatDAO dbs.DAO diff --git a/internal/db/models/metric_stat_dao_test.go b/internal/db/models/metric_stat_dao_test.go index d94b745c..13b7e496 100644 --- a/internal/db/models/metric_stat_dao_test.go +++ b/internal/db/models/metric_stat_dao_test.go @@ -1,6 +1,9 @@ package models_test import ( + "testing" + "time" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" _ "github.com/go-sql-driver/mysql" _ "github.com/iwind/TeaGo/bootstrap" @@ -8,8 +11,6 @@ import ( "github.com/iwind/TeaGo/rands" "github.com/iwind/TeaGo/types" timeutil "github.com/iwind/TeaGo/utils/time" - "testing" - "time" ) func TestNewMetricStatDAO_InsertMany(t *testing.T) { diff --git a/internal/db/models/metric_sum_stat_dao.go b/internal/db/models/metric_sum_stat_dao.go index 9f2a37a5..e1d0e89b 100644 --- a/internal/db/models/metric_sum_stat_dao.go +++ b/internal/db/models/metric_sum_stat_dao.go @@ -1,6 +1,9 @@ package models import ( + "sync" + "time" + "github.com/TeaOSLab/EdgeAPI/internal/goman" "github.com/TeaOSLab/EdgeAPI/internal/remotelogs" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" @@ -11,8 +14,6 @@ import ( "github.com/iwind/TeaGo/rands" "github.com/iwind/TeaGo/types" timeutil "github.com/iwind/TeaGo/utils/time" - "sync" - "time" ) type MetricSumStatDAO dbs.DAO diff --git a/internal/db/models/metric_sum_stat_dao_test.go b/internal/db/models/metric_sum_stat_dao_test.go index ca42a336..159a1330 100644 --- a/internal/db/models/metric_sum_stat_dao_test.go +++ b/internal/db/models/metric_sum_stat_dao_test.go @@ -1,12 +1,13 @@ package models_test import ( + "testing" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" _ "github.com/go-sql-driver/mysql" _ "github.com/iwind/TeaGo/bootstrap" "github.com/iwind/TeaGo/dbs" timeutil "github.com/iwind/TeaGo/utils/time" - "testing" ) func TestMetricSumStatDAO_FindNodeSum(t *testing.T) { diff --git a/internal/db/models/nameservers/ns_domain_model_ext.go b/internal/db/models/nameservers/ns_domain_model_ext.go index 8d87d0e6..9ce4d14b 100644 --- a/internal/db/models/nameservers/ns_domain_model_ext.go +++ b/internal/db/models/nameservers/ns_domain_model_ext.go @@ -2,6 +2,7 @@ package nameservers import ( "encoding/json" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/remotelogs" ) diff --git a/internal/db/models/nameservers/ns_record_model_ext.go b/internal/db/models/nameservers/ns_record_model_ext.go index f7c63f29..3afe0e58 100644 --- a/internal/db/models/nameservers/ns_record_model_ext.go +++ b/internal/db/models/nameservers/ns_record_model_ext.go @@ -2,6 +2,7 @@ package nameservers import ( "encoding/json" + "github.com/iwind/TeaGo/types" ) diff --git a/internal/db/models/node_cluster_dao.go b/internal/db/models/node_cluster_dao.go index 0f7297e7..48978d75 100644 --- a/internal/db/models/node_cluster_dao.go +++ b/internal/db/models/node_cluster_dao.go @@ -3,6 +3,8 @@ package models import ( "encoding/json" "errors" + "strconv" + "github.com/TeaOSLab/EdgeAPI/internal/db/models/dns" dbutils "github.com/TeaOSLab/EdgeAPI/internal/db/utils" "github.com/TeaOSLab/EdgeAPI/internal/utils" @@ -16,7 +18,6 @@ import ( "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/rands" "github.com/iwind/TeaGo/types" - "strconv" ) const ( diff --git a/internal/db/models/node_cluster_dao_test.go b/internal/db/models/node_cluster_dao_test.go index 3b723ce9..ec753ea8 100644 --- a/internal/db/models/node_cluster_dao_test.go +++ b/internal/db/models/node_cluster_dao_test.go @@ -1,9 +1,10 @@ package models import ( + "testing" + _ "github.com/go-sql-driver/mysql" "github.com/iwind/TeaGo/dbs" - "testing" ) func TestNodeClusterDAO_DisableNodeCluster(t *testing.T) { diff --git a/internal/db/models/node_cluster_firewall_action_model_ext.go b/internal/db/models/node_cluster_firewall_action_model_ext.go index ce4bf917..b76cd377 100644 --- a/internal/db/models/node_cluster_firewall_action_model_ext.go +++ b/internal/db/models/node_cluster_firewall_action_model_ext.go @@ -2,6 +2,7 @@ package models import ( "encoding/json" + "github.com/iwind/TeaGo/maps" ) diff --git a/internal/db/models/node_dao.go b/internal/db/models/node_dao.go index 441808d8..f9b0bf40 100644 --- a/internal/db/models/node_dao.go +++ b/internal/db/models/node_dao.go @@ -4,6 +4,11 @@ import ( "crypto/sha256" "encoding/json" "fmt" + "sort" + "strconv" + "strings" + "time" + teaconst "github.com/TeaOSLab/EdgeAPI/internal/const" "github.com/TeaOSLab/EdgeAPI/internal/db/models/dns" dbutils "github.com/TeaOSLab/EdgeAPI/internal/db/utils" @@ -26,10 +31,6 @@ import ( "github.com/iwind/TeaGo/rands" "github.com/iwind/TeaGo/types" timeutil "github.com/iwind/TeaGo/utils/time" - "sort" - "strconv" - "strings" - "time" ) const ( @@ -1022,6 +1023,7 @@ func (this *NodeDAO) ComposeNodeConfig(tx *dbs.Tx, nodeId int64, dataMap *shared GroupId: int64(node.GroupId), EnableIPLists: node.EnableIPLists, APINodeAddrs: node.DecodeAPINodeAddrs(), + BypassMobile: node.BypassMobile, DataMap: dataMap, } @@ -1768,6 +1770,21 @@ func (this *NodeDAO) UpdateNodeSystem(tx *dbs.Tx, nodeId int64, maxCPU int32) er return this.NotifyUpdate(tx, nodeId) } +// UpdateNodeBypassMobile 设置是否过移动 +func (this *NodeDAO) UpdateNodeBypassMobile(tx *dbs.Tx, nodeId int64, bypass int32) error { + if nodeId <= 0 { + return errors.New("invalid nodeId") + } + var op = NewNodeOperator() + op.Id = nodeId + op.BypassMobile = bypass + err := this.Save(tx, op) + if err != nil { + return err + } + return this.NotifyUpdate(tx, nodeId) +} + // UpdateNodeCache 设置缓存相关 func (this *NodeDAO) UpdateNodeCache(tx *dbs.Tx, nodeId int64, maxCacheDiskCapacityJSON []byte, maxCacheMemoryCapacityJSON []byte, cacheDiskDir string, cacheDiskSubDirs []*serverconfigs.CacheDir) error { if nodeId <= 0 { diff --git a/internal/db/models/node_dao_limit.go b/internal/db/models/node_dao_limit.go index 041162b9..e2899f52 100644 --- a/internal/db/models/node_dao_limit.go +++ b/internal/db/models/node_dao_limit.go @@ -1,10 +1,11 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . //go:build !plus package models import ( "errors" + teaconst "github.com/TeaOSLab/EdgeAPI/internal/const" "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/types" diff --git a/internal/db/models/node_dao_test.go b/internal/db/models/node_dao_test.go index 74c525e4..7413311e 100644 --- a/internal/db/models/node_dao_test.go +++ b/internal/db/models/node_dao_test.go @@ -5,6 +5,9 @@ package models_test import ( "encoding/json" + "testing" + "time" + teaconst "github.com/TeaOSLab/EdgeAPI/internal/const" "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/utils" @@ -12,8 +15,6 @@ import ( _ "github.com/go-sql-driver/mysql" "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/logs" - "testing" - "time" ) func TestNodeDAO_FindAllNodeIdsMatch(t *testing.T) { diff --git a/internal/db/models/node_grant_dao.go b/internal/db/models/node_grant_dao.go index ffbfbe9a..0c5f6fcb 100644 --- a/internal/db/models/node_grant_dao.go +++ b/internal/db/models/node_grant_dao.go @@ -2,6 +2,7 @@ package models import ( "errors" + dbutils "github.com/TeaOSLab/EdgeAPI/internal/db/utils" _ "github.com/go-sql-driver/mysql" "github.com/iwind/TeaGo/Tea" diff --git a/internal/db/models/node_ip_address_dao.go b/internal/db/models/node_ip_address_dao.go index d9c526ef..4b336e4c 100644 --- a/internal/db/models/node_ip_address_dao.go +++ b/internal/db/models/node_ip_address_dao.go @@ -3,6 +3,7 @@ package models import ( "encoding/json" "errors" + "github.com/TeaOSLab/EdgeAPI/internal/db/models/dns" dbutils "github.com/TeaOSLab/EdgeAPI/internal/db/utils" "github.com/TeaOSLab/EdgeAPI/internal/utils" diff --git a/internal/db/models/node_ip_address_dao_test.go b/internal/db/models/node_ip_address_dao_test.go index 15ab9279..5a1eccbe 100644 --- a/internal/db/models/node_ip_address_dao_test.go +++ b/internal/db/models/node_ip_address_dao_test.go @@ -4,10 +4,11 @@ package models import ( + "testing" + "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" _ "github.com/go-sql-driver/mysql" "github.com/iwind/TeaGo/dbs" - "testing" ) func TestNodeIPAddressDAO_FireThresholds(t *testing.T) { diff --git a/internal/db/models/node_ip_address_log_dao_test.go b/internal/db/models/node_ip_address_log_dao_test.go index 1b41c294..a3c5cb17 100644 --- a/internal/db/models/node_ip_address_log_dao_test.go +++ b/internal/db/models/node_ip_address_log_dao_test.go @@ -1,10 +1,11 @@ package models import ( + "testing" + "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" _ "github.com/go-sql-driver/mysql" _ "github.com/iwind/TeaGo/bootstrap" - "testing" ) func TestNodeIPAddressDAO_FindFirstNodeAccessIPAddress(t *testing.T) { diff --git a/internal/db/models/node_ip_address_model_ext.go b/internal/db/models/node_ip_address_model_ext.go index ea35bb40..b1fab57f 100644 --- a/internal/db/models/node_ip_address_model_ext.go +++ b/internal/db/models/node_ip_address_model_ext.go @@ -2,6 +2,7 @@ package models import ( "encoding/json" + "github.com/TeaOSLab/EdgeAPI/internal/remotelogs" "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" "github.com/iwind/TeaGo/lists" diff --git a/internal/db/models/node_ip_address_threshold_dao.go b/internal/db/models/node_ip_address_threshold_dao.go index 770ecad1..32df3770 100644 --- a/internal/db/models/node_ip_address_threshold_dao.go +++ b/internal/db/models/node_ip_address_threshold_dao.go @@ -2,6 +2,7 @@ package models import ( "encoding/json" + "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" _ "github.com/go-sql-driver/mysql" diff --git a/internal/db/models/node_ip_address_threshold_model_ext.go b/internal/db/models/node_ip_address_threshold_model_ext.go index 53f5ec02..c85b3c7e 100644 --- a/internal/db/models/node_ip_address_threshold_model_ext.go +++ b/internal/db/models/node_ip_address_threshold_model_ext.go @@ -2,6 +2,7 @@ package models import ( "encoding/json" + "github.com/TeaOSLab/EdgeAPI/internal/remotelogs" "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" ) diff --git a/internal/db/models/node_log_dao.go b/internal/db/models/node_log_dao.go index a8bb7b8f..b60de42f 100644 --- a/internal/db/models/node_log_dao.go +++ b/internal/db/models/node_log_dao.go @@ -1,6 +1,10 @@ package models import ( + "strconv" + "strings" + "time" + dbutils "github.com/TeaOSLab/EdgeAPI/internal/db/utils" "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeAPI/internal/remotelogs" @@ -13,9 +17,6 @@ import ( "github.com/iwind/TeaGo/types" stringutil "github.com/iwind/TeaGo/utils/string" timeutil "github.com/iwind/TeaGo/utils/time" - "strconv" - "strings" - "time" ) type NodeLogDAO dbs.DAO diff --git a/internal/db/models/node_log_dao_ext.go b/internal/db/models/node_log_dao_ext.go index 46ba56b9..0b3c1c3a 100644 --- a/internal/db/models/node_log_dao_ext.go +++ b/internal/db/models/node_log_dao_ext.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . //go:build !plus package models @@ -8,6 +8,6 @@ import ( "github.com/iwind/TeaGo/dbs" ) -func (this *NodeLogDAO) deleteNodeLogsWithCluster(tx *dbs.Tx, role nodeconfigs.NodeRole, clusterId int64) error { +func (this *NodeLogDAO) deleteNodeLogsWithCluster(tx *dbs.Tx, role nodeconfigs.NodeRole, clusterId int64) error { return nil -} \ No newline at end of file +} diff --git a/internal/db/models/node_login_dao.go b/internal/db/models/node_login_dao.go index 5b5e0dab..b8563f24 100644 --- a/internal/db/models/node_login_dao.go +++ b/internal/db/models/node_login_dao.go @@ -2,6 +2,7 @@ package models import ( "errors" + "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" _ "github.com/go-sql-driver/mysql" "github.com/iwind/TeaGo/Tea" diff --git a/internal/db/models/node_login_dao_ext.go b/internal/db/models/node_login_dao_ext.go index 2d56682d..14e7acf4 100644 --- a/internal/db/models/node_login_dao_ext.go +++ b/internal/db/models/node_login_dao_ext.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . //go:build !plus package models diff --git a/internal/db/models/node_login_dao_test.go b/internal/db/models/node_login_dao_test.go index 87b3e043..d5c99ef1 100644 --- a/internal/db/models/node_login_dao_test.go +++ b/internal/db/models/node_login_dao_test.go @@ -1,9 +1,10 @@ package models import ( + "testing" + _ "github.com/go-sql-driver/mysql" "github.com/iwind/TeaGo/dbs" - "testing" ) func TestNodeLoginDAO_FindFrequentPorts(t *testing.T) { diff --git a/internal/db/models/node_model.go b/internal/db/models/node_model.go index 34614ebe..e51b2169 100644 --- a/internal/db/models/node_model.go +++ b/internal/db/models/node_model.go @@ -49,6 +49,7 @@ type Node struct { IsBackupForGroup bool `field:"isBackupForGroup"` // 是否为分组备用节点 BackupIPs dbs.JSON `field:"backupIPs"` // 备用IP ActionStatus dbs.JSON `field:"actionStatus"` // 当前动作配置 + BypassMobile int32 `field:"bypassMobile"` // 是否过移动 } type NodeOperator struct { @@ -97,6 +98,7 @@ type NodeOperator struct { IsBackupForGroup any // 是否为分组备用节点 BackupIPs any // 备用IP ActionStatus any // 当前动作配置 + BypassMobile any // 是否过移动 } func NewNodeOperator() *NodeOperator { diff --git a/internal/db/models/node_model_ext.go b/internal/db/models/node_model_ext.go index 5197c3e2..ca0f5176 100644 --- a/internal/db/models/node_model_ext.go +++ b/internal/db/models/node_model_ext.go @@ -2,14 +2,15 @@ package models import ( "encoding/json" + "sort" + "time" + "github.com/TeaOSLab/EdgeAPI/internal/remotelogs" "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/ddosconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared" timeutil "github.com/iwind/TeaGo/utils/time" - "sort" - "time" ) // DecodeInstallStatus 安装状态 diff --git a/internal/db/models/node_model_ext_schdule.go b/internal/db/models/node_model_ext_schdule.go index 3dff55ac..f1f7e138 100644 --- a/internal/db/models/node_model_ext_schdule.go +++ b/internal/db/models/node_model_ext_schdule.go @@ -1,4 +1,4 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . //go:build !plus package models @@ -6,4 +6,4 @@ package models // HasScheduleSettings 检查是否设置了调度 func (this *Node) HasScheduleSettings() bool { return false -} \ No newline at end of file +} diff --git a/internal/db/models/node_region_dao.go b/internal/db/models/node_region_dao.go index dc758c5d..23e1c4af 100644 --- a/internal/db/models/node_region_dao.go +++ b/internal/db/models/node_region_dao.go @@ -2,6 +2,7 @@ package models import ( "encoding/json" + "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeAPI/internal/utils/numberutils" _ "github.com/go-sql-driver/mysql" diff --git a/internal/db/models/node_task_dao.go b/internal/db/models/node_task_dao.go index df317dd1..0e634571 100644 --- a/internal/db/models/node_task_dao.go +++ b/internal/db/models/node_task_dao.go @@ -1,6 +1,9 @@ package models import ( + "strings" + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/configutils" "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" _ "github.com/go-sql-driver/mysql" @@ -8,8 +11,6 @@ import ( "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/types" - "strings" - "time" ) type NodeTaskType = string diff --git a/internal/db/models/node_task_dao_ext.go b/internal/db/models/node_task_dao_ext.go index e1635253..70deba3e 100644 --- a/internal/db/models/node_task_dao_ext.go +++ b/internal/db/models/node_task_dao_ext.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . //go:build !plus package models diff --git a/internal/db/models/node_task_dao_test.go b/internal/db/models/node_task_dao_test.go index b2481b26..5c45d175 100644 --- a/internal/db/models/node_task_dao_test.go +++ b/internal/db/models/node_task_dao_test.go @@ -1,12 +1,13 @@ package models_test import ( + "testing" + "time" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" _ "github.com/go-sql-driver/mysql" "github.com/iwind/TeaGo/dbs" - "testing" - "time" ) func TestNodeTaskDAO_CreateNodeTask(t *testing.T) { diff --git a/internal/db/models/node_threshold_dao_ext.go b/internal/db/models/node_threshold_dao_ext.go index de7746f8..1888c451 100644 --- a/internal/db/models/node_threshold_dao_ext.go +++ b/internal/db/models/node_threshold_dao_ext.go @@ -1,4 +1,4 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . //go:build !plus package models diff --git a/internal/db/models/node_traffic_daily_stat_dao.go b/internal/db/models/node_traffic_daily_stat_dao.go index ad9f5452..46d9b9d1 100644 --- a/internal/db/models/node_traffic_daily_stat_dao.go +++ b/internal/db/models/node_traffic_daily_stat_dao.go @@ -1,6 +1,8 @@ package models import ( + "time" + "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeAPI/internal/goman" "github.com/TeaOSLab/EdgeAPI/internal/remotelogs" @@ -11,7 +13,6 @@ import ( "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/rands" timeutil "github.com/iwind/TeaGo/utils/time" - "time" ) type NodeTrafficDailyStatDAO dbs.DAO diff --git a/internal/db/models/node_traffic_daily_stat_dao_ext.go b/internal/db/models/node_traffic_daily_stat_dao_ext.go index fabf844f..b138f74f 100644 --- a/internal/db/models/node_traffic_daily_stat_dao_ext.go +++ b/internal/db/models/node_traffic_daily_stat_dao_ext.go @@ -1,4 +1,4 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . //go:build !plus package models diff --git a/internal/db/models/node_value_dao.go b/internal/db/models/node_value_dao.go index c9f523de..ed938566 100644 --- a/internal/db/models/node_value_dao.go +++ b/internal/db/models/node_value_dao.go @@ -2,6 +2,9 @@ package models import ( "encoding/json" + "strings" + "time" + "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" _ "github.com/go-sql-driver/mysql" @@ -10,8 +13,6 @@ import ( "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/types" timeutil "github.com/iwind/TeaGo/utils/time" - "strings" - "time" ) type NodeValueDAO dbs.DAO diff --git a/internal/db/models/node_value_dao_ext.go b/internal/db/models/node_value_dao_ext.go index 86f1edec..01114a08 100644 --- a/internal/db/models/node_value_dao_ext.go +++ b/internal/db/models/node_value_dao_ext.go @@ -1,4 +1,4 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . //go:build !plus package models diff --git a/internal/db/models/node_value_dao_test.go b/internal/db/models/node_value_dao_test.go index e4a25408..dcf710ca 100644 --- a/internal/db/models/node_value_dao_test.go +++ b/internal/db/models/node_value_dao_test.go @@ -1,6 +1,9 @@ package models_test import ( + "testing" + "time" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" _ "github.com/go-sql-driver/mysql" @@ -10,8 +13,6 @@ import ( "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/rands" "github.com/iwind/TeaGo/types" - "testing" - "time" ) func TestNodeValueDAO_CreateValue(t *testing.T) { diff --git a/internal/db/models/node_value_model_ext.go b/internal/db/models/node_value_model_ext.go index cd566e81..7c43d624 100644 --- a/internal/db/models/node_value_model_ext.go +++ b/internal/db/models/node_value_model_ext.go @@ -2,6 +2,7 @@ package models import ( "encoding/json" + "github.com/iwind/TeaGo/maps" ) diff --git a/internal/db/models/ns_cluster_dao.go b/internal/db/models/ns_cluster_dao.go index 4e514b35..f729115d 100644 --- a/internal/db/models/ns_cluster_dao.go +++ b/internal/db/models/ns_cluster_dao.go @@ -1,12 +1,13 @@ package models import ( + "strconv" + "strings" + "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" _ "github.com/go-sql-driver/mysql" "github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/dbs" - "strconv" - "strings" ) const ( diff --git a/internal/db/models/ns_cluster_dao_test.go b/internal/db/models/ns_cluster_dao_test.go index 8452dbc7..b84b3dc0 100644 --- a/internal/db/models/ns_cluster_dao_test.go +++ b/internal/db/models/ns_cluster_dao_test.go @@ -1,10 +1,11 @@ package models import ( + "testing" + _ "github.com/go-sql-driver/mysql" _ "github.com/iwind/TeaGo/bootstrap" "github.com/iwind/TeaGo/dbs" - "testing" ) diff --git a/internal/db/models/ns_cluster_model_ext.go b/internal/db/models/ns_cluster_model_ext.go index 766d5496..62ca0433 100644 --- a/internal/db/models/ns_cluster_model_ext.go +++ b/internal/db/models/ns_cluster_model_ext.go @@ -2,6 +2,7 @@ package models import ( "encoding/json" + "github.com/TeaOSLab/EdgeAPI/internal/remotelogs" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/ddosconfigs" ) diff --git a/internal/db/models/ns_node_dao.go b/internal/db/models/ns_node_dao.go index 278b8ad2..609e9aed 100644 --- a/internal/db/models/ns_node_dao.go +++ b/internal/db/models/ns_node_dao.go @@ -4,6 +4,7 @@ package models import ( "encoding/json" + "github.com/TeaOSLab/EdgeAPI/internal/utils" "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" _ "github.com/go-sql-driver/mysql" diff --git a/internal/db/models/origin_dao.go b/internal/db/models/origin_dao.go index 9c98678c..e58ba87c 100644 --- a/internal/db/models/origin_dao.go +++ b/internal/db/models/origin_dao.go @@ -3,6 +3,7 @@ package models import ( "encoding/json" "errors" + "github.com/TeaOSLab/EdgeAPI/internal/utils" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/ossconfigs" diff --git a/internal/db/models/origin_dao_test.go b/internal/db/models/origin_dao_test.go index 9352b241..1ddcbd86 100644 --- a/internal/db/models/origin_dao_test.go +++ b/internal/db/models/origin_dao_test.go @@ -1,9 +1,10 @@ package models import ( + "testing" + _ "github.com/go-sql-driver/mysql" "github.com/iwind/TeaGo/dbs" - "testing" ) func TestOriginServerDAO_ComposeOriginConfig(t *testing.T) { diff --git a/internal/db/models/origin_model_ext.go b/internal/db/models/origin_model_ext.go index db5ffefd..ec88b4d1 100644 --- a/internal/db/models/origin_model_ext.go +++ b/internal/db/models/origin_model_ext.go @@ -3,6 +3,7 @@ package models import ( "encoding/json" "errors" + "github.com/TeaOSLab/EdgeAPI/internal/remotelogs" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" ) diff --git a/internal/db/models/plan_dao.go b/internal/db/models/plan_dao.go index 6edc6fa9..fb8206c9 100644 --- a/internal/db/models/plan_dao.go +++ b/internal/db/models/plan_dao.go @@ -4,6 +4,7 @@ package models import ( "encoding/json" + "github.com/TeaOSLab/EdgeAPI/internal/utils" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" _ "github.com/go-sql-driver/mysql" diff --git a/internal/db/models/regions/region_city_dao.go b/internal/db/models/regions/region_city_dao.go index 04f5c800..7743e79a 100644 --- a/internal/db/models/regions/region_city_dao.go +++ b/internal/db/models/regions/region_city_dao.go @@ -2,6 +2,9 @@ package regions import ( "encoding/json" + "sort" + "strconv" + "github.com/TeaOSLab/EdgeAPI/internal/utils" "github.com/TeaOSLab/EdgeAPI/internal/utils/numberutils" _ "github.com/go-sql-driver/mysql" @@ -9,8 +12,6 @@ import ( "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/types" - "sort" - "strconv" ) const ( diff --git a/internal/db/models/regions/region_city_model_ext.go b/internal/db/models/regions/region_city_model_ext.go index 665e4ede..05b44f1a 100644 --- a/internal/db/models/regions/region_city_model_ext.go +++ b/internal/db/models/regions/region_city_model_ext.go @@ -2,6 +2,7 @@ package regions import ( "encoding/json" + "github.com/TeaOSLab/EdgeAPI/internal/remotelogs" "github.com/iwind/TeaGo/lists" ) diff --git a/internal/db/models/regions/region_country_dao.go b/internal/db/models/regions/region_country_dao.go index 3832488c..f9c07117 100644 --- a/internal/db/models/regions/region_country_dao.go +++ b/internal/db/models/regions/region_country_dao.go @@ -2,6 +2,10 @@ package regions import ( "encoding/json" + "sort" + "strconv" + "strings" + "github.com/TeaOSLab/EdgeAPI/internal/utils" "github.com/TeaOSLab/EdgeAPI/internal/utils/numberutils" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/regionconfigs" @@ -11,9 +15,6 @@ import ( "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/types" "github.com/mozillazg/go-pinyin" - "sort" - "strconv" - "strings" ) const ( diff --git a/internal/db/models/regions/region_country_dao_test.go b/internal/db/models/regions/region_country_dao_test.go index 1c85bf3a..4ddc403c 100644 --- a/internal/db/models/regions/region_country_dao_test.go +++ b/internal/db/models/regions/region_country_dao_test.go @@ -1,10 +1,11 @@ package regions import ( + "testing" + _ "github.com/go-sql-driver/mysql" _ "github.com/iwind/TeaGo/bootstrap" "github.com/iwind/TeaGo/dbs" - "testing" ) func TestRegionCountryDAO_FindCountryIdWithName(t *testing.T) { diff --git a/internal/db/models/regions/region_country_model_ext.go b/internal/db/models/regions/region_country_model_ext.go index fd9f4e96..422cd6a4 100644 --- a/internal/db/models/regions/region_country_model_ext.go +++ b/internal/db/models/regions/region_country_model_ext.go @@ -2,6 +2,7 @@ package regions import ( "encoding/json" + "github.com/TeaOSLab/EdgeAPI/internal/remotelogs" "github.com/iwind/TeaGo/lists" ) diff --git a/internal/db/models/regions/region_provider_dao.go b/internal/db/models/regions/region_provider_dao.go index 3be80ce6..be98d965 100644 --- a/internal/db/models/regions/region_provider_dao.go +++ b/internal/db/models/regions/region_provider_dao.go @@ -2,14 +2,15 @@ package regions import ( "encoding/json" + "sort" + "strconv" + "github.com/TeaOSLab/EdgeAPI/internal/utils" "github.com/TeaOSLab/EdgeAPI/internal/utils/numberutils" _ "github.com/go-sql-driver/mysql" "github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/maps" - "sort" - "strconv" ) const ( diff --git a/internal/db/models/regions/region_provider_model_ext.go b/internal/db/models/regions/region_provider_model_ext.go index b3a4482f..061e7a12 100644 --- a/internal/db/models/regions/region_provider_model_ext.go +++ b/internal/db/models/regions/region_provider_model_ext.go @@ -2,6 +2,7 @@ package regions import ( "encoding/json" + "github.com/TeaOSLab/EdgeAPI/internal/remotelogs" "github.com/iwind/TeaGo/lists" ) diff --git a/internal/db/models/regions/region_province_dao.go b/internal/db/models/regions/region_province_dao.go index d6ca8a67..fbfbb38f 100644 --- a/internal/db/models/regions/region_province_dao.go +++ b/internal/db/models/regions/region_province_dao.go @@ -2,6 +2,10 @@ package regions import ( "encoding/json" + "sort" + "strconv" + "strings" + "github.com/TeaOSLab/EdgeAPI/internal/utils" "github.com/TeaOSLab/EdgeAPI/internal/utils/numberutils" _ "github.com/go-sql-driver/mysql" @@ -9,9 +13,6 @@ import ( "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/types" - "sort" - "strconv" - "strings" ) const ( diff --git a/internal/db/models/regions/region_province_dao_test.go b/internal/db/models/regions/region_province_dao_test.go index d73d7ce8..be3887c1 100644 --- a/internal/db/models/regions/region_province_dao_test.go +++ b/internal/db/models/regions/region_province_dao_test.go @@ -1,9 +1,10 @@ package regions import ( + "testing" + _ "github.com/go-sql-driver/mysql" "github.com/iwind/TeaGo/dbs" - "testing" ) func TestRegionProvinceDAO_FindProvinceIdWithName(t *testing.T) { diff --git a/internal/db/models/regions/region_province_model_ext.go b/internal/db/models/regions/region_province_model_ext.go index cd08a95c..940d2d9d 100644 --- a/internal/db/models/regions/region_province_model_ext.go +++ b/internal/db/models/regions/region_province_model_ext.go @@ -2,6 +2,7 @@ package regions import ( "encoding/json" + "github.com/TeaOSLab/EdgeAPI/internal/remotelogs" "github.com/iwind/TeaGo/lists" ) diff --git a/internal/db/models/regions/region_town_dao.go b/internal/db/models/regions/region_town_dao.go index 704fd0d4..8b7df137 100644 --- a/internal/db/models/regions/region_town_dao.go +++ b/internal/db/models/regions/region_town_dao.go @@ -2,14 +2,15 @@ package regions import ( "encoding/json" + "sort" + "strconv" + "github.com/TeaOSLab/EdgeAPI/internal/utils" "github.com/TeaOSLab/EdgeAPI/internal/utils/numberutils" _ "github.com/go-sql-driver/mysql" "github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/maps" - "sort" - "strconv" ) const ( diff --git a/internal/db/models/regions/region_town_model_ext.go b/internal/db/models/regions/region_town_model_ext.go index 197e462a..ea9125a8 100644 --- a/internal/db/models/regions/region_town_model_ext.go +++ b/internal/db/models/regions/region_town_model_ext.go @@ -2,6 +2,7 @@ package regions import ( "encoding/json" + "github.com/TeaOSLab/EdgeAPI/internal/remotelogs" "github.com/iwind/TeaGo/lists" ) diff --git a/internal/db/models/report_node_dao.go b/internal/db/models/report_node_dao.go index 486bece4..320b3c6d 100644 --- a/internal/db/models/report_node_dao.go +++ b/internal/db/models/report_node_dao.go @@ -2,6 +2,7 @@ package models import ( "encoding/json" + dbutils "github.com/TeaOSLab/EdgeAPI/internal/db/utils" "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeAPI/internal/utils" diff --git a/internal/db/models/report_result_dao.go b/internal/db/models/report_result_dao.go index 23a9a2f8..38636749 100644 --- a/internal/db/models/report_result_dao.go +++ b/internal/db/models/report_result_dao.go @@ -1,6 +1,8 @@ package models import ( + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/configutils" "github.com/TeaOSLab/EdgeCommon/pkg/reporterconfigs" _ "github.com/go-sql-driver/mysql" @@ -8,7 +10,6 @@ import ( "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/types" - "time" ) type ReportResultDAO dbs.DAO diff --git a/internal/db/models/reverse_proxy_dao.go b/internal/db/models/reverse_proxy_dao.go index 20e0e044..b069d89f 100644 --- a/internal/db/models/reverse_proxy_dao.go +++ b/internal/db/models/reverse_proxy_dao.go @@ -4,6 +4,7 @@ import ( "encoding/json" "errors" "fmt" + "github.com/TeaOSLab/EdgeAPI/internal/utils" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared" diff --git a/internal/db/models/server_bandwidth_stat_dao.go b/internal/db/models/server_bandwidth_stat_dao.go index bccf4196..f530853a 100644 --- a/internal/db/models/server_bandwidth_stat_dao.go +++ b/internal/db/models/server_bandwidth_stat_dao.go @@ -2,6 +2,12 @@ package models import ( "fmt" + "math" + "regexp" + "strings" + "sync" + "time" + "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeAPI/internal/goman" "github.com/TeaOSLab/EdgeAPI/internal/remotelogs" @@ -15,11 +21,6 @@ import ( "github.com/iwind/TeaGo/rands" "github.com/iwind/TeaGo/types" timeutil "github.com/iwind/TeaGo/utils/time" - "math" - "regexp" - "strings" - "sync" - "time" ) type ServerBandwidthStatDAO dbs.DAO diff --git a/internal/db/models/server_bandwidth_stat_dao_test.go b/internal/db/models/server_bandwidth_stat_dao_test.go index 5d2752aa..efd1095d 100644 --- a/internal/db/models/server_bandwidth_stat_dao_test.go +++ b/internal/db/models/server_bandwidth_stat_dao_test.go @@ -2,6 +2,9 @@ package models_test import ( "fmt" + "testing" + "time" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" _ "github.com/go-sql-driver/mysql" _ "github.com/iwind/TeaGo/bootstrap" @@ -9,8 +12,6 @@ import ( "github.com/iwind/TeaGo/logs" "github.com/iwind/TeaGo/rands" timeutil "github.com/iwind/TeaGo/utils/time" - "testing" - "time" ) func TestServerBandwidthStatDAO_UpdateServerBandwidth(t *testing.T) { diff --git a/internal/db/models/server_bill_dao.go b/internal/db/models/server_bill_dao.go index 54c1cc0c..7c26f8ca 100644 --- a/internal/db/models/server_bill_dao.go +++ b/internal/db/models/server_bill_dao.go @@ -1,12 +1,13 @@ package models import ( + "math" + "time" + _ "github.com/go-sql-driver/mysql" "github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/maps" - "math" - "time" ) type ServerBillDAO dbs.DAO diff --git a/internal/db/models/server_bill_dao_test.go b/internal/db/models/server_bill_dao_test.go index 68ba56f4..809d776b 100644 --- a/internal/db/models/server_bill_dao_test.go +++ b/internal/db/models/server_bill_dao_test.go @@ -1,11 +1,12 @@ package models import ( + "testing" + _ "github.com/go-sql-driver/mysql" _ "github.com/iwind/TeaGo/bootstrap" "github.com/iwind/TeaGo/dbs" timeutil "github.com/iwind/TeaGo/utils/time" - "testing" ) func TestServerBillDAO_CreateOrUpdateServerBill(t *testing.T) { diff --git a/internal/db/models/server_daily_stat_dao_test.go b/internal/db/models/server_daily_stat_dao_test.go index db4c2417..50a690a1 100644 --- a/internal/db/models/server_daily_stat_dao_test.go +++ b/internal/db/models/server_daily_stat_dao_test.go @@ -2,6 +2,9 @@ package models_test import ( "fmt" + "testing" + "time" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" _ "github.com/go-sql-driver/mysql" @@ -9,8 +12,6 @@ import ( "github.com/iwind/TeaGo/logs" "github.com/iwind/TeaGo/rands" timeutil "github.com/iwind/TeaGo/utils/time" - "testing" - "time" ) func TestServerDailyStatDAO_SaveStats(t *testing.T) { diff --git a/internal/db/models/server_dao.go b/internal/db/models/server_dao.go index d7d56891..dddb1c99 100644 --- a/internal/db/models/server_dao.go +++ b/internal/db/models/server_dao.go @@ -4,6 +4,11 @@ import ( "encoding/json" "errors" "fmt" + "regexp" + "strconv" + "strings" + "time" + teaconst "github.com/TeaOSLab/EdgeAPI/internal/const" "github.com/TeaOSLab/EdgeAPI/internal/db/models/dns" dbutils "github.com/TeaOSLab/EdgeAPI/internal/db/utils" @@ -23,10 +28,6 @@ import ( "github.com/iwind/TeaGo/rands" "github.com/iwind/TeaGo/types" timeutil "github.com/iwind/TeaGo/utils/time" - "regexp" - "strconv" - "strings" - "time" ) const ( @@ -3178,3 +3179,15 @@ func (this *ServerDAO) NotifyUserClustersChange(tx *dbs.Tx, userId int64) error return nil } + +// FindUserServerByServerName 根据域名查找Server +func (this *ServerDAO) FindUserServerByServerName(tx *dbs.Tx, serverName string) (result []*Server, err error) { + _, err = this.Query(tx). + State(ServerStateEnabled). + Where("(JSON_CONTAINS(serverNames, :jsonQuery1) OR JSON_CONTAINS(serverNames, :jsonQuery2))"). + Param("jsonQuery1", maps.Map{"name": serverName}.AsJSON()). + Param("jsonQuery2", maps.Map{"subNames": serverName}.AsJSON()). + Slice(&result). + FindAll() + return +} diff --git a/internal/db/models/server_dao_copy_ext.go b/internal/db/models/server_dao_copy_ext.go index ec88c4d3..07029a97 100644 --- a/internal/db/models/server_dao_copy_ext.go +++ b/internal/db/models/server_dao_copy_ext.go @@ -1,10 +1,11 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . //go:build !plus package models import ( "errors" + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" "github.com/iwind/TeaGo/dbs" ) diff --git a/internal/db/models/server_dao_ext.go b/internal/db/models/server_dao_ext.go index 95d5e30f..c6614b46 100644 --- a/internal/db/models/server_dao_ext.go +++ b/internal/db/models/server_dao_ext.go @@ -1,4 +1,4 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . //go:build !plus package models diff --git a/internal/db/models/server_dao_test.go b/internal/db/models/server_dao_test.go index 293a27c3..89f778c9 100644 --- a/internal/db/models/server_dao_test.go +++ b/internal/db/models/server_dao_test.go @@ -4,6 +4,9 @@ import ( "crypto/md5" "encoding/json" "fmt" + "testing" + "time" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/utils" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" @@ -14,8 +17,6 @@ import ( "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/types" timeutil "github.com/iwind/TeaGo/utils/time" - "testing" - "time" ) func TestServerDAO_CreateManyServers(t *testing.T) { diff --git a/internal/db/models/server_group_dao.go b/internal/db/models/server_group_dao.go index b5609e6f..26078e71 100644 --- a/internal/db/models/server_group_dao.go +++ b/internal/db/models/server_group_dao.go @@ -2,6 +2,7 @@ package models import ( "encoding/json" + "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeAPI/internal/utils" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" diff --git a/internal/db/models/server_model_ext.go b/internal/db/models/server_model_ext.go index cc4342d7..b6955dad 100644 --- a/internal/db/models/server_model_ext.go +++ b/internal/db/models/server_model_ext.go @@ -3,6 +3,7 @@ package models import ( "context" "encoding/json" + "github.com/TeaOSLab/EdgeAPI/internal/remotelogs" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" ) diff --git a/internal/db/models/ssl_cert_dao.go b/internal/db/models/ssl_cert_dao.go index 02587c9a..4ff1182a 100644 --- a/internal/db/models/ssl_cert_dao.go +++ b/internal/db/models/ssl_cert_dao.go @@ -4,6 +4,10 @@ import ( "bytes" "encoding/json" "errors" + "regexp" + "strings" + "time" + dbutils "github.com/TeaOSLab/EdgeAPI/internal/db/utils" "github.com/TeaOSLab/EdgeAPI/internal/utils" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared" @@ -13,9 +17,6 @@ import ( "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/types" timeutil "github.com/iwind/TeaGo/utils/time" - "regexp" - "strings" - "time" ) const ( diff --git a/internal/db/models/ssl_cert_dao_test.go b/internal/db/models/ssl_cert_dao_test.go index 5e0f0756..1a7964e5 100644 --- a/internal/db/models/ssl_cert_dao_test.go +++ b/internal/db/models/ssl_cert_dao_test.go @@ -2,12 +2,13 @@ package models_test import ( "encoding/json" + "testing" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" _ "github.com/go-sql-driver/mysql" "github.com/iwind/TeaGo/assert" "github.com/iwind/TeaGo/dbs" timeutil "github.com/iwind/TeaGo/utils/time" - "testing" ) func TestSSLCertDAO_ListCertsToUpdateOCSP(t *testing.T) { diff --git a/internal/db/models/ssl_policy_dao.go b/internal/db/models/ssl_policy_dao.go index d4d3a165..88b4e58d 100644 --- a/internal/db/models/ssl_policy_dao.go +++ b/internal/db/models/ssl_policy_dao.go @@ -3,6 +3,7 @@ package models import ( "encoding/json" "errors" + "github.com/TeaOSLab/EdgeAPI/internal/utils" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/sslconfigs" diff --git a/internal/db/models/ssl_policy_model_ext.go b/internal/db/models/ssl_policy_model_ext.go index 18592875..00e653d1 100644 --- a/internal/db/models/ssl_policy_model_ext.go +++ b/internal/db/models/ssl_policy_model_ext.go @@ -2,6 +2,7 @@ package models import ( "encoding/json" + "github.com/TeaOSLab/EdgeAPI/internal/remotelogs" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/sslconfigs" ) diff --git a/internal/db/models/stats/node_cluster_traffic_daily_stat_dao.go b/internal/db/models/stats/node_cluster_traffic_daily_stat_dao.go index 496e48c3..8c78e185 100644 --- a/internal/db/models/stats/node_cluster_traffic_daily_stat_dao.go +++ b/internal/db/models/stats/node_cluster_traffic_daily_stat_dao.go @@ -1,6 +1,8 @@ package stats import ( + "time" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeAPI/internal/goman" @@ -12,7 +14,6 @@ import ( "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/rands" timeutil "github.com/iwind/TeaGo/utils/time" - "time" ) type NodeClusterTrafficDailyStatDAO dbs.DAO diff --git a/internal/db/models/stats/node_traffic_hourly_stat_dao.go b/internal/db/models/stats/node_traffic_hourly_stat_dao.go index 8b4bf5d1..deb7aac1 100644 --- a/internal/db/models/stats/node_traffic_hourly_stat_dao.go +++ b/internal/db/models/stats/node_traffic_hourly_stat_dao.go @@ -1,6 +1,8 @@ package stats import ( + "time" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeAPI/internal/goman" @@ -12,7 +14,6 @@ import ( "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/rands" timeutil "github.com/iwind/TeaGo/utils/time" - "time" ) type NodeTrafficHourlyStatDAO dbs.DAO diff --git a/internal/db/models/stats/server_client_browser_monthly_stat_dao.go b/internal/db/models/stats/server_client_browser_monthly_stat_dao.go index e15ef80d..1fbc8b59 100644 --- a/internal/db/models/stats/server_client_browser_monthly_stat_dao.go +++ b/internal/db/models/stats/server_client_browser_monthly_stat_dao.go @@ -1,6 +1,8 @@ package stats import ( + "time" + "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeAPI/internal/goman" "github.com/TeaOSLab/EdgeAPI/internal/remotelogs" @@ -10,7 +12,6 @@ import ( "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/rands" timeutil "github.com/iwind/TeaGo/utils/time" - "time" ) func init() { diff --git a/internal/db/models/stats/server_client_browser_monthly_stat_dao_test.go b/internal/db/models/stats/server_client_browser_monthly_stat_dao_test.go index d321961f..0cbdcc2b 100644 --- a/internal/db/models/stats/server_client_browser_monthly_stat_dao_test.go +++ b/internal/db/models/stats/server_client_browser_monthly_stat_dao_test.go @@ -1,10 +1,11 @@ package stats import ( + "testing" + _ "github.com/go-sql-driver/mysql" _ "github.com/iwind/TeaGo/bootstrap" "github.com/iwind/TeaGo/dbs" - "testing" ) func TestServerClientBrowserMonthlyStatDAO_IncreaseMonthlyCount(t *testing.T) { diff --git a/internal/db/models/stats/server_client_system_monthly_stat_dao.go b/internal/db/models/stats/server_client_system_monthly_stat_dao.go index 1bebb886..ed81c329 100644 --- a/internal/db/models/stats/server_client_system_monthly_stat_dao.go +++ b/internal/db/models/stats/server_client_system_monthly_stat_dao.go @@ -1,6 +1,8 @@ package stats import ( + "time" + "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeAPI/internal/goman" "github.com/TeaOSLab/EdgeAPI/internal/remotelogs" @@ -10,7 +12,6 @@ import ( "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/rands" timeutil "github.com/iwind/TeaGo/utils/time" - "time" ) func init() { diff --git a/internal/db/models/stats/server_client_system_monthly_stat_dao_test.go b/internal/db/models/stats/server_client_system_monthly_stat_dao_test.go index f9820182..1bf76e0b 100644 --- a/internal/db/models/stats/server_client_system_monthly_stat_dao_test.go +++ b/internal/db/models/stats/server_client_system_monthly_stat_dao_test.go @@ -1,8 +1,9 @@ package stats import ( - _ "github.com/go-sql-driver/mysql" "testing" + + _ "github.com/go-sql-driver/mysql" ) func TestServerClientSystemMonthlyStatDAO_Clean(t *testing.T) { diff --git a/internal/db/models/stats/server_domain_hourly_stat_dao.go b/internal/db/models/stats/server_domain_hourly_stat_dao.go index c94ee084..56e8ef1a 100644 --- a/internal/db/models/stats/server_domain_hourly_stat_dao.go +++ b/internal/db/models/stats/server_domain_hourly_stat_dao.go @@ -1,6 +1,11 @@ package stats import ( + "sort" + "strings" + "sync" + "time" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeAPI/internal/goman" @@ -12,10 +17,6 @@ import ( "github.com/iwind/TeaGo/rands" "github.com/iwind/TeaGo/types" timeutil "github.com/iwind/TeaGo/utils/time" - "sort" - "strings" - "sync" - "time" ) type ServerDomainHourlyStatDAO dbs.DAO diff --git a/internal/db/models/stats/server_domain_hourly_stat_dao_test.go b/internal/db/models/stats/server_domain_hourly_stat_dao_test.go index 66017847..d1b0a15d 100644 --- a/internal/db/models/stats/server_domain_hourly_stat_dao_test.go +++ b/internal/db/models/stats/server_domain_hourly_stat_dao_test.go @@ -2,6 +2,9 @@ package stats import ( "fmt" + "testing" + "time" + _ "github.com/go-sql-driver/mysql" "github.com/iwind/TeaGo/assert" _ "github.com/iwind/TeaGo/bootstrap" @@ -9,8 +12,6 @@ import ( "github.com/iwind/TeaGo/rands" "github.com/iwind/TeaGo/types" timeutil "github.com/iwind/TeaGo/utils/time" - "testing" - "time" ) func TestServerDomainHourlyStatDAO_PartitionTable(t *testing.T) { diff --git a/internal/db/models/stats/server_http_firewall_daily_stat_dao.go b/internal/db/models/stats/server_http_firewall_daily_stat_dao.go index f8f5c9aa..ed2a8293 100644 --- a/internal/db/models/stats/server_http_firewall_daily_stat_dao.go +++ b/internal/db/models/stats/server_http_firewall_daily_stat_dao.go @@ -1,6 +1,8 @@ package stats import ( + "time" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeAPI/internal/goman" @@ -11,7 +13,6 @@ import ( "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/rands" timeutil "github.com/iwind/TeaGo/utils/time" - "time" ) type ServerHTTPFirewallDailyStatDAO dbs.DAO diff --git a/internal/db/models/stats/server_http_firewall_hourly_stat_dao.go b/internal/db/models/stats/server_http_firewall_hourly_stat_dao.go index 129d680b..a43f5028 100644 --- a/internal/db/models/stats/server_http_firewall_hourly_stat_dao.go +++ b/internal/db/models/stats/server_http_firewall_hourly_stat_dao.go @@ -1,6 +1,8 @@ package stats import ( + "time" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeAPI/internal/goman" @@ -11,7 +13,6 @@ import ( "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/rands" timeutil "github.com/iwind/TeaGo/utils/time" - "time" ) type ServerHTTPFirewallHourlyStatDAO dbs.DAO diff --git a/internal/db/models/stats/server_region_city_monthly_stat_dao.go b/internal/db/models/stats/server_region_city_monthly_stat_dao.go index 82e82ee3..1a49670f 100644 --- a/internal/db/models/stats/server_region_city_monthly_stat_dao.go +++ b/internal/db/models/stats/server_region_city_monthly_stat_dao.go @@ -1,6 +1,8 @@ package stats import ( + "time" + "github.com/TeaOSLab/EdgeAPI/internal/db/models/regions" "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeAPI/internal/goman" @@ -11,7 +13,6 @@ import ( "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/rands" timeutil "github.com/iwind/TeaGo/utils/time" - "time" ) func init() { diff --git a/internal/db/models/stats/server_region_city_monthly_stat_dao_test.go b/internal/db/models/stats/server_region_city_monthly_stat_dao_test.go index 1deb0b7e..81e89348 100644 --- a/internal/db/models/stats/server_region_city_monthly_stat_dao_test.go +++ b/internal/db/models/stats/server_region_city_monthly_stat_dao_test.go @@ -1,8 +1,9 @@ package stats import ( - _ "github.com/go-sql-driver/mysql" "testing" + + _ "github.com/go-sql-driver/mysql" ) func TestServerRegionCityMonthlyStatDAO_Clean(t *testing.T) { diff --git a/internal/db/models/stats/server_region_country_daily_stat_dao.go b/internal/db/models/stats/server_region_country_daily_stat_dao.go index 2776d86f..13005f40 100644 --- a/internal/db/models/stats/server_region_country_daily_stat_dao.go +++ b/internal/db/models/stats/server_region_country_daily_stat_dao.go @@ -1,6 +1,8 @@ package stats import ( + "time" + "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeAPI/internal/goman" "github.com/TeaOSLab/EdgeAPI/internal/remotelogs" @@ -10,7 +12,6 @@ import ( "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/rands" timeutil "github.com/iwind/TeaGo/utils/time" - "time" ) func init() { diff --git a/internal/db/models/stats/server_region_country_daily_stat_dao_test.go b/internal/db/models/stats/server_region_country_daily_stat_dao_test.go index 38d304ac..108a5304 100644 --- a/internal/db/models/stats/server_region_country_daily_stat_dao_test.go +++ b/internal/db/models/stats/server_region_country_daily_stat_dao_test.go @@ -2,11 +2,12 @@ package stats import ( "encoding/json" + "testing" + _ "github.com/go-sql-driver/mysql" _ "github.com/iwind/TeaGo/bootstrap" "github.com/iwind/TeaGo/dbs" timeutil "github.com/iwind/TeaGo/utils/time" - "testing" ) func TestServerRegionCountryDailyStatDAO_IncreaseDailyStat(t *testing.T) { diff --git a/internal/db/models/stats/server_region_country_monthly_stat_dao.go b/internal/db/models/stats/server_region_country_monthly_stat_dao.go index 79e85361..5e694825 100644 --- a/internal/db/models/stats/server_region_country_monthly_stat_dao.go +++ b/internal/db/models/stats/server_region_country_monthly_stat_dao.go @@ -1,6 +1,8 @@ package stats import ( + "time" + "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeAPI/internal/goman" "github.com/TeaOSLab/EdgeAPI/internal/remotelogs" @@ -10,7 +12,6 @@ import ( "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/rands" timeutil "github.com/iwind/TeaGo/utils/time" - "time" ) func init() { diff --git a/internal/db/models/stats/server_region_provider_monthly_stat_dao.go b/internal/db/models/stats/server_region_provider_monthly_stat_dao.go index 91bb6272..b914cbb6 100644 --- a/internal/db/models/stats/server_region_provider_monthly_stat_dao.go +++ b/internal/db/models/stats/server_region_provider_monthly_stat_dao.go @@ -1,6 +1,8 @@ package stats import ( + "time" + "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeAPI/internal/goman" "github.com/TeaOSLab/EdgeAPI/internal/remotelogs" @@ -10,7 +12,6 @@ import ( "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/rands" timeutil "github.com/iwind/TeaGo/utils/time" - "time" ) func init() { diff --git a/internal/db/models/stats/server_region_provider_monthly_stat_dao_test.go b/internal/db/models/stats/server_region_provider_monthly_stat_dao_test.go index 2ef02de9..03d78919 100644 --- a/internal/db/models/stats/server_region_provider_monthly_stat_dao_test.go +++ b/internal/db/models/stats/server_region_provider_monthly_stat_dao_test.go @@ -1,8 +1,9 @@ package stats import ( - _ "github.com/go-sql-driver/mysql" "testing" + + _ "github.com/go-sql-driver/mysql" ) diff --git a/internal/db/models/stats/server_region_province_monthly_stat_dao.go b/internal/db/models/stats/server_region_province_monthly_stat_dao.go index 4de62c30..a7400ff7 100644 --- a/internal/db/models/stats/server_region_province_monthly_stat_dao.go +++ b/internal/db/models/stats/server_region_province_monthly_stat_dao.go @@ -1,6 +1,8 @@ package stats import ( + "time" + "github.com/TeaOSLab/EdgeAPI/internal/db/models/regions" "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeAPI/internal/goman" @@ -11,7 +13,6 @@ import ( "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/rands" timeutil "github.com/iwind/TeaGo/utils/time" - "time" ) func init() { diff --git a/internal/db/models/stats/traffic_daily_stat_dao.go b/internal/db/models/stats/traffic_daily_stat_dao.go index 33666bcf..1510d1a7 100644 --- a/internal/db/models/stats/traffic_daily_stat_dao.go +++ b/internal/db/models/stats/traffic_daily_stat_dao.go @@ -1,6 +1,8 @@ package stats import ( + "time" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeAPI/internal/goman" @@ -12,7 +14,6 @@ import ( "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/rands" timeutil "github.com/iwind/TeaGo/utils/time" - "time" ) type TrafficDailyStatDAO dbs.DAO diff --git a/internal/db/models/stats/traffic_daily_stat_dao_test.go b/internal/db/models/stats/traffic_daily_stat_dao_test.go index 34f0c46a..b033079f 100644 --- a/internal/db/models/stats/traffic_daily_stat_dao_test.go +++ b/internal/db/models/stats/traffic_daily_stat_dao_test.go @@ -1,11 +1,12 @@ package stats import ( + "testing" + "time" + _ "github.com/go-sql-driver/mysql" "github.com/iwind/TeaGo/dbs" timeutil "github.com/iwind/TeaGo/utils/time" - "testing" - "time" ) func TestTrafficDailyStatDAO_IncreaseDayBytes(t *testing.T) { diff --git a/internal/db/models/stats/traffic_hourly_stat_dao.go b/internal/db/models/stats/traffic_hourly_stat_dao.go index 8cb2c874..f4b7481d 100644 --- a/internal/db/models/stats/traffic_hourly_stat_dao.go +++ b/internal/db/models/stats/traffic_hourly_stat_dao.go @@ -1,6 +1,8 @@ package stats import ( + "time" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeAPI/internal/goman" @@ -12,7 +14,6 @@ import ( "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/rands" timeutil "github.com/iwind/TeaGo/utils/time" - "time" ) type TrafficHourlyStatDAO dbs.DAO diff --git a/internal/db/models/stats/traffic_hourly_stat_dao_test.go b/internal/db/models/stats/traffic_hourly_stat_dao_test.go index e0053787..e558195b 100644 --- a/internal/db/models/stats/traffic_hourly_stat_dao_test.go +++ b/internal/db/models/stats/traffic_hourly_stat_dao_test.go @@ -1,11 +1,12 @@ package stats import ( + "testing" + "time" + _ "github.com/go-sql-driver/mysql" "github.com/iwind/TeaGo/dbs" timeutil "github.com/iwind/TeaGo/utils/time" - "testing" - "time" ) func TestTrafficHourlyStatDAO_IncreaseDayBytes(t *testing.T) { diff --git a/internal/db/models/sys_event_dao.go b/internal/db/models/sys_event_dao.go index c070b05b..ad0a7551 100644 --- a/internal/db/models/sys_event_dao.go +++ b/internal/db/models/sys_event_dao.go @@ -3,6 +3,7 @@ package models import ( "encoding/json" "errors" + _ "github.com/go-sql-driver/mysql" "github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/dbs" diff --git a/internal/db/models/sys_event_dao_test.go b/internal/db/models/sys_event_dao_test.go index 1d540a80..07d89d7c 100644 --- a/internal/db/models/sys_event_dao_test.go +++ b/internal/db/models/sys_event_dao_test.go @@ -1,8 +1,9 @@ package models import ( - _ "github.com/go-sql-driver/mysql" "testing" + + _ "github.com/go-sql-driver/mysql" ) func TestSysEvent_DecodeEvent(t *testing.T) { diff --git a/internal/db/models/sys_locker_dao.go b/internal/db/models/sys_locker_dao.go index be2ef5fd..b1446d10 100644 --- a/internal/db/models/sys_locker_dao.go +++ b/internal/db/models/sys_locker_dao.go @@ -2,13 +2,14 @@ package models import ( "errors" + "strings" + "time" + _ "github.com/go-sql-driver/mysql" "github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/types" - "strings" - "time" ) type SysLockerDAO dbs.DAO diff --git a/internal/db/models/sys_locker_dao_test.go b/internal/db/models/sys_locker_dao_test.go index 42aa61e1..5474e0a9 100644 --- a/internal/db/models/sys_locker_dao_test.go +++ b/internal/db/models/sys_locker_dao_test.go @@ -1,12 +1,13 @@ package models import ( - _ "github.com/go-sql-driver/mysql" - "github.com/iwind/TeaGo/dbs" - "github.com/iwind/TeaGo/types" "sync" "testing" "time" + + _ "github.com/go-sql-driver/mysql" + "github.com/iwind/TeaGo/dbs" + "github.com/iwind/TeaGo/types" ) func TestSysLockerDAO_Lock(t *testing.T) { diff --git a/internal/db/models/sys_locker_increment.go b/internal/db/models/sys_locker_increment.go index b475bcee..b6b6951a 100644 --- a/internal/db/models/sys_locker_increment.go +++ b/internal/db/models/sys_locker_increment.go @@ -1,4 +1,4 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package models diff --git a/internal/db/models/sys_locker_increment_test.go b/internal/db/models/sys_locker_increment_test.go index e9d3fa8f..7ac9d27d 100644 --- a/internal/db/models/sys_locker_increment_test.go +++ b/internal/db/models/sys_locker_increment_test.go @@ -1,10 +1,11 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package models_test import ( - "github.com/TeaOSLab/EdgeAPI/internal/db/models" "testing" + + "github.com/TeaOSLab/EdgeAPI/internal/db/models" ) func TestNewSysLockerIncrement(t *testing.T) { diff --git a/internal/db/models/sys_setting_dao.go b/internal/db/models/sys_setting_dao.go index c686be61..173b1cb5 100644 --- a/internal/db/models/sys_setting_dao.go +++ b/internal/db/models/sys_setting_dao.go @@ -3,6 +3,9 @@ package models import ( "encoding/json" "fmt" + "strconv" + "time" + "github.com/TeaOSLab/EdgeAPI/internal/remotelogs" "github.com/TeaOSLab/EdgeAPI/internal/utils" "github.com/TeaOSLab/EdgeAPI/internal/zero" @@ -13,8 +16,6 @@ import ( "github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/types" - "strconv" - "time" ) type SysSettingDAO dbs.DAO diff --git a/internal/db/models/sys_setting_dao_test.go b/internal/db/models/sys_setting_dao_test.go index 5b87634d..e253c546 100644 --- a/internal/db/models/sys_setting_dao_test.go +++ b/internal/db/models/sys_setting_dao_test.go @@ -1,9 +1,10 @@ package models import ( + "testing" + _ "github.com/go-sql-driver/mysql" "github.com/iwind/TeaGo/dbs" - "testing" ) func TestSysSettingDAO_UpdateSetting(t *testing.T) { diff --git a/internal/db/models/updating_server_list_dao.go b/internal/db/models/updating_server_list_dao.go index f3adfbf4..e5d10df2 100644 --- a/internal/db/models/updating_server_list_dao.go +++ b/internal/db/models/updating_server_list_dao.go @@ -2,6 +2,9 @@ package models import ( "encoding/json" + "sort" + "time" + "github.com/TeaOSLab/EdgeAPI/internal/goman" "github.com/TeaOSLab/EdgeAPI/internal/remotelogs" _ "github.com/go-sql-driver/mysql" @@ -10,8 +13,6 @@ import ( "github.com/iwind/TeaGo/types" stringutil "github.com/iwind/TeaGo/utils/string" timeutil "github.com/iwind/TeaGo/utils/time" - "sort" - "time" ) type UpdatingServerListDAO dbs.DAO diff --git a/internal/db/models/updating_server_list_model_ext.go b/internal/db/models/updating_server_list_model_ext.go index cfe92c99..98c37867 100644 --- a/internal/db/models/updating_server_list_model_ext.go +++ b/internal/db/models/updating_server_list_model_ext.go @@ -2,6 +2,7 @@ package models import ( "encoding/json" + "github.com/TeaOSLab/EdgeAPI/internal/remotelogs" ) diff --git a/internal/db/models/user_access_key_dao.go b/internal/db/models/user_access_key_dao.go index 150662a3..78077629 100644 --- a/internal/db/models/user_access_key_dao.go +++ b/internal/db/models/user_access_key_dao.go @@ -1,12 +1,13 @@ package models import ( + "time" + "github.com/TeaOSLab/EdgeAPI/internal/errors" _ "github.com/go-sql-driver/mysql" "github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/rands" - "time" ) const ( diff --git a/internal/db/models/user_bandwidth_stat_dao_test.go b/internal/db/models/user_bandwidth_stat_dao_test.go index b48152f3..11ab53e1 100644 --- a/internal/db/models/user_bandwidth_stat_dao_test.go +++ b/internal/db/models/user_bandwidth_stat_dao_test.go @@ -1,14 +1,15 @@ package models_test import ( + "testing" + "time" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" _ "github.com/go-sql-driver/mysql" _ "github.com/iwind/TeaGo/bootstrap" "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/logs" timeutil "github.com/iwind/TeaGo/utils/time" - "testing" - "time" ) func TestUserBandwidthStatDAO_FindUserPeekBandwidthInMonth(t *testing.T) { diff --git a/internal/db/models/user_dao.go b/internal/db/models/user_dao.go index f4a4a66c..afb583cb 100644 --- a/internal/db/models/user_dao.go +++ b/internal/db/models/user_dao.go @@ -2,6 +2,7 @@ package models import ( "encoding/json" + dbutils "github.com/TeaOSLab/EdgeAPI/internal/db/utils" "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeAPI/internal/utils" diff --git a/internal/db/models/user_dao_ext.go b/internal/db/models/user_dao_ext.go index da5a8aa9..5b3813fc 100644 --- a/internal/db/models/user_dao_ext.go +++ b/internal/db/models/user_dao_ext.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . //go:build !plus package models diff --git a/internal/db/models/user_dao_test.go b/internal/db/models/user_dao_test.go index e169c594..d9fd4f5c 100644 --- a/internal/db/models/user_dao_test.go +++ b/internal/db/models/user_dao_test.go @@ -1,12 +1,13 @@ package models_test import ( + "testing" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeCommon/pkg/userconfigs" _ "github.com/go-sql-driver/mysql" _ "github.com/iwind/TeaGo/bootstrap" "github.com/iwind/TeaGo/dbs" - "testing" ) func TestUserDAO_UpdateUserFeatures(t *testing.T) { diff --git a/internal/db/models/user_identity_dao.go b/internal/db/models/user_identity_dao.go index c9fc85cf..05dfb636 100644 --- a/internal/db/models/user_identity_dao.go +++ b/internal/db/models/user_identity_dao.go @@ -2,11 +2,12 @@ package models import ( "encoding/json" + "time" + "github.com/TeaOSLab/EdgeCommon/pkg/userconfigs" _ "github.com/go-sql-driver/mysql" "github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/dbs" - "time" ) const ( diff --git a/internal/db/models/user_model_ext.go b/internal/db/models/user_model_ext.go index f1f2f57f..cb94f446 100644 --- a/internal/db/models/user_model_ext.go +++ b/internal/db/models/user_model_ext.go @@ -2,6 +2,7 @@ package models import ( "encoding/json" + "github.com/TeaOSLab/EdgeAPI/internal/remotelogs" ) diff --git a/internal/db/models/user_node_dao.go b/internal/db/models/user_node_dao.go index f74f6351..9df9d935 100644 --- a/internal/db/models/user_node_dao.go +++ b/internal/db/models/user_node_dao.go @@ -2,6 +2,9 @@ package models import ( "encoding/json" + "strconv" + "strings" + "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeAPI/internal/utils" "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" @@ -11,8 +14,6 @@ import ( "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/rands" "github.com/iwind/TeaGo/types" - "strconv" - "strings" ) const ( diff --git a/internal/db/models/user_node_model_ext.go b/internal/db/models/user_node_model_ext.go index 38602647..0a72e685 100644 --- a/internal/db/models/user_node_model_ext.go +++ b/internal/db/models/user_node_model_ext.go @@ -3,6 +3,7 @@ package models import ( "context" "encoding/json" + "github.com/TeaOSLab/EdgeAPI/internal/utils" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" ) diff --git a/internal/db/models/user_plan_bandwidth_stat_dao.go b/internal/db/models/user_plan_bandwidth_stat_dao.go index 7be97b33..33082c72 100644 --- a/internal/db/models/user_plan_bandwidth_stat_dao.go +++ b/internal/db/models/user_plan_bandwidth_stat_dao.go @@ -2,6 +2,10 @@ package models import ( "errors" + "math" + "sync" + "time" + "github.com/TeaOSLab/EdgeAPI/internal/goman" "github.com/TeaOSLab/EdgeAPI/internal/remotelogs" "github.com/TeaOSLab/EdgeAPI/internal/utils/regexputils" @@ -12,9 +16,6 @@ import ( "github.com/iwind/TeaGo/rands" "github.com/iwind/TeaGo/types" timeutil "github.com/iwind/TeaGo/utils/time" - "math" - "sync" - "time" ) type UserPlanBandwidthStatDAO dbs.DAO diff --git a/internal/db/models/user_plan_bandwidth_stat_dao_test.go b/internal/db/models/user_plan_bandwidth_stat_dao_test.go index 012e38da..dc850abc 100644 --- a/internal/db/models/user_plan_bandwidth_stat_dao_test.go +++ b/internal/db/models/user_plan_bandwidth_stat_dao_test.go @@ -1,12 +1,13 @@ package models_test import ( + "testing" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" _ "github.com/go-sql-driver/mysql" _ "github.com/iwind/TeaGo/bootstrap" "github.com/iwind/TeaGo/dbs" timeutil "github.com/iwind/TeaGo/utils/time" - "testing" ) func TestUserPlanBandwidthStatDAO_FindMonthlyPercentile(t *testing.T) { diff --git a/internal/db/models/user_plan_stat_dao_community.go b/internal/db/models/user_plan_stat_dao_community.go index 3ebae037..a5fb576d 100644 --- a/internal/db/models/user_plan_stat_dao_community.go +++ b/internal/db/models/user_plan_stat_dao_community.go @@ -1,4 +1,4 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . //go:build !plus package models diff --git a/internal/db/models/utils.go b/internal/db/models/utils.go index 809e6d7b..8cb93ae1 100644 --- a/internal/db/models/utils.go +++ b/internal/db/models/utils.go @@ -2,11 +2,12 @@ package models import ( "errors" + "strings" + "sync" + "github.com/go-sql-driver/mysql" "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/types" - "strings" - "sync" ) // SharedCacheLocker 缓存专用Locker diff --git a/internal/db/models/utils_test.go b/internal/db/models/utils_test.go index a7ea82dc..fae9242c 100644 --- a/internal/db/models/utils_test.go +++ b/internal/db/models/utils_test.go @@ -1,13 +1,14 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package models_test import ( "errors" + "testing" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/iwind/TeaGo/assert" "github.com/iwind/TeaGo/dbs" - "testing" ) func TestIsMySQLError(t *testing.T) { diff --git a/internal/db/utils/disk.go b/internal/db/utils/disk.go index d6b976d8..a83bf761 100644 --- a/internal/db/utils/disk.go +++ b/internal/db/utils/disk.go @@ -1,13 +1,14 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package dbutils import ( + "time" + "github.com/TeaOSLab/EdgeAPI/internal/goman" "github.com/go-sql-driver/mysql" "github.com/iwind/TeaGo/dbs" "golang.org/x/sys/unix" - "time" ) const minFreeSpaceGB = 3 diff --git a/internal/db/utils/disk_test.go b/internal/db/utils/disk_test.go index 73c1c8be..d2f7b8bc 100644 --- a/internal/db/utils/disk_test.go +++ b/internal/db/utils/disk_test.go @@ -1,11 +1,12 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package dbutils_test import ( + "testing" + dbutils "github.com/TeaOSLab/EdgeAPI/internal/db/utils" _ "github.com/iwind/TeaGo/bootstrap" - "testing" ) func TestHasFreeSpace(t *testing.T) { diff --git a/internal/db/utils/utils.go b/internal/db/utils/utils.go index 9c8ee824..fd9ff710 100644 --- a/internal/db/utils/utils.go +++ b/internal/db/utils/utils.go @@ -1,18 +1,19 @@ package dbutils import ( - executils "github.com/TeaOSLab/EdgeAPI/internal/utils/exec" - "github.com/iwind/TeaGo/Tea" - "github.com/iwind/TeaGo/dbs" - "github.com/iwind/TeaGo/lists" - "github.com/iwind/TeaGo/logs" - "github.com/iwind/TeaGo/types" "net" "os" "os/exec" "regexp" "strings" "time" + + executils "github.com/TeaOSLab/EdgeAPI/internal/utils/exec" + "github.com/iwind/TeaGo/Tea" + "github.com/iwind/TeaGo/dbs" + "github.com/iwind/TeaGo/lists" + "github.com/iwind/TeaGo/logs" + "github.com/iwind/TeaGo/types" ) // NewQuery 构造Query diff --git a/internal/db/utils/utils_test.go b/internal/db/utils/utils_test.go index 6d6a90bc..2c84206d 100644 --- a/internal/db/utils/utils_test.go +++ b/internal/db/utils/utils_test.go @@ -3,9 +3,10 @@ package dbutils_test import ( + "testing" + dbutils "github.com/TeaOSLab/EdgeAPI/internal/db/utils" "github.com/iwind/TeaGo/assert" - "testing" ) func TestQuoteLike(t *testing.T) { diff --git a/internal/dnsclients/dnspod/response_custom_line_group_list.go b/internal/dnsclients/dnspod/response_custom_line_group_list.go index ce025179..be928ec0 100644 --- a/internal/dnsclients/dnspod/response_custom_line_group_list.go +++ b/internal/dnsclients/dnspod/response_custom_line_group_list.go @@ -1,4 +1,4 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package dnspod diff --git a/internal/dnsclients/dnspod/response_domain_info.go b/internal/dnsclients/dnspod/response_domain_info.go index 9b857c8e..372b8221 100644 --- a/internal/dnsclients/dnspod/response_domain_info.go +++ b/internal/dnsclients/dnspod/response_domain_info.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package dnspod diff --git a/internal/dnsclients/dnspod/response_domain_list.go b/internal/dnsclients/dnspod/response_domain_list.go index 10cabc3b..b94ba47e 100644 --- a/internal/dnsclients/dnspod/response_domain_list.go +++ b/internal/dnsclients/dnspod/response_domain_list.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package dnspod diff --git a/internal/dnsclients/dnspod/response_record_create.go b/internal/dnsclients/dnspod/response_record_create.go index 7ce0839c..20f6226e 100644 --- a/internal/dnsclients/dnspod/response_record_create.go +++ b/internal/dnsclients/dnspod/response_record_create.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package dnspod diff --git a/internal/dnsclients/dnspod/response_record_line.go b/internal/dnsclients/dnspod/response_record_line.go index bcd2c657..99f9865c 100644 --- a/internal/dnsclients/dnspod/response_record_line.go +++ b/internal/dnsclients/dnspod/response_record_line.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package dnspod diff --git a/internal/dnsclients/dnspod/response_record_list.go b/internal/dnsclients/dnspod/response_record_list.go index c17a68f4..308388a2 100644 --- a/internal/dnsclients/dnspod/response_record_list.go +++ b/internal/dnsclients/dnspod/response_record_list.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package dnspod diff --git a/internal/dnsclients/dnspod/response_record_modify.go b/internal/dnsclients/dnspod/response_record_modify.go index 677611a0..6e7e476a 100644 --- a/internal/dnsclients/dnspod/response_record_modify.go +++ b/internal/dnsclients/dnspod/response_record_modify.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package dnspod diff --git a/internal/dnsclients/dnspod/response_record_remove.go b/internal/dnsclients/dnspod/response_record_remove.go index 18df80a4..26123e81 100644 --- a/internal/dnsclients/dnspod/response_record_remove.go +++ b/internal/dnsclients/dnspod/response_record_remove.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package dnspod diff --git a/internal/dnsclients/domain_records_cache.go b/internal/dnsclients/domain_records_cache.go index 231dfaff..0fcd3995 100644 --- a/internal/dnsclients/domain_records_cache.go +++ b/internal/dnsclients/domain_records_cache.go @@ -1,15 +1,16 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package dnsclients import ( + "sync" + "time" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/dnsclients/dnstypes" "github.com/TeaOSLab/EdgeAPI/internal/remotelogs" "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/types" - "sync" - "time" ) func init() { diff --git a/internal/dnsclients/domain_records_cahce_test.go b/internal/dnsclients/domain_records_cahce_test.go index 424bce7c..4cfb4a75 100644 --- a/internal/dnsclients/domain_records_cahce_test.go +++ b/internal/dnsclients/domain_records_cahce_test.go @@ -1,12 +1,13 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package dnsclients_test import ( + "testing" + "github.com/TeaOSLab/EdgeAPI/internal/dnsclients" "github.com/TeaOSLab/EdgeAPI/internal/dnsclients/dnstypes" "github.com/iwind/TeaGo/dbs" - "testing" ) func TestDomainRecordsCache_WriteDomainRecords(t *testing.T) { @@ -22,7 +23,7 @@ func TestDomainRecordsCache_WriteDomainRecords(t *testing.T) { }, }) - //time.Sleep(30 * time.Second) + // time.Sleep(30 * time.Second) { t.Log(cache.QueryDomainRecord(1, "a", "hello", "A")) diff --git a/internal/dnsclients/edgeapi/response_base.go b/internal/dnsclients/edgeapi/response_base.go index 547dd274..b0ab5984 100644 --- a/internal/dnsclients/edgeapi/response_base.go +++ b/internal/dnsclients/edgeapi/response_base.go @@ -1,9 +1,10 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package edgeapi import ( "errors" + "github.com/iwind/TeaGo/types" ) diff --git a/internal/dnsclients/edgeapi/response_create_ns_record.go b/internal/dnsclients/edgeapi/response_create_ns_record.go index d44a9eb4..3b37708b 100644 --- a/internal/dnsclients/edgeapi/response_create_ns_record.go +++ b/internal/dnsclients/edgeapi/response_create_ns_record.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package edgeapi diff --git a/internal/dnsclients/edgeapi/response_find_all_ns_routes.go b/internal/dnsclients/edgeapi/response_find_all_ns_routes.go index e7f38ccb..60808066 100644 --- a/internal/dnsclients/edgeapi/response_find_all_ns_routes.go +++ b/internal/dnsclients/edgeapi/response_find_all_ns_routes.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package edgeapi diff --git a/internal/dnsclients/edgeapi/response_find_ns_domain_with_name.go b/internal/dnsclients/edgeapi/response_find_ns_domain_with_name.go index fd0242cc..2dd1e617 100644 --- a/internal/dnsclients/edgeapi/response_find_ns_domain_with_name.go +++ b/internal/dnsclients/edgeapi/response_find_ns_domain_with_name.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package edgeapi diff --git a/internal/dnsclients/edgeapi/response_find_ns_record_with_name_and_type.go b/internal/dnsclients/edgeapi/response_find_ns_record_with_name_and_type.go index bedd8c8e..0780be08 100644 --- a/internal/dnsclients/edgeapi/response_find_ns_record_with_name_and_type.go +++ b/internal/dnsclients/edgeapi/response_find_ns_record_with_name_and_type.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package edgeapi diff --git a/internal/dnsclients/edgeapi/response_find_ns_records_with_name_and_type.go b/internal/dnsclients/edgeapi/response_find_ns_records_with_name_and_type.go index 5203331d..96412a1a 100644 --- a/internal/dnsclients/edgeapi/response_find_ns_records_with_name_and_type.go +++ b/internal/dnsclients/edgeapi/response_find_ns_records_with_name_and_type.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package edgeapi diff --git a/internal/dnsclients/edgeapi/response_get_api_access_token.go b/internal/dnsclients/edgeapi/response_get_api_access_token.go index 389bcc7d..13fb80fc 100644 --- a/internal/dnsclients/edgeapi/response_get_api_access_token.go +++ b/internal/dnsclients/edgeapi/response_get_api_access_token.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package edgeapi diff --git a/internal/dnsclients/edgeapi/response_interface.go b/internal/dnsclients/edgeapi/response_interface.go index e75f2f09..701b2c26 100644 --- a/internal/dnsclients/edgeapi/response_interface.go +++ b/internal/dnsclients/edgeapi/response_interface.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package edgeapi diff --git a/internal/dnsclients/edgeapi/response_list_ns_domains.go b/internal/dnsclients/edgeapi/response_list_ns_domains.go index cea18f29..c10e3212 100644 --- a/internal/dnsclients/edgeapi/response_list_ns_domains.go +++ b/internal/dnsclients/edgeapi/response_list_ns_domains.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package edgeapi diff --git a/internal/dnsclients/edgeapi/response_list_ns_records.go b/internal/dnsclients/edgeapi/response_list_ns_records.go index a6968069..5091334e 100644 --- a/internal/dnsclients/edgeapi/response_list_ns_records.go +++ b/internal/dnsclients/edgeapi/response_list_ns_records.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package edgeapi diff --git a/internal/dnsclients/edgeapi/response_success.go b/internal/dnsclients/edgeapi/response_success.go index e77bdc34..987f9d36 100644 --- a/internal/dnsclients/edgeapi/response_success.go +++ b/internal/dnsclients/edgeapi/response_success.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package edgeapi diff --git a/internal/dnsclients/edgeapi/response_update_ns_record.go b/internal/dnsclients/edgeapi/response_update_ns_record.go index a99b4711..f93c5897 100644 --- a/internal/dnsclients/edgeapi/response_update_ns_record.go +++ b/internal/dnsclients/edgeapi/response_update_ns_record.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package edgeapi diff --git a/internal/dnsclients/provider_alidns.go b/internal/dnsclients/provider_alidns.go index ebc341cf..ce54e0ae 100644 --- a/internal/dnsclients/provider_alidns.go +++ b/internal/dnsclients/provider_alidns.go @@ -2,13 +2,14 @@ package dnsclients import ( "errors" + "strings" + "github.com/TeaOSLab/EdgeAPI/internal/dnsclients/dnstypes" "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses" "github.com/aliyun/alibaba-cloud-sdk-go/services/alidns" "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/types" - "strings" ) // AliDNSProvider 阿里云服务商 diff --git a/internal/dnsclients/provider_alidns_test.go b/internal/dnsclients/provider_alidns_test.go index b2ce43ba..1c55ad2f 100644 --- a/internal/dnsclients/provider_alidns_test.go +++ b/internal/dnsclients/provider_alidns_test.go @@ -2,13 +2,14 @@ package dnsclients import ( "encoding/json" + "testing" + "github.com/TeaOSLab/EdgeAPI/internal/dnsclients/dnstypes" _ "github.com/go-sql-driver/mysql" _ "github.com/iwind/TeaGo/bootstrap" "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/logs" "github.com/iwind/TeaGo/maps" - "testing" ) func TestAliDNSProvider_GetDomains(t *testing.T) { diff --git a/internal/dnsclients/provider_base.go b/internal/dnsclients/provider_base.go index 10745615..65819667 100644 --- a/internal/dnsclients/provider_base.go +++ b/internal/dnsclients/provider_base.go @@ -2,6 +2,7 @@ package dnsclients import ( "fmt" + "github.com/TeaOSLab/EdgeAPI/internal/dnsclients/dnstypes" ) diff --git a/internal/dnsclients/provider_base_test.go b/internal/dnsclients/provider_base_test.go index d6001493..f4447f43 100644 --- a/internal/dnsclients/provider_base_test.go +++ b/internal/dnsclients/provider_base_test.go @@ -3,10 +3,11 @@ package dnsclients_test import ( + "testing" + "github.com/TeaOSLab/EdgeAPI/internal/dnsclients" "github.com/TeaOSLab/EdgeAPI/internal/dnsclients/dnstypes" "github.com/TeaOSLab/EdgeAPI/internal/errors" - "testing" ) func TestBaseProvider_WrapError(t *testing.T) { diff --git a/internal/dnsclients/provider_cloud_flare.go b/internal/dnsclients/provider_cloud_flare.go index 1db5dd71..53f11412 100644 --- a/internal/dnsclients/provider_cloud_flare.go +++ b/internal/dnsclients/provider_cloud_flare.go @@ -7,12 +7,6 @@ import ( "crypto/tls" "encoding/json" "fmt" - teaconst "github.com/TeaOSLab/EdgeAPI/internal/const" - "github.com/TeaOSLab/EdgeAPI/internal/dnsclients/cloudflare" - "github.com/TeaOSLab/EdgeAPI/internal/dnsclients/dnstypes" - "github.com/TeaOSLab/EdgeAPI/internal/errors" - "github.com/iwind/TeaGo/maps" - "github.com/iwind/TeaGo/types" "io" "net/http" "net/url" @@ -20,6 +14,13 @@ import ( "strings" "sync" "time" + + teaconst "github.com/TeaOSLab/EdgeAPI/internal/const" + "github.com/TeaOSLab/EdgeAPI/internal/dnsclients/cloudflare" + "github.com/TeaOSLab/EdgeAPI/internal/dnsclients/dnstypes" + "github.com/TeaOSLab/EdgeAPI/internal/errors" + "github.com/iwind/TeaGo/maps" + "github.com/iwind/TeaGo/types" ) const CloudFlareAPIEndpoint = "https://api.cloudflare.com/client/v4/" diff --git a/internal/dnsclients/provider_cloud_flare_test.go b/internal/dnsclients/provider_cloud_flare_test.go index d465b433..0e8762e0 100644 --- a/internal/dnsclients/provider_cloud_flare_test.go +++ b/internal/dnsclients/provider_cloud_flare_test.go @@ -4,12 +4,13 @@ package dnsclients import ( "encoding/json" + "testing" + "github.com/TeaOSLab/EdgeAPI/internal/dnsclients/dnstypes" "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/logs" "github.com/iwind/TeaGo/maps" - "testing" ) func TestCloudFlareProvider_GetDomains(t *testing.T) { diff --git a/internal/dnsclients/provider_custom_http.go b/internal/dnsclients/provider_custom_http.go index 292ef56e..2d5c8ac3 100644 --- a/internal/dnsclients/provider_custom_http.go +++ b/internal/dnsclients/provider_custom_http.go @@ -6,14 +6,15 @@ import ( "crypto/tls" "encoding/json" "fmt" - teaconst "github.com/TeaOSLab/EdgeAPI/internal/const" - "github.com/TeaOSLab/EdgeAPI/internal/dnsclients/dnstypes" - "github.com/TeaOSLab/EdgeAPI/internal/errors" - "github.com/iwind/TeaGo/maps" "io" "net/http" "strconv" "time" + + teaconst "github.com/TeaOSLab/EdgeAPI/internal/const" + "github.com/TeaOSLab/EdgeAPI/internal/dnsclients/dnstypes" + "github.com/TeaOSLab/EdgeAPI/internal/errors" + "github.com/iwind/TeaGo/maps" ) var customHTTPClient = &http.Client{ diff --git a/internal/dnsclients/provider_custom_http_test.go b/internal/dnsclients/provider_custom_http_test.go index 2efd0a39..a75ae02c 100644 --- a/internal/dnsclients/provider_custom_http_test.go +++ b/internal/dnsclients/provider_custom_http_test.go @@ -1,10 +1,11 @@ package dnsclients import ( + "testing" + "github.com/TeaOSLab/EdgeAPI/internal/dnsclients/dnstypes" "github.com/iwind/TeaGo/logs" "github.com/iwind/TeaGo/maps" - "testing" ) func TestCustomHTTPProvider_GetDomains(t *testing.T) { diff --git a/internal/dnsclients/provider_dns_la.go b/internal/dnsclients/provider_dns_la.go new file mode 100644 index 00000000..e576fff9 --- /dev/null +++ b/internal/dnsclients/provider_dns_la.go @@ -0,0 +1,605 @@ +package dnsclients + +import ( + "bytes" + "crypto/tls" + "encoding/base64" + "encoding/json" + "fmt" + "io" + "net/http" + "net/url" + "strconv" + "strings" + "sync" + "time" + + teaconst "github.com/TeaOSLab/EdgeAPI/internal/const" + "github.com/TeaOSLab/EdgeAPI/internal/dnsclients/dnsla" + "github.com/TeaOSLab/EdgeAPI/internal/dnsclients/dnstypes" + "github.com/TeaOSLab/EdgeAPI/internal/errors" + "github.com/iwind/TeaGo/maps" + "github.com/iwind/TeaGo/types" +) + +const DNSLaAPIEndpoint = "https://api.dns.la" + +var dnsLAHTTPClient = &http.Client{ + Timeout: 10 * time.Second, + Transport: &http.Transport{ + TLSClientConfig: &tls.Config{ + InsecureSkipVerify: true, + }, + }, +} + +type DNSLaProvider struct { + BaseProvider + + ProviderId int64 + + apiId string + secret string + + routesLocker sync.Mutex + cachedRoutes map[string][]*dnstypes.Route // domain => []Route +} + +// Auth 认证 +func (this *DNSLaProvider) Auth(params maps.Map) error { + this.apiId = params.GetString("apiId") + this.secret = params.GetString("secret") + + if len(this.apiId) == 0 { + return errors.New("'apiId' should not be empty") + } + if len(this.secret) == 0 { + return errors.New("'secret' should not be empty") + } + + this.cachedRoutes = map[string][]*dnstypes.Route{} + + return nil +} + +// MaskParams 对参数进行掩码 +func (this *DNSLaProvider) MaskParams(params maps.Map) { + if params == nil { + return + } + params["secret"] = MaskString(params.GetString("secret")) +} + +// GetDomains 获取所有域名列表 +func (this *DNSLaProvider) GetDomains() (domains []string, err error) { + for i := 1; i < 5000; i++ { + var resp = &dnsla.DomainListResponse{} + err = this.doAPI(http.MethodGet, "/api/domainList", map[string]string{ + "pageSize": "100", + "pageIndex": types.String(i), + }, nil, resp) + if err != nil { + return nil, err + } + if !resp.Success() { + return nil, resp.Error() + } + + if len(resp.Data.Results) == 0 { + return + } + + for _, data := range resp.Data.Results { + domains = append(domains, strings.TrimSuffix(data.Domain, ".")) + } + } + return +} + +// GetRecords 获取域名解析记录列表 +func (this *DNSLaProvider) GetRecords(domain string) (records []*dnstypes.Record, err error) { + domainId, err := this.getDomainId(domain) + if err != nil { + return nil, err + } + if len(domainId) == 0 { + return + } + + for i := 1; i < 5000; i++ { + var resp = &dnsla.RecordListResponse{} + err = this.doAPI(http.MethodGet, "/api/recordList", map[string]string{ + "domainId": domainId, + "pageSize": "100", + "pageIndex": types.String(i), + }, nil, resp) + if err != nil { + return + } + if !resp.Success() { + return nil, resp.Error() + } + if len(resp.Data.Results) == 0 { + break + } + for _, rawRecord := range resp.Data.Results { + var recordType = this.recordTypeName(rawRecord.Type) + + // 修正Record + if recordType == dnstypes.RecordTypeCNAME && !strings.HasSuffix(rawRecord.Data, ".") { + rawRecord.Data += "." + } + + records = append(records, &dnstypes.Record{ + Id: rawRecord.Id, + Name: rawRecord.Host, + Type: recordType, + Value: rawRecord.Data, + Route: rawRecord.LineCode, + TTL: types.Int32(rawRecord.TTL), + }) + } + } + + // 写入缓存 + if this.ProviderId > 0 { + sharedDomainRecordsCache.WriteDomainRecords(this.ProviderId, domain, records) + } + + return +} + +// GetRoutes 读取域名支持的线路数据 +func (this *DNSLaProvider) GetRoutes(domain string) (routes []*dnstypes.Route, err error) { + var resp = &dnsla.AllLineListResponse{} + err = this.doAPI(http.MethodGet, "/api/allLineList", nil, nil, resp) + if err != nil { + return + } + if !resp.Success() { + return nil, resp.Error() + } + + for _, data := range resp.Data { + routes = append(routes, &dnstypes.Route{ + Name: data.Name, + Code: data.Id + "$" + data.Code, // ID + $ + CODE + }) + routes = append(routes, this.travelLines(data.Children)...) + } + + this.routesLocker.Lock() + this.cachedRoutes[domain] = routes + this.routesLocker.Unlock() + + return +} + +// QueryRecord 查询单个记录 +func (this *DNSLaProvider) QueryRecord(domain string, name string, recordType dnstypes.RecordType) (*dnstypes.Record, error) { + // 从缓存中读取 + if this.ProviderId > 0 { + record, hasRecords, _ := sharedDomainRecordsCache.QueryDomainRecord(this.ProviderId, domain, name, recordType) + if hasRecords { // 有效的搜索 + return record, nil + } + } + + domainId, err := this.getDomainId(domain) + if err != nil { + return nil, err + } + if len(domainId) == 0 { + return nil, nil + } + + var resp = &dnsla.RecordListResponse{} + err = this.doAPI(http.MethodGet, "/api/recordList", map[string]string{ + "domainId": domainId, + "pageSize": "100", + "pageIndex": "1", + "host": name, + "type": types.String(this.recordTypeId(recordType)), + }, nil, resp) + if err != nil { + return nil, err + } + if !resp.Success() { + return nil, resp.Error() + } + if len(resp.Data.Results) == 0 { + return nil, nil + } + for _, rawRecord := range resp.Data.Results { + var recordTypeName = this.recordTypeName(rawRecord.Type) + + if rawRecord.Host == name && recordTypeName == recordType { + // 修正Record + if recordType == dnstypes.RecordTypeCNAME && !strings.HasSuffix(rawRecord.Data, ".") { + rawRecord.Data += "." + } + + return &dnstypes.Record{ + Id: rawRecord.Id, + Name: rawRecord.Host, + Type: recordTypeName, + Value: rawRecord.Data, + Route: rawRecord.LineCode, + TTL: types.Int32(rawRecord.TTL), + }, nil + } + } + + return nil, nil +} + +// QueryRecords 查询多个记录 +func (this *DNSLaProvider) QueryRecords(domain string, name string, recordType dnstypes.RecordType) ([]*dnstypes.Record, error) { + // 从缓存中读取 + if this.ProviderId > 0 { + records, hasRecords, _ := sharedDomainRecordsCache.QueryDomainRecords(this.ProviderId, domain, name, recordType) + if hasRecords { // 有效的搜索 + return records, nil + } + } + + domainId, err := this.getDomainId(domain) + if err != nil { + return nil, err + } + if len(domainId) == 0 { + return nil, nil + } + + var result []*dnstypes.Record + for pageIndex := 1; pageIndex < 5000; pageIndex++ { + var resp = &dnsla.RecordListResponse{} + err = this.doAPI(http.MethodGet, "/api/recordList", map[string]string{ + "domainId": domainId, + "pageSize": "100", + "pageIndex": types.String(pageIndex), + "host": name, + "type": types.String(this.recordTypeId(recordType)), + }, nil, resp) + if err != nil { + return nil, err + } + if !resp.Success() { + return nil, resp.Error() + } + if len(resp.Data.Results) == 0 { + break + } + for _, rawRecord := range resp.Data.Results { + var recordTypeName = this.recordTypeName(rawRecord.Type) + if rawRecord.Host == name && recordTypeName == recordType { + + // 修正Record + if recordType == dnstypes.RecordTypeCNAME && !strings.HasSuffix(rawRecord.Data, ".") { + rawRecord.Data += "." + } + + result = append(result, &dnstypes.Record{ + Id: rawRecord.Id, + Name: rawRecord.Host, + Type: recordTypeName, + Value: rawRecord.Data, + Route: rawRecord.LineCode, + TTL: types.Int32(rawRecord.TTL), + }) + } + } + } + + return result, nil +} + +// AddRecord 设置记录 +func (this *DNSLaProvider) AddRecord(domain string, newRecord *dnstypes.Record) error { + routeId, err := this.routeToId(domain, newRecord.Route) + if err != nil { + return err + } + + var ttl = newRecord.TTL + if ttl <= 0 { + ttl = 600 + } + + domainId, err := this.getDomainId(domain) + if err != nil { + return err + } + + if newRecord.Type == dnstypes.RecordTypeCNAME && !strings.HasSuffix(newRecord.Value, ".") { + newRecord.Value += "." + } + + recordJSON, err := json.Marshal(map[string]any{ + "domainId": domainId, + "host": newRecord.Name, + "type": this.recordTypeId(newRecord.Type), + "data": newRecord.Value, + "ttl": ttl, + "lineId": routeId, + }) + if err != nil { + return err + } + + var resp = &dnsla.RecordCreateResponse{} + err = this.doAPI(http.MethodPost, "/api/record", nil, recordJSON, resp) + if err != nil { + return err + } + if !resp.Success() { + return resp.Error() + } + newRecord.Id = types.String(resp.Data.Id) + + // 加入缓存 + if this.ProviderId > 0 { + sharedDomainRecordsCache.AddDomainRecord(this.ProviderId, domain, newRecord) + } + + return nil +} + +// UpdateRecord 修改记录 +func (this *DNSLaProvider) UpdateRecord(domain string, record *dnstypes.Record, newRecord *dnstypes.Record) error { + if len(record.Id) == 0 { + return errors.New("record id required") + } + + routeId, err := this.routeToId(domain, newRecord.Route) + if err != nil { + return err + } + + var ttl = newRecord.TTL + if ttl <= 0 { + ttl = 600 + } + + domainId, err := this.getDomainId(domain) + if err != nil { + return err + } + + if newRecord.Type == dnstypes.RecordTypeCNAME && !strings.HasSuffix(newRecord.Value, ".") { + newRecord.Value += "." + } + + recordJSON, err := json.Marshal(map[string]any{ + "id": record.Id, + "domainId": domainId, + "host": newRecord.Name, + "type": this.recordTypeId(newRecord.Type), + "data": newRecord.Value, + "ttl": ttl, + "lineId": routeId, + }) + if err != nil { + return err + } + + var resp = &dnsla.RecordUpdateResponse{} + err = this.doAPI(http.MethodPut, "/api/record", nil, recordJSON, resp) + if err != nil { + return err + } + if !resp.Success() { + return resp.Error() + } + newRecord.Id = record.Id + + // 修改缓存 + if this.ProviderId > 0 { + sharedDomainRecordsCache.UpdateDomainRecord(this.ProviderId, domain, newRecord) + } + + return nil +} + +// DeleteRecord 删除记录 +func (this *DNSLaProvider) DeleteRecord(domain string, record *dnstypes.Record) error { + var resp = &dnsla.RecordDeleteResponse{} + err := this.doAPI(http.MethodDelete, "/api/record", map[string]string{ + "id": record.Id, + }, nil, resp) + if err != nil { + return err + } + if !resp.Success() { + // ignore not found error + if resp.Code == 404 { + return nil + } + + return resp.Error() + } + + // 删除缓存 + if this.ProviderId > 0 { + sharedDomainRecordsCache.DeleteDomainRecord(this.ProviderId, domain, record.Id) + } + + return nil +} + +// DefaultRoute 默认线路 +func (this *DNSLaProvider) DefaultRoute() string { + return "default" +} + +// 发送请求 +func (this *DNSLaProvider) doAPI(method string, path string, params map[string]string, postJSONData []byte, respPtr interface{}) error { + var apiURL = DNSLaAPIEndpoint + path + + if len(params) > 0 { + var query = &url.Values{} + for k, v := range params { + query.Set(k, v) + } + apiURL += "?" + query.Encode() + } + + var bodyReader io.Reader + if len(postJSONData) > 0 { + bodyReader = bytes.NewReader(postJSONData) + } + + req, err := http.NewRequest(method, apiURL, bodyReader) + if err != nil { + return err + } + req.Header.Set("User-Agent", teaconst.ProductName+"/"+teaconst.Version) + req.Header.Set("Authorization", "Basic "+base64.StdEncoding.EncodeToString([]byte(this.apiId+":"+this.secret))) + + if len(postJSONData) > 0 { + req.Header.Set("Content-Type", "application/json; charset=utf-8") + } + + resp, err := dnsLAHTTPClient.Do(req) + if err != nil { + return err + } + defer func() { + _ = resp.Body.Close() + }() + + data, err := io.ReadAll(resp.Body) + if err != nil { + return err + } + + if resp.StatusCode == 0 { + return errors.New("invalid response status '" + strconv.Itoa(resp.StatusCode) + "', response '" + string(data) + "'") + } + + if resp.StatusCode != http.StatusOK { + return errors.New("response error: " + string(data)) + } + + if respPtr != nil { + err = json.Unmarshal(data, respPtr) + if err != nil { + return fmt.Errorf("decode json failed: %w: %s", err, string(data)) + } + } + + return nil +} + +func (this *DNSLaProvider) getDomainId(domain string) (string, error) { + var resp = &dnsla.DomainResponse{} + err := this.doAPI(http.MethodGet, "/api/domain", map[string]string{ + "domain": domain, + }, nil, resp) + if err != nil { + return "", err + } + return resp.Data.Id, nil +} + +func (this *DNSLaProvider) recordTypeName(recordTypeId int) string { + switch recordTypeId { + case 1: + return "A" + case 2: + return "NS" + case 5: + return "CNAME" + case 15: + return "MX" + case 16: + return "TXT" + case 28: + return "AAAA" + case 33: + return "SRV" + case 257: + return "CAA" + case 256: + return "URL转发" + } + return "UNKNOWN" +} + +func (this *DNSLaProvider) recordTypeId(recordTypeName string) int { + switch recordTypeName { + case "A": + return 1 + case "NS": + return 2 + case "CNAME": + return 5 + case "MX": + return 15 + case "TXT": + return 16 + case "AAAA": + return 28 + case "SRV": + return 33 + case "CAA": + return 257 + case "URL转发": + return 256 + } + return 0 +} + +func (this *DNSLaProvider) travelLines(children []dnsla.AllLineListResponseChild) (result []*dnstypes.Route) { + if len(children) == 0 { + return + } + for _, child := range children { + result = append(result, &dnstypes.Route{ + Name: child.Name, + Code: child.Id + "$" + child.Code, + }) + result = append(result, this.travelLines(child.Children)...) + } + return +} + +func (this *DNSLaProvider) routeToId(domain string, routeCode string) (string, error) { + if len(routeCode) == 0 { + return "", nil + } + if routeCode == "default" { + return "", nil + } + + // 新的线路:id@code + if strings.Contains(routeCode, "$") { + return strings.Split(routeCode, "$")[0], nil + } + + // 兼容老的线路 + this.routesLocker.Lock() + var hasCachedRoutes = len(this.cachedRoutes[domain]) > 0 + this.routesLocker.Unlock() + + if !hasCachedRoutes { + _, err := this.GetRoutes(domain) + if err != nil { + return "", err + } + } + + this.routesLocker.Lock() + defer this.routesLocker.Unlock() + if len(this.cachedRoutes) == 0 { + return "", nil + } + + for _, cachedRoute := range this.cachedRoutes[domain] { + if strings.HasSuffix(cachedRoute.Code, "$"+routeCode) { + return strings.Split(cachedRoute.Code, "$")[0], nil + } + } + + return "", errors.New("invalid route code '" + routeCode + "'") +} diff --git a/internal/dnsclients/provider_dns_la_test.go b/internal/dnsclients/provider_dns_la_test.go new file mode 100644 index 00000000..fb055f08 --- /dev/null +++ b/internal/dnsclients/provider_dns_la_test.go @@ -0,0 +1,217 @@ +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . +//go:build plus + +package dnsclients_test + +import ( + "encoding/json" + "errors" + "testing" + + "github.com/TeaOSLab/EdgeAPI/internal/dnsclients" + "github.com/TeaOSLab/EdgeAPI/internal/dnsclients/dnstypes" + "github.com/iwind/TeaGo/dbs" + "github.com/iwind/TeaGo/logs" + "github.com/iwind/TeaGo/maps" +) + +func TestDNSLaProvider_GetDomains(t *testing.T) { + provider, err := testDNSLaProvider() + if err != nil { + t.Fatal(err) + } + + domains, err := provider.GetDomains() + if err != nil { + t.Fatal(err) + } + t.Log(domains) +} + +func TestDNSLAProvider_GetRecords(t *testing.T) { + provider, err := testDNSLaProvider() + if err != nil { + t.Fatal(err) + } + + records, err := provider.GetRecords("hello2.com") + if err != nil { + t.Fatal(err) + } + for _, record := range records { + t.Log(record.Id, record.Name, record.Type, record.Value, record.Route, record.TTL) + } + // logs.PrintAsJSON(records, t) +} + +func TestDNSLaProvider_GetRoutes(t *testing.T) { + provider, err := testDNSLaProvider() + if err != nil { + t.Fatal(err) + } + + routes, err := provider.GetRoutes("hello2.com") + if err != nil { + t.Fatal(err) + } + t.Log(len(routes), "routes") + logs.PrintAsJSON(routes, t) +} + +func TestDNSLaProvider_QueryRecord(t *testing.T) { + provider, err := testDNSLaProvider() + if err != nil { + t.Fatal(err) + } + + for _, recordName := range []string{"www", "test", "@", ""} { + t.Log("===", recordName, "===") + record, err := provider.QueryRecord("hello2.com", recordName, dnstypes.RecordTypeA) + if err != nil { + t.Fatal(err) + } + logs.PrintAsJSON(record, t) + } +} + +func TestDNSLaProvider_QueryRecords(t *testing.T) { + provider, err := testDNSLaProvider() + if err != nil { + t.Fatal(err) + } + + for _, recordName := range []string{"www", "test", "@", ""} { + t.Log("===", recordName, "===") + records, err := provider.QueryRecords("hello2.com", recordName, dnstypes.RecordTypeA) + if err != nil { + t.Fatal(err) + } + logs.PrintAsJSON(records, t) + } +} + +func TestDNSLaProvider_AddRecord(t *testing.T) { + provider, err := testDNSLaProvider() + if err != nil { + t.Fatal(err) + } + + // 116234436886664192 + { + var record = &dnstypes.Record{ + Id: "", + Name: "test1", + Type: dnstypes.RecordTypeA, + Value: "192.168.1.100", + Route: "mobi", + TTL: 600, + } + err := provider.AddRecord("hello2.com", record) + if err != nil { + t.Fatal(err) + } + t.Log("id:", record.Id) + } + + /**{ + var record = &dnstypes.Record{ + Id: "", + Name: "test1", + Type: dnstypes.RecordTypeA, + Value: "192.168.1.101", + Route: "unic", + TTL: 600, + } + err := provider.AddRecord("hello2.com", record) + if err != nil { + t.Fatal(err) + } + t.Log("id:", record.Id) + }**/ + + /**{ + var record = &dnstypes.Record{ + Id: "", + Name: "test2", + Type: dnstypes.RecordTypeCNAME, + Value: "goedge.cn.", + Route: "", + TTL: 0, + } + err := provider.AddRecord("goedge.cn", record) + if err != nil { + t.Fatal(err) + } + }**/ +} + +func TestDNSLaProvider_UpdateRecord(t *testing.T) { + provider, err := testDNSLaProvider() + if err != nil { + t.Fatal(err) + } + + var record = &dnstypes.Record{ + Id: "116234436886664192", + } + var newRecord = &dnstypes.Record{ + Id: "", + Name: "test1", + Type: dnstypes.RecordTypeA, + Value: "192.168.1.102", + Route: "mobi", + TTL: 3600, + } + err = provider.UpdateRecord("hello2.com", record, newRecord) + if err != nil { + t.Fatal(err) + } +} + +func TestDNSLaProvider_DeleteRecord(t *testing.T) { + provider, err := testDNSLaProvider() + if err != nil { + t.Fatal(err) + } + + err = provider.DeleteRecord("hello2.com", &dnstypes.Record{ + Id: "116223920176894976", + Name: "", + Type: "", + Value: "", + Route: "", + TTL: 0, + }) + if err != nil { + t.Fatal(err) + } +} + +func testDNSLaProvider() (dnsclients.ProviderInterface, error) { + dbs.NotifyReady() + + db, err := dbs.Default() + if err != nil { + return nil, err + } + one, err := db.FindOne("SELECT * FROM edgeDNSProviders WHERE type='dnsla' ORDER BY id DESC") + if err != nil { + return nil, err + } + if one == nil { + return nil, errors.New("can not find providers with type 'dnsla'") + } + apiParams := maps.Map{} + err = json.Unmarshal([]byte(one.GetString("apiParams")), &apiParams) + if err != nil { + return nil, err + } + provider := &dnsclients.DNSLaProvider{ + ProviderId: one.GetInt64("id"), + } + err = provider.Auth(apiParams) + if err != nil { + return nil, err + } + return provider, nil +} diff --git a/internal/dnsclients/provider_dnspod.go b/internal/dnsclients/provider_dnspod.go index 5fd4c04b..7016ac29 100644 --- a/internal/dnsclients/provider_dnspod.go +++ b/internal/dnsclients/provider_dnspod.go @@ -5,16 +5,17 @@ import ( "encoding/json" "errors" "fmt" - "github.com/TeaOSLab/EdgeAPI/internal/dnsclients/dnspod" - "github.com/TeaOSLab/EdgeAPI/internal/dnsclients/dnstypes" - "github.com/TeaOSLab/EdgeAPI/internal/utils/numberutils" - "github.com/iwind/TeaGo/maps" - "github.com/iwind/TeaGo/types" "io" "net/http" "net/url" "strings" "time" + + "github.com/TeaOSLab/EdgeAPI/internal/dnsclients/dnspod" + "github.com/TeaOSLab/EdgeAPI/internal/dnsclients/dnstypes" + "github.com/TeaOSLab/EdgeAPI/internal/utils/numberutils" + "github.com/iwind/TeaGo/maps" + "github.com/iwind/TeaGo/types" ) const ( diff --git a/internal/dnsclients/provider_dnspod_test.go b/internal/dnsclients/provider_dnspod_test.go index 13714857..65ddeb47 100644 --- a/internal/dnsclients/provider_dnspod_test.go +++ b/internal/dnsclients/provider_dnspod_test.go @@ -2,12 +2,13 @@ package dnsclients_test import ( "encoding/json" + "testing" + "github.com/TeaOSLab/EdgeAPI/internal/dnsclients" "github.com/TeaOSLab/EdgeAPI/internal/dnsclients/dnstypes" "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/logs" "github.com/iwind/TeaGo/maps" - "testing" ) const DNSPodTestDomain = "goedge.cloud" diff --git a/internal/dnsclients/provider_edge_dns_api.go b/internal/dnsclients/provider_edge_dns_api.go index 5cb80f49..e2fb84f5 100644 --- a/internal/dnsclients/provider_edge_dns_api.go +++ b/internal/dnsclients/provider_edge_dns_api.go @@ -8,16 +8,17 @@ import ( "encoding/json" "errors" "fmt" - teaconst "github.com/TeaOSLab/EdgeAPI/internal/const" - "github.com/TeaOSLab/EdgeAPI/internal/dnsclients/dnstypes" - "github.com/TeaOSLab/EdgeAPI/internal/dnsclients/edgeapi" - "github.com/iwind/TeaGo/maps" - "github.com/iwind/TeaGo/types" "io" "net/http" "regexp" "strings" "time" + + teaconst "github.com/TeaOSLab/EdgeAPI/internal/const" + "github.com/TeaOSLab/EdgeAPI/internal/dnsclients/dnstypes" + "github.com/TeaOSLab/EdgeAPI/internal/dnsclients/edgeapi" + "github.com/iwind/TeaGo/maps" + "github.com/iwind/TeaGo/types" ) var edgeDNSHTTPClient = &http.Client{ diff --git a/internal/dnsclients/provider_edge_dns_api_test.go b/internal/dnsclients/provider_edge_dns_api_test.go index 84965b72..bc9edb7a 100644 --- a/internal/dnsclients/provider_edge_dns_api_test.go +++ b/internal/dnsclients/provider_edge_dns_api_test.go @@ -3,11 +3,12 @@ package dnsclients_test import ( + "testing" + "github.com/TeaOSLab/EdgeAPI/internal/dnsclients" "github.com/TeaOSLab/EdgeAPI/internal/dnsclients/dnstypes" "github.com/iwind/TeaGo/logs" "github.com/iwind/TeaGo/maps" - "testing" ) const edgeDNSAPIDomainName = "hello2.com" diff --git a/internal/dnsclients/provider_huawei_dns.go b/internal/dnsclients/provider_huawei_dns.go index 97463428..d10932ad 100644 --- a/internal/dnsclients/provider_huawei_dns.go +++ b/internal/dnsclients/provider_huawei_dns.go @@ -9,11 +9,6 @@ import ( "crypto/tls" "encoding/json" "fmt" - "github.com/TeaOSLab/EdgeAPI/internal/dnsclients/dnstypes" - "github.com/TeaOSLab/EdgeAPI/internal/dnsclients/huaweidns" - "github.com/TeaOSLab/EdgeAPI/internal/errors" - "github.com/iwind/TeaGo/maps" - "github.com/iwind/TeaGo/types" "io" "net/http" "net/url" @@ -22,6 +17,12 @@ import ( "strconv" "strings" "time" + + "github.com/TeaOSLab/EdgeAPI/internal/dnsclients/dnstypes" + "github.com/TeaOSLab/EdgeAPI/internal/dnsclients/huaweidns" + "github.com/TeaOSLab/EdgeAPI/internal/errors" + "github.com/iwind/TeaGo/maps" + "github.com/iwind/TeaGo/types" ) // HuaweiDNSDefaultEndpoint 默认Endpoint diff --git a/internal/dnsclients/provider_huawei_dns_test.go b/internal/dnsclients/provider_huawei_dns_test.go index 6f888113..4701f1b6 100644 --- a/internal/dnsclients/provider_huawei_dns_test.go +++ b/internal/dnsclients/provider_huawei_dns_test.go @@ -4,11 +4,12 @@ package dnsclients import ( "encoding/json" + "testing" + "github.com/TeaOSLab/EdgeAPI/internal/dnsclients/dnstypes" "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/logs" "github.com/iwind/TeaGo/maps" - "testing" ) func TestHuaweiDNSProvider_GetDomains(t *testing.T) { diff --git a/internal/dnsclients/provider_tencent_dns.go b/internal/dnsclients/provider_tencent_dns.go index 8df478f8..808244aa 100644 --- a/internal/dnsclients/provider_tencent_dns.go +++ b/internal/dnsclients/provider_tencent_dns.go @@ -1,9 +1,11 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package dnsclients import ( "errors" + "strings" + "github.com/TeaOSLab/EdgeAPI/internal/dnsclients/dnstypes" "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/types" @@ -11,7 +13,6 @@ import ( tencenterrors "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors" "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile" dnspod "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dnspod/v20210323" - "strings" ) // TencentDNSProvider 腾讯云DNS云解析 diff --git a/internal/dnsclients/types.go b/internal/dnsclients/types.go index d9a5afb6..33ec7718 100644 --- a/internal/dnsclients/types.go +++ b/internal/dnsclients/types.go @@ -15,11 +15,17 @@ const ( ProviderTypeLocalEdgeDNS ProviderType = "localEdgeDNS" // 和当前系统集成的EdgeDNS ProviderTypeEdgeDNSAPI ProviderType = "edgeDNSAPI" // 通过API连接的EdgeDNS ProviderTypeCustomHTTP ProviderType = "customHTTP" // 自定义HTTP接口 + ProviderTypeDNSLA ProviderType = "dnsla" // DNSLA ) // FindAllProviderTypes 所有的服务商类型 func FindAllProviderTypes() []maps.Map { var typeMaps = []maps.Map{ + { + "name": "DNS.LA", + "code": ProviderTypeDNSLA, + "description": "DNS.LA提供的DNS服务。", + }, { "name": "阿里云DNS", "code": ProviderTypeAliDNS, @@ -52,7 +58,7 @@ func FindAllProviderTypes() []maps.Map { typeMaps = append(typeMaps, maps.Map{ "name": "自定义HTTP DNS", "code": ProviderTypeCustomHTTP, - "description": "通过自定义的HTTP接口提供DNS服务,具体使用方法请参考官网文档:https://goedge.cn/docs/DNS/CustomHTTP.md ", + "description": "通过自定义的HTTP接口提供DNS服务,具体使用方法请参考官网文档:https://goedge.cloud/docs/DNS/CustomHTTP.md ", }) return typeMaps } diff --git a/internal/dnsclients/types_ext.go b/internal/dnsclients/types_ext.go index ea480a60..b94d4291 100644 --- a/internal/dnsclients/types_ext.go +++ b/internal/dnsclients/types_ext.go @@ -34,6 +34,10 @@ func FindProvider(providerType ProviderType, providerId int64) ProviderInterface return &EdgeDNSAPIProvider{ ProviderId: providerId, } + case ProviderTypeDNSLA: + return &DNSLaProvider{ + ProviderId: providerId, + } } return nil diff --git a/internal/dnsclients/utils.go b/internal/dnsclients/utils.go index 69fa4711..56bf004e 100644 --- a/internal/dnsclients/utils.go +++ b/internal/dnsclients/utils.go @@ -1,11 +1,12 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package dnsclients import ( "encoding/json" - "github.com/iwind/TeaGo/maps" "strings" + + "github.com/iwind/TeaGo/maps" ) // MaskString 对字符串进行掩码 diff --git a/internal/dnsclients/utils_test.go b/internal/dnsclients/utils_test.go index da254026..d61cfa31 100644 --- a/internal/dnsclients/utils_test.go +++ b/internal/dnsclients/utils_test.go @@ -1,11 +1,12 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package dnsclients_test import ( + "testing" + "github.com/TeaOSLab/EdgeAPI/internal/dnsclients" "github.com/iwind/TeaGo/assert" - "testing" ) func TestIsMasked(t *testing.T) { diff --git a/internal/errors/error.go b/internal/errors/error.go index cf834ae4..a45d5176 100644 --- a/internal/errors/error.go +++ b/internal/errors/error.go @@ -2,10 +2,11 @@ package errors import ( "errors" - "github.com/iwind/TeaGo/Tea" "path/filepath" "runtime" "strconv" + + "github.com/iwind/TeaGo/Tea" ) type errorObj struct { diff --git a/internal/installers/deploy_manager.go b/internal/installers/deploy_manager.go index 90a5cce1..3b491e02 100644 --- a/internal/installers/deploy_manager.go +++ b/internal/installers/deploy_manager.go @@ -1,11 +1,12 @@ package installers import ( + "regexp" + "sync" + "github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/files" stringutil "github.com/iwind/TeaGo/utils/string" - "regexp" - "sync" ) var SharedDeployManager = NewDeployManager() diff --git a/internal/installers/errors.go b/internal/installers/errors.go index 7f1c0049..2adafba6 100644 --- a/internal/installers/errors.go +++ b/internal/installers/errors.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package installers diff --git a/internal/installers/helpers/unzip_test.go b/internal/installers/helpers/unzip_test.go index 0f6d9921..b1167c27 100644 --- a/internal/installers/helpers/unzip_test.go +++ b/internal/installers/helpers/unzip_test.go @@ -1,10 +1,11 @@ package helpers_test import ( + "testing" + "github.com/TeaOSLab/EdgeAPI/internal/installers/helpers" "github.com/iwind/TeaGo/Tea" _ "github.com/iwind/TeaGo/bootstrap" - "testing" ) func TestUnzip_Run(t *testing.T) { diff --git a/internal/installers/installer_base.go b/internal/installers/installer_base.go index ea4a2370..4b2a4221 100644 --- a/internal/installers/installer_base.go +++ b/internal/installers/installer_base.go @@ -3,17 +3,18 @@ package installers import ( "errors" "fmt" - "github.com/TeaOSLab/EdgeCommon/pkg/configutils" - "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" - "github.com/iwind/TeaGo/Tea" - stringutil "github.com/iwind/TeaGo/utils/string" - "golang.org/x/crypto/ssh" "net" "path/filepath" "regexp" "strconv" "strings" "time" + + "github.com/TeaOSLab/EdgeCommon/pkg/configutils" + "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" + "github.com/iwind/TeaGo/Tea" + stringutil "github.com/iwind/TeaGo/utils/string" + "golang.org/x/crypto/ssh" ) type BaseInstaller struct { diff --git a/internal/installers/installer_base_test.go b/internal/installers/installer_base_test.go index 922b5707..73d4c682 100644 --- a/internal/installers/installer_base_test.go +++ b/internal/installers/installer_base_test.go @@ -1,8 +1,9 @@ package installers import ( - _ "github.com/iwind/TeaGo/bootstrap" "testing" + + _ "github.com/iwind/TeaGo/bootstrap" ) func TestBaseInstaller_LookupLatest(t *testing.T) { diff --git a/internal/installers/installer_node.go b/internal/installers/installer_node.go index f0ce58a7..0f6e6104 100644 --- a/internal/installers/installer_node.go +++ b/internal/installers/installer_node.go @@ -4,11 +4,12 @@ import ( "bytes" "errors" "fmt" - "github.com/TeaOSLab/EdgeAPI/internal/db/models" - "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" "os" "path/filepath" "regexp" + + "github.com/TeaOSLab/EdgeAPI/internal/db/models" + "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" ) type NodeInstaller struct { diff --git a/internal/installers/installer_node_test.go b/internal/installers/installer_node_test.go index 8aa4123c..4c637858 100644 --- a/internal/installers/installer_node_test.go +++ b/internal/installers/installer_node_test.go @@ -1,8 +1,9 @@ package installers import ( - "github.com/TeaOSLab/EdgeAPI/internal/db/models" "testing" + + "github.com/TeaOSLab/EdgeAPI/internal/db/models" ) func TestNodeInstaller_Install(t *testing.T) { diff --git a/internal/installers/queue_node.go b/internal/installers/queue_node.go index 3f165078..10667407 100644 --- a/internal/installers/queue_node.go +++ b/internal/installers/queue_node.go @@ -3,13 +3,14 @@ package installers import ( "errors" "fmt" + "time" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/goman" "github.com/TeaOSLab/EdgeAPI/internal/utils" "github.com/TeaOSLab/EdgeAPI/internal/utils/numberutils" "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" "github.com/iwind/TeaGo/logs" - "time" ) var sharedNodeQueue = NewNodeQueue() diff --git a/internal/installers/ssh_client.go b/internal/installers/ssh_client.go index 50c1727f..76e90ed7 100644 --- a/internal/installers/ssh_client.go +++ b/internal/installers/ssh_client.go @@ -2,12 +2,13 @@ package installers import ( "bytes" - "github.com/pkg/sftp" - "golang.org/x/crypto/ssh" "io" "net" "os" "strings" + + "github.com/pkg/sftp" + "golang.org/x/crypto/ssh" ) type SSHClient struct { diff --git a/internal/installers/ssh_client_test.go b/internal/installers/ssh_client_test.go index 15d7c568..acd48dbc 100644 --- a/internal/installers/ssh_client_test.go +++ b/internal/installers/ssh_client_test.go @@ -3,10 +3,11 @@ package installers import ( - "golang.org/x/crypto/ssh" "net" "testing" "time" + + "golang.org/x/crypto/ssh" ) func testSSHClient(t *testing.T, username string, password string) *SSHClient { diff --git a/internal/installers/upgrade_limiter.go b/internal/installers/upgrade_limiter.go index dcdecfe0..2475df09 100644 --- a/internal/installers/upgrade_limiter.go +++ b/internal/installers/upgrade_limiter.go @@ -1,13 +1,14 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package installers import ( + "sync" + "time" + "github.com/TeaOSLab/EdgeAPI/internal/utils/sizes" "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" "github.com/iwind/TeaGo/types" - "sync" - "time" ) const ( diff --git a/internal/installers/upgrade_limiter_test.go b/internal/installers/upgrade_limiter_test.go index 70b9eef6..2929c47f 100644 --- a/internal/installers/upgrade_limiter_test.go +++ b/internal/installers/upgrade_limiter_test.go @@ -1,13 +1,14 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package installers_test import ( + "testing" + "time" + "github.com/TeaOSLab/EdgeAPI/internal/installers" "github.com/TeaOSLab/EdgeAPI/internal/utils/sizes" "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" - "testing" - "time" ) func TestNewUpgradeLimiter(t *testing.T) { diff --git a/internal/instances/api_config.go b/internal/instances/api_config.go index 1eedb601..12cb5ca0 100644 --- a/internal/instances/api_config.go +++ b/internal/instances/api_config.go @@ -1,4 +1,4 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package instances diff --git a/internal/instances/instance.go b/internal/instances/instance.go index 522fe159..24753c48 100644 --- a/internal/instances/instance.go +++ b/internal/instances/instance.go @@ -1,4 +1,4 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package instances @@ -7,6 +7,15 @@ import ( "encoding/json" "errors" "fmt" + "log" + "net" + "os" + "path/filepath" + "regexp" + "runtime" + "strings" + "time" + teaconst "github.com/TeaOSLab/EdgeAPI/internal/const" "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/installers/helpers" @@ -23,14 +32,6 @@ import ( "github.com/iwind/TeaGo/rands" "github.com/iwind/TeaGo/types" "gopkg.in/yaml.v3" - "log" - "net" - "os" - "path/filepath" - "regexp" - "runtime" - "strings" - "time" ) type Instance struct { diff --git a/internal/instances/instance_test.go b/internal/instances/instance_test.go index ed853a43..bd5a2650 100644 --- a/internal/instances/instance_test.go +++ b/internal/instances/instance_test.go @@ -1,12 +1,13 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package instances_test import ( + "testing" + "github.com/TeaOSLab/EdgeAPI/internal/instances" "github.com/iwind/TeaGo/Tea" _ "github.com/iwind/TeaGo/bootstrap" - "testing" ) var instance = instances.NewInstance(instances.Options{ diff --git a/internal/instances/options.go b/internal/instances/options.go index f8938993..f54a1108 100644 --- a/internal/instances/options.go +++ b/internal/instances/options.go @@ -1,4 +1,4 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package instances diff --git a/internal/nodes/api_node.go b/internal/nodes/api_node.go index 56163bd4..487fd345 100644 --- a/internal/nodes/api_node.go +++ b/internal/nodes/api_node.go @@ -6,6 +6,19 @@ import ( "encoding/json" "errors" "fmt" + "log" + "net" + "os" + "os/exec" + "os/signal" + "runtime" + "sort" + "strconv" + "strings" + "sync" + "syscall" + "time" + "github.com/TeaOSLab/EdgeAPI/internal/configs" teaconst "github.com/TeaOSLab/EdgeAPI/internal/const" "github.com/TeaOSLab/EdgeAPI/internal/db/models" @@ -29,18 +42,6 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/credentials" "google.golang.org/grpc/status" - "log" - "net" - "os" - "os/exec" - "os/signal" - "runtime" - "sort" - "strconv" - "strings" - "sync" - "syscall" - "time" // grpc decompression _ "google.golang.org/grpc/encoding/gzip" diff --git a/internal/nodes/api_node_ext.go b/internal/nodes/api_node_ext.go index 5fb6b952..cb5871f4 100644 --- a/internal/nodes/api_node_ext.go +++ b/internal/nodes/api_node_ext.go @@ -1,8 +1,8 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . //go:build !plus package nodes func (this *APINode) startAccessLogStorages() { - + } diff --git a/internal/nodes/api_node_services.go b/internal/nodes/api_node_services.go index 4698318b..4430464c 100644 --- a/internal/nodes/api_node_services.go +++ b/internal/nodes/api_node_services.go @@ -3,13 +3,14 @@ package nodes import ( + "reflect" + "strings" + "github.com/TeaOSLab/EdgeAPI/internal/rpc/services" "github.com/TeaOSLab/EdgeAPI/internal/rpc/services/clients" "github.com/TeaOSLab/EdgeAPI/internal/rpc/services/users" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "google.golang.org/grpc" - "reflect" - "strings" ) // 注册服务 diff --git a/internal/nodes/ip_library_updater.go b/internal/nodes/ip_library_updater.go index c87bcd82..47495b15 100644 --- a/internal/nodes/ip_library_updater.go +++ b/internal/nodes/ip_library_updater.go @@ -1,9 +1,13 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package nodes import ( "errors" + "io" + "os" + "time" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/goman" "github.com/TeaOSLab/EdgeAPI/internal/remotelogs" @@ -11,9 +15,6 @@ import ( "github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/types" - "io" - "os" - "time" ) func init() { diff --git a/internal/nodes/node_status_executor.go b/internal/nodes/node_status_executor.go index 044af6bf..bd8dab50 100644 --- a/internal/nodes/node_status_executor.go +++ b/internal/nodes/node_status_executor.go @@ -2,6 +2,11 @@ package nodes import ( "encoding/json" + "os" + "runtime" + "strings" + "time" + teaconst "github.com/TeaOSLab/EdgeAPI/internal/const" "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/events" @@ -11,10 +16,6 @@ import ( "github.com/iwind/TeaGo/lists" "github.com/shirou/gopsutil/v3/cpu" "github.com/shirou/gopsutil/v3/disk" - "os" - "runtime" - "strings" - "time" ) type NodeStatusExecutor struct { diff --git a/internal/nodes/node_status_executor_test.go b/internal/nodes/node_status_executor_test.go index f56d9923..834874f4 100644 --- a/internal/nodes/node_status_executor_test.go +++ b/internal/nodes/node_status_executor_test.go @@ -1,9 +1,10 @@ package nodes import ( - "github.com/shirou/gopsutil/v3/cpu" "testing" "time" + + "github.com/shirou/gopsutil/v3/cpu" ) func TestNodeStatusExecutor_CPU(t *testing.T) { diff --git a/internal/nodes/node_status_executor_unix.go b/internal/nodes/node_status_executor_unix.go index 54d72d9e..bb9f1d5c 100644 --- a/internal/nodes/node_status_executor_unix.go +++ b/internal/nodes/node_status_executor_unix.go @@ -4,11 +4,12 @@ package nodes import ( + "runtime" + "runtime/debug" + "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" "github.com/shirou/gopsutil/v3/load" "github.com/shirou/gopsutil/v3/mem" - "runtime" - "runtime/debug" ) // 更新内存 diff --git a/internal/nodes/node_status_executor_windows.go b/internal/nodes/node_status_executor_windows.go index 4866e06c..49754d41 100644 --- a/internal/nodes/node_status_executor_windows.go +++ b/internal/nodes/node_status_executor_windows.go @@ -4,11 +4,12 @@ package nodes import ( "context" - "github.com/shirou/gopsutil/v3/cpu" - "github.com/shirou/gopsutil/v3/mem" "math" "sync" "time" + + "github.com/shirou/gopsutil/v3/cpu" + "github.com/shirou/gopsutil/v3/mem" ) type WindowsLoadValue struct { diff --git a/internal/nodes/rest_server.go b/internal/nodes/rest_server.go index 5f90ea15..053e6637 100644 --- a/internal/nodes/rest_server.go +++ b/internal/nodes/rest_server.go @@ -4,11 +4,6 @@ import ( "context" "crypto/tls" "encoding/json" - "github.com/TeaOSLab/EdgeAPI/internal/db/models" - "github.com/TeaOSLab/EdgeAPI/internal/rpc/services" - rpcutils "github.com/TeaOSLab/EdgeAPI/internal/rpc/utils" - "github.com/TeaOSLab/EdgeAPI/internal/utils/sizes" - "github.com/iwind/TeaGo/maps" "io" "net" "net/http" @@ -16,6 +11,12 @@ import ( "regexp" "strings" "time" + + "github.com/TeaOSLab/EdgeAPI/internal/db/models" + "github.com/TeaOSLab/EdgeAPI/internal/rpc/services" + rpcutils "github.com/TeaOSLab/EdgeAPI/internal/rpc/utils" + "github.com/TeaOSLab/EdgeAPI/internal/utils/sizes" + "github.com/iwind/TeaGo/maps" ) var servicePathReg = regexp.MustCompile(`^/([a-zA-Z0-9]+)/([a-zA-Z0-9]+)$`) diff --git a/internal/nodes/start_issue.go b/internal/nodes/start_issue.go index 4dc022c5..bcafc0fc 100644 --- a/internal/nodes/start_issue.go +++ b/internal/nodes/start_issue.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package nodes diff --git a/internal/remotelogs/utils.go b/internal/remotelogs/utils.go index abe1ad32..6b2c59b5 100644 --- a/internal/remotelogs/utils.go +++ b/internal/remotelogs/utils.go @@ -1,6 +1,8 @@ package remotelogs import ( + "time" + "github.com/TeaOSLab/EdgeAPI/internal/configs" teaconst "github.com/TeaOSLab/EdgeAPI/internal/const" "github.com/TeaOSLab/EdgeAPI/internal/goman" @@ -9,7 +11,6 @@ import ( "github.com/cespare/xxhash" "github.com/iwind/TeaGo/logs" "github.com/iwind/TeaGo/types" - "time" ) var logChan = make(chan *pb.NodeLog, 64) // 队列数量不需要太长,因为日志通常仅仅为调试用 diff --git a/internal/rpc/services/clients/service_client_agent.go b/internal/rpc/services/clients/service_client_agent.go index 11c0ebf3..53340f5a 100644 --- a/internal/rpc/services/clients/service_client_agent.go +++ b/internal/rpc/services/clients/service_client_agent.go @@ -1,9 +1,10 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package clients import ( "context" + "github.com/TeaOSLab/EdgeAPI/internal/db/models/clients" "github.com/TeaOSLab/EdgeAPI/internal/rpc/services" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" diff --git a/internal/rpc/services/clients/service_client_agent_ip.go b/internal/rpc/services/clients/service_client_agent_ip.go index c229fe93..272822a1 100644 --- a/internal/rpc/services/clients/service_client_agent_ip.go +++ b/internal/rpc/services/clients/service_client_agent_ip.go @@ -1,9 +1,10 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package clients import ( "context" + "github.com/TeaOSLab/EdgeAPI/internal/db/models/clients" "github.com/TeaOSLab/EdgeAPI/internal/rpc/services" rpcutils "github.com/TeaOSLab/EdgeAPI/internal/rpc/utils" diff --git a/internal/rpc/services/clients/service_formal_client_browser.go b/internal/rpc/services/clients/service_formal_client_browser.go index 1fbb0d32..90baf2ea 100644 --- a/internal/rpc/services/clients/service_formal_client_browser.go +++ b/internal/rpc/services/clients/service_formal_client_browser.go @@ -1,9 +1,10 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package clients import ( "context" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeAPI/internal/rpc/services" diff --git a/internal/rpc/services/clients/service_formal_client_system.go b/internal/rpc/services/clients/service_formal_client_system.go index 405ba70b..9acadaed 100644 --- a/internal/rpc/services/clients/service_formal_client_system.go +++ b/internal/rpc/services/clients/service_formal_client_system.go @@ -1,9 +1,10 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package clients import ( "context" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeAPI/internal/rpc/services" diff --git a/internal/rpc/services/reporters/utils.go b/internal/rpc/services/reporters/utils.go index fe8cdf50..bfb42228 100644 --- a/internal/rpc/services/reporters/utils.go +++ b/internal/rpc/services/reporters/utils.go @@ -4,12 +4,13 @@ package reporters import ( "context" + "net" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared" "github.com/iwind/TeaGo/dbs" "google.golang.org/grpc/peer" - "net" ) // 校验客户端IP diff --git a/internal/rpc/services/service_acme_authentication.go b/internal/rpc/services/service_acme_authentication.go index b43b35ad..953c15a7 100644 --- a/internal/rpc/services/service_acme_authentication.go +++ b/internal/rpc/services/service_acme_authentication.go @@ -2,6 +2,7 @@ package services import ( "context" + "github.com/TeaOSLab/EdgeAPI/internal/db/models/acme" "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" diff --git a/internal/rpc/services/service_acme_provider.go b/internal/rpc/services/service_acme_provider.go index 5949f4ce..33bac4aa 100644 --- a/internal/rpc/services/service_acme_provider.go +++ b/internal/rpc/services/service_acme_provider.go @@ -4,6 +4,7 @@ package services import ( "context" + "github.com/TeaOSLab/EdgeAPI/internal/acme" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" ) diff --git a/internal/rpc/services/service_acme_provider_account.go b/internal/rpc/services/service_acme_provider_account.go index 7dc0f8e4..52d886b7 100644 --- a/internal/rpc/services/service_acme_provider_account.go +++ b/internal/rpc/services/service_acme_provider_account.go @@ -4,6 +4,7 @@ package services import ( "context" + acmeutils "github.com/TeaOSLab/EdgeAPI/internal/acme" "github.com/TeaOSLab/EdgeAPI/internal/db/models/acme" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" diff --git a/internal/rpc/services/service_acme_task.go b/internal/rpc/services/service_acme_task.go index 28b31f0d..05d59821 100644 --- a/internal/rpc/services/service_acme_task.go +++ b/internal/rpc/services/service_acme_task.go @@ -2,6 +2,7 @@ package services import ( "context" + "github.com/TeaOSLab/EdgeAPI/internal/acme" "github.com/TeaOSLab/EdgeAPI/internal/db/models" acmemodels "github.com/TeaOSLab/EdgeAPI/internal/db/models/acme" @@ -239,7 +240,7 @@ func (this *ACMETaskService) CreateACMETask(ctx context.Context, req *pb.CreateA } var tx = this.NullTx() - taskId, err := acmemodels.SharedACMETaskDAO.CreateACMETask(tx, adminId, userId, req.AuthType, req.AcmeUserId, req.DnsProviderId, req.DnsDomain, req.Domains, req.AutoRenew, req.AuthURL) + taskId, err := acmemodels.SharedACMETaskDAO.CreateACMETask(tx, adminId, userId, req.AuthType, req.AcmeUserId, req.DnsProviderId, req.DnsDomain, req.Domains, req.AutoRenew, req.AuthURL, req.Async) if err != nil { return nil, err } diff --git a/internal/rpc/services/service_acme_user.go b/internal/rpc/services/service_acme_user.go index 5151037b..4157a1e4 100644 --- a/internal/rpc/services/service_acme_user.go +++ b/internal/rpc/services/service_acme_user.go @@ -2,6 +2,7 @@ package services import ( "context" + "github.com/TeaOSLab/EdgeAPI/internal/acme" acmemodels "github.com/TeaOSLab/EdgeAPI/internal/db/models/acme" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" diff --git a/internal/rpc/services/service_admin.go b/internal/rpc/services/service_admin.go index 77306c1b..d34b7073 100644 --- a/internal/rpc/services/service_admin.go +++ b/internal/rpc/services/service_admin.go @@ -3,6 +3,8 @@ package services import ( "context" "encoding/json" + "time" + teaconst "github.com/TeaOSLab/EdgeAPI/internal/const" "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/db/models/stats" @@ -14,7 +16,6 @@ import ( "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeCommon/pkg/systemconfigs" timeutil "github.com/iwind/TeaGo/utils/time" - "time" ) // AdminService 管理员相关服务 diff --git a/internal/rpc/services/service_admin_ext.go b/internal/rpc/services/service_admin_ext.go index 7e0d2f44..562b1ba2 100644 --- a/internal/rpc/services/service_admin_ext.go +++ b/internal/rpc/services/service_admin_ext.go @@ -1,10 +1,11 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . //go:build !plus package services import ( "context" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/iwind/TeaGo/dbs" ) diff --git a/internal/rpc/services/service_admin_test.go b/internal/rpc/services/service_admin_test.go index c5b32b6d..5896872a 100644 --- a/internal/rpc/services/service_admin_test.go +++ b/internal/rpc/services/service_admin_test.go @@ -3,6 +3,9 @@ package services import ( "context" "encoding/base64" + "testing" + "time" + teaconst "github.com/TeaOSLab/EdgeAPI/internal/const" "github.com/TeaOSLab/EdgeAPI/internal/encrypt" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" @@ -10,8 +13,6 @@ import ( "github.com/iwind/TeaGo/maps" stringutil "github.com/iwind/TeaGo/utils/string" "google.golang.org/grpc/metadata" - "testing" - "time" ) func TestAdminService_Login(t *testing.T) { diff --git a/internal/rpc/services/service_api_access_token.go b/internal/rpc/services/service_api_access_token.go index 528fb78d..ba1b538d 100644 --- a/internal/rpc/services/service_api_access_token.go +++ b/internal/rpc/services/service_api_access_token.go @@ -3,6 +3,7 @@ package services import ( "context" "errors" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" ) diff --git a/internal/rpc/services/service_api_method_stat.go b/internal/rpc/services/service_api_method_stat.go index d24b3f79..0b9fda76 100644 --- a/internal/rpc/services/service_api_method_stat.go +++ b/internal/rpc/services/service_api_method_stat.go @@ -4,6 +4,7 @@ package services import ( "context" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/utils" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" diff --git a/internal/rpc/services/service_api_node.go b/internal/rpc/services/service_api_node.go index 883bdf4c..dfff2bea 100644 --- a/internal/rpc/services/service_api_node.go +++ b/internal/rpc/services/service_api_node.go @@ -6,6 +6,11 @@ import ( "crypto/md5" "errors" "fmt" + "io" + "os" + "path/filepath" + "runtime" + teaconst "github.com/TeaOSLab/EdgeAPI/internal/const" "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/installers" @@ -15,10 +20,6 @@ import ( "github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/dbs" stringutil "github.com/iwind/TeaGo/utils/string" - "io" - "os" - "path/filepath" - "runtime" ) type APINodeService struct { diff --git a/internal/rpc/services/service_api_token.go b/internal/rpc/services/service_api_token.go index 95cb9155..28114f86 100644 --- a/internal/rpc/services/service_api_token.go +++ b/internal/rpc/services/service_api_token.go @@ -4,6 +4,7 @@ package services import ( "context" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" rpcutils "github.com/TeaOSLab/EdgeAPI/internal/rpc/utils" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" diff --git a/internal/rpc/services/service_authority_node.go b/internal/rpc/services/service_authority_node.go index 0831d279..0ea2031c 100644 --- a/internal/rpc/services/service_authority_node.go +++ b/internal/rpc/services/service_authority_node.go @@ -3,13 +3,14 @@ package services import ( "context" "encoding/json" + "time" + "github.com/TeaOSLab/EdgeAPI/internal/db/models/authority" "github.com/TeaOSLab/EdgeAPI/internal/errors" rpcutils "github.com/TeaOSLab/EdgeAPI/internal/rpc/utils" "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "google.golang.org/grpc/metadata" - "time" ) type AuthorityNodeService struct { diff --git a/internal/rpc/services/service_base.go b/internal/rpc/services/service_base.go index 66fb9fe4..f520bc9a 100644 --- a/internal/rpc/services/service_base.go +++ b/internal/rpc/services/service_base.go @@ -4,6 +4,7 @@ import ( "context" "encoding/base64" "encoding/json" + teaconst "github.com/TeaOSLab/EdgeAPI/internal/const" "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/db/models/authority" diff --git a/internal/rpc/services/service_db.go b/internal/rpc/services/service_db.go index bbb3e3e3..ecaaa11b 100644 --- a/internal/rpc/services/service_db.go +++ b/internal/rpc/services/service_db.go @@ -2,11 +2,12 @@ package services import ( "context" + "strings" + "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/lists" - "strings" ) // DBService 数据库相关服务 diff --git a/internal/rpc/services/service_db_node.go b/internal/rpc/services/service_db_node.go index 153e23f6..cdec167f 100644 --- a/internal/rpc/services/service_db_node.go +++ b/internal/rpc/services/service_db_node.go @@ -3,12 +3,13 @@ package services import ( "context" "errors" + "strings" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/lists" "github.com/iwind/TeaGo/types" - "strings" ) // DBNodeService 数据库节点相关服务 diff --git a/internal/rpc/services/service_db_test.go b/internal/rpc/services/service_db_test.go index 8da51b0d..e047c430 100644 --- a/internal/rpc/services/service_db_test.go +++ b/internal/rpc/services/service_db_test.go @@ -1,9 +1,10 @@ package services import ( + "testing" + "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/logs" - "testing" ) func TestDBService_FindAllDBTables(t *testing.T) { diff --git a/internal/rpc/services/service_dns.go b/internal/rpc/services/service_dns.go index 478efae8..45a7d04a 100644 --- a/internal/rpc/services/service_dns.go +++ b/internal/rpc/services/service_dns.go @@ -2,6 +2,7 @@ package services import ( "context" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/db/models/dns/dnsutils" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" diff --git a/internal/rpc/services/service_dns_domain.go b/internal/rpc/services/service_dns_domain.go index 274382f0..659f3ab1 100644 --- a/internal/rpc/services/service_dns_domain.go +++ b/internal/rpc/services/service_dns_domain.go @@ -3,6 +3,8 @@ package services import ( "context" "encoding/json" + "net" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/db/models/dns" "github.com/TeaOSLab/EdgeAPI/internal/db/models/dns/dnsutils" @@ -18,7 +20,6 @@ import ( "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/lists" "github.com/iwind/TeaGo/maps" - "net" ) // DNSDomainService DNS域名相关服务 diff --git a/internal/rpc/services/service_dns_provider.go b/internal/rpc/services/service_dns_provider.go index 84167957..25f9d682 100644 --- a/internal/rpc/services/service_dns_provider.go +++ b/internal/rpc/services/service_dns_provider.go @@ -3,6 +3,7 @@ package services import ( "context" "encoding/json" + "github.com/TeaOSLab/EdgeAPI/internal/db/models/dns" "github.com/TeaOSLab/EdgeAPI/internal/dnsclients" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" diff --git a/internal/rpc/services/service_dns_task.go b/internal/rpc/services/service_dns_task.go index e25937e5..11bc8dde 100644 --- a/internal/rpc/services/service_dns_task.go +++ b/internal/rpc/services/service_dns_task.go @@ -3,6 +3,7 @@ package services import ( "context" "fmt" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/db/models/dns" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" diff --git a/internal/rpc/services/service_file.go b/internal/rpc/services/service_file.go index 2d9517e9..17b026da 100644 --- a/internal/rpc/services/service_file.go +++ b/internal/rpc/services/service_file.go @@ -2,6 +2,7 @@ package services import ( "context" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" ) diff --git a/internal/rpc/services/service_file_chunk.go b/internal/rpc/services/service_file_chunk.go index ea96dadd..ede01bfc 100644 --- a/internal/rpc/services/service_file_chunk.go +++ b/internal/rpc/services/service_file_chunk.go @@ -2,6 +2,7 @@ package services import ( "context" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" rpcutils "github.com/TeaOSLab/EdgeAPI/internal/rpc/utils" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" diff --git a/internal/rpc/services/service_firewall.go b/internal/rpc/services/service_firewall.go index dff437d5..4853f49a 100644 --- a/internal/rpc/services/service_firewall.go +++ b/internal/rpc/services/service_firewall.go @@ -4,6 +4,10 @@ package services import ( "context" + "sort" + "strconv" + "time" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/db/models/regions" "github.com/TeaOSLab/EdgeAPI/internal/db/models/stats" @@ -12,9 +16,6 @@ import ( "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/iwind/TeaGo/types" timeutil "github.com/iwind/TeaGo/utils/time" - "sort" - "strconv" - "time" ) // FirewallService 防火墙全局服务 diff --git a/internal/rpc/services/service_http_access_log.go b/internal/rpc/services/service_http_access_log.go index e3a6b275..57d006d4 100644 --- a/internal/rpc/services/service_http_access_log.go +++ b/internal/rpc/services/service_http_access_log.go @@ -2,6 +2,8 @@ package services import ( "context" + "sync" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/errors" rpcutils "github.com/TeaOSLab/EdgeAPI/internal/rpc/utils" @@ -9,7 +11,6 @@ import ( "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/lists" - "sync" ) // HTTPAccessLogService 访问日志相关服务 diff --git a/internal/rpc/services/service_http_access_log_ext.go b/internal/rpc/services/service_http_access_log_ext.go index 3892ccd1..979255ad 100644 --- a/internal/rpc/services/service_http_access_log_ext.go +++ b/internal/rpc/services/service_http_access_log_ext.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . //go:build !plus package services diff --git a/internal/rpc/services/service_http_auth_policy.go b/internal/rpc/services/service_http_auth_policy.go index 034af132..a8c0cc65 100644 --- a/internal/rpc/services/service_http_auth_policy.go +++ b/internal/rpc/services/service_http_auth_policy.go @@ -4,6 +4,7 @@ package services import ( "context" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" ) diff --git a/internal/rpc/services/service_http_cache_policy.go b/internal/rpc/services/service_http_cache_policy.go index b5affa36..d627f77a 100644 --- a/internal/rpc/services/service_http_cache_policy.go +++ b/internal/rpc/services/service_http_cache_policy.go @@ -3,6 +3,7 @@ package services import ( "context" "encoding/json" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/utils" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" diff --git a/internal/rpc/services/service_http_cache_task.go b/internal/rpc/services/service_http_cache_task.go index a64f5236..aa1e8e55 100644 --- a/internal/rpc/services/service_http_cache_task.go +++ b/internal/rpc/services/service_http_cache_task.go @@ -1,9 +1,11 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package services import ( "context" + "time" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeAPI/internal/utils" @@ -11,7 +13,6 @@ import ( "github.com/TeaOSLab/EdgeCommon/pkg/userconfigs" "github.com/iwind/TeaGo/types" timeutil "github.com/iwind/TeaGo/utils/time" - "time" ) // HTTPCacheTaskService 缓存任务管理 diff --git a/internal/rpc/services/service_http_cache_task_key.go b/internal/rpc/services/service_http_cache_task_key.go index 656022a9..ae80cb73 100644 --- a/internal/rpc/services/service_http_cache_task_key.go +++ b/internal/rpc/services/service_http_cache_task_key.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package services @@ -6,6 +6,7 @@ import ( "context" "encoding/json" "errors" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/utils" "github.com/TeaOSLab/EdgeAPI/internal/utils/regexputils" diff --git a/internal/rpc/services/service_http_cache_task_test.go b/internal/rpc/services/service_http_cache_task_test.go index c8d47bfe..937289e7 100644 --- a/internal/rpc/services/service_http_cache_task_test.go +++ b/internal/rpc/services/service_http_cache_task_test.go @@ -1,11 +1,12 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package services import ( + "testing" + "github.com/TeaOSLab/EdgeAPI/internal/utils" "github.com/iwind/TeaGo/assert" - "testing" ) func TestHTTPCacheTaskService_ParseDomain(t *testing.T) { diff --git a/internal/rpc/services/service_http_fastcgi.go b/internal/rpc/services/service_http_fastcgi.go index beaff7d5..839c044e 100644 --- a/internal/rpc/services/service_http_fastcgi.go +++ b/internal/rpc/services/service_http_fastcgi.go @@ -5,6 +5,7 @@ package services import ( "context" "encoding/json" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/iwind/TeaGo/types" diff --git a/internal/rpc/services/service_http_firewall_policy.go b/internal/rpc/services/service_http_firewall_policy.go index 27295c80..02ec8125 100644 --- a/internal/rpc/services/service_http_firewall_policy.go +++ b/internal/rpc/services/service_http_firewall_policy.go @@ -3,6 +3,8 @@ package services import ( "context" "encoding/json" + "net" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeCommon/pkg/iplibrary" @@ -10,7 +12,6 @@ import ( "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/ipconfigs" "github.com/iwind/TeaGo/lists" - "net" ) // HTTPFirewallPolicyService HTTP防火墙(WAF)相关服务 diff --git a/internal/rpc/services/service_http_firewall_policy_test.go b/internal/rpc/services/service_http_firewall_policy_test.go index 352bb535..0822d63b 100644 --- a/internal/rpc/services/service_http_firewall_policy_test.go +++ b/internal/rpc/services/service_http_firewall_policy_test.go @@ -1,11 +1,12 @@ package services import ( + "testing" + rpcutils "github.com/TeaOSLab/EdgeAPI/internal/rpc/utils" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/logs" - "testing" ) func TestHTTPFirewallPolicyService_CheckHTTPFirewallPolicyIPStatus(t *testing.T) { diff --git a/internal/rpc/services/service_http_firewall_rule_group.go b/internal/rpc/services/service_http_firewall_rule_group.go index d28f0c68..851a96e1 100644 --- a/internal/rpc/services/service_http_firewall_rule_group.go +++ b/internal/rpc/services/service_http_firewall_rule_group.go @@ -3,6 +3,7 @@ package services import ( "context" "encoding/json" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" diff --git a/internal/rpc/services/service_http_firewall_rule_set.go b/internal/rpc/services/service_http_firewall_rule_set.go index 0a8028a7..50d582c0 100644 --- a/internal/rpc/services/service_http_firewall_rule_set.go +++ b/internal/rpc/services/service_http_firewall_rule_set.go @@ -3,6 +3,7 @@ package services import ( "context" "encoding/json" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs" diff --git a/internal/rpc/services/service_http_header.go b/internal/rpc/services/service_http_header.go index 349e6e6f..470cecb8 100644 --- a/internal/rpc/services/service_http_header.go +++ b/internal/rpc/services/service_http_header.go @@ -3,6 +3,7 @@ package services import ( "context" "encoding/json" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" diff --git a/internal/rpc/services/service_http_header_policy.go b/internal/rpc/services/service_http_header_policy.go index 694fb801..f4eec5ed 100644 --- a/internal/rpc/services/service_http_header_policy.go +++ b/internal/rpc/services/service_http_header_policy.go @@ -3,6 +3,7 @@ package services import ( "context" "encoding/json" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" diff --git a/internal/rpc/services/service_http_location.go b/internal/rpc/services/service_http_location.go index 057077cd..20b5db85 100644 --- a/internal/rpc/services/service_http_location.go +++ b/internal/rpc/services/service_http_location.go @@ -3,6 +3,7 @@ package services import ( "context" "encoding/json" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" rpcutils "github.com/TeaOSLab/EdgeAPI/internal/rpc/utils" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" diff --git a/internal/rpc/services/service_http_page.go b/internal/rpc/services/service_http_page.go index d1d1a90d..e4cd7603 100644 --- a/internal/rpc/services/service_http_page.go +++ b/internal/rpc/services/service_http_page.go @@ -5,6 +5,7 @@ import ( "encoding/json" "errors" "fmt" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/utils/regexputils" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" diff --git a/internal/rpc/services/service_http_rewrite_rule.go b/internal/rpc/services/service_http_rewrite_rule.go index 4af5cb70..b56a1bb3 100644 --- a/internal/rpc/services/service_http_rewrite_rule.go +++ b/internal/rpc/services/service_http_rewrite_rule.go @@ -2,6 +2,7 @@ package services import ( "context" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/iwind/TeaGo/types" diff --git a/internal/rpc/services/service_http_web.go b/internal/rpc/services/service_http_web.go index e7e87f95..b17f1f2d 100644 --- a/internal/rpc/services/service_http_web.go +++ b/internal/rpc/services/service_http_web.go @@ -4,6 +4,8 @@ import ( "context" "encoding/json" "fmt" + "strings" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeAPI/internal/utils/domainutils" @@ -12,7 +14,6 @@ import ( "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/lists" - "strings" ) type HTTPWebService struct { diff --git a/internal/rpc/services/service_http_web_community.go b/internal/rpc/services/service_http_web_community.go index 71e7195a..881ef17a 100644 --- a/internal/rpc/services/service_http_web_community.go +++ b/internal/rpc/services/service_http_web_community.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . //go:build !plus // +build !plus @@ -6,6 +6,7 @@ package services import ( "context" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" ) diff --git a/internal/rpc/services/service_http_websocket.go b/internal/rpc/services/service_http_websocket.go index ef092162..9e255e73 100644 --- a/internal/rpc/services/service_http_websocket.go +++ b/internal/rpc/services/service_http_websocket.go @@ -2,6 +2,7 @@ package services import ( "context" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" ) diff --git a/internal/rpc/services/service_ip_item.go b/internal/rpc/services/service_ip_item.go index 18e1aaee..61d35505 100644 --- a/internal/rpc/services/service_ip_item.go +++ b/internal/rpc/services/service_ip_item.go @@ -2,6 +2,9 @@ package services import ( "context" + "net" + "time" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/errors" rpcutils "github.com/TeaOSLab/EdgeAPI/internal/rpc/utils" @@ -10,8 +13,6 @@ import ( "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/ipconfigs" - "net" - "time" ) // IPItemService IP条目相关服务 diff --git a/internal/rpc/services/service_ip_library.go b/internal/rpc/services/service_ip_library.go index 5182452f..9abfcb48 100644 --- a/internal/rpc/services/service_ip_library.go +++ b/internal/rpc/services/service_ip_library.go @@ -2,6 +2,7 @@ package services import ( "context" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" rpcutils "github.com/TeaOSLab/EdgeAPI/internal/rpc/utils" "github.com/TeaOSLab/EdgeCommon/pkg/iplibrary" diff --git a/internal/rpc/services/service_ip_library_artifact.go b/internal/rpc/services/service_ip_library_artifact.go index 15adddc6..81c0b88c 100644 --- a/internal/rpc/services/service_ip_library_artifact.go +++ b/internal/rpc/services/service_ip_library_artifact.go @@ -1,10 +1,11 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package services import ( "context" "encoding/json" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/errors" rpcutils "github.com/TeaOSLab/EdgeAPI/internal/rpc/utils" diff --git a/internal/rpc/services/service_ip_library_file.go b/internal/rpc/services/service_ip_library_file.go index 08dfd4cb..ff93d855 100644 --- a/internal/rpc/services/service_ip_library_file.go +++ b/internal/rpc/services/service_ip_library_file.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package services @@ -6,6 +6,7 @@ import ( "context" "encoding/json" "errors" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/db/models/regions" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" diff --git a/internal/rpc/services/service_ip_list.go b/internal/rpc/services/service_ip_list.go index 0b5059ee..b2bfa5ae 100644 --- a/internal/rpc/services/service_ip_list.go +++ b/internal/rpc/services/service_ip_list.go @@ -2,6 +2,7 @@ package services import ( "context" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeAPI/internal/utils" diff --git a/internal/rpc/services/service_latest_item.go b/internal/rpc/services/service_latest_item.go index 52e1f5f0..3c9328d0 100644 --- a/internal/rpc/services/service_latest_item.go +++ b/internal/rpc/services/service_latest_item.go @@ -4,6 +4,7 @@ package services import ( "context" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" ) diff --git a/internal/rpc/services/service_log.go b/internal/rpc/services/service_log.go index a75f8742..044cc9ab 100644 --- a/internal/rpc/services/service_log.go +++ b/internal/rpc/services/service_log.go @@ -3,6 +3,7 @@ package services import ( "context" "encoding/json" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" rpcutils "github.com/TeaOSLab/EdgeAPI/internal/rpc/utils" "github.com/TeaOSLab/EdgeCommon/pkg/langs" diff --git a/internal/rpc/services/service_login.go b/internal/rpc/services/service_login.go index 69557c9e..b601f365 100644 --- a/internal/rpc/services/service_login.go +++ b/internal/rpc/services/service_login.go @@ -3,6 +3,7 @@ package services import ( "context" "encoding/json" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" diff --git a/internal/rpc/services/service_login_session.go b/internal/rpc/services/service_login_session.go index 00778d17..3ca1e888 100644 --- a/internal/rpc/services/service_login_session.go +++ b/internal/rpc/services/service_login_session.go @@ -1,10 +1,11 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package services import ( "context" "errors" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" ) diff --git a/internal/rpc/services/service_login_ticket.go b/internal/rpc/services/service_login_ticket.go index 0b20ea44..13ffbe17 100644 --- a/internal/rpc/services/service_login_ticket.go +++ b/internal/rpc/services/service_login_ticket.go @@ -1,10 +1,11 @@ -// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package services import ( "context" "errors" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeCommon/pkg/iputils" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" diff --git a/internal/rpc/services/service_message.go b/internal/rpc/services/service_message.go index 125b6b75..626a5f9e 100644 --- a/internal/rpc/services/service_message.go +++ b/internal/rpc/services/service_message.go @@ -2,6 +2,7 @@ package services import ( "context" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" diff --git a/internal/rpc/services/service_metric_chart.go b/internal/rpc/services/service_metric_chart.go index 72dc18b1..ac08d144 100644 --- a/internal/rpc/services/service_metric_chart.go +++ b/internal/rpc/services/service_metric_chart.go @@ -5,6 +5,7 @@ package services import ( "context" "encoding/json" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/iwind/TeaGo/maps" diff --git a/internal/rpc/services/service_metric_item.go b/internal/rpc/services/service_metric_item.go index 552d4960..ab4f92fa 100644 --- a/internal/rpc/services/service_metric_item.go +++ b/internal/rpc/services/service_metric_item.go @@ -4,6 +4,7 @@ package services import ( "context" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/iwind/TeaGo/types" diff --git a/internal/rpc/services/service_metric_stat.go b/internal/rpc/services/service_metric_stat.go index 5ba54725..d8793c15 100644 --- a/internal/rpc/services/service_metric_stat.go +++ b/internal/rpc/services/service_metric_stat.go @@ -4,15 +4,16 @@ package services import ( "context" + "strings" + "sync" + "time" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/goman" "github.com/TeaOSLab/EdgeAPI/internal/remotelogs" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/types" - "strings" - "sync" - "time" ) // 队列相关数据 diff --git a/internal/rpc/services/service_node.go b/internal/rpc/services/service_node.go index 723f76b6..c9971497 100644 --- a/internal/rpc/services/service_node.go +++ b/internal/rpc/services/service_node.go @@ -4,6 +4,13 @@ import ( "bytes" "context" "encoding/json" + "io" + "net" + "path/filepath" + "strings" + "sync" + "time" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/db/models/dns" "github.com/TeaOSLab/EdgeAPI/internal/dnsclients/dnstypes" @@ -25,12 +32,6 @@ import ( "github.com/iwind/TeaGo/lists" "github.com/iwind/TeaGo/types" stringutil "github.com/iwind/TeaGo/utils/string" - "io" - "net" - "path/filepath" - "strings" - "sync" - "time" ) // NodeVersionCache 节点版本缓存 @@ -387,6 +388,7 @@ func (this *NodeService) ListEnabledNodesMatch(ctx context.Context, req *pb.List OfflineDay: node.OfflineDay, IsBackupForCluster: node.IsBackupForCluster, IsBackupForGroup: node.IsBackupForGroup, + BypassMobile: node.BypassMobile, }) } @@ -689,6 +691,7 @@ func (this *NodeService) FindEnabledNode(ctx context.Context, req *pb.FindEnable OfflineDay: node.OfflineDay, IsBackupForCluster: node.IsBackupForCluster, IsBackupForGroup: node.IsBackupForGroup, + BypassMobile: node.BypassMobile, }}, nil } @@ -1758,6 +1761,21 @@ func (this *NodeService) UpdateNodeSystem(ctx context.Context, req *pb.UpdateNod return this.Success() } +// UpdateNodeBypassMobile 修改节点过移动 +func (this *NodeService) UpdateNodeBypassMobile(ctx context.Context, req *pb.UpdateNodeBypassMobile) (*pb.RPCSuccess, error) { + _, err := this.ValidateAdmin(ctx) + if err != nil { + return nil, err + } + + var tx = this.NullTx() + err = models.SharedNodeDAO.UpdateNodeBypassMobile(tx, req.NodeId, req.BypassMobile) + if err != nil { + return nil, err + } + return this.Success() +} + // UpdateNodeCache 修改节点缓存设置 func (this *NodeService) UpdateNodeCache(ctx context.Context, req *pb.UpdateNodeCacheRequest) (*pb.RPCSuccess, error) { _, err := this.ValidateAdmin(ctx) diff --git a/internal/rpc/services/service_node_cluster.go b/internal/rpc/services/service_node_cluster.go index c2d3677f..1aa38a5a 100644 --- a/internal/rpc/services/service_node_cluster.go +++ b/internal/rpc/services/service_node_cluster.go @@ -3,6 +3,8 @@ package services import ( "context" "encoding/json" + "strconv" + teaconst "github.com/TeaOSLab/EdgeAPI/internal/const" "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/db/models/dns" @@ -19,7 +21,6 @@ import ( "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/rands" "github.com/iwind/TeaGo/types" - "strconv" ) type NodeClusterService struct { diff --git a/internal/rpc/services/service_node_cluster_ext.go b/internal/rpc/services/service_node_cluster_ext.go index 74616dbc..02411a40 100644 --- a/internal/rpc/services/service_node_cluster_ext.go +++ b/internal/rpc/services/service_node_cluster_ext.go @@ -1,10 +1,11 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . //go:build !plus package services import ( "context" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" ) diff --git a/internal/rpc/services/service_node_cluster_firewall_action.go b/internal/rpc/services/service_node_cluster_firewall_action.go index a3efeb87..8fbe86dd 100644 --- a/internal/rpc/services/service_node_cluster_firewall_action.go +++ b/internal/rpc/services/service_node_cluster_firewall_action.go @@ -3,6 +3,7 @@ package services import ( "context" "encoding/json" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/iwind/TeaGo/maps" diff --git a/internal/rpc/services/service_node_cluster_metric_item.go b/internal/rpc/services/service_node_cluster_metric_item.go index e5cddc13..0cece9d8 100644 --- a/internal/rpc/services/service_node_cluster_metric_item.go +++ b/internal/rpc/services/service_node_cluster_metric_item.go @@ -4,6 +4,7 @@ package services import ( "context" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/iwind/TeaGo/types" diff --git a/internal/rpc/services/service_node_ext.go b/internal/rpc/services/service_node_ext.go index 8f56b048..d81fb508 100644 --- a/internal/rpc/services/service_node_ext.go +++ b/internal/rpc/services/service_node_ext.go @@ -1,10 +1,11 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . //go:build !plus package services import ( "context" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" ) diff --git a/internal/rpc/services/service_node_grant.go b/internal/rpc/services/service_node_grant.go index ca612c62..cbfc7fdf 100644 --- a/internal/rpc/services/service_node_grant.go +++ b/internal/rpc/services/service_node_grant.go @@ -4,15 +4,16 @@ import ( "context" "errors" "fmt" + "net" + "regexp" + "strings" + "time" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/utils/numberutils" "github.com/TeaOSLab/EdgeCommon/pkg/configutils" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "golang.org/x/crypto/ssh" - "net" - "regexp" - "strings" - "time" ) type NodeGrantService struct { diff --git a/internal/rpc/services/service_node_group.go b/internal/rpc/services/service_node_group.go index a6484adc..a60cdcbd 100644 --- a/internal/rpc/services/service_node_group.go +++ b/internal/rpc/services/service_node_group.go @@ -2,6 +2,7 @@ package services import ( "context" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" ) diff --git a/internal/rpc/services/service_node_ip_address.go b/internal/rpc/services/service_node_ip_address.go index a73f7669..26e962f5 100644 --- a/internal/rpc/services/service_node_ip_address.go +++ b/internal/rpc/services/service_node_ip_address.go @@ -2,6 +2,7 @@ package services import ( "context" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/utils" "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" diff --git a/internal/rpc/services/service_node_ip_address_log.go b/internal/rpc/services/service_node_ip_address_log.go index 89052fb9..3b309c07 100644 --- a/internal/rpc/services/service_node_ip_address_log.go +++ b/internal/rpc/services/service_node_ip_address_log.go @@ -4,6 +4,7 @@ package services import ( "context" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" ) diff --git a/internal/rpc/services/service_node_ip_address_threshold.go b/internal/rpc/services/service_node_ip_address_threshold.go index 510674fe..962ad025 100644 --- a/internal/rpc/services/service_node_ip_address_threshold.go +++ b/internal/rpc/services/service_node_ip_address_threshold.go @@ -5,6 +5,7 @@ package services import ( "context" "encoding/json" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" diff --git a/internal/rpc/services/service_node_log.go b/internal/rpc/services/service_node_log.go index d73e0e96..c4ef001a 100644 --- a/internal/rpc/services/service_node_log.go +++ b/internal/rpc/services/service_node_log.go @@ -2,6 +2,7 @@ package services import ( "context" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" rpcutils "github.com/TeaOSLab/EdgeAPI/internal/rpc/utils" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" diff --git a/internal/rpc/services/service_node_login.go b/internal/rpc/services/service_node_login.go index 5597053e..28f72365 100644 --- a/internal/rpc/services/service_node_login.go +++ b/internal/rpc/services/service_node_login.go @@ -4,13 +4,14 @@ package services import ( "context" + "net" + "sync" + "time" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeCommon/pkg/configutils" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/iwind/TeaGo/types" - "net" - "sync" - "time" ) // NodeLoginService 节点登录相关 diff --git a/internal/rpc/services/service_node_region.go b/internal/rpc/services/service_node_region.go index 036048e5..8a94383e 100644 --- a/internal/rpc/services/service_node_region.go +++ b/internal/rpc/services/service_node_region.go @@ -2,6 +2,7 @@ package services import ( "context" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" ) diff --git a/internal/rpc/services/service_node_stream.go b/internal/rpc/services/service_node_stream.go index d766aff1..abb8ea1c 100644 --- a/internal/rpc/services/service_node_stream.go +++ b/internal/rpc/services/service_node_stream.go @@ -3,6 +3,11 @@ package services import ( "context" "fmt" + "strconv" + "sync" + "sync/atomic" + "time" + teaconst "github.com/TeaOSLab/EdgeAPI/internal/const" "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/errors" @@ -12,10 +17,6 @@ import ( "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/iwind/TeaGo/logs" - "strconv" - "sync" - "sync/atomic" - "time" ) var primaryNodeId int64 = 0 diff --git a/internal/rpc/services/service_node_task.go b/internal/rpc/services/service_node_task.go index 5651fb78..925cd164 100644 --- a/internal/rpc/services/service_node_task.go +++ b/internal/rpc/services/service_node_task.go @@ -2,6 +2,8 @@ package services import ( "context" + "time" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/installers" rpcutils "github.com/TeaOSLab/EdgeAPI/internal/rpc/utils" @@ -9,7 +11,6 @@ import ( "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/iwind/TeaGo/dbs" stringutil "github.com/iwind/TeaGo/utils/string" - "time" ) // NodeTaskService 节点同步任务相关服务 diff --git a/internal/rpc/services/service_node_threshold.go b/internal/rpc/services/service_node_threshold.go index 0a5ac792..db273214 100644 --- a/internal/rpc/services/service_node_threshold.go +++ b/internal/rpc/services/service_node_threshold.go @@ -4,6 +4,7 @@ package services import ( "context" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" rpcutils "github.com/TeaOSLab/EdgeAPI/internal/rpc/utils" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" diff --git a/internal/rpc/services/service_node_value.go b/internal/rpc/services/service_node_value.go index ed4a5350..7cbdc58f 100644 --- a/internal/rpc/services/service_node_value.go +++ b/internal/rpc/services/service_node_value.go @@ -4,6 +4,7 @@ package services import ( "context" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" rpcutils "github.com/TeaOSLab/EdgeAPI/internal/rpc/utils" "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" diff --git a/internal/rpc/services/service_origin.go b/internal/rpc/services/service_origin.go index ee969a2d..309eb365 100644 --- a/internal/rpc/services/service_origin.go +++ b/internal/rpc/services/service_origin.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "errors" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/ossconfigs" diff --git a/internal/rpc/services/service_ping.go b/internal/rpc/services/service_ping.go index 3c6a3054..983006ab 100644 --- a/internal/rpc/services/service_ping.go +++ b/internal/rpc/services/service_ping.go @@ -1,9 +1,10 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package services import ( "context" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" ) diff --git a/internal/rpc/services/service_plan_community.go b/internal/rpc/services/service_plan_community.go index 6cecbc0c..db05d92d 100644 --- a/internal/rpc/services/service_plan_community.go +++ b/internal/rpc/services/service_plan_community.go @@ -5,6 +5,7 @@ package services import ( "context" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" ) diff --git a/internal/rpc/services/service_region_city.go b/internal/rpc/services/service_region_city.go index 5ab2ec4e..8c1f7aa0 100644 --- a/internal/rpc/services/service_region_city.go +++ b/internal/rpc/services/service_region_city.go @@ -4,6 +4,7 @@ package services import ( "context" + "github.com/TeaOSLab/EdgeAPI/internal/db/models/regions" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" ) diff --git a/internal/rpc/services/service_region_country.go b/internal/rpc/services/service_region_country.go index 26dacb59..a3e633b9 100644 --- a/internal/rpc/services/service_region_country.go +++ b/internal/rpc/services/service_region_country.go @@ -3,6 +3,7 @@ package services import ( "context" "encoding/json" + "github.com/TeaOSLab/EdgeAPI/internal/db/models/regions" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" ) diff --git a/internal/rpc/services/service_region_provider.go b/internal/rpc/services/service_region_provider.go index f762f1dc..9e04df5e 100644 --- a/internal/rpc/services/service_region_provider.go +++ b/internal/rpc/services/service_region_provider.go @@ -4,6 +4,7 @@ package services import ( "context" + "github.com/TeaOSLab/EdgeAPI/internal/db/models/regions" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" ) diff --git a/internal/rpc/services/service_region_province.go b/internal/rpc/services/service_region_province.go index bf0add37..44efd3cf 100644 --- a/internal/rpc/services/service_region_province.go +++ b/internal/rpc/services/service_region_province.go @@ -2,6 +2,7 @@ package services import ( "context" + "github.com/TeaOSLab/EdgeAPI/internal/db/models/regions" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" ) diff --git a/internal/rpc/services/service_region_town.go b/internal/rpc/services/service_region_town.go index 95cb7f3b..8a6f276d 100644 --- a/internal/rpc/services/service_region_town.go +++ b/internal/rpc/services/service_region_town.go @@ -4,6 +4,7 @@ package services import ( "context" + "github.com/TeaOSLab/EdgeAPI/internal/db/models/regions" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" ) diff --git a/internal/rpc/services/service_reverse_proxy.go b/internal/rpc/services/service_reverse_proxy.go index 801807f8..d84afa69 100644 --- a/internal/rpc/services/service_reverse_proxy.go +++ b/internal/rpc/services/service_reverse_proxy.go @@ -3,6 +3,7 @@ package services import ( "context" "encoding/json" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared" diff --git a/internal/rpc/services/service_server.go b/internal/rpc/services/service_server.go index 06d7bf4a..99721d88 100644 --- a/internal/rpc/services/service_server.go +++ b/internal/rpc/services/service_server.go @@ -5,6 +5,11 @@ import ( "encoding/json" "errors" "fmt" + "net" + "net/url" + "regexp" + "strings" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/db/models/clients" "github.com/TeaOSLab/EdgeAPI/internal/db/models/dns" @@ -19,10 +24,6 @@ import ( "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/types" timeutil "github.com/iwind/TeaGo/utils/time" - "net" - "net/url" - "regexp" - "strings" ) type ServerService struct { diff --git a/internal/rpc/services/service_server_.go b/internal/rpc/services/service_server_.go index 64da2711..ae79440b 100644 --- a/internal/rpc/services/service_server_.go +++ b/internal/rpc/services/service_server_.go @@ -1,6 +1,10 @@ package services import ( + "strings" + "sync" + "time" + teaconst "github.com/TeaOSLab/EdgeAPI/internal/const" "github.com/TeaOSLab/EdgeAPI/internal/db/models/stats" "github.com/TeaOSLab/EdgeAPI/internal/errors" @@ -11,9 +15,6 @@ import ( "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/types" timeutil "github.com/iwind/TeaGo/utils/time" - "strings" - "sync" - "time" ) type TrafficStat struct { diff --git a/internal/rpc/services/service_server_bandwidth_stat.go b/internal/rpc/services/service_server_bandwidth_stat.go index a7b3ee66..6f68a8d2 100644 --- a/internal/rpc/services/service_server_bandwidth_stat.go +++ b/internal/rpc/services/service_server_bandwidth_stat.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package services @@ -6,6 +6,11 @@ import ( "context" "encoding/json" "errors" + "os" + "strings" + "sync" + "time" + teaconst "github.com/TeaOSLab/EdgeAPI/internal/const" "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/db/models/stats" @@ -19,10 +24,6 @@ import ( "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/types" timeutil "github.com/iwind/TeaGo/utils/time" - "os" - "strings" - "sync" - "time" ) var serverBandwidthStatsMap = map[string]*pb.ServerBandwidthStat{} // server key => bandwidth @@ -117,7 +118,7 @@ func init() { // 分时统计 err = models.SharedUserPlanBandwidthStatDAO.UpdateUserPlanBandwidth(tx, stat.UserId, stat.UserPlanId, stat.NodeRegionId, stat.Day, stat.TimeAt, stat.Bytes, stat.TotalBytes, stat.CachedBytes, stat.AttackBytes, stat.CountRequests, stat.CountCachedRequests, stat.CountAttackRequests, stat.CountWebsocketConnections) if err != nil { - remotelogs.Error("SharedUserPlanBandwidthStatDAO", "UpdateUserPlanBandwidth: " + err.Error()) + remotelogs.Error("SharedUserPlanBandwidthStatDAO", "UpdateUserPlanBandwidth: "+err.Error()) } } } diff --git a/internal/rpc/services/service_server_client_browser_monthly_stat.go b/internal/rpc/services/service_server_client_browser_monthly_stat.go index 0a59028a..d75c62b6 100644 --- a/internal/rpc/services/service_server_client_browser_monthly_stat.go +++ b/internal/rpc/services/service_server_client_browser_monthly_stat.go @@ -2,6 +2,7 @@ package services import ( "context" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/db/models/stats" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" diff --git a/internal/rpc/services/service_server_client_system_monthly_stat.go b/internal/rpc/services/service_server_client_system_monthly_stat.go index 3d6e3010..13832409 100644 --- a/internal/rpc/services/service_server_client_system_monthly_stat.go +++ b/internal/rpc/services/service_server_client_system_monthly_stat.go @@ -2,6 +2,7 @@ package services import ( "context" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/db/models/stats" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" diff --git a/internal/rpc/services/service_server_community.go b/internal/rpc/services/service_server_community.go index b3ef18c2..90d12098 100644 --- a/internal/rpc/services/service_server_community.go +++ b/internal/rpc/services/service_server_community.go @@ -6,6 +6,7 @@ package services import ( "context" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" ) diff --git a/internal/rpc/services/service_server_daily_stat.go b/internal/rpc/services/service_server_daily_stat.go index 70e2b2b4..c43cf6f5 100644 --- a/internal/rpc/services/service_server_daily_stat.go +++ b/internal/rpc/services/service_server_daily_stat.go @@ -2,6 +2,10 @@ package services import ( "context" + "math" + "strings" + "time" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/db/models/stats" "github.com/TeaOSLab/EdgeAPI/internal/errors" @@ -10,9 +14,6 @@ import ( "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/iwind/TeaGo/dbs" timeutil "github.com/iwind/TeaGo/utils/time" - "math" - "strings" - "time" ) // ServerDailyStatService 服务统计相关服务 diff --git a/internal/rpc/services/service_server_domain_hourly_stat.go b/internal/rpc/services/service_server_domain_hourly_stat.go index ee6bc5d6..8141b4df 100644 --- a/internal/rpc/services/service_server_domain_hourly_stat.go +++ b/internal/rpc/services/service_server_domain_hourly_stat.go @@ -4,6 +4,7 @@ package services import ( "context" + "github.com/TeaOSLab/EdgeAPI/internal/db/models/stats" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" ) diff --git a/internal/rpc/services/service_server_group.go b/internal/rpc/services/service_server_group.go index 99f32b2d..1514c65a 100644 --- a/internal/rpc/services/service_server_group.go +++ b/internal/rpc/services/service_server_group.go @@ -3,6 +3,7 @@ package services import ( "context" "encoding/json" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" diff --git a/internal/rpc/services/service_server_http_firewall_daily_stat.go b/internal/rpc/services/service_server_http_firewall_daily_stat.go index cf392655..23409327 100644 --- a/internal/rpc/services/service_server_http_firewall_daily_stat.go +++ b/internal/rpc/services/service_server_http_firewall_daily_stat.go @@ -2,14 +2,15 @@ package services import ( "context" + "sort" + "time" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/db/models/stats" "github.com/TeaOSLab/EdgeAPI/internal/utils" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/iwind/TeaGo/types" timeutil "github.com/iwind/TeaGo/utils/time" - "sort" - "time" ) // ServerHTTPFirewallDailyStatService WAF统计 diff --git a/internal/rpc/services/service_server_http_firewall_daily_stat_test.go b/internal/rpc/services/service_server_http_firewall_daily_stat_test.go index 7152f271..1a75d5a4 100644 --- a/internal/rpc/services/service_server_http_firewall_daily_stat_test.go +++ b/internal/rpc/services/service_server_http_firewall_daily_stat_test.go @@ -1,11 +1,12 @@ package services import ( + "testing" + rpcutils "github.com/TeaOSLab/EdgeAPI/internal/rpc/utils" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/logs" - "testing" ) func TestServerHTTPFirewallDailyStatService_ComposeServerHTTPFirewallDashboard(t *testing.T) { diff --git a/internal/rpc/services/service_server_region_city_monthly_stat.go b/internal/rpc/services/service_server_region_city_monthly_stat.go index 8dd329a6..6b433cc0 100644 --- a/internal/rpc/services/service_server_region_city_monthly_stat.go +++ b/internal/rpc/services/service_server_region_city_monthly_stat.go @@ -2,6 +2,7 @@ package services import ( "context" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/db/models/regions" "github.com/TeaOSLab/EdgeAPI/internal/db/models/stats" diff --git a/internal/rpc/services/service_server_region_country_monthly_stat.go b/internal/rpc/services/service_server_region_country_monthly_stat.go index 4601a2a9..a76679ed 100644 --- a/internal/rpc/services/service_server_region_country_monthly_stat.go +++ b/internal/rpc/services/service_server_region_country_monthly_stat.go @@ -2,6 +2,7 @@ package services import ( "context" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/db/models/regions" "github.com/TeaOSLab/EdgeAPI/internal/db/models/stats" diff --git a/internal/rpc/services/service_server_region_provider_monthly_stat.go b/internal/rpc/services/service_server_region_provider_monthly_stat.go index 6a747698..ba45cf1c 100644 --- a/internal/rpc/services/service_server_region_provider_monthly_stat.go +++ b/internal/rpc/services/service_server_region_provider_monthly_stat.go @@ -2,6 +2,7 @@ package services import ( "context" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/db/models/regions" "github.com/TeaOSLab/EdgeAPI/internal/db/models/stats" diff --git a/internal/rpc/services/service_server_region_province_monthly_stat.go b/internal/rpc/services/service_server_region_province_monthly_stat.go index 2a7f7256..927c751a 100644 --- a/internal/rpc/services/service_server_region_province_monthly_stat.go +++ b/internal/rpc/services/service_server_region_province_monthly_stat.go @@ -2,6 +2,7 @@ package services import ( "context" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/db/models/regions" "github.com/TeaOSLab/EdgeAPI/internal/db/models/stats" diff --git a/internal/rpc/services/service_server_stat_board.go b/internal/rpc/services/service_server_stat_board.go index e4082d84..4747b1f4 100644 --- a/internal/rpc/services/service_server_stat_board.go +++ b/internal/rpc/services/service_server_stat_board.go @@ -4,6 +4,8 @@ package services import ( "context" + "time" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/db/models/regions" "github.com/TeaOSLab/EdgeAPI/internal/db/models/stats" @@ -16,7 +18,6 @@ import ( "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/systemconfigs" timeutil "github.com/iwind/TeaGo/utils/time" - "time" ) // ServerStatBoardService 统计看板条目 diff --git a/internal/rpc/services/service_server_stat_board_chart.go b/internal/rpc/services/service_server_stat_board_chart.go index a5a5a7bc..9df76c45 100644 --- a/internal/rpc/services/service_server_stat_board_chart.go +++ b/internal/rpc/services/service_server_stat_board_chart.go @@ -4,6 +4,7 @@ package services import ( "context" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/iwind/TeaGo/types" diff --git a/internal/rpc/services/service_server_test.go b/internal/rpc/services/service_server_test.go index 276971c9..7d86ee06 100644 --- a/internal/rpc/services/service_server_test.go +++ b/internal/rpc/services/service_server_test.go @@ -1,13 +1,14 @@ package services import ( + "testing" + rpcutils "github.com/TeaOSLab/EdgeAPI/internal/rpc/utils" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" _ "github.com/iwind/TeaGo/bootstrap" "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/logs" timeutil "github.com/iwind/TeaGo/utils/time" - "testing" ) func TestServerService_UploadServerHTTPRequestStat(t *testing.T) { diff --git a/internal/rpc/services/service_ssl_cert.go b/internal/rpc/services/service_ssl_cert.go index 7e58c5bb..3b4a9034 100644 --- a/internal/rpc/services/service_ssl_cert.go +++ b/internal/rpc/services/service_ssl_cert.go @@ -3,6 +3,7 @@ package services import ( "context" "encoding/json" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/db/models/acme" "github.com/TeaOSLab/EdgeAPI/internal/errors" diff --git a/internal/rpc/services/service_ssl_policy.go b/internal/rpc/services/service_ssl_policy.go index 8d9bfa39..99664e20 100644 --- a/internal/rpc/services/service_ssl_policy.go +++ b/internal/rpc/services/service_ssl_policy.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "errors" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" rpcutils "github.com/TeaOSLab/EdgeAPI/internal/rpc/utils" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" diff --git a/internal/rpc/services/service_sys_locker.go b/internal/rpc/services/service_sys_locker.go index a84dc4fb..b8885a17 100644 --- a/internal/rpc/services/service_sys_locker.go +++ b/internal/rpc/services/service_sys_locker.go @@ -2,6 +2,7 @@ package services import ( "context" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" ) diff --git a/internal/rpc/services/service_sys_setting.go b/internal/rpc/services/service_sys_setting.go index c013a03b..5e913edd 100644 --- a/internal/rpc/services/service_sys_setting.go +++ b/internal/rpc/services/service_sys_setting.go @@ -2,6 +2,7 @@ package services import ( "context" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" ) diff --git a/internal/rpc/services/service_traffic_daily_stat.go b/internal/rpc/services/service_traffic_daily_stat.go index bd57e30f..24aa21eb 100644 --- a/internal/rpc/services/service_traffic_daily_stat.go +++ b/internal/rpc/services/service_traffic_daily_stat.go @@ -5,10 +5,11 @@ package services import ( "context" "fmt" + "regexp" + "github.com/TeaOSLab/EdgeAPI/internal/db/models/stats" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/iwind/TeaGo/types" - "regexp" ) // TrafficDailyStatService 按日统计服务 diff --git a/internal/rpc/services/service_updating_server_list.go b/internal/rpc/services/service_updating_server_list.go index 0b79026c..b72239b0 100644 --- a/internal/rpc/services/service_updating_server_list.go +++ b/internal/rpc/services/service_updating_server_list.go @@ -1,10 +1,11 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package services import ( "context" "encoding/json" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/utils" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" diff --git a/internal/rpc/services/service_user_access_key.go b/internal/rpc/services/service_user_access_key.go index 40382a53..63eca6e9 100644 --- a/internal/rpc/services/service_user_access_key.go +++ b/internal/rpc/services/service_user_access_key.go @@ -2,6 +2,7 @@ package services import ( "context" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" ) diff --git a/internal/rpc/services/service_user_identity.go b/internal/rpc/services/service_user_identity.go index f41038e0..44ea617e 100644 --- a/internal/rpc/services/service_user_identity.go +++ b/internal/rpc/services/service_user_identity.go @@ -1,9 +1,10 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package services import ( "context" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" diff --git a/internal/rpc/services/service_user_plan_community.go b/internal/rpc/services/service_user_plan_community.go index bdb1c8be..04b0e192 100644 --- a/internal/rpc/services/service_user_plan_community.go +++ b/internal/rpc/services/service_user_plan_community.go @@ -6,6 +6,7 @@ package services import ( "context" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" ) diff --git a/internal/rpc/services/sevice_http_gzip.go b/internal/rpc/services/sevice_http_gzip.go index ef31c58a..f6bed60b 100644 --- a/internal/rpc/services/sevice_http_gzip.go +++ b/internal/rpc/services/sevice_http_gzip.go @@ -3,6 +3,7 @@ package services import ( "context" "encoding/json" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared" diff --git a/internal/rpc/services/users/service_user.go b/internal/rpc/services/users/service_user.go index afe7ee35..b8ae9ee9 100644 --- a/internal/rpc/services/users/service_user.go +++ b/internal/rpc/services/users/service_user.go @@ -3,6 +3,9 @@ package users import ( "context" "encoding/json" + "strings" + "time" + teaconst "github.com/TeaOSLab/EdgeAPI/internal/const" "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/errors" @@ -16,8 +19,6 @@ import ( "github.com/TeaOSLab/EdgeCommon/pkg/userconfigs" "github.com/iwind/TeaGo/types" timeutil "github.com/iwind/TeaGo/utils/time" - "strings" - "time" ) // UserService 用户相关服务 diff --git a/internal/rpc/services/users/service_user_ext.go b/internal/rpc/services/users/service_user_ext.go index 2603841b..8b5f6a24 100644 --- a/internal/rpc/services/users/service_user_ext.go +++ b/internal/rpc/services/users/service_user_ext.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . //go:build !plus package users @@ -6,6 +6,7 @@ package users import ( "context" "errors" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/iwind/TeaGo/dbs" diff --git a/internal/rpc/tasks/cache_task_manager.go b/internal/rpc/tasks/cache_task_manager.go index bdf7a21e..24c07e06 100644 --- a/internal/rpc/tasks/cache_task_manager.go +++ b/internal/rpc/tasks/cache_task_manager.go @@ -3,6 +3,9 @@ package tasks import ( + "sync" + "time" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/db/models/stats" "github.com/TeaOSLab/EdgeAPI/internal/goman" @@ -13,8 +16,6 @@ import ( "github.com/iwind/TeaGo/lists" "github.com/iwind/TeaGo/types" timeutil "github.com/iwind/TeaGo/utils/time" - "sync" - "time" ) var SharedCacheTaskManager = NewCacheTaskManager() diff --git a/internal/rpc/utils/utils_ext.go b/internal/rpc/utils/utils_ext.go index aa8c0aa8..1cc25ce3 100644 --- a/internal/rpc/utils/utils_ext.go +++ b/internal/rpc/utils/utils_ext.go @@ -6,6 +6,7 @@ import ( "context" "encoding/base64" "encoding/json" + teaconst "github.com/TeaOSLab/EdgeAPI/internal/const" "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/encrypt" diff --git a/internal/setup/setup.go b/internal/setup/setup.go index 27134953..9d42e1d1 100644 --- a/internal/setup/setup.go +++ b/internal/setup/setup.go @@ -3,6 +3,10 @@ package setup import ( "encoding/json" "fmt" + "os" + "strconv" + "strings" + "github.com/TeaOSLab/EdgeAPI/internal/configs" "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/errors" @@ -10,9 +14,6 @@ import ( "github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/cmd" "github.com/iwind/TeaGo/types" - "os" - "strconv" - "strings" ) type Setup struct { diff --git a/internal/setup/setup_test.go b/internal/setup/setup_test.go index 08a98820..7cf7b0bd 100644 --- a/internal/setup/setup_test.go +++ b/internal/setup/setup_test.go @@ -1,8 +1,9 @@ package setup import ( - _ "github.com/iwind/TeaGo/bootstrap" "testing" + + _ "github.com/iwind/TeaGo/bootstrap" ) func TestSetup_Run(t *testing.T) { diff --git a/internal/setup/sql.json b/internal/setup/sql.json index 7fd80a2c..ce4e071b 100644 --- a/internal/setup/sql.json +++ b/internal/setup/sql.json @@ -141,7 +141,7 @@ "name": "edgeACMETasks", "engine": "InnoDB", "charset": "utf8mb4_general_ci", - "definition": "CREATE TABLE `edgeACMETasks` (\n `id` bigint(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n `adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',\n `userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',\n `isOn` tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用',\n `acmeUserId` int(11) unsigned DEFAULT '0' COMMENT 'ACME用户ID',\n `dnsDomain` varchar(255) DEFAULT NULL COMMENT 'DNS主域名',\n `dnsProviderId` bigint(11) unsigned DEFAULT '0' COMMENT 'DNS服务商',\n `domains` json DEFAULT NULL COMMENT '证书域名',\n `createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',\n `state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',\n `certId` bigint(11) unsigned DEFAULT '0' COMMENT '生成的证书ID',\n `autoRenew` tinyint(1) unsigned DEFAULT '0' COMMENT '是否自动更新',\n `authType` varchar(64) DEFAULT NULL COMMENT '认证类型',\n `authURL` varchar(1024) DEFAULT NULL COMMENT '认证URL',\n PRIMARY KEY (`id`),\n KEY `adminId` (`adminId`),\n KEY `userId` (`userId`),\n KEY `acmeUserId` (`acmeUserId`),\n KEY `certId` (`certId`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='ACME任务'", + "definition": "CREATE TABLE `edgeACMETasks` (\n `id` bigint(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n `adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',\n `userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',\n `isOn` tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用',\n `acmeUserId` int(11) unsigned DEFAULT '0' COMMENT 'ACME用户ID',\n `dnsDomain` varchar(255) DEFAULT NULL COMMENT 'DNS主域名',\n `dnsProviderId` bigint(11) unsigned DEFAULT '0' COMMENT 'DNS服务商',\n `domains` json DEFAULT NULL COMMENT '证书域名',\n `createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',\n `state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',\n `async` tinyint(1) unsigned DEFAULT '0' COMMENT 'async', \n `certId` bigint(11) unsigned DEFAULT '0' COMMENT '生成的证书ID',\n `autoRenew` tinyint(1) unsigned DEFAULT '0' COMMENT '是否自动更新',\n `status` tinyint(3) unsigned DEFAULT '0',\n `authType` varchar(64) DEFAULT NULL COMMENT '认证类型',\n `authURL` varchar(1024) DEFAULT NULL COMMENT '认证URL',\n PRIMARY KEY (`id`),\n KEY `adminId` (`adminId`),\n KEY `userId` (`userId`),\n KEY `acmeUserId` (`acmeUserId`),\n KEY `certId` (`certId`),\n KEY `async` (`async`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='ACME任务'", "fields": [ { "name": "id", @@ -198,6 +198,14 @@ { "name": "authURL", "definition": "varchar(1024) COMMENT '认证URL'" + }, + { + "name": "async", + "definition": "tinyint(1) unsigned DEFAULT '0' COMMENT 'async'" + }, + { + "name": "status", + "definition": "tinyint(3) unsigned DEFAULT '0'" } ], "indexes": [ @@ -220,6 +228,10 @@ { "name": "certId", "definition": "KEY `certId` (`certId`) USING BTREE" + }, + { + "name": "async", + "definition": "KEY `async` (`async`) USING BTREE" } ], "records": [] @@ -122093,7 +122105,7 @@ "name": "edgeNodes", "engine": "InnoDB", "charset": "utf8mb4_general_ci", - "definition": "CREATE TABLE `edgeNodes` (\n `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n `adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',\n `userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',\n `level` tinyint(1) unsigned DEFAULT '1' COMMENT '级别',\n `lnAddrs` json DEFAULT NULL COMMENT 'Ln级别访问地址',\n `isOn` tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用',\n `isUp` tinyint(1) unsigned DEFAULT '1' COMMENT '是否在线',\n `countUp` int(11) unsigned DEFAULT '0' COMMENT '连续在线次数',\n `countDown` int(11) unsigned DEFAULT '0' COMMENT '连续下线次数',\n `isActive` tinyint(1) unsigned DEFAULT '1' COMMENT '是否活跃',\n `inactiveNotifiedAt` bigint(11) unsigned DEFAULT '0' COMMENT '离线通知时间',\n `uniqueId` varchar(32) DEFAULT NULL COMMENT '节点ID',\n `secret` varchar(32) DEFAULT NULL COMMENT '密钥',\n `name` varchar(255) DEFAULT NULL COMMENT '节点名',\n `code` varchar(255) DEFAULT NULL COMMENT '代号',\n `clusterId` int(11) unsigned DEFAULT '0' COMMENT '主集群ID',\n `secondaryClusterIds` json DEFAULT NULL COMMENT '从集群ID',\n `regionId` int(11) unsigned DEFAULT '0' COMMENT '区域ID',\n `groupId` int(11) unsigned DEFAULT '0' COMMENT '分组ID',\n `createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',\n `status` json DEFAULT NULL COMMENT '最新的状态',\n `version` int(11) unsigned DEFAULT '0' COMMENT '当前版本号',\n `latestVersion` int(11) unsigned DEFAULT '0' COMMENT '最后版本号',\n `installDir` varchar(512) DEFAULT NULL COMMENT '安装目录',\n `isInstalled` tinyint(1) unsigned DEFAULT '0' COMMENT '是否已安装',\n `installStatus` json DEFAULT NULL COMMENT '安装状态',\n `state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',\n `connectedAPINodes` json DEFAULT NULL COMMENT '当前连接的API节点',\n `maxCPU` int(4) unsigned DEFAULT '0' COMMENT '可以使用的最多CPU',\n `maxThreads` int(11) unsigned DEFAULT '0' COMMENT '最大线程数',\n `ddosProtection` json DEFAULT NULL COMMENT 'DDOS配置',\n `dnsRoutes` json DEFAULT NULL COMMENT 'DNS线路设置',\n `maxCacheDiskCapacity` json DEFAULT NULL COMMENT '硬盘缓存容量',\n `maxCacheMemoryCapacity` json DEFAULT NULL COMMENT '内存缓存容量',\n `cacheDiskDir` varchar(255) DEFAULT NULL COMMENT '主缓存目录',\n `cacheDiskSubDirs` json DEFAULT NULL COMMENT '其他缓存目录',\n `dnsResolver` json DEFAULT NULL COMMENT 'DNS解析器',\n `enableIPLists` tinyint(1) unsigned DEFAULT '1' COMMENT '启用IP名单',\n `apiNodeAddrs` json DEFAULT NULL COMMENT 'API节点地址',\n `offlineDay` varchar(8) DEFAULT NULL COMMENT '下线日期YYYYMMDD',\n `offlineIsNotified` tinyint(1) unsigned DEFAULT '0' COMMENT '下线是否已通知',\n `isBackupForCluster` tinyint(1) unsigned DEFAULT '0' COMMENT '是否为集群备用节点',\n `isBackupForGroup` tinyint(1) unsigned DEFAULT '0' COMMENT '是否为分组备用节点',\n `backupIPs` json DEFAULT NULL COMMENT '备用IP',\n `actionStatus` json DEFAULT NULL COMMENT '当前动作配置',\n PRIMARY KEY (`id`),\n KEY `uniqueId` (`uniqueId`),\n KEY `clusterId` (`clusterId`),\n KEY `groupId` (`groupId`),\n KEY `regionId` (`regionId`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='节点'", + "definition": "CREATE TABLE `edgeNodes` (\n `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n `adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',\n `userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',\n `level` tinyint(1) unsigned DEFAULT '1' COMMENT '级别',\n `lnAddrs` json DEFAULT NULL COMMENT 'Ln级别访问地址',\n `isOn` tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用',\n `isUp` tinyint(1) unsigned DEFAULT '1' COMMENT '是否在线',\n `countUp` int(11) unsigned DEFAULT '0' COMMENT '连续在线次数',\n `countDown` int(11) unsigned DEFAULT '0' COMMENT '连续下线次数',\n `isActive` tinyint(1) unsigned DEFAULT '1' COMMENT '是否活跃',\n `inactiveNotifiedAt` bigint(11) unsigned DEFAULT '0' COMMENT '离线通知时间',\n `uniqueId` varchar(32) DEFAULT NULL COMMENT '节点ID',\n `secret` varchar(32) DEFAULT NULL COMMENT '密钥',\n `name` varchar(255) DEFAULT NULL COMMENT '节点名',\n `code` varchar(255) DEFAULT NULL COMMENT '代号',\n `clusterId` int(11) unsigned DEFAULT '0' COMMENT '主集群ID',\n `secondaryClusterIds` json DEFAULT NULL COMMENT '从集群ID',\n `regionId` int(11) unsigned DEFAULT '0' COMMENT '区域ID',\n `groupId` int(11) unsigned DEFAULT '0' COMMENT '分组ID',\n `createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',\n `status` json DEFAULT NULL COMMENT '最新的状态',\n `version` int(11) unsigned DEFAULT '0' COMMENT '当前版本号',\n `latestVersion` int(11) unsigned DEFAULT '0' COMMENT '最后版本号',\n `installDir` varchar(512) DEFAULT NULL COMMENT '安装目录',\n `isInstalled` tinyint(1) unsigned DEFAULT '0' COMMENT '是否已安装',\n `installStatus` json DEFAULT NULL COMMENT '安装状态',\n `state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',\n `connectedAPINodes` json DEFAULT NULL COMMENT '当前连接的API节点',\n `maxCPU` int(4) unsigned DEFAULT '0' COMMENT '可以使用的最多CPU',\n `maxThreads` int(11) unsigned DEFAULT '0' COMMENT '最大线程数',\n `ddosProtection` json DEFAULT NULL COMMENT 'DDOS配置',\n `dnsRoutes` json DEFAULT NULL COMMENT 'DNS线路设置',\n `maxCacheDiskCapacity` json DEFAULT NULL COMMENT '硬盘缓存容量',\n `maxCacheMemoryCapacity` json DEFAULT NULL COMMENT '内存缓存容量',\n `cacheDiskDir` varchar(255) DEFAULT NULL COMMENT '主缓存目录',\n `cacheDiskSubDirs` json DEFAULT NULL COMMENT '其他缓存目录',\n `dnsResolver` json DEFAULT NULL COMMENT 'DNS解析器',\n `enableIPLists` tinyint(1) unsigned DEFAULT '1' COMMENT '启用IP名单',\n `apiNodeAddrs` json DEFAULT NULL COMMENT 'API节点地址',\n `offlineDay` varchar(8) DEFAULT NULL COMMENT '下线日期YYYYMMDD',\n `offlineIsNotified` tinyint(1) unsigned DEFAULT '0' COMMENT '下线是否已通知',\n `isBackupForCluster` tinyint(1) unsigned DEFAULT '0' COMMENT '是否为集群备用节点',\n `isBackupForGroup` tinyint(1) unsigned DEFAULT '0' COMMENT '是否为分组备用节点',\n `backupIPs` json DEFAULT NULL COMMENT '备用IP',\n `actionStatus` json DEFAULT NULL COMMENT '当前动作配置',\n `bypassMobile` int(4) unsigned DEFAULT '0' COMMENT '是否过移动',\n PRIMARY KEY (`id`),\n KEY `uniqueId` (`uniqueId`),\n KEY `clusterId` (`clusterId`),\n KEY `groupId` (`groupId`),\n KEY `regionId` (`regionId`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='节点'", "fields": [ { "name": "id", @@ -122274,6 +122286,10 @@ { "name": "actionStatus", "definition": "json COMMENT '当前动作配置'" + }, + { + "name": "bypassMobile", + "definition": "int(4) unsigned DEFAULT '0' COMMENT '是否过移动'" } ], "indexes": [ diff --git a/internal/setup/sql_dump.go b/internal/setup/sql_dump.go index 124ca94b..65054277 100644 --- a/internal/setup/sql_dump.go +++ b/internal/setup/sql_dump.go @@ -3,17 +3,18 @@ package setup import ( "errors" "fmt" - "github.com/go-sql-driver/mysql" - "github.com/iwind/TeaGo/dbs" - "github.com/iwind/TeaGo/lists" - "github.com/iwind/TeaGo/maps" - "github.com/iwind/TeaGo/types" "io" "regexp" "runtime" "sort" "strings" "sync" + + "github.com/go-sql-driver/mysql" + "github.com/iwind/TeaGo/dbs" + "github.com/iwind/TeaGo/lists" + "github.com/iwind/TeaGo/maps" + "github.com/iwind/TeaGo/types" ) var recordsTables = []*SQLRecordsTable{ diff --git a/internal/setup/sql_dump_test.go b/internal/setup/sql_dump_test.go index e28faee7..1c8d130b 100644 --- a/internal/setup/sql_dump_test.go +++ b/internal/setup/sql_dump_test.go @@ -2,9 +2,10 @@ package setup import ( "encoding/json" - "github.com/iwind/TeaGo/dbs" "testing" "time" + + "github.com/iwind/TeaGo/dbs" ) func TestSQLDump_Dump(t *testing.T) { diff --git a/internal/setup/sql_executor.go b/internal/setup/sql_executor.go index f2ba6d2a..fb1f7a72 100644 --- a/internal/setup/sql_executor.go +++ b/internal/setup/sql_executor.go @@ -4,6 +4,9 @@ import ( "crypto/rand" "encoding/json" "fmt" + "io" + "time" + "github.com/TeaOSLab/EdgeAPI/internal/configs" "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeCommon/pkg/dnsconfigs" @@ -15,8 +18,6 @@ import ( "github.com/iwind/TeaGo/rands" "github.com/iwind/TeaGo/types" stringutil "github.com/iwind/TeaGo/utils/string" - "io" - "time" ) // SQLExecutor 安装或升级SQL执行器 @@ -53,7 +54,7 @@ func (this *SQLExecutor) Run(showLog bool) error { // prevent default configure loading var globalConfig = dbs.GlobalConfig() if globalConfig != nil && len(globalConfig.DBs) == 0 { - globalConfig.DBs = map[string]*dbs.DBConfig{"prod": this.dbConfig} + globalConfig.DBs = map[string]*dbs.DBConfig{Tea.Env: this.dbConfig} } defer func() { diff --git a/internal/setup/sql_executor_ext.go b/internal/setup/sql_executor_ext.go index 79f9ce15..29e0f875 100644 --- a/internal/setup/sql_executor_ext.go +++ b/internal/setup/sql_executor_ext.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . //go:build !plus package setup diff --git a/internal/setup/sql_executor_test.go b/internal/setup/sql_executor_test.go index 45505aa0..2559914e 100644 --- a/internal/setup/sql_executor_test.go +++ b/internal/setup/sql_executor_test.go @@ -1,8 +1,9 @@ package setup import ( - "github.com/iwind/TeaGo/dbs" "testing" + + "github.com/iwind/TeaGo/dbs" ) func TestSQLExecutor_Run(t *testing.T) { diff --git a/internal/setup/sql_upgrade.go b/internal/setup/sql_upgrade.go index 8a43bfc2..b6a8ddcb 100644 --- a/internal/setup/sql_upgrade.go +++ b/internal/setup/sql_upgrade.go @@ -2,6 +2,9 @@ package setup import ( "encoding/json" + "strconv" + "strings" + "github.com/TeaOSLab/EdgeAPI/internal/acme" "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/db/models/stats" @@ -16,8 +19,6 @@ import ( "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/rands" "github.com/iwind/TeaGo/types" - "strconv" - "strings" ) type upgradeVersion struct { diff --git a/internal/setup/sql_upgrade_ext.go b/internal/setup/sql_upgrade_ext.go index c611c7dd..3cbca487 100644 --- a/internal/setup/sql_upgrade_ext.go +++ b/internal/setup/sql_upgrade_ext.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . //go:build !plus package setup @@ -6,13 +6,14 @@ package setup import ( "encoding/json" "fmt" + "regexp" + "github.com/TeaOSLab/EdgeCommon/pkg/dnsconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/systemconfigs" "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/types" timeutil "github.com/iwind/TeaGo/utils/time" - "regexp" ) // v0.2.8.1 diff --git a/internal/setup/sql_upgrade_ext_test.go b/internal/setup/sql_upgrade_ext_test.go index 69ec33b5..b1a1a761 100644 --- a/internal/setup/sql_upgrade_ext_test.go +++ b/internal/setup/sql_upgrade_ext_test.go @@ -1,11 +1,12 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . //go:build !plus package setup import ( - "github.com/iwind/TeaGo/dbs" "testing" + + "github.com/iwind/TeaGo/dbs" ) func TestUpgradeSQLData_v0_5_6(t *testing.T) { @@ -28,7 +29,6 @@ func TestUpgradeSQLData_v0_5_6(t *testing.T) { t.Log("ok") } - func TestUpgradeSQLData_v1_3_4(t *testing.T) { db, err := dbs.NewInstanceFromConfig(&dbs.DBConfig{ Driver: "mysql", @@ -48,5 +48,3 @@ func TestUpgradeSQLData_v1_3_4(t *testing.T) { } t.Log("ok") } - - diff --git a/internal/setup/sql_upgrade_test.go b/internal/setup/sql_upgrade_test.go index 2f52ccba..c8a46c8d 100644 --- a/internal/setup/sql_upgrade_test.go +++ b/internal/setup/sql_upgrade_test.go @@ -1,8 +1,9 @@ package setup import ( - "github.com/iwind/TeaGo/dbs" "testing" + + "github.com/iwind/TeaGo/dbs" ) func TestUpgradeSQLData(t *testing.T) { diff --git a/internal/setup/utils.go b/internal/setup/utils.go index fabbd37e..4aea656e 100644 --- a/internal/setup/utils.go +++ b/internal/setup/utils.go @@ -3,10 +3,11 @@ package setup import ( + "strings" + teaconst "github.com/TeaOSLab/EdgeAPI/internal/const" "github.com/iwind/TeaGo/types" stringutil "github.com/iwind/TeaGo/utils/string" - "strings" ) // ComposeSQLVersion 组合SQL的版本号 diff --git a/internal/setup/utils_test.go b/internal/setup/utils_test.go index 6b396038..99630c81 100644 --- a/internal/setup/utils_test.go +++ b/internal/setup/utils_test.go @@ -3,9 +3,10 @@ package setup_test import ( + "testing" + "github.com/TeaOSLab/EdgeAPI/internal/setup" "github.com/iwind/TeaGo/assert" - "testing" ) func TestComposeSQLVersion(t *testing.T) { diff --git a/internal/tasks/dns_task_executor.go b/internal/tasks/dns_task_executor.go index fed1f052..a6004f2c 100644 --- a/internal/tasks/dns_task_executor.go +++ b/internal/tasks/dns_task_executor.go @@ -2,6 +2,10 @@ package tasks import ( "encoding/json" + "net" + "strings" + "time" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" dnsmodels "github.com/TeaOSLab/EdgeAPI/internal/db/models/dns" "github.com/TeaOSLab/EdgeAPI/internal/dnsclients" @@ -12,9 +16,6 @@ import ( "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/lists" - "net" - "strings" - "time" ) func init() { diff --git a/internal/tasks/dns_task_executor_test.go b/internal/tasks/dns_task_executor_test.go index 30fa0643..f9bbc21c 100644 --- a/internal/tasks/dns_task_executor_test.go +++ b/internal/tasks/dns_task_executor_test.go @@ -3,10 +3,11 @@ package tasks_test import ( - "github.com/TeaOSLab/EdgeAPI/internal/tasks" - "github.com/iwind/TeaGo/dbs" "testing" "time" + + "github.com/TeaOSLab/EdgeAPI/internal/tasks" + "github.com/iwind/TeaGo/dbs" ) func TestDNSTaskExecutor_Loop(t *testing.T) { diff --git a/internal/tasks/event_looper.go b/internal/tasks/event_looper.go index 5f3e66d6..a96278ba 100644 --- a/internal/tasks/event_looper.go +++ b/internal/tasks/event_looper.go @@ -1,10 +1,11 @@ package tasks import ( + "time" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/goman" "github.com/iwind/TeaGo/dbs" - "time" ) func init() { diff --git a/internal/tasks/health_check_cluster_task.go b/internal/tasks/health_check_cluster_task.go index 1264699e..8b83d028 100644 --- a/internal/tasks/health_check_cluster_task.go +++ b/internal/tasks/health_check_cluster_task.go @@ -3,6 +3,9 @@ package tasks import ( "bytes" "encoding/json" + "strings" + "time" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/goman" "github.com/TeaOSLab/EdgeAPI/internal/utils" @@ -11,8 +14,6 @@ import ( "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/types" - "strings" - "time" ) // HealthCheckClusterTask 单个集群的健康检查任务 diff --git a/internal/tasks/health_check_cluster_task_test.go b/internal/tasks/health_check_cluster_task_test.go index 68d7ae0a..a99321f3 100644 --- a/internal/tasks/health_check_cluster_task_test.go +++ b/internal/tasks/health_check_cluster_task_test.go @@ -1,9 +1,10 @@ package tasks_test import ( + "testing" + "github.com/TeaOSLab/EdgeAPI/internal/tasks" "github.com/iwind/TeaGo/dbs" - "testing" ) func TestHealthCheckClusterTask_Loop(t *testing.T) { diff --git a/internal/tasks/health_check_executor.go b/internal/tasks/health_check_executor.go index 648ec21b..978b7701 100644 --- a/internal/tasks/health_check_executor.go +++ b/internal/tasks/health_check_executor.go @@ -4,6 +4,13 @@ import ( "context" "crypto/tls" "encoding/json" + "net" + "net/http" + "strconv" + "strings" + "sync" + "time" + teaconst "github.com/TeaOSLab/EdgeAPI/internal/const" "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/errors" @@ -17,12 +24,6 @@ import ( "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/types" timeutil "github.com/iwind/TeaGo/utils/time" - "net" - "net/http" - "strconv" - "strings" - "sync" - "time" ) type HealthCheckExecutor struct { diff --git a/internal/tasks/health_check_executor_ext.go b/internal/tasks/health_check_executor_ext.go index 432806f1..134f5096 100644 --- a/internal/tasks/health_check_executor_ext.go +++ b/internal/tasks/health_check_executor_ext.go @@ -1,4 +1,4 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . //go:build !plus package tasks diff --git a/internal/tasks/health_check_executor_test.go b/internal/tasks/health_check_executor_test.go index 947b5299..29083420 100644 --- a/internal/tasks/health_check_executor_test.go +++ b/internal/tasks/health_check_executor_test.go @@ -4,10 +4,11 @@ package tasks_test import ( + "testing" + teaconst "github.com/TeaOSLab/EdgeAPI/internal/const" "github.com/TeaOSLab/EdgeAPI/internal/tasks" "github.com/iwind/TeaGo/dbs" - "testing" ) func TestHealthCheckExecutor_Run(t *testing.T) { diff --git a/internal/tasks/health_check_task.go b/internal/tasks/health_check_task.go index fb163611..08b6163e 100644 --- a/internal/tasks/health_check_task.go +++ b/internal/tasks/health_check_task.go @@ -3,6 +3,8 @@ package tasks import ( "bytes" "encoding/json" + "time" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/goman" "github.com/TeaOSLab/EdgeAPI/internal/remotelogs" @@ -10,7 +12,6 @@ import ( "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/lists" - "time" ) func init() { diff --git a/internal/tasks/health_check_task_test.go b/internal/tasks/health_check_task_test.go index 1c60e896..4df95f7d 100644 --- a/internal/tasks/health_check_task_test.go +++ b/internal/tasks/health_check_task_test.go @@ -1,11 +1,12 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package tasks_test import ( - "github.com/TeaOSLab/EdgeAPI/internal/tasks" "testing" "time" + + "github.com/TeaOSLab/EdgeAPI/internal/tasks" ) func TestNewHealthCheckTask(t *testing.T) { diff --git a/internal/tasks/log_task.go b/internal/tasks/log_task.go index dab2d10a..4de106c7 100644 --- a/internal/tasks/log_task.go +++ b/internal/tasks/log_task.go @@ -3,12 +3,13 @@ package tasks import ( "encoding/json" "fmt" + "time" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/goman" "github.com/TeaOSLab/EdgeAPI/internal/utils/numberutils" "github.com/TeaOSLab/EdgeCommon/pkg/systemconfigs" "github.com/iwind/TeaGo/dbs" - "time" ) func init() { diff --git a/internal/tasks/log_task_test.go b/internal/tasks/log_task_test.go index 590df6ca..b162a3f9 100644 --- a/internal/tasks/log_task_test.go +++ b/internal/tasks/log_task_test.go @@ -1,10 +1,11 @@ package tasks_test import ( - "github.com/TeaOSLab/EdgeAPI/internal/tasks" - "github.com/iwind/TeaGo/dbs" "testing" "time" + + "github.com/TeaOSLab/EdgeAPI/internal/tasks" + "github.com/iwind/TeaGo/dbs" ) func TestLogTask_LoopClean(t *testing.T) { diff --git a/internal/tasks/message_task.go b/internal/tasks/message_task.go index fabdbbc5..a81bd2c0 100644 --- a/internal/tasks/message_task.go +++ b/internal/tasks/message_task.go @@ -1,10 +1,11 @@ package tasks import ( + "time" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/goman" "github.com/iwind/TeaGo/dbs" - "time" ) func init() { diff --git a/internal/tasks/monitor_item_value_task.go b/internal/tasks/monitor_item_value_task.go index b387d1d2..2f55f5f4 100644 --- a/internal/tasks/monitor_item_value_task.go +++ b/internal/tasks/monitor_item_value_task.go @@ -3,11 +3,12 @@ package tasks import ( + "time" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/goman" "github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/dbs" - "time" ) func init() { diff --git a/internal/tasks/monitor_item_value_task_test.go b/internal/tasks/monitor_item_value_task_test.go index 1bd00683..1ae407dd 100644 --- a/internal/tasks/monitor_item_value_task_test.go +++ b/internal/tasks/monitor_item_value_task_test.go @@ -3,10 +3,11 @@ package tasks_test import ( - "github.com/TeaOSLab/EdgeAPI/internal/tasks" - "github.com/iwind/TeaGo/dbs" "testing" "time" + + "github.com/TeaOSLab/EdgeAPI/internal/tasks" + "github.com/iwind/TeaGo/dbs" ) func TestMonitorItemValueTask_Loop(t *testing.T) { diff --git a/internal/tasks/node_log_cleaner_task.go b/internal/tasks/node_log_cleaner_task.go index a4c954d1..62a716aa 100644 --- a/internal/tasks/node_log_cleaner_task.go +++ b/internal/tasks/node_log_cleaner_task.go @@ -1,10 +1,11 @@ package tasks import ( + "time" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/goman" "github.com/iwind/TeaGo/dbs" - "time" ) func init() { diff --git a/internal/tasks/node_log_cleaner_task_test.go b/internal/tasks/node_log_cleaner_task_test.go index 84f29313..23cd6721 100644 --- a/internal/tasks/node_log_cleaner_task_test.go +++ b/internal/tasks/node_log_cleaner_task_test.go @@ -1,10 +1,11 @@ package tasks_test import ( - "github.com/TeaOSLab/EdgeAPI/internal/tasks" - "github.com/iwind/TeaGo/dbs" "testing" "time" + + "github.com/TeaOSLab/EdgeAPI/internal/tasks" + "github.com/iwind/TeaGo/dbs" ) func TestNodeLogCleaner_loop(t *testing.T) { diff --git a/internal/tasks/node_monitor_task.go b/internal/tasks/node_monitor_task.go index 91a33527..15dd720d 100644 --- a/internal/tasks/node_monitor_task.go +++ b/internal/tasks/node_monitor_task.go @@ -1,14 +1,15 @@ package tasks import ( + "strings" + "time" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/goman" "github.com/TeaOSLab/EdgeAPI/internal/installers" "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" "github.com/iwind/TeaGo/dbs" "github.com/iwind/TeaGo/types" - "strings" - "time" ) func init() { diff --git a/internal/tasks/node_monitor_task_test.go b/internal/tasks/node_monitor_task_test.go index 55093801..070d5442 100644 --- a/internal/tasks/node_monitor_task_test.go +++ b/internal/tasks/node_monitor_task_test.go @@ -1,11 +1,12 @@ package tasks_test import ( + "testing" + "time" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/tasks" "github.com/iwind/TeaGo/dbs" - "testing" - "time" ) func TestNodeMonitorTask_loop(t *testing.T) { diff --git a/internal/tasks/node_task_extractor.go b/internal/tasks/node_task_extractor.go index 99b65672..b34c7926 100644 --- a/internal/tasks/node_task_extractor.go +++ b/internal/tasks/node_task_extractor.go @@ -1,11 +1,12 @@ package tasks import ( + "time" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/goman" "github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs" "github.com/iwind/TeaGo/dbs" - "time" ) func init() { diff --git a/internal/tasks/server_access_log_cleaner.go b/internal/tasks/server_access_log_cleaner.go index 9f6681ca..fd2ca332 100644 --- a/internal/tasks/server_access_log_cleaner.go +++ b/internal/tasks/server_access_log_cleaner.go @@ -2,15 +2,16 @@ package tasks import ( "encoding/json" + "regexp" + "strings" + "time" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeAPI/internal/goman" "github.com/TeaOSLab/EdgeCommon/pkg/systemconfigs" "github.com/iwind/TeaGo/dbs" timeutil "github.com/iwind/TeaGo/utils/time" - "regexp" - "strings" - "time" ) func init() { diff --git a/internal/tasks/server_access_log_cleaner_test.go b/internal/tasks/server_access_log_cleaner_test.go index 1016609c..6c8beaea 100644 --- a/internal/tasks/server_access_log_cleaner_test.go +++ b/internal/tasks/server_access_log_cleaner_test.go @@ -1,10 +1,11 @@ package tasks_test import ( - "github.com/TeaOSLab/EdgeAPI/internal/tasks" - "github.com/iwind/TeaGo/dbs" "testing" "time" + + "github.com/TeaOSLab/EdgeAPI/internal/tasks" + "github.com/iwind/TeaGo/dbs" ) func TestServerAccessLogCleaner_Loop(t *testing.T) { diff --git a/internal/tasks/ssl_cert_expire_check_executor.go b/internal/tasks/ssl_cert_expire_check_executor.go index 6646060c..a4424700 100644 --- a/internal/tasks/ssl_cert_expire_check_executor.go +++ b/internal/tasks/ssl_cert_expire_check_executor.go @@ -2,6 +2,10 @@ package tasks import ( "encoding/json" + "strconv" + "strings" + "time" + "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/db/models/acme" "github.com/TeaOSLab/EdgeAPI/internal/goman" @@ -9,9 +13,6 @@ import ( "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/types" timeutil "github.com/iwind/TeaGo/utils/time" - "strconv" - "strings" - "time" ) func init() { diff --git a/internal/tasks/ssl_cert_expire_check_executor_test.go b/internal/tasks/ssl_cert_expire_check_executor_test.go index 581ad612..56aacaa7 100644 --- a/internal/tasks/ssl_cert_expire_check_executor_test.go +++ b/internal/tasks/ssl_cert_expire_check_executor_test.go @@ -1,11 +1,12 @@ package tasks_test import ( + "testing" + "time" + "github.com/TeaOSLab/EdgeAPI/internal/tasks" "github.com/iwind/TeaGo/dbs" timeutil "github.com/iwind/TeaGo/utils/time" - "testing" - "time" ) func TestSSLCertExpireCheckExecutor_loop(t *testing.T) { diff --git a/internal/tasks/ssl_cert_issue_executor.go b/internal/tasks/ssl_cert_issue_executor.go new file mode 100644 index 00000000..8f9f728b --- /dev/null +++ b/internal/tasks/ssl_cert_issue_executor.go @@ -0,0 +1,121 @@ +package tasks + +import ( + "github.com/TeaOSLab/EdgeAPI/internal/db/models/acme" + "github.com/TeaOSLab/EdgeAPI/internal/goman" + "github.com/iwind/TeaGo/dbs" + "github.com/iwind/TeaGo/logs" + "sync" + "time" +) + +func init() { + dbs.OnReadyDone(func() { + goman.New(func() { + NewSSLCertIssueExecutor(5 * time.Second).Start() + }) + }) +} + +// SSLCertIssueExecutor 证书签发任务 +type SSLCertIssueExecutor struct { + BaseTask + ticker *time.Ticker +} + +func NewSSLCertIssueExecutor(duration time.Duration) *SSLCertIssueExecutor { + return &SSLCertIssueExecutor{ + ticker: time.NewTicker(duration), + } +} + +// Start 启动任务 +func (this *SSLCertIssueExecutor) Start() { + for range this.ticker.C { + err := this.Loop() + if err != nil { + this.logErr("SSLCertExpireCheckExecutor", err.Error()) + } + } +} + +var ( + concurrent = 10 + mutex sync.Mutex + queue = make(chan *acme.ACMETask, 10) + runningTaskIds = make(map[int64]bool) +) + +func taskConsumer(wg *sync.WaitGroup) { + defer wg.Done() + for task := range queue { + mutex.Lock() + runningTaskIds[int64(task.Id)] = true + mutex.Unlock() + + go func(t *acme.ACMETask) { + defer func() { + mutex.Lock() + delete(runningTaskIds, int64(t.Id)) + mutex.Unlock() + }() + + ok, errMsg := acme.SharedACMETaskDAO.RunTaskAndAutoBindServer(nil, int64(t.Id), t.DecodeDomains()) + if !ok { + logs.Printf(errMsg) + } + }(task) + } +} + +func taskProducer(wg *sync.WaitGroup) { + defer wg.Done() + + for { + time.Sleep(2 * time.Second) + if len(runningTaskIds) < concurrent { + excludeTasks := make([]int64, 0, len(runningTaskIds)) + for k := range runningTaskIds { + excludeTasks = append(excludeTasks, k) + } + tasks, err := acme.SharedACMETaskDAO.FindIssueACMETask(nil, 2, int64(concurrent-len(runningTaskIds)), excludeTasks) + if err != nil { + logs.Printf("Failed to find tasks from database, %v", err) + continue + } + if len(tasks) == 0 { + continue + } + + for _, task := range tasks { + queue <- task + } + } + } +} + +// Loop 单次执行 +func (this *SSLCertIssueExecutor) Loop() error { + // 检查是否为主节点 + if !this.IsPrimaryNode() { + return nil + } + var queue = make(chan *acme.ACMETask, concurrent) + tasks, err := acme.SharedACMETaskDAO.FindIssueACMETask(nil, 2, int64(concurrent), nil) + if err != nil { + return err + } + if len(tasks) == 0 { + return nil + } + for _, task := range tasks { + queue <- task + } + + var wg sync.WaitGroup + wg.Add(2) + go taskConsumer(&wg) + go taskProducer(&wg) + wg.Wait() + return nil +} diff --git a/internal/tasks/ssl_cert_update_ocsp_task.go b/internal/tasks/ssl_cert_update_ocsp_task.go index db2b8450..d15fd980 100644 --- a/internal/tasks/ssl_cert_update_ocsp_task.go +++ b/internal/tasks/ssl_cert_update_ocsp_task.go @@ -9,6 +9,10 @@ import ( "crypto/x509" "errors" "fmt" + "io" + "net/http" + "time" + teaconst "github.com/TeaOSLab/EdgeAPI/internal/const" "github.com/TeaOSLab/EdgeAPI/internal/db/models" "github.com/TeaOSLab/EdgeAPI/internal/goman" @@ -16,9 +20,6 @@ import ( "github.com/TeaOSLab/EdgeAPI/internal/utils" "github.com/iwind/TeaGo/dbs" "golang.org/x/crypto/ocsp" - "io" - "net/http" - "time" ) func init() { diff --git a/internal/tasks/ssl_cert_update_ocsp_task_test.go b/internal/tasks/ssl_cert_update_ocsp_task_test.go index dff185bf..12bdc4b9 100644 --- a/internal/tasks/ssl_cert_update_ocsp_task_test.go +++ b/internal/tasks/ssl_cert_update_ocsp_task_test.go @@ -3,10 +3,11 @@ package tasks_test import ( - "github.com/TeaOSLab/EdgeAPI/internal/tasks" - "github.com/iwind/TeaGo/dbs" "testing" "time" + + "github.com/TeaOSLab/EdgeAPI/internal/tasks" + "github.com/iwind/TeaGo/dbs" ) func TestSSLCertUpdateOCSPTask_Loop(t *testing.T) { diff --git a/internal/tasks/task_base.go b/internal/tasks/task_base.go index 3f3f59ff..638310a0 100644 --- a/internal/tasks/task_base.go +++ b/internal/tasks/task_base.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package tasks diff --git a/internal/tasks/task_interface.go b/internal/tasks/task_interface.go index eaedadc1..d945db90 100644 --- a/internal/tasks/task_interface.go +++ b/internal/tasks/task_interface.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package tasks diff --git a/internal/utils/cache_map.go b/internal/utils/cache_map.go index 1c0dfb0d..40331284 100644 --- a/internal/utils/cache_map.go +++ b/internal/utils/cache_map.go @@ -3,8 +3,9 @@ package utils import ( - "github.com/iwind/TeaGo/maps" "sync" + + "github.com/iwind/TeaGo/maps" ) type CacheMap struct { diff --git a/internal/utils/cache_map_test.go b/internal/utils/cache_map_test.go index 8a0e3f95..2b5461e7 100644 --- a/internal/utils/cache_map_test.go +++ b/internal/utils/cache_map_test.go @@ -3,8 +3,9 @@ package utils import ( - "github.com/iwind/TeaGo/assert" "testing" + + "github.com/iwind/TeaGo/assert" ) func TestNewCacheMap(t *testing.T) { diff --git a/internal/utils/compare.go b/internal/utils/compare.go index 1e166548..10596631 100644 --- a/internal/utils/compare.go +++ b/internal/utils/compare.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package utils diff --git a/internal/utils/compare_test.go b/internal/utils/compare_test.go index f60454e5..5ff45957 100644 --- a/internal/utils/compare_test.go +++ b/internal/utils/compare_test.go @@ -1,10 +1,11 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package utils_test import ( - "github.com/TeaOSLab/EdgeAPI/internal/utils" "testing" + + "github.com/TeaOSLab/EdgeAPI/internal/utils" ) func TestEqualConfig(t *testing.T) { diff --git a/internal/utils/domain.go b/internal/utils/domain.go index 07b6c7d1..f0786cc5 100644 --- a/internal/utils/domain.go +++ b/internal/utils/domain.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package utils diff --git a/internal/utils/domainutils/utils.go b/internal/utils/domainutils/utils.go index 65f44c2c..741287cd 100644 --- a/internal/utils/domainutils/utils.go +++ b/internal/utils/domainutils/utils.go @@ -1,4 +1,4 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package domainutils @@ -14,7 +14,7 @@ func ValidateDomainFormat(domain string) bool { if piece == "-" || strings.HasPrefix(piece, "-") || strings.HasSuffix(piece, "-") || - //strings.Contains(piece, "--") || + // strings.Contains(piece, "--") || len(piece) > 63 || // 支持中文、大写字母、下划线 !regexp.MustCompile(`^[\p{Han}_a-zA-Z0-9-]+$`).MatchString(piece) { diff --git a/internal/utils/email.go b/internal/utils/email.go index acbd12fc..4afabdfc 100644 --- a/internal/utils/email.go +++ b/internal/utils/email.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package utils diff --git a/internal/utils/email_test.go b/internal/utils/email_test.go index f51f239d..934f81b2 100644 --- a/internal/utils/email_test.go +++ b/internal/utils/email_test.go @@ -1,11 +1,12 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package utils_test import ( + "testing" + "github.com/TeaOSLab/EdgeAPI/internal/utils" "github.com/iwind/TeaGo/assert" - "testing" ) func TestValidateEmail(t *testing.T) { diff --git a/internal/utils/exec/cmd.go b/internal/utils/exec/cmd.go index 997bdf1b..afbd7972 100644 --- a/internal/utils/exec/cmd.go +++ b/internal/utils/exec/cmd.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package executils diff --git a/internal/utils/exec/cmd_test.go b/internal/utils/exec/cmd_test.go index 8f0ea363..676f100c 100644 --- a/internal/utils/exec/cmd_test.go +++ b/internal/utils/exec/cmd_test.go @@ -1,11 +1,12 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package executils_test import ( - executils "github.com/TeaOSLab/EdgeAPI/internal/utils/exec" "testing" "time" + + executils "github.com/TeaOSLab/EdgeAPI/internal/utils/exec" ) func TestNewTimeoutCmd_Sleep(t *testing.T) { diff --git a/internal/utils/exec/look_linux.go b/internal/utils/exec/look_linux.go index 9b158350..fecff41e 100644 --- a/internal/utils/exec/look_linux.go +++ b/internal/utils/exec/look_linux.go @@ -1,14 +1,15 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . //go:build linux package executils import ( - "golang.org/x/sys/unix" "io/fs" "os" "os/exec" "syscall" + + "golang.org/x/sys/unix" ) // LookPath customize our LookPath() function, to work in broken $PATH environment variable @@ -56,4 +57,3 @@ func LookPath(file string) (string, error) { Err: exec.ErrNotFound, } } - diff --git a/internal/utils/exec/look_others.go b/internal/utils/exec/look_others.go index a759c8ef..38c7e943 100644 --- a/internal/utils/exec/look_others.go +++ b/internal/utils/exec/look_others.go @@ -1,4 +1,4 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . //go:build !linux package executils diff --git a/internal/utils/expires/id_key_map_test.go b/internal/utils/expires/id_key_map_test.go index 589dd88b..b6978840 100644 --- a/internal/utils/expires/id_key_map_test.go +++ b/internal/utils/expires/id_key_map_test.go @@ -3,9 +3,10 @@ package expires import ( + "testing" + "github.com/iwind/TeaGo/assert" "github.com/iwind/TeaGo/logs" - "testing" ) func TestNewIdKeyMap(t *testing.T) { diff --git a/internal/utils/expires/list.go b/internal/utils/expires/list.go index 6b5b6430..14b7c770 100644 --- a/internal/utils/expires/list.go +++ b/internal/utils/expires/list.go @@ -1,8 +1,9 @@ package expires import ( - "github.com/TeaOSLab/EdgeAPI/internal/zero" "sync" + + "github.com/TeaOSLab/EdgeAPI/internal/zero" ) type ItemMap = map[uint64]zero.Zero diff --git a/internal/utils/expires/list_test.go b/internal/utils/expires/list_test.go index 14ee5a52..a78c81bb 100644 --- a/internal/utils/expires/list_test.go +++ b/internal/utils/expires/list_test.go @@ -1,14 +1,15 @@ package expires import ( - "github.com/TeaOSLab/EdgeAPI/internal/utils" - "github.com/iwind/TeaGo/assert" - "github.com/iwind/TeaGo/logs" - timeutil "github.com/iwind/TeaGo/utils/time" "math" "runtime" "testing" "time" + + "github.com/TeaOSLab/EdgeAPI/internal/utils" + "github.com/iwind/TeaGo/assert" + "github.com/iwind/TeaGo/logs" + timeutil "github.com/iwind/TeaGo/utils/time" ) func TestList_Add(t *testing.T) { diff --git a/internal/utils/expires/manager.go b/internal/utils/expires/manager.go index 9214772d..70e1a2b8 100644 --- a/internal/utils/expires/manager.go +++ b/internal/utils/expires/manager.go @@ -3,10 +3,11 @@ package expires import ( - "github.com/TeaOSLab/EdgeAPI/internal/goman" - "github.com/TeaOSLab/EdgeAPI/internal/zero" "sync" "time" + + "github.com/TeaOSLab/EdgeAPI/internal/goman" + "github.com/TeaOSLab/EdgeAPI/internal/zero" ) var SharedManager = NewManager() diff --git a/internal/utils/firewall.go b/internal/utils/firewall.go index 8d231e49..7d6fd0fd 100644 --- a/internal/utils/firewall.go +++ b/internal/utils/firewall.go @@ -1,13 +1,14 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package utils import ( + "os/exec" + "runtime" + "github.com/TeaOSLab/EdgeAPI/internal/remotelogs" executils "github.com/TeaOSLab/EdgeAPI/internal/utils/exec" "github.com/iwind/TeaGo/types" - "os/exec" - "runtime" ) func AddPortsToFirewall(ports []int) { diff --git a/internal/utils/json.go b/internal/utils/json.go index 052604d1..1c35babf 100644 --- a/internal/utils/json.go +++ b/internal/utils/json.go @@ -1,4 +1,4 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package utils diff --git a/internal/utils/json_test.go b/internal/utils/json_test.go index fcbd652f..fc788069 100644 --- a/internal/utils/json_test.go +++ b/internal/utils/json_test.go @@ -1,12 +1,13 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package utils_test import ( "errors" + "testing" + "github.com/TeaOSLab/EdgeAPI/internal/utils" "github.com/iwind/TeaGo/logs" - "testing" ) func TestJSONClone(t *testing.T) { diff --git a/internal/utils/lookup.go b/internal/utils/lookup.go index a02a509d..2665bac9 100644 --- a/internal/utils/lookup.go +++ b/internal/utils/lookup.go @@ -2,6 +2,8 @@ package utils import ( "errors" + "sync" + teaconst "github.com/TeaOSLab/EdgeAPI/internal/const" "github.com/TeaOSLab/EdgeAPI/internal/utils/taskutils" "github.com/TeaOSLab/EdgeCommon/pkg/configutils" @@ -10,7 +12,6 @@ import ( "github.com/iwind/TeaGo/lists" "github.com/iwind/TeaGo/logs" "github.com/miekg/dns" - "sync" ) var sharedDNSClient *dns.Client diff --git a/internal/utils/lookup_test.go b/internal/utils/lookup_test.go index 94b373d7..d16163a9 100644 --- a/internal/utils/lookup_test.go +++ b/internal/utils/lookup_test.go @@ -3,9 +3,10 @@ package utils_test import ( + "testing" + "github.com/TeaOSLab/EdgeAPI/internal/utils" "github.com/TeaOSLab/EdgeCommon/pkg/dnsconfigs" - "testing" ) func TestLookupCNAME(t *testing.T) { diff --git a/internal/utils/maps/fixed_map.go b/internal/utils/maps/fixed_map.go index 2c46d02c..969d57af 100644 --- a/internal/utils/maps/fixed_map.go +++ b/internal/utils/maps/fixed_map.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package maputils diff --git a/internal/utils/maps/fixed_map_test.go b/internal/utils/maps/fixed_map_test.go index e9f61c9f..3208d6ed 100644 --- a/internal/utils/maps/fixed_map_test.go +++ b/internal/utils/maps/fixed_map_test.go @@ -1,11 +1,12 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package maputils_test import ( + "testing" + maputils "github.com/TeaOSLab/EdgeAPI/internal/utils/maps" "github.com/iwind/TeaGo/assert" - "testing" ) func TestNewFixedMap(t *testing.T) { diff --git a/internal/utils/mobile.go b/internal/utils/mobile.go index 3a9d61da..a72f345a 100644 --- a/internal/utils/mobile.go +++ b/internal/utils/mobile.go @@ -1,4 +1,4 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package utils diff --git a/internal/utils/mobile_test.go b/internal/utils/mobile_test.go index add4bfd4..a8ad6a83 100644 --- a/internal/utils/mobile_test.go +++ b/internal/utils/mobile_test.go @@ -1,11 +1,12 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package utils_test import ( + "testing" + "github.com/TeaOSLab/EdgeAPI/internal/utils" "github.com/iwind/TeaGo/assert" - "testing" ) func TestIsValidMobile(t *testing.T) { diff --git a/internal/utils/numberutils/utils.go b/internal/utils/numberutils/utils.go index 08b1ffbf..fb2db71f 100644 --- a/internal/utils/numberutils/utils.go +++ b/internal/utils/numberutils/utils.go @@ -2,9 +2,10 @@ package numberutils import ( "fmt" - "github.com/iwind/TeaGo/types" "strconv" "strings" + + "github.com/iwind/TeaGo/types" ) func FormatInt64(value int64) string { diff --git a/internal/utils/numberutils/utils_test.go b/internal/utils/numberutils/utils_test.go index 9fa9a823..c84a8cfb 100644 --- a/internal/utils/numberutils/utils_test.go +++ b/internal/utils/numberutils/utils_test.go @@ -1,11 +1,12 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package numberutils_test import ( - "github.com/TeaOSLab/EdgeAPI/internal/utils/numberutils" "math" "testing" + + "github.com/TeaOSLab/EdgeAPI/internal/utils/numberutils" ) func TestMax(t *testing.T) { diff --git a/internal/utils/progress.go b/internal/utils/progress.go index 11737e12..2f3f1568 100644 --- a/internal/utils/progress.go +++ b/internal/utils/progress.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package utils diff --git a/internal/utils/regexputils/expr.go b/internal/utils/regexputils/expr.go index 91aa78dd..addac0b2 100644 --- a/internal/utils/regexputils/expr.go +++ b/internal/utils/regexputils/expr.go @@ -1,4 +1,4 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package regexputils diff --git a/internal/utils/regexputils/expr_test.go b/internal/utils/regexputils/expr_test.go index 1d14d120..9824846d 100644 --- a/internal/utils/regexputils/expr_test.go +++ b/internal/utils/regexputils/expr_test.go @@ -1,11 +1,12 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package regexputils_test import ( + "testing" + "github.com/TeaOSLab/EdgeAPI/internal/utils/regexputils" "github.com/iwind/TeaGo/assert" - "testing" ) func TestExpr(t *testing.T) { diff --git a/internal/utils/service.go b/internal/utils/service.go index 872d182e..526fabe8 100644 --- a/internal/utils/service.go +++ b/internal/utils/service.go @@ -1,14 +1,15 @@ package utils import ( - "github.com/iwind/TeaGo/Tea" - "github.com/iwind/TeaGo/files" - "github.com/iwind/TeaGo/logs" "log" "os" "path/filepath" "runtime" "sync" + + "github.com/iwind/TeaGo/Tea" + "github.com/iwind/TeaGo/files" + "github.com/iwind/TeaGo/logs" ) // 服务管理器 diff --git a/internal/utils/service_linux.go b/internal/utils/service_linux.go index f1f2756a..8dbf5092 100644 --- a/internal/utils/service_linux.go +++ b/internal/utils/service_linux.go @@ -5,13 +5,14 @@ package utils import ( "errors" + "os" + "os/exec" + "regexp" + teaconst "github.com/TeaOSLab/EdgeAPI/internal/const" executils "github.com/TeaOSLab/EdgeAPI/internal/utils/exec" "github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/files" - "os" - "os/exec" - "regexp" ) var systemdServiceFile = "/etc/systemd/system/edge-api.service" diff --git a/internal/utils/service_test.go b/internal/utils/service_test.go index 48907427..5634610c 100644 --- a/internal/utils/service_test.go +++ b/internal/utils/service_test.go @@ -1,8 +1,9 @@ package utils import ( - teaconst "github.com/TeaOSLab/EdgeAPI/internal/const" "testing" + + teaconst "github.com/TeaOSLab/EdgeAPI/internal/const" ) func TestServiceManager_Log(t *testing.T) { diff --git a/internal/utils/service_windows.go b/internal/utils/service_windows.go index 7818476f..f3947727 100644 --- a/internal/utils/service_windows.go +++ b/internal/utils/service_windows.go @@ -5,12 +5,13 @@ package utils import ( "fmt" + "os/exec" + teaconst "github.com/TeaOSLab/EdgeAPI/internal/const" "github.com/iwind/TeaGo/Tea" "golang.org/x/sys/windows" "golang.org/x/sys/windows/svc" "golang.org/x/sys/windows/svc/mgr" - "os/exec" ) // 安装服务 diff --git a/internal/utils/sha1.go b/internal/utils/sha1.go index 1f51629b..f666caa6 100644 --- a/internal/utils/sha1.go +++ b/internal/utils/sha1.go @@ -1,14 +1,15 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package utils import ( "crypto/sha1" "fmt" - "github.com/iwind/TeaGo/rands" - "github.com/iwind/TeaGo/types" "sync/atomic" "time" + + "github.com/iwind/TeaGo/rands" + "github.com/iwind/TeaGo/types" ) const sha1RandomPrefix = "SHA1_RANDOM" diff --git a/internal/utils/sha1_test.go b/internal/utils/sha1_test.go index 8dc074ee..f6d5d4fa 100644 --- a/internal/utils/sha1_test.go +++ b/internal/utils/sha1_test.go @@ -1,11 +1,12 @@ -// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2022 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package utils_test import ( + "testing" + "github.com/TeaOSLab/EdgeAPI/internal/utils" "github.com/iwind/TeaGo/types" - "testing" ) func TestSha1Random(t *testing.T) { diff --git a/internal/utils/sizes/sizes_test.go b/internal/utils/sizes/sizes_test.go index f4e16aa0..cadd094b 100644 --- a/internal/utils/sizes/sizes_test.go +++ b/internal/utils/sizes/sizes_test.go @@ -3,9 +3,10 @@ package sizes_test import ( + "testing" + "github.com/TeaOSLab/EdgeAPI/internal/utils/sizes" "github.com/iwind/TeaGo/assert" - "testing" ) func TestSizes(t *testing.T) { diff --git a/internal/utils/strings.go b/internal/utils/strings.go index 336cf816..d3a9f1d4 100644 --- a/internal/utils/strings.go +++ b/internal/utils/strings.go @@ -3,6 +3,7 @@ package utils import ( + "github.com/iwind/TeaGo/lists" "strings" ) @@ -133,3 +134,12 @@ func parseKeywordValue(value string) (arg splitArg) { } return } + +func ListIsGreaterEqualThanOther(list []string, otherList []string) bool { + for _, v := range otherList { + if !lists.Contains(list, v) { + return false + } + } + return true +} diff --git a/internal/utils/strings_test.go b/internal/utils/strings_test.go index 78562bf8..b92f9e67 100644 --- a/internal/utils/strings_test.go +++ b/internal/utils/strings_test.go @@ -3,9 +3,10 @@ package utils_test import ( + "testing" + "github.com/TeaOSLab/EdgeAPI/internal/utils" "github.com/iwind/TeaGo/assert" - "testing" ) func TestSplitStrings(t *testing.T) { diff --git a/internal/utils/system_test.go b/internal/utils/system_test.go index 71ccbd4a..a22255fb 100644 --- a/internal/utils/system_test.go +++ b/internal/utils/system_test.go @@ -3,8 +3,9 @@ package utils_test import ( - "github.com/TeaOSLab/EdgeAPI/internal/utils" "testing" + + "github.com/TeaOSLab/EdgeAPI/internal/utils" ) func TestSystemMemoryGB(t *testing.T) { diff --git a/internal/utils/taskutils/concurrent.go b/internal/utils/taskutils/concurrent.go index 0806b304..d6ca96b7 100644 --- a/internal/utils/taskutils/concurrent.go +++ b/internal/utils/taskutils/concurrent.go @@ -1,4 +1,4 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package taskutils diff --git a/internal/utils/taskutils/concurrent_test.go b/internal/utils/taskutils/concurrent_test.go index 72bf97a7..f69239a3 100644 --- a/internal/utils/taskutils/concurrent_test.go +++ b/internal/utils/taskutils/concurrent_test.go @@ -1,11 +1,12 @@ -// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . +// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cloud . package taskutils_test import ( - "github.com/TeaOSLab/EdgeAPI/internal/utils/taskutils" "sync" "testing" + + "github.com/TeaOSLab/EdgeAPI/internal/utils/taskutils" ) func TestRunConcurrent(t *testing.T) { diff --git a/internal/utils/testutils/memory.go b/internal/utils/testutils/memory.go index ea619763..9a72b4df 100644 --- a/internal/utils/testutils/memory.go +++ b/internal/utils/testutils/memory.go @@ -4,10 +4,11 @@ package testutils import ( "fmt" - timeutil "github.com/iwind/TeaGo/utils/time" "runtime" "testing" "time" + + timeutil "github.com/iwind/TeaGo/utils/time" ) func StartMemoryStatsGC(t *testing.T) { diff --git a/internal/utils/time.go b/internal/utils/time.go index af54c0b1..5fdca4ff 100644 --- a/internal/utils/time.go +++ b/internal/utils/time.go @@ -2,13 +2,14 @@ package utils import ( "fmt" + "regexp" + "time" + "github.com/TeaOSLab/EdgeAPI/internal/errors" "github.com/TeaOSLab/EdgeAPI/internal/utils/regexputils" "github.com/iwind/TeaGo/lists" "github.com/iwind/TeaGo/types" timeutil "github.com/iwind/TeaGo/utils/time" - "regexp" - "time" ) // 分钟时间点 diff --git a/internal/utils/time_test.go b/internal/utils/time_test.go index fbf001f2..5885abf7 100644 --- a/internal/utils/time_test.go +++ b/internal/utils/time_test.go @@ -1,9 +1,10 @@ package utils_test import ( - "github.com/TeaOSLab/EdgeAPI/internal/utils" "testing" "time" + + "github.com/TeaOSLab/EdgeAPI/internal/utils" ) func TestRangeDays(t *testing.T) { diff --git a/internal/utils/ttlcache/cache.go b/internal/utils/ttlcache/cache.go index a1c7b415..d4cfe395 100644 --- a/internal/utils/ttlcache/cache.go +++ b/internal/utils/ttlcache/cache.go @@ -1,8 +1,9 @@ package ttlcache import ( - "github.com/TeaOSLab/EdgeAPI/internal/utils" "time" + + "github.com/TeaOSLab/EdgeAPI/internal/utils" ) var SharedCache = NewCache() diff --git a/internal/utils/ttlcache/cache_test.go b/internal/utils/ttlcache/cache_test.go index 67e505ab..8c470eec 100644 --- a/internal/utils/ttlcache/cache_test.go +++ b/internal/utils/ttlcache/cache_test.go @@ -1,16 +1,17 @@ package ttlcache import ( - "github.com/TeaOSLab/EdgeAPI/internal/utils" - "github.com/TeaOSLab/EdgeAPI/internal/utils/testutils" - "github.com/iwind/TeaGo/assert" - "github.com/iwind/TeaGo/rands" - "github.com/iwind/TeaGo/types" "runtime" "strconv" "sync/atomic" "testing" "time" + + "github.com/TeaOSLab/EdgeAPI/internal/utils" + "github.com/TeaOSLab/EdgeAPI/internal/utils/testutils" + "github.com/iwind/TeaGo/assert" + "github.com/iwind/TeaGo/rands" + "github.com/iwind/TeaGo/types" ) func TestNewCache(t *testing.T) { diff --git a/internal/utils/ttlcache/manager.go b/internal/utils/ttlcache/manager.go index d830225d..e1fed467 100644 --- a/internal/utils/ttlcache/manager.go +++ b/internal/utils/ttlcache/manager.go @@ -3,10 +3,11 @@ package ttlcache import ( - "github.com/TeaOSLab/EdgeAPI/internal/goman" - "github.com/TeaOSLab/EdgeAPI/internal/zero" "sync" "time" + + "github.com/TeaOSLab/EdgeAPI/internal/goman" + "github.com/TeaOSLab/EdgeAPI/internal/zero" ) var SharedManager = NewManager() diff --git a/internal/utils/ttlcache/piece.go b/internal/utils/ttlcache/piece.go index d42ab141..c0775000 100644 --- a/internal/utils/ttlcache/piece.go +++ b/internal/utils/ttlcache/piece.go @@ -1,11 +1,12 @@ package ttlcache import ( + "sync" + "time" + "github.com/TeaOSLab/EdgeAPI/internal/utils" "github.com/TeaOSLab/EdgeAPI/internal/utils/expires" "github.com/iwind/TeaGo/types" - "sync" - "time" ) type Piece struct { diff --git a/internal/utils/ttlcache/piece_test.go b/internal/utils/ttlcache/piece_test.go index 0ec0ff15..1fae7645 100644 --- a/internal/utils/ttlcache/piece_test.go +++ b/internal/utils/ttlcache/piece_test.go @@ -1,9 +1,10 @@ package ttlcache import ( - "github.com/iwind/TeaGo/rands" "testing" "time" + + "github.com/iwind/TeaGo/rands" ) func TestPiece_Add(t *testing.T) { diff --git a/internal/utils/unix_time.go b/internal/utils/unix_time.go index f5e76831..15a6ea1f 100644 --- a/internal/utils/unix_time.go +++ b/internal/utils/unix_time.go @@ -1,9 +1,10 @@ package utils import ( + "time" + "github.com/TeaOSLab/EdgeAPI/internal/goman" "github.com/iwind/TeaGo/types" - "time" ) var unixTime = time.Now().Unix() diff --git a/internal/utils/unzip_test.go b/internal/utils/unzip_test.go index ed179b32..fd0df694 100644 --- a/internal/utils/unzip_test.go +++ b/internal/utils/unzip_test.go @@ -1,9 +1,10 @@ package utils import ( + "testing" + "github.com/iwind/TeaGo/Tea" _ "github.com/iwind/TeaGo/bootstrap" - "testing" ) func TestUnzip_Run(t *testing.T) {