diff --git a/IP_region_query/ipquery b/IP_region_query/ipquery index 15a0f0e..c98a3de 100644 Binary files a/IP_region_query/ipquery and b/IP_region_query/ipquery differ diff --git a/cap.c b/cap.c index 7034296..8dc15da 100644 --- a/cap.c +++ b/cap.c @@ -203,12 +203,13 @@ void usage() puts("MAIL: aixiao@aixiao.me"); puts("Date: 20241024"); puts(" Usage: denyip [-d] [-i ] [-s ] [-h|-?]"); - puts(" -d Daemon mode"); - puts(" -i interface (default eth0)"); - puts(" -s regular signal (default start|stop) "); - puts(" start Enable Iptables rule"); - puts(" stop Disable Iptables rule"); - puts(" -h|-? Help Information"); + puts(" -d --daemon Daemon mode"); + puts(" -i --interface interface (default eth0)"); + puts(" -l print iptables rule"); + puts(" -s --signal regular signal (default start|stop) "); + puts(" start Enable Iptables rule"); + puts(" stop Disable Iptables rule"); + puts(" -h|-? Help Information"); puts(""); exit(0); @@ -269,8 +270,19 @@ int main(int argc, char **argv) memset(&device, 0, sizeof(device)); memset(errbuf, 0, PCAP_ERRBUF_SIZE); + int longindex = 0; + char optstring[] = "di:s:lh?"; + static struct option longopts[] = { + { "interface", required_argument, 0, 'i' }, + { "signal", required_argument, 0, 's' }, + { "daemon", no_argument, 0, 'd' }, + { "l", no_argument, 0, 'l' }, + { "help", no_argument, 0, 'h' }, + { "?", no_argument, 0, '?' }, + { 0, 0, 0, 0 } + }; - while ((opt = getopt(argc, argv, "di:s:h?")) != -1) { + while (-1 != (opt = getopt_long(argc, argv, optstring, longopts, &longindex))) { switch (opt) { case 'd': if (daemon(1, 1)) { @@ -280,6 +292,10 @@ int main(int argc, char **argv) case 'i': strcpy(interface, optarg); break; + case 'l': + system("iptables -L -v -n --line-numbers"); + exit(0); + break; case 's': if (strcmp(optarg, "start") == 0) { memset(Ipset_Command, 0, BUFFER); @@ -319,6 +335,11 @@ int main(int argc, char **argv) } } + if (strcmp(interface, "eth0") != 0) + { + + } + // 创建共享内存 shmid = shmget(SHM_KEY, SHM_SIZE, IPC_CREAT | 0666); diff --git a/cap.h b/cap.h index 7a20ef0..121155b 100644 --- a/cap.h +++ b/cap.h @@ -15,6 +15,7 @@ #include #include #include +#include #include #include "ip2region/ip2region.h" diff --git a/cap.o b/cap.o index 01d3e93..a7ae1c1 100644 Binary files a/cap.o and b/cap.o differ diff --git a/common.o b/common.o index fe67c2c..d8c2f5d 100644 Binary files a/common.o and b/common.o differ diff --git a/denyip b/denyip index 5a97a67..959c4d9 100644 Binary files a/denyip and b/denyip differ