blob: aa839861cacfb4ac8835c28cce2b22fd1134f5af (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
#include "cgit.h"
#include <string.h>
// for useragent in "ClaudeBot/1.0" "GPTBot/1.2" "Amazonbot/0.1" "Google-CloudVertexBot" "Google-Extended"
const char* knownUserAgentContains[] = {
"ClaudeBot/1.0",
"GPTBot/1.2",
"Amazonbot/0.1",
"Google-CloudVertexBot",
"Google-Extended",
// ""
};
int is_suspected_bot(char* userAgent)
{
for (int i = 0; i < sizeof(knownUserAgentContains) / sizeof(knownUserAgentContains[0]); i++)
{
if (strstr(userAgent, knownUserAgentContains[i]) != NULL)
{
return true;
}
}
return false;
}
void render_bot_err_page()
{
ctx.page.title = "Human verification";
cgit_print_http_headers();
cgit_print_docstart();
cgit_print_pageheader();
html("<h1>Please verify that you are human.</h1>\n");
html("<p>meow</p>\n");
cgit_print_docend();
fflush(stdout);
for (int i = 0; i < 1000; i++)
{
printf("%s\n", ctx.env.user_agent);
// sendfile(STDOUT_FILENO, fileno(fopen("/dev/urandom", "r")), NULL, 1*1024*1024);
}
fflush(stdout);
}
|