Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ip connection limit option #534

Merged
merged 2 commits into from
Feb 6, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/server/kiwix-serve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ void usage()
<< "\t-V, --version\t\tprint software version" << std::endl
<< "\t-z, --nodatealiases\tcreate URL aliases for each content by removing the date" << std::endl
<< "\t-c, --customIndex\tadd path to custom index.html for welcome page" << std::endl
<< "\t-L, --ipConnectionLimit\tLimit on the number of (concurrent) connections made to the server from the same IP address (default: infinite, recommended: >= 6)" << std::endl
kelson42 marked this conversation as resolved.
Show resolved Hide resolved
<< std::endl

<< "Documentation:" << std::endl
Expand Down Expand Up @@ -202,6 +203,7 @@ int main(int argc, char** argv)
bool isVerboseFlag = false;
bool monitorLibrary = false;
unsigned int PPID = 0;
int ipConnectionLimit = 0;

static struct option long_options[]
= {{"daemon", no_argument, 0, 'd'},
Expand All @@ -220,13 +222,14 @@ int main(int argc, char** argv)
{"urlRootLocation", required_argument, 0, 'r'},
{"customIndex", required_argument, 0, 'c'},
{"monitorLibrary", no_argument, 0, 'M'},
{"ipConnectionLimit", required_argument, 0, 'L'},
{0, 0, 0, 0}};

/* Argument parsing */
while (true) {
int option_index = 0;
int c
= getopt_long(argc, argv, "hzmnbdvVla:p:f:t:r:i:c:M", long_options, &option_index);
= getopt_long(argc, argv, "hzmnbdvVla:p:f:t:r:i:c:ML:", long_options, &option_index);

if (c != -1) {
switch (c) {
Expand Down Expand Up @@ -278,6 +281,9 @@ int main(int argc, char** argv)
case 'M':
monitorLibrary = true;
break;
case 'L':
ipConnectionLimit = atoi(optarg);
break;
}
} else {
if (optind < argc) {
Expand Down Expand Up @@ -364,6 +370,7 @@ int main(int argc, char** argv)
server.setTaskbar(!noSearchBarFlag, !noLibraryButtonFlag);
server.setBlockExternalLinks(blockExternalLinks);
server.setIndexTemplateString(indexTemplateString);
server.setIpConnectionLimit(ipConnectionLimit);

if (! server.start()) {
exit(1);
Expand Down