From afc1b2e97e789f1d57f1853143ad5f9837955e93 Mon Sep 17 00:00:00 2001 From: flykhan Date: Thu, 21 Sep 2023 16:15:24 +0800 Subject: [PATCH] =?UTF-8?q?=E9=BB=91=E5=90=8D=E5=8D=95=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E5=A2=9E=E5=8A=A0=E5=88=A0=E9=99=A4=E5=89=8D,=20?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=88=A4=E6=96=AD=E8=A7=84=E5=88=99,=20?= =?UTF-8?q?=E7=9C=8B=E9=BB=91=E5=90=8D=E5=8D=95=E6=95=B0=E6=8D=AE=E5=BA=93?= =?UTF-8?q?=E4=B8=AD=E6=98=AF=E5=90=A6=E5=8F=AF=E4=BB=A5=E6=9F=A5=E5=88=B0?= =?UTF-8?q?=E5=B7=B2=E6=9C=89=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- router/router | Bin 24592 -> 0 bytes router/router.c | 55 ++++++++++++++++++++++++++++++++++++------------ 2 files changed, 41 insertions(+), 14 deletions(-) delete mode 100755 router/router diff --git a/router/router b/router/router deleted file mode 100755 index e6af7f8048ab7a32016adef6b0ef211a9a7273c6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 24592 zcmeHPeRx#WnLkMw2p=Xv5fP}~MbUs}Ou|P&rA$Z$Z(NWRL1`5yA(@a!GKup60fnXv z!Ayr}>emJztl0X&T0dfIA)t^TO0a9Uv3<0(b)QWw2{VE<+7_dWW`FPbxN~PR*L8QF z-M=__a^Lg*&ilUSJ)if?J@=mPIhQO>O-W%Yq_S@@;Q9h9aOO_y?Mpd;`^=u`nC2N9HqL@B>maLA~jx6cx+ zq9_RmNRNE&S-@G)QXWzC7&(McWf<2uPwtUkMCwJPo}yXOe??XKsBHAVLZ+`sb$}z@ zL4+0YYmAaCg_1sh1;yL0;Vh_wM-+Woz)Vr4_igBrpINRs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4g}e~(2H@nlRVZ*O+j+{kq1U4m=fnq#e=e5$xF=j z>(SHm85~=KmxskGd8p9X=}}TT;RR+o-YVXzJejK87Z4|J@zbp0Mbsfx@u;Y?*x_Kw zI|DyeO?YeWYw{qo3GG7(5S8Vjao}hlONLlap`l{wh4Hdt$9Ae0(thTxw zKGgZiJP{zbUVhIwzKKh?>^jr^1d1HO2o>!}Lg4I5evQM(+a2XgZ%?$k& zsSa?lb9gn*#V+c1kwWqiG3)zN9XyH752bLqAjUOOzX&P#a;HwMPuo%*T((UD*K;nm zpQYBr5@t6cLVH(A|9Gkc9K&;UPS`5^4xxbMHm@h8KZ&Dw-U5oB(uTfz?w%_J)&7_i z=QdQF=pFc{y(yKydOp8}oI>ylf+zhVC^<#f0j9k!#jEG|15&?L>XHBCr}AIIY!f0> zr%Jz3?yoh<4aZz5sPb3(s{Gre{vs)-_66FdzS`d-ebPzPzYiGoDe{j8wNEf!uy~Rc z7ZTe)gjBP>+Go(DK7W_hWFbq&6@4f{KTAG;<}c79P5G-#B=V0X=&R>4+619-zNAWD z<*WFgBFsgs6{8c|_gN`|WwLdhtkgQqzuk3sT8MD5z zkK`b2yu(h3rl9l`9YmU0Up?n(E)Yt}Ph~>sDgH}D2vhZ^o_n@Q{kDYsHKiyi?NgA5 z>@G&C(w}1>BBIPGO2b^`Z5Ca4tKh~dL7AAq^1Rj9G3)mf2(D4SXmJVH+4xuGSMwi@ S&t& 0) + { + printf("黑名单中已存在此IP\n"); + continue; + } + // 将IP地址加入黑名单 MYSQL_BIND parmas[1]; parmas[0].buffer_type = MYSQL_TYPE_STRING; @@ -205,7 +217,7 @@ void menu_choice() printf("请输入要删除的黑名单IP:格式如 192.168.6.5\n"); fgets(delete_blacked_ip, sizeof(delete_blacked_ip), stdin); delete_blacked_ip[strlen(delete_blacked_ip) - 1] = '\0'; // 将最后的换行符替换为字符串结束符 - printf("delete_blacked_ip: %s\n", delete_blacked_ip); + // IP 格式检查 if (is_ip_valid(delete_blacked_ip) != 0) { @@ -213,22 +225,37 @@ void menu_choice() continue; } - // 将IP地址从黑名单中删除 - MYSQL_BIND parmas[1]; - parmas[0].buffer_type = MYSQL_TYPE_STRING; - parmas[0].buffer = delete_blacked_ip; - parmas[0].buffer_length = strlen(delete_blacked_ip); - parmas[0].is_null = 0; - parmas[0].length = &parmas[0].buffer_length; - const char *delete_ip_fw_sql = "delete from ip_fw where ip = ?"; - int result = delete (delete_ip_fw_sql, parmas); - if (result > 0) + // 查询数据库黑名单IP表中是否已存在此IP + char search_ip_fw_sql[1024]; + sprintf(search_ip_fw_sql, "select * from ip_fw where ip = '%s'", delete_blacked_ip); + int ret = result_rows(search_ip_fw_sql); + printf("查询结果为%d\n", ret); + + if (ret > 0) { - printf("黑名单删除成功\n"); + printf("delete_blacked_ip: %s\n", delete_blacked_ip); + + // 将IP地址从黑名单中删除 + MYSQL_BIND parmas[1]; + parmas[0].buffer_type = MYSQL_TYPE_STRING; + parmas[0].buffer = delete_blacked_ip; + parmas[0].buffer_length = strlen(delete_blacked_ip); + parmas[0].is_null = 0; + parmas[0].length = &parmas[0].buffer_length; + const char *delete_ip_fw_sql = "delete from ip_fw where ip = ?"; + int result = delete (delete_ip_fw_sql, parmas); + if (result > 0) + { + printf("黑名单删除成功\n"); + } + else + { + printf("黑名单删除失败\n"); + } } else { - printf("黑名单删除失败\n"); + printf("黑名单中不存在此IP\n"); } }