-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathconfig.py
More file actions
163 lines (144 loc) · 4.34 KB
/
Copy pathconfig.py
File metadata and controls
163 lines (144 loc) · 4.34 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#!/usr/bin/env python3
"""
Production Configuration for VFS Global Guinea-Bissau Automation
Centralized configuration management for all components
"""
import os
from pathlib import Path
from typing import Dict, List, Optional
# Base paths
BASE_DIR = Path(__file__).parent
DATA_DIR = BASE_DIR / "data"
LOGS_DIR = BASE_DIR / "logs"
DOCS_DIR = BASE_DIR / "documents"
INFO_DIR = BASE_DIR / "info"
TEMPLATES_DIR = BASE_DIR / "templates"
STATIC_DIR = BASE_DIR / "static"
# Ensure directories exist
for directory in [DATA_DIR, LOGS_DIR, DOCS_DIR, INFO_DIR, TEMPLATES_DIR, STATIC_DIR]:
directory.mkdir(exist_ok=True)
# VFS Global Configuration
VFS_CONFIG = {
"base_url": "https://visa.vfsglobal.com",
"booking_url": "https://visa.vfsglobal.com/gnb/pt/prt/book-appointment",
"login_url": "https://visa.vfsglobal.com/gnb/pt/prt/login",
"monitoring_duration": 4, # minutes
"max_clients_per_session": 5,
"check_interval": 30, # seconds between checks
}
# Browser Configuration
BROWSER_CONFIG = {
"headless": True,
"use_playwright": True,
"viewport_width": 1920,
"viewport_height": 1080,
"user_agent_rotation": True,
"stealth_mode": True,
}
# Rate Limiting Configuration
RATE_LIMITING = {
"min_delay": 3, # seconds
"max_delay": 8, # seconds
"max_retries": 5,
"consecutive_error_limit": 3,
"backoff_multiplier": 1.5,
}
# Cloudflare Bypass Configuration
CLOUDFLARE_BYPASS = {
"enabled": True,
"max_attempts": 10,
"strategies": [
"advanced_stealth",
"proxy_rotation",
"captcha_solving",
"browser_restart",
"selenium_fallback",
"basic_bypass",
"enhanced_ua_rotation",
"header_spoofing",
"javascript_challenge",
"multi_browser"
],
"wait_timeout": 30, # seconds
}
# Proxy Configuration
PROXY_CONFIG = {
"enabled": True,
"rotation_enabled": True,
"test_timeout": 10, # seconds
"max_retries": 3,
"fallback_to_direct": True,
}
# Logging Configuration
LOGGING_CONFIG = {
"level": "INFO",
"format": "%(asctime)s - %(name)s - %(levelname)s - %(message)s",
"file": LOGS_DIR / "vfs_automation.log",
"max_size": 10 * 1024 * 1024, # 10MB
"backup_count": 5,
}
# Mobile App Configuration
MOBILE_CONFIG = {
"host": "0.0.0.0",
"port": 5000,
"debug": False,
"secret_key": "vfs_booking_mobile_app_2024_secure",
"max_file_size": 10 * 1024 * 1024, # 10MB
"allowed_extensions": {".jpg", ".jpeg", ".png", ".pdf"},
}
# Security Configuration
SECURITY_CONFIG = {
"encrypt_passwords": False, # Set to True in production
"session_timeout": 3600, # 1 hour
"max_login_attempts": 5,
"password_min_length": 8,
}
# File Upload Configuration
UPLOAD_CONFIG = {
"max_file_size": 10 * 1024 * 1024, # 10MB
"allowed_types": ["image/jpeg", "image/png", "application/pdf"],
"save_path": DOCS_DIR,
"metadata_path": DOCS_DIR / "_metadata",
}
# Database Configuration (for future SQLite migration)
DATABASE_CONFIG = {
"type": "csv", # "csv" or "sqlite"
"csv_path": DATA_DIR / "clients.csv",
"sqlite_path": DATA_DIR / "clients.db",
}
# Notification Configuration
NOTIFICATION_CONFIG = {
"email_enabled": False,
"telegram_enabled": False,
"webhook_enabled": False,
"success_notifications": True,
"error_notifications": True,
}
# Development/Production Environment Detection
def is_production() -> bool:
"""Detect if running in production environment."""
return os.getenv("ENVIRONMENT", "development").lower() == "production"
def get_config() -> Dict:
"""Get complete configuration based on environment."""
config = {
"vfs": VFS_CONFIG,
"browser": BROWSER_CONFIG,
"rate_limiting": RATE_LIMITING,
"cloudflare_bypass": CLOUDFLARE_BYPASS,
"proxy": PROXY_CONFIG,
"logging": LOGGING_CONFIG,
"mobile": MOBILE_CONFIG,
"security": SECURITY_CONFIG,
"upload": UPLOAD_CONFIG,
"database": DATABASE_CONFIG,
"notification": NOTIFICATION_CONFIG,
"production": is_production(),
}
# Override with environment variables if in production
if is_production():
config["mobile"]["debug"] = False
config["logging"]["level"] = "WARNING"
config["security"]["encrypt_passwords"] = True
return config
# Export configuration
CONFIG = get_config()