mediarelay 1.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,70 @@
1
+ # Commercial Restricted License (CRL)
2
+
3
+ **Version 1.1**
4
+
5
+ **Copyright (c) 2025 tboy1337**
6
+
7
+ ## Grant of Rights
8
+
9
+ Subject to the terms and conditions of this license, the copyright holder grants you a worldwide, royalty-free, non-exclusive license to use, copy, modify, and distribute this software and associated documentation files (the "Software") for **Non-Commercial Use** only.
10
+
11
+ ## Definitions
12
+
13
+ **"Non-Commercial Use"** means use of the Software that is not primarily intended for or directed toward commercial advantage or monetary compensation. Non-Commercial Use includes:
14
+
15
+ - Personal use, learning, and experimentation
16
+ - Academic research and education
17
+ - Open source projects that are not monetized
18
+ - Internal evaluation within a commercial organization (limited to 30 days)
19
+ - Use by registered non-profit organizations for their non-profit activities
20
+
21
+ **"Commercial Use"** means any use of the Software that is primarily intended for or directed toward commercial advantage or monetary compensation, including but not limited to:
22
+
23
+ - Use in any product or service that generates revenue
24
+ - Use by for-profit organizations in their business operations
25
+ - Integration into commercial software or services
26
+ - Use in providing paid consulting, support, or services
27
+ - Use in any business process that contributes to revenue generation
28
+ - Use by organizations with annual revenue exceeding $100,000 USD
29
+
30
+ **Note:** Any Commercial Use of the Software requires a separate commercial license from the copyright holder.
31
+
32
+ ## Conditions
33
+
34
+ For Non-Commercial Use, you may:
35
+
36
+ - Use, copy, and modify the Software
37
+ - Distribute copies of the Software
38
+ - Distribute your modifications under this same license
39
+
40
+ You must:
41
+
42
+ - Include this license notice in all copies or substantial portions of the Software
43
+ - Not remove or alter any copyright notices
44
+
45
+ ## Restrictions
46
+
47
+ You may not:
48
+
49
+ - Use the Software for Commercial Use without a commercial license
50
+ - Sublicense the Software under different terms
51
+ - Use the Software in any way that violates applicable laws
52
+ - Remove, obscure, or modify any licensing, copyright, or other legal notices
53
+
54
+ ## No Warranty
55
+
56
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
57
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
58
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
59
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
60
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
61
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
62
+ SOFTWARE.
63
+
64
+ ## Termination
65
+
66
+ This license terminates automatically if you violate any of its terms. Upon termination, you must cease all use and distribution of the Software and destroy all copies in your possession.
67
+
68
+ ## Governing Law
69
+
70
+ This license shall be governed by and construed in accordance with the laws of the United Kingdom, without regard to its conflict of law provisions.
@@ -0,0 +1,414 @@
1
+ Metadata-Version: 2.4
2
+ Name: mediarelay
3
+ Version: 1.0.1
4
+ Summary: A video streaming server that allows you to securely share your personal video library over the internet
5
+ Author: tboy1337
6
+ License: # Commercial Restricted License (CRL)
7
+
8
+ **Version 1.1**
9
+
10
+ **Copyright (c) 2025 tboy1337**
11
+
12
+ ## Grant of Rights
13
+
14
+ Subject to the terms and conditions of this license, the copyright holder grants you a worldwide, royalty-free, non-exclusive license to use, copy, modify, and distribute this software and associated documentation files (the "Software") for **Non-Commercial Use** only.
15
+
16
+ ## Definitions
17
+
18
+ **"Non-Commercial Use"** means use of the Software that is not primarily intended for or directed toward commercial advantage or monetary compensation. Non-Commercial Use includes:
19
+
20
+ - Personal use, learning, and experimentation
21
+ - Academic research and education
22
+ - Open source projects that are not monetized
23
+ - Internal evaluation within a commercial organization (limited to 30 days)
24
+ - Use by registered non-profit organizations for their non-profit activities
25
+
26
+ **"Commercial Use"** means any use of the Software that is primarily intended for or directed toward commercial advantage or monetary compensation, including but not limited to:
27
+
28
+ - Use in any product or service that generates revenue
29
+ - Use by for-profit organizations in their business operations
30
+ - Integration into commercial software or services
31
+ - Use in providing paid consulting, support, or services
32
+ - Use in any business process that contributes to revenue generation
33
+ - Use by organizations with annual revenue exceeding $100,000 USD
34
+
35
+ **Note:** Any Commercial Use of the Software requires a separate commercial license from the copyright holder.
36
+
37
+ ## Conditions
38
+
39
+ For Non-Commercial Use, you may:
40
+
41
+ - Use, copy, and modify the Software
42
+ - Distribute copies of the Software
43
+ - Distribute your modifications under this same license
44
+
45
+ You must:
46
+
47
+ - Include this license notice in all copies or substantial portions of the Software
48
+ - Not remove or alter any copyright notices
49
+
50
+ ## Restrictions
51
+
52
+ You may not:
53
+
54
+ - Use the Software for Commercial Use without a commercial license
55
+ - Sublicense the Software under different terms
56
+ - Use the Software in any way that violates applicable laws
57
+ - Remove, obscure, or modify any licensing, copyright, or other legal notices
58
+
59
+ ## No Warranty
60
+
61
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
62
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
63
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
64
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
65
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
66
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
67
+ SOFTWARE.
68
+
69
+ ## Termination
70
+
71
+ This license terminates automatically if you violate any of its terms. Upon termination, you must cease all use and distribution of the Software and destroy all copies in your possession.
72
+
73
+ ## Governing Law
74
+
75
+ This license shall be governed by and construed in accordance with the laws of the United Kingdom, without regard to its conflict of law provisions.
76
+
77
+ Project-URL: Homepage, https://github.com/tboy1337/MediaRelay
78
+ Project-URL: Documentation, https://github.com/tboy1337/MediaRelay/tree/main/docs
79
+ Project-URL: Repository, https://github.com/tboy1337/MediaRelay
80
+ Project-URL: Issues, https://github.com/tboy1337/MediaRelay/issues
81
+ Keywords: video,streaming,server,media,flask,security,authentication
82
+ Classifier: Development Status :: 5 - Production/Stable
83
+ Classifier: Intended Audience :: Developers
84
+ Classifier: Intended Audience :: End Users/Desktop
85
+ Classifier: Topic :: Multimedia :: Video
86
+ Classifier: Topic :: Internet :: WWW/HTTP :: WSGI :: Application
87
+ Classifier: Programming Language :: Python :: 3
88
+ Classifier: Programming Language :: Python :: 3.12
89
+ Classifier: Programming Language :: Python :: 3.13
90
+ Classifier: Programming Language :: Python :: 3.14
91
+ Classifier: Operating System :: OS Independent
92
+ Classifier: Operating System :: Microsoft :: Windows
93
+ Classifier: Operating System :: POSIX :: Linux
94
+ Classifier: Operating System :: MacOS
95
+ Classifier: Environment :: Web Environment
96
+ Classifier: Framework :: Flask
97
+ Classifier: Typing :: Typed
98
+ Requires-Python: >=3.12
99
+ Description-Content-Type: text/markdown
100
+ License-File: LICENSE.md
101
+ Requires-Dist: Flask
102
+ Requires-Dist: Werkzeug
103
+ Requires-Dist: waitress
104
+ Requires-Dist: flask-limiter
105
+ Requires-Dist: python-dotenv
106
+ Requires-Dist: click
107
+ Requires-Dist: colorlog
108
+ Requires-Dist: structlog
109
+ Requires-Dist: psutil
110
+ Provides-Extra: dev
111
+ Requires-Dist: pytest; extra == "dev"
112
+ Requires-Dist: pytest-timeout; extra == "dev"
113
+ Requires-Dist: pytest-xdist; extra == "dev"
114
+ Requires-Dist: pytest-cov; extra == "dev"
115
+ Requires-Dist: pytest-html; extra == "dev"
116
+ Requires-Dist: pytest-json-report; extra == "dev"
117
+ Requires-Dist: pytest-flask; extra == "dev"
118
+ Requires-Dist: pylint; extra == "dev"
119
+ Requires-Dist: mypy; extra == "dev"
120
+ Requires-Dist: black; extra == "dev"
121
+ Requires-Dist: isort; extra == "dev"
122
+ Requires-Dist: bandit; extra == "dev"
123
+ Requires-Dist: types-psutil; extra == "dev"
124
+ Requires-Dist: types-waitress; extra == "dev"
125
+ Requires-Dist: autopep8; extra == "dev"
126
+ Requires-Dist: safety; extra == "dev"
127
+ Dynamic: license-file
128
+
129
+ # MediaRelay
130
+
131
+ A video streaming server that allows you to securely share your personal video library over the internet. Built with robust security, monitoring, and performance features.
132
+
133
+ ## ✨ Features
134
+
135
+ ### 🔒 Security
136
+ - **Multi-layer Authentication**: HTTP Basic Auth + Session Management
137
+ - **Path Traversal Protection**: Prevents unauthorized file access
138
+ - **Security Headers**: XSS, CSRF, clickjacking protection
139
+ - **Rate Limiting**: Configurable request throttling
140
+ - **Security Audit Logging**: Comprehensive security event tracking
141
+ - **Session Management**: Secure sessions with configurable timeouts
142
+
143
+ ### 🎥 Media Streaming
144
+ - **Universal Format Support**: MP4, MKV, AVI, MOV, WebM, M4V, FLV
145
+ - **Subtitle Support**: SRT subtitle files
146
+ - **Audio Support**: MP3, AAC, OGG, WAV
147
+ - **Range Requests**: Efficient streaming with seek support
148
+ - **Mobile Optimized**: Responsive design for all devices
149
+
150
+ ### 📊 Monitoring & Performance
151
+ - **Health Check Endpoint**: Real-time server status
152
+ - **Performance Metrics**: Request timing and throughput monitoring
153
+ - **Comprehensive Logging**: Application, security, error, and performance logs
154
+ - **Multi-threaded**: Configurable concurrency for high performance
155
+ - **Resource Monitoring**: Memory and disk usage tracking
156
+
157
+ ### 🛠️ Advanced Features
158
+ - **Environment Configuration**: Full environment variable support
159
+ - **100% Test Coverage**: Comprehensive test suite with security tests
160
+ - **Service Management**: System service configurations for Windows and Linux
161
+ - **Log Rotation**: Automatic log rotation and archival
162
+ - **API Support**: RESTful JSON API for integration
163
+
164
+ ## 📋 Requirements
165
+
166
+ - **Python**: 3.12 or higher
167
+ - **Operating System**: Windows 10+, macOS 10.15+, or Linux (Ubuntu 20.04+ recommended)
168
+ - **Memory**: Minimum 2GB RAM, 4GB+ recommended for optimal performance
169
+ - **Storage**: 1GB for application, additional space for video content
170
+ - **Network**: Stable internet connection for remote access
171
+
172
+ ## 🚀 Quick Start
173
+
174
+ ### 1. Installation
175
+
176
+ ```bash
177
+ # Clone the repository
178
+ git clone https://github.com/tboy1337/MediaRelay.git
179
+ cd MediaRelay
180
+
181
+ # Create virtual environment (recommended)
182
+ python -m venv venv
183
+ source venv/bin/activate # Linux/macOS
184
+ venv\Scripts\activate # Windows
185
+
186
+ # Install the package
187
+ pip install mediarelay
188
+
189
+ # For development (editable install with testing and linting tools)
190
+ pip install -e ".[dev]"
191
+ ```
192
+
193
+ ### 2. Configuration
194
+
195
+ ```bash
196
+ # Generate sample configuration
197
+ python config.py
198
+
199
+ # Copy and edit configuration
200
+ copy .env.example .env
201
+ # Edit .env with your settings
202
+ ```
203
+
204
+ ### 3. Security Setup
205
+
206
+ Generate required security credentials:
207
+
208
+ ```bash
209
+ # Generate Flask secret key and password hash
210
+ mediarelay-genpass
211
+ ```
212
+
213
+ The script will:
214
+ 1. **Ask for your preferred username** (e.g., `admin`, `user`, etc.)
215
+ 2. **Generate or create your password**:
216
+ - Choose 'y' to generate a secure 35-character password automatically
217
+ - Choose 'n' to enter your own password (minimum 8 characters)
218
+ 3. **Generate a Flask secret key** (for session security)
219
+ 4. **Create a password hash** (for secure authentication)
220
+
221
+ **Example output:**
222
+ ```
223
+ ============================================================
224
+ CONFIGURATION VALUES FOR .env FILE
225
+ ============================================================
226
+ VIDEO_SERVER_SECRET_KEY=a1b2c3d4e5f67890abcdef1234567890abcdef1234567890abcdef1234567890
227
+ VIDEO_SERVER_USERNAME=admin
228
+ VIDEO_SERVER_PASSWORD_HASH=pbkdf2:sha256:600000$abc123$def456...
229
+ ```
230
+
231
+ **Important Security Notes**:
232
+ - **Save your password securely** - you'll need it to log in to the web interface
233
+ - **Copy all three generated values** to your `.env` file immediately
234
+ - **Never share your secret key or password hash** - treat them like private keys
235
+ - **Regenerate credentials** if you suspect they've been compromised
236
+ - The script uses **cryptographically secure random generation** for maximum security
237
+
238
+ ### 4. Start the Server
239
+
240
+ ```bash
241
+ # Start the server
242
+ mediarelay
243
+
244
+ # Or with custom configuration
245
+ mediarelay --host 0.0.0.0 --port 8080
246
+ ```
247
+
248
+ Once the server is running, you can access it in your web browser at:
249
+ - **Local access**: http://localhost:5000
250
+ - **Network access**: http://YOUR_IP_ADDRESS:5000 (if configured with --host 0.0.0.0)
251
+
252
+ ### 🔧 Configuration
253
+
254
+ #### Step-by-Step Configuration Process
255
+
256
+ 1. **Create your configuration file**:
257
+ ```bash
258
+ copy .env.example .env
259
+ ```
260
+
261
+ 2. **Generate security credentials**:
262
+ ```bash
263
+ mediarelay-genpass
264
+ ```
265
+
266
+ 3. **Update your `.env` file** with the generated values:
267
+ - Replace `VIDEO_SERVER_SECRET_KEY=your-secret-key-here` with your generated secret key
268
+ - Replace `VIDEO_SERVER_USERNAME=tboy1337` with your chosen username
269
+ - Replace `VIDEO_SERVER_PASSWORD_HASH=your-password-hash-here` with your generated hash
270
+
271
+ 4. **Configure other settings** as needed (video directory, port, etc.)
272
+
273
+ 5. **Start the server** (configuration is validated on startup):
274
+ ```bash
275
+ mediarelay
276
+ ```
277
+
278
+ #### Key Environment Variables
279
+
280
+ ```bash
281
+ # Server Configuration
282
+ VIDEO_SERVER_HOST=0.0.0.0
283
+ VIDEO_SERVER_PORT=5000
284
+ VIDEO_SERVER_DIRECTORY=/path/to/videos
285
+ VIDEO_SERVER_THREADS=6
286
+
287
+ # Security (Required - Generate using mediarelay-genpass)
288
+ VIDEO_SERVER_USERNAME=your_username # Your chosen username
289
+ VIDEO_SERVER_PASSWORD_HASH=your_secure_hash # Generated password hash
290
+ VIDEO_SERVER_SECRET_KEY=your_secret_key # Generated Flask secret key
291
+
292
+ # Performance
293
+ VIDEO_SERVER_RATE_LIMIT_PER_MIN=60
294
+ VIDEO_SERVER_SESSION_TIMEOUT=3600
295
+ VIDEO_SERVER_MAX_FILE_SIZE=21474836480 # 20GB default, set to 0 to disable
296
+
297
+ # Session Cookies (set Secure=true when serving over HTTPS)
298
+ VIDEO_SERVER_SESSION_COOKIE_SECURE=true
299
+ VIDEO_SERVER_SESSION_COOKIE_HTTPONLY=true
300
+ VIDEO_SERVER_SESSION_COOKIE_SAMESITE=Strict
301
+
302
+ # Logging
303
+ VIDEO_SERVER_LOG_LEVEL=INFO
304
+ VIDEO_SERVER_LOG_DIR=./logs
305
+ ```
306
+
307
+ ## 🔒 Security
308
+
309
+ ### Authentication & Authorization
310
+
311
+ ```python
312
+ # Multi-layer authentication
313
+ HTTP_BASIC_AUTH + SESSION_MANAGEMENT + CSRF_PROTECTION
314
+ ```
315
+
316
+ ### Security Headers
317
+
318
+ ```http
319
+ X-Content-Type-Options: nosniff
320
+ X-Frame-Options: SAMEORIGIN
321
+ X-XSS-Protection: 1; mode=block
322
+ Strict-Transport-Security: max-age=31536000 # Only when SESSION_COOKIE_SECURE=true
323
+ Content-Security-Policy: default-src 'self'
324
+ ```
325
+
326
+ ### Security Monitoring
327
+
328
+ All security events are logged:
329
+ - Authentication attempts (success/failure)
330
+ - Path traversal attempts
331
+ - Rate limit violations
332
+ - File access attempts
333
+ - Security header violations
334
+
335
+ ## 📈 Performance
336
+
337
+ ### Performance Features
338
+
339
+ - **Multi-threading**: Configurable worker threads
340
+ - **Range Requests**: Efficient video streaming
341
+ - **HTTP Caching**: Browser caching for static content
342
+ - **Connection Pooling**: Supports multiple users simultaneously
343
+ - **Memory Management**: Automatic resource cleanup
344
+
345
+ ## 📊 API Usage
346
+
347
+ ### Available Endpoints
348
+
349
+ ```bash
350
+ # Health check (no auth required)
351
+ GET /health
352
+
353
+ # Directory listing
354
+ GET /api/files?path=movies
355
+
356
+ # File streaming
357
+ GET /stream/path/to/video.mp4
358
+
359
+ # Web interface
360
+ GET /
361
+ GET /path/to/directory/
362
+ ```
363
+
364
+ ### Using the API
365
+
366
+ ```python
367
+ import requests
368
+ from requests.auth import HTTPBasicAuth
369
+
370
+ auth = HTTPBasicAuth('username', 'password')
371
+
372
+ # Get file listing
373
+ response = requests.get(
374
+ 'http://localhost:5000/api/files',
375
+ auth=auth
376
+ )
377
+ files = response.json()
378
+
379
+ # Stream video
380
+ video_url = 'http://localhost:5000/stream/movie.mp4'
381
+ response = requests.get(video_url, auth=auth, stream=True)
382
+ ```
383
+
384
+ ## 🔧 Troubleshooting
385
+
386
+ ### Common Issues
387
+
388
+ **Server won't start**: Check logs in `logs/error.log`
389
+ **Authentication issues**:
390
+ - Verify your `.env` file has all three security values from `generate_password.py`
391
+ - Ensure you're using the correct username and password you generated
392
+ - Regenerate credentials if needed: `mediarelay-genpass`
393
+ **Performance problems**: Increase thread count (`VIDEO_SERVER_THREADS`)
394
+ **Network access**: Check firewall and port forwarding
395
+ **Missing .env file**: Copy `.env.example` to `.env` and configure
396
+
397
+ ### Debug Mode
398
+
399
+ ```bash
400
+ VIDEO_SERVER_DEBUG=true
401
+ VIDEO_SERVER_LOG_LEVEL=DEBUG
402
+ mediarelay
403
+ ```
404
+
405
+ ### Support
406
+
407
+ - **Documentation**: Check `docs/` directory
408
+ - **Logs**: Review application logs in `logs/`
409
+ - **Health Check**: `curl http://localhost:5000/health`
410
+ - **Issues**: Create GitHub issue with logs and configuration
411
+
412
+ ## 📄 License
413
+
414
+ This project is licensed under the CRL License - see the [LICENSE.md](LICENSE.md) file for details.