Skip to content

Commit 3ad277a

Browse files
author
Incharajayaram
committed
feat : change to 2xxx ports and DB port
1 parent 14aa547 commit 3ad277a

29 files changed

Lines changed: 99 additions & 99 deletions

File tree

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Database Configuration
22
DB_HOST=localhost
3-
DB_PORT=5432
3+
DB_PORT=5437
44
DB_NAME=your_database_name
55
DB_USERNAME=your_db_username
66
DB_PASSWORD=your_db_password
-2 Bytes
Binary file not shown.

Email_client/QuMail.EmailProtocol/Controllers/AESController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class AESController : ControllerBase
1313
private static readonly HttpClient Http = new HttpClient();
1414
private readonly ILogger<AESController> _logger;
1515

16-
private const string AesBaseUrl = "http://aes-server:8082";
16+
private const string AesBaseUrl = "http://aes-server:2022";
1717

1818
public AESController(ILogger<AESController> logger)
1919
{

Email_client/QuMail.EmailProtocol/Controllers/EmailController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ public class EmailController : ControllerBase
2929
{
3030
Timeout = TimeSpan.FromSeconds(30) // Increased from 10s for slow container startup
3131
};
32-
private const string OtpBaseUrl = "http://otp-server:8081"; // OTP API Docker network address
33-
private const string AesBaseUrl = "http://aes-server:8082"; // AES API Docker network address
32+
private const string OtpBaseUrl = "http://otp-server:2021"; // OTP API Docker network address
33+
private const string AesBaseUrl = "http://aes-server:2022"; // AES API Docker network address
3434
private const int MaxRetries = 3;
3535

3636
public EmailController(

Key_Manager/km/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,4 @@ def health_check():
6464
}), 200, {"Content-Type": "application/json"}
6565

6666
if __name__ == "__main__":
67-
app.run(host="127.0.0.1", port=8080)
67+
app.run(host="127.0.0.1", port=2020)

Key_Manager/km_client.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ static int extract_key_id(const char *headers_path, char *out, size_t outsz) {
3333
int km_fetch_new_key(size_t size, const char *key_out, const char *keyid_out) {
3434
char cmd[1024];
3535
snprintf(cmd, sizeof(cmd),
36-
"curl -sSf -D headers.tmp -o \"%s\" \"http://127.0.0.1:8080/otp/keys?size=%lu\"",
36+
"curl -sSf -D headers.tmp -o \"%s\" \"http://127.0.0.1:2020/otp/keys?size=%lu\"",
3737
key_out, (unsigned long)size);
3838
if (run_cmd(cmd) != 0) return 1;
3939

@@ -61,7 +61,7 @@ int km_fetch_key_by_id(const char *key_id, const char *key_out) {
6161

6262
char cmd[1024];
6363
snprintf(cmd, sizeof(cmd),
64-
"curl -sSf -o \"%s\" \"http://127.0.0.1:8080/otp/keys/%s\"",
64+
"curl -sSf -o \"%s\" \"http://127.0.0.1:2020/otp/keys/%s\"",
6565
key_out, idclean);
6666
if(run_cmd(cmd) != 0){
6767
fprintf(stderr, "KM: HTTP fetch failed (bad key_id or KM Down)\n");

README.md

0 Bytes

🏗️ Architecture Overview

This application consists of multiple components working together:

  • Frontend: Flutter desktop application (Windows)
  • Backend: .NET 8 Web API with authentication and email management
  • Database: PostgreSQL for user authentication and email storage
  • Crypto Services: Multiple Python services for different encryption layers
    • Key Manager (Port 80802020): Manages quantum keys
    • OTP API (Port 80812021): One-Time Pad encryption/decryption
    • AES Server (Port 80822022): AES-256-GCM encryption/decryption
    • Main Backend API (Port 5001): Handles PQC operations and all email functionality

📋 Prerequisites

Before setting up the application, ensure you have the following installed:

Create a .env file in the root directory:

# Database Configuration
DB_HOST=localhost
DB_PORT=5437
DB_PORT=5432
DB_NAME=quantum_auth
DB_USERNAME=postgres
DB_PASSWORD=your_postgres_password_here

# JWT Configuration
JWT_SECRET_KEY=your-super-secret-jwt-key-here-must-be-at-least-32-characters-long-for-security
JWT_ISSUER=QuMail
JWT_AUDIENCE=QuMail-Users
JWT_EXPIRES_MINUTES=60

# Application Secret (Generate a new 32-character base64 key)
APP_SECRET_KEY=your-base64-encoded-secret-key-here

4. Build and Start Services

Option A: Automated Setup (Windows)

# Start all services automatically
start_server.bat

Option B: Manual Setup

Step 1: Start Crypto Services

# Terminal 1 - Key Manager (Port 2020)
# Terminal 1 - Key Manager (Port 8080)
cd Key_Manager/km
python server.py

# Terminal 2 - OTP API (Port 2021)
# Terminal 2 - OTP API (Port 8081)
cd level1
python otp_api_test.py

# Terminal 3 - AES Server (Port 2022)
# Terminal 3 - AES Server (Port 8082)
cd level2new
python server2.py

Step 2: Start Backend API

Key Manager Service

cd Key_Manager/km
python server.py
  • Runs on: http://localhost:8080http://localhost:2020
  • Manages quantum keys for encryption
  • Stores keys in key_store.json

OTP API Service

cd level1
python otp_api_test.py
  • Runs on: http://localhost:8081http://localhost:2021
  • Provides One-Time Pad encryption/decryption
  • Requires encoder.exe in the same directory

AES Server Service

cd level2new
python server2.py
  • Runs on: http://localhost:8082http://localhost:2022
  • Provides AES-256-GCM encryption/decryption
  • Integrates with Key Manager for key exchange

Backend API Service (Handles PQC Operations)

cd Email_client/QuMail.EmailProtocol
dotnet run --urls "http://localhost:5001"

Check Service Health

# Check if all services are running
curl http://localhost:5001/api/health
curl http://localhost:2020/health
curl http://localhost:2021/api/otp/health
curl http://localhost:2022/api/health
curl http://localhost:8080/health
curl http://localhost:8081/api/otp/health
curl http://localhost:8082/api/health

Test User Credentials

  • Email: test@example.com
  • Password: password123

Port Conflicts

If you encounter port conflicts, check what's using the ports:

# Windows
netstat -ano | findstr :5001
netstat -ano | findstr :2020
netstat -ano | findstr :2021
netstat -ano | findstr :2022
netstat -ano | findstr :2023
netstat -ano | findstr :8080
netstat -ano | findstr :8081
netstat -ano | findstr :8082
netstat -ano | findstr :8083

# Kill process by PID
taskkill /F /PID <process_id>

Flutter Build Issues

# Clean Flutter cache
flutter clean
flutter pub get

# Check Flutter doctor
flutter doctor

# Rebuild
flutter build windows

auth/auth_server.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
# Database configuration
3030
DB_HOST = os.getenv('DB_HOST', 'postgres')
31-
DB_PORT = os.getenv('DB_PORT', '5432')
31+
DB_PORT = os.getenv('DB_PORT', '5437')
3232
DB_NAME = os.getenv('DB_NAME', 'quantum_auth')
3333
DB_USERNAME = os.getenv('DB_USERNAME', 'postgres')
3434
DB_PASSWORD = os.getenv('DB_PASSWORD', 'quantum_secure_password_2024')
@@ -290,4 +290,4 @@ def refresh_token(current_user):
290290
return jsonify({'error': 'Token refresh failed'}), 500
291291

292292
if __name__ == '__main__':
293-
app.run(host='0.0.0.0', port=8083, debug=False)
293+
app.run(host='0.0.0.0', port=2023, debug=False)

docker/aes-server/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ RUN adduser --disabled-password --gecos '' appuser && chown -R appuser /app
2828
USER appuser
2929

3030
# Expose port
31-
EXPOSE 8082
31+
EXPOSE 2022
3232

3333
# Set environment variables
3434
ENV FLASK_APP=aes_server.py

docker/auth/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ RUN adduser --disabled-password --gecos '' appuser && chown -R appuser /app
2323
USER appuser
2424

2525
# Expose port
26-
EXPOSE 8083
26+
EXPOSE 2023
2727

2828
# Set environment variables
2929
ENV FLASK_APP=auth_server.py
@@ -32,7 +32,7 @@ ENV PYTHONPATH=/app
3232

3333
# Health check
3434
HEALTHCHECK --interval=30s --timeout=10s --retries=3 \
35-
CMD curl -f http://localhost:8083/health || exit 1
35+
CMD curl -f http://localhost:2023/health || exit 1
3636

3737
# Run the application
3838
CMD ["python", "auth_server.py"]

0 commit comments

Comments
 (0)