|
|
@@ -751,15 +751,16 @@ void GBUdb::compress() { |
|
|
|
MyDataset = BuildCompressedDataset.New(); // Put the new dataset in place. |
|
|
|
delete BuildCompressedDataset.Old(); // Delete the old dataset. |
|
|
|
} // All done, so we're unlocked. |
|
|
|
|
|
|
|
|
|
|
|
int GBUdb::readIgnoreList(const char* FileName) { // setIgnore for a list of IPs |
|
|
|
int IPCount = 0; // Keep track of the IPs we read. |
|
|
|
try { // Capture any exceptions. |
|
|
|
char IPLineBuffer[256]; // Create a line buffer. |
|
|
|
char IPLineBuffer[256]; // Create a line buffer.
|
|
|
|
const int SafeBufferSize = sizeof(IPLineBuffer) - 1; // Safe size always leaves a NULL on the end. |
|
|
|
ifstream ListFile(FileName, ios::in); // Open up the list file. |
|
|
|
while(ListFile.good()) { // While we've got a good file (not eof) |
|
|
|
memset(IPLineBuffer, 0, sizeof(IPLineBuffer)); // Clear the buffer. |
|
|
|
ListFile.getline(IPLineBuffer, sizeof(IPLineBuffer)); // Read the line. |
|
|
|
ListFile.getline(IPLineBuffer, SafeBufferSize); // Read the line. (safely NULL terminated) |
|
|
|
|
|
|
|
// Now we have an IP on a line (in theory). We will parse |
|
|
|
// the ip and process any that parse correctly. |
|
|
@@ -769,10 +770,10 @@ int GBUdb::readIgnoreList(const char* FileName) { |
|
|
|
char* cursor = IPLineBuffer; // Start on the first byte. |
|
|
|
|
|
|
|
if('#' == *cursor) continue; // Lines that start with # are comments. |
|
|
|
while(0 < *cursor && isspace(*cursor)) ++cursor; // Eat any leading spaces.
|
|
|
|
|
|
|
|
// First octet. |
|
|
|
|
|
|
|
while(NULL!=cursor && !isdigit(*cursor)) ++cursor; // Eat any nondigits. |
|
|
|
if(!isdigit(*cursor)) continue; // If it's not a digit skip this line. |
|
|
|
if(255 < atoi(cursor)) continue; // If the octet is out of range skip! |
|
|
|
IP += atoi(cursor); IP <<= 8; // Grab the first int and shift it. |