Adding to README, adding in new code for reading to a host in file
This commit is contained in:
parent
258e2c8de3
commit
8935ad2e54
@ -14,3 +14,4 @@ I would like to get better with C, and will be using C much more in the near fut
|
||||
2. Daemonize this program to be started up by systemd.
|
||||
- As part of daemonization, remember and remove added hosts on teardown.
|
||||
3. Log dns requests that look at the hosts file -- To see how many go where
|
||||
4. As part of daemonization -- only block hosts within a time limit.
|
||||
|
19
main.c
19
main.c
@ -5,6 +5,10 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
/**
|
||||
* TODO - daemonize, add in reading of config file,
|
||||
* block sites within a certain time limit.
|
||||
*/
|
||||
const char *blockString = "0.0.0.0 ";
|
||||
|
||||
FILE *fopenHostsFile(int mode)
|
||||
@ -59,6 +63,21 @@ void showHosts()
|
||||
}
|
||||
}
|
||||
|
||||
void readToHost(char *host, FILE *hostsFile)
|
||||
{
|
||||
char buf[256];
|
||||
char *ptr;
|
||||
|
||||
while ((fgets(buf, 256, hostsFile)) != NULL)
|
||||
{
|
||||
ptr = strcasestr(host, buf);
|
||||
if (ptr != NULL)
|
||||
break;
|
||||
}
|
||||
|
||||
// FILE should be read to the host itself.
|
||||
}
|
||||
|
||||
/**
|
||||
* Entrypoint.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user