修改百度API地址

This commit is contained in:
2025-07-23 14:27:02 +08:00
parent bd21381806
commit 1440451f8a
4 changed files with 6 additions and 5 deletions

Binary file not shown.

View File

@@ -121,11 +121,13 @@ int is_ip_in_set(char cn_ip[MAXIPSET_][MAXIPLEN], const char *ip)
if (ip == NULL) {
return 0; // 错误无效的IP地址指针
}
for (int i = 0; i < MAXIPSET_; i++) {
if (cn_ip[i][0] != '\0' && strcmp(cn_ip[i], ip) == 0) {
return 1; // 找到匹配的IP地址
}
}
return 0; // 没有找到匹配的IP地址
}
@@ -145,10 +147,8 @@ int cn_ip_len(char cn_ip[MAXIPSET_][MAXIPLEN])
int truncate_file(const char *path)
{
int fd;
// 以只写模式打开文件并截断到0字节
fd = open(path, O_WRONLY | O_TRUNC);
int fd = open(path, O_WRONLY | O_TRUNC);
if (fd == -1) {
perror("truncate_file: Failed to open file");
return -1;

3
cap.c
View File

@@ -38,7 +38,7 @@ void Processing_IP_addresses(char *src_ip)
// 如果ipset规则已经存在则跳过查询
snprintf(ipset_query_command, sizeof(ipset_query_command), "ipset test %s %s 2>/dev/null", RULE_NAME, src_ip);
if (system(ipset_query_command) == 0) {
_printf(RED "Ipset 规则内已经存在 %s\n" REDEND, src_ip);
//_printf(RED "Ipset 规则内已经存在 %s\n" REDEND, src_ip);
return;
}
@@ -50,6 +50,7 @@ void Processing_IP_addresses(char *src_ip)
printf("%s ", cn_ip[i]);
}
}
if (cn_ip_len(cn_ip) >= 10240) { // 清理集合
clear_ip_set(cn_ip);
truncate_file("cn.txt"); // 清空文件

View File

@@ -98,7 +98,7 @@ char *GetLocalAddr(char *url)
char *CurlGetIpArea(char *ip)
{
char url[256] = { 0 };
snprintf(url, sizeof(url), "https://qifu.baidu.com/ip/geo/v1/district?ip=%s", ip);
snprintf(url, sizeof(url), "https://qifu-api.baidubce.com/ip/geo/v1/district?ip=%s", ip);
CURL *curl_handle;
CURLcode res;