Skip to content

Commit

Permalink
Update the main ReadMe file
Browse files Browse the repository at this point in the history
  • Loading branch information
BorcilaVasile committed Jan 14, 2025
1 parent 8d1363f commit 461120a
Show file tree
Hide file tree
Showing 9 changed files with 137 additions and 3 deletions.
10 changes: 10 additions & 0 deletions Client/error_log.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Internal server error: Invalid token or client ID
Internal server error: Invalid token or client ID
Internal server error: Invalid token or client ID
Internal server error: Invalid token or client ID
Internal server error: Invalid token or client ID
Internal server error: Invalid token or client ID
Internal server error: Invalid token or client ID
Internal server error: Invalid token or client ID
Internal server error: Invalid token or client ID
Internal server error: Invalid token or client ID
4 changes: 2 additions & 2 deletions Client/main_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ void freeMatrix(int** matrix, int dimension) {

void clientTask(int client_id, const std::string& username, const std::string& password) {
try {
Client client(true); // creează un client nou
Client client(true);
client.connectToServer("0.0.0.0", 8000);
client.authenticate(username, password);

// fiecare client execută mai multe operațiuni
std::cout << "[Client " << client_id << "] sayHello: "
<< client.sayHello("Client " + std::to_string(client_id)) << std::endl;

// operatiuni de matrice
// operatiuni pe matrice
int dimension = 2;
int** A = new int*[dimension];
int** B = new int*[dimension];
Expand Down
111 changes: 110 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,103 @@ This project provides a Remote Procedure Call (RPC) library that facilitates com
- **File Operations**: Supports remote file operations such as open, read, write, and close.

## Installation
```bash
#!/bin/bash

# Definește directoarele de instalare
LIB_DIR="/usr/local/lib"
INCLUDE_DIR="/usr/local/include"
PKG_CONFIG_DIR="/usr/local/lib/pkgconfig"
DEFAULT_CERTIFICATE_PATH="/usr/local/lib/certificate.crt"

# Verifică dacă scriptul este rulat cu permisiuni de root
if [ "$EUID" -ne 0 ]; then
echo "Te rog rulează scriptul cu permisiuni de root."
exit 1
fi

# Verifică și instalează protobuf dacă nu este instalat
if ! dpkg -s protobuf-compiler libprotobuf-dev >/dev/null 2>&1; then
echo "Protobuf nu este instalat. Instalare protobuf..."
apt-get update
apt-get install -y protobuf-compiler libprotobuf-dev
else
echo "Protobuf este deja instalat."
fi

# Verifică și instalează openssl dacă nu este instalat
if ! dpkg -s openssl libssl-dev >/dev/null 2>&1; then
echo "OpenSSL nu este instalat. Instalare OpenSSL..."
apt-get update
apt-get install -y openssl libssl-dev
else
echo "OpenSSL este deja instalat."
fi

# Copiază fișierele de antet
echo "Copiere fișiere de antet în ${INCLUDE_DIR}..."
cp -r include/RPC/* ${INCLUDE_DIR}/

# Verifică dacă fișierul certificatului există
if [ ! -f "$DEFAULT_CERTIFICATE_PATH" ]; then
echo "Certificatul TLS nu a fost găsit la locația implicită (${DEFAULT_CERTIFICATE_PATH})."
echo "Creare certificat implicit pentru teste..."
openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
-keyout "${DEFAULT_CERTIFICATE_PATH}" -out "${DEFAULT_CERTIFICATE_PATH}" \
-subj "/C=US/ST=State/L=City/O=Organization/OU=Department/CN=example.com"
echo "Certificatul a fost creat și salvat la ${DEFAULT_CERTIFICATE_PATH}."
else
echo "Certificatul TLS a fost găsit la ${DEFAULT_CERTIFICATE_PATH}."
fi

# Setează permisiunile necesare pentru certificatul TLS
echo "Setare permisiuni pentru certificatul TLS..."
chmod 644 "${DEFAULT_CERTIFICATE_PATH}"
if [ $? -eq 0 ]; then
echo "Permisiunile au fost setate cu succes: 644 (citire pentru toți utilizatorii)."
else
echo "Eroare la setarea permisiunilor pentru certificatul TLS."
exit 1
fi

# Setează variabila de mediu pentru certificatul TLS
if [ -z "$RPC_CERTIFICATE_PATH" ]; then
echo "Setarea variabilei de mediu RPC_CERTIFICATE_PATH..."
export RPC_CERTIFICATE_PATH="${DEFAULT_CERTIFICATE_PATH}"
echo "Variabila RPC_CERTIFICATE_PATH a fost setată la ${RPC_CERTIFICATE_PATH}."
else
echo "Variabila RPC_CERTIFICATE_PATH este deja setată la ${RPC_CERTIFICATE_PATH}."
fi

# Creează fișierul pkg-config pentru a permite utilizarea corectă în proiecte
echo "Creare fișierul pkg-config pentru libRPC..."
cat <<EOL > ${PKG_CONFIG_DIR}/libRPC.pc
prefix=${LIB_DIR}
exec_prefix=\${prefix}
libdir=\${exec_prefix}/lib
includedir=\${prefix}/include
Name: libRPC
Description: Biblioteca RPC pentru aplicații client-server
Version: 1.0
Libs: -L\${libdir} -lRPC
Cflags: -I\${includedir}/RPC
EOL

# Actualizează cache-ul bibliotecilor dinamice
echo "Actualizare cache biblioteci dinamice..."
ldconfig

# Mesaj final
echo "Biblioteca RPC a fost instalată cu succes în sistem!"
echo "Certificatul este localizat la: ${RPC_CERTIFICATE_PATH}"

# Oferă instrucțiuni de utilizare pentru utilizatori
echo "Pentru a utiliza biblioteca în proiecte, adăugați opțiunile corespunzătoare în CMake sau Makefile:"
echo " - CMake: target_link_libraries(proiect libRPC)"
echo " - Makefile: -L/usr/local/lib -lRPC -I/usr/local/include"
echo "Asigurați-vă că variabila de mediu RPC_CERTIFICATE_PATH este configurată corect pentru aplicația dumneavoastră."
```

### Prerequisites

Expand Down Expand Up @@ -111,4 +208,16 @@ int main() {
printf("Server stopped.\n");
return 0;
}
```
```
## Future Implementations
- **Cross-Platform Compatibility**: Extend support for macOS and Windows.
- **Advanced Error Reporting**: Implement detailed logs for better debugging.
- **Load Balancing**: Integrate support for distributing client requests across multiple servers.
- **Multi-Language Support**: Develop bindings for languages like Python and Java.
- **WebSocket Integration**: Add support for WebSocket-based communication.
- **Custom Authentication**: Enable integration with external authentication providers.
- **File Streaming**: Support for streaming large files between client and server.
- **Performance Metrics**: Add tools for monitoring and visualizing server performance in real-time.
- **Access to your own workspace on server**: Every client should have access only to their own files, regardless of the permissions they have, with the only one able to override this being the server administrator.
10 changes: 10 additions & 0 deletions Server/error_log.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Invalid token or client ID
Invalid token or client ID
Invalid token or client ID
Invalid token or client ID
Invalid token or client ID
Invalid token or client ID
Invalid token or client ID
Invalid token or client ID
Invalid token or client ID
Invalid token or client ID
1 change: 1 addition & 0 deletions Server/test_file_0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello from Client 0
1 change: 1 addition & 0 deletions Server/test_file_1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello from Client 1
1 change: 1 addition & 0 deletions Server/test_file_2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello from Client 2
1 change: 1 addition & 0 deletions Server/test_file_3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello from Client 3
1 change: 1 addition & 0 deletions Server/test_file_4.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello from Client 4

0 comments on commit 461120a

Please sign in to comment.