Project Overview
The project involves creating a server that responds to client queries by searching through a text file. This system ensures efficient query handling and rapid response times, making it useful for applications requiring fast text searches.
Installation
Dependencies
To install the necessary dependencies, use the following command:
pip install -r requirements.txt
This ensures that all required Python packages are installed for both the server and the client to function correctly.
Configuration Settings
The config.py file is used to generate config.ini, which contains essential server settings. Users can modify this file to adjust parameters such as:
- SSL Settings: Enable or disable SSL authentication.
- File Paths: Define the path to the text file for searching.
- SSL Certificates and Keys: Configure the location of SSL credentials.
Running the Server
To start the server, navigate to the directory where server.py is located and run:
python server.py
This command initializes the server and makes it ready to receive client queries.
Running the Client
To query the server, navigate to the client folder and execute:
python client.py
The client prompts for input, processes the query, and returns the response within milliseconds. The system efficiently handles string queries, especially those with a minimum length of 10 characters.
Testing the System
All functions used in the server and client were tested using pytest. To check for errors, run:
pytest test-server.py
The final project folder contains four test cases for the server and one test for the client.
SSL Authentication
SSL authentication is disabled by default. To enable it:
- Modify the
config.pyfile to enable SSL. - Run
config.pyto apply the changes. - Ensure
server.pyand the necessary SSL certificate (server.crt) and key (server.key) are in the same folder.
Creating an SSL Certificate
To generate an SSL certificate and key, run:
openssl req -new -x509 -days 365 -nodes -out server.crt -keyout server.key -config localhost.cnf
This creates two files—server.crt and server.key—required for secure communication.
Installing OpenSSL
For different Linux distributions, use:
- Fedora:
sudo dnf install openssl - Arch Linux:
sudo pacman -S openssl - Ubuntu:
sudo apt install openssl
Running as a Daemon
To run the server as a background service, create a systemd service file (e.g., server1.service):
[Unit]
Description=Server Service
[Service]
Restart=always
WorkingDirectory=/your/working/directory
ExecStart=/usr/bin/python3 server.py
[Install]
WantedBy=multi-user.target
Save this file in /etc/systemd/system/ and enable the service with:
sudo systemctl enable server1.service
sudo systemctl start server1.service
To check its status:
sudo systemctl status server1.service
To stop the service:
sudo systemctl stop server1.service
Additional Files
The project includes supplementary files:
200k_download.py– Downloads a 200k dataset for testing.generate.py– Creates synthetic data similar to the 200k dataset.- Output Files (
.csv) – Performance data from different algorithms. - Report Files (
.pdf) – Documentation of the project. string_search.py– Contains search algorithms used.speed_testing_string_search.py– Measures algorithm efficiency.
Conclusion
This project effectively demonstrates text search efficiency in a server-client setup. Further improvements could involve optimizing search algorithms, implementing advanced indexing techniques, and enhancing security through stronger SSL configurations.