Added docker support

This commit is contained in:
Rasmus Rasmussen 2025-05-19 22:44:13 +02:00
parent 5ca72cad99
commit 50e6f227a0
5 changed files with 43 additions and 16 deletions

24
Dockerfile Normal file
View File

@ -0,0 +1,24 @@
FROM gcc:latest
RUN apt update && apt install -y cmake
WORKDIR /app
#COPY a.png /app/
#COPY content /app/
#COPY wordlist /app/
#COPY include /app/
#COPY src /app/
#COPY CMakeLists.txt /app/
COPY . /app/
RUN ls -lh .
RUN cmake .
RUN make
EXPOSE 8888
EXPOSE 8889
CMD ["./tarpit", "wordlist/", "content/style.css", "content/images/", "a.png"]

View File

@ -48,10 +48,10 @@ cmake_force:
SHELL = /bin/sh
# The CMake executable.
CMAKE_COMMAND = /usr/bin/cmake
CMAKE_COMMAND = "/home/skingging/Tar Apps/clion-2025.1.1/bin/cmake/linux/x64/bin/cmake"
# The command to remove a file.
RM = /usr/bin/cmake -E rm -f
RM = "/home/skingging/Tar Apps/clion-2025.1.1/bin/cmake/linux/x64/bin/cmake" -E rm -f
# Escaping for special characters.
EQUALS = =
@ -67,8 +67,8 @@ CMAKE_BINARY_DIR = /home/skingging/Documents/Projects/CPP/AI-Tarpit-Reimagined
# Special rule for the target edit_cache
edit_cache:
@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --cyan "Running CMake cache editor..."
/usr/bin/ccmake -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --cyan "No interactive CMake dialog available..."
"/home/skingging/Tar Apps/clion-2025.1.1/bin/cmake/linux/x64/bin/cmake" -E echo No\ interactive\ CMake\ dialog\ available.
.PHONY : edit_cache
# Special rule for the target edit_cache
@ -78,7 +78,7 @@ edit_cache/fast: edit_cache
# Special rule for the target rebuild_cache
rebuild_cache:
@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --cyan "Running CMake to regenerate build system..."
/usr/bin/cmake --regenerate-during-build -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
"/home/skingging/Tar Apps/clion-2025.1.1/bin/cmake/linux/x64/bin/cmake" --regenerate-during-build -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
.PHONY : rebuild_cache
# Special rule for the target rebuild_cache

View File

@ -8,6 +8,7 @@ class Options {
public:
string word_lists;
string images;
string favicon;
string css;
};

View File

@ -94,11 +94,11 @@ void ServerUtils::process_request(const int client_fd) {
}
else if (url == "/favicon.png") {
send_image(client_fd, "/home/skingging/Documents/Projects/CPP/AI-Tarpit-Reimagined/a.png", PNG);
send_image(client_fd, options_.favicon, PNG);
}
else if (WordUtils::contains_image(url)) {
string p = "/home/skingging/Documents/Projects/CPP/AI-Tarpit-Reimagined/content/images/";
string p = options_.images;
p += WordUtils::extract_image_name(url);
send_image(client_fd, p, AVIF);
}

View File

@ -14,34 +14,36 @@ using namespace std;
int main(const int argc, const char* argv[]) {
Options options;
if (argc > 4)
{
if (argc > 5) {
cout << "Too many arguments";
return 0;
}
if (!FileUtils::fileExists(argv[1]))
{
if (!FileUtils::fileExists(argv[1])) {
cout << "Filepath: " << argv[1] << " doesn't exist.";
return 0;
}
options.word_lists = argv[1];
if (!FileUtils::fileExists(argv[2]))
{
if (!FileUtils::fileExists(argv[2])) {
cout << "Filepath: " << argv[2] << " doesn't exist.";
return 0;
}
options.css = argv[2];
if (!FileUtils::fileExists(argv[3]))
{
if (!FileUtils::fileExists(argv[3])) {
cout << "Filepath: " << argv[3] << " doesn't exist.";
return 0;
}
options.images = argv[3];
cout << options.word_lists << " " << options.css << " " << options.images << " " << endl;
if (!FileUtils::fileExists(argv[4])) {
cout << "Filepath: " << argv[4] << " doesn't exist.";
return 0;
}
options.favicon = argv[4];
//cout << options.word_lists << " " << options.css << " " << options.images << " " << endl;
auto queue = make_shared<ConcurrentQueue<Track>>();
auto metrics = make_shared<unordered_map<uint32_t, Crawler>>();