fbi-proxy 1.0.0

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.
package/README.md ADDED
@@ -0,0 +1,158 @@
1
+ # fbi-proxy
2
+
3
+ FBI Proxy is a super easy way to turn your local network over https.
4
+
5
+ ## Quick Start
6
+
7
+ ```bash
8
+ # Build the Rust proxy (production)
9
+ npm run build-proxy
10
+
11
+ # Start the proxy system
12
+ npm start
13
+
14
+ # Development mode with auto-reload
15
+ npm run dev
16
+ ```
17
+
18
+ ## Build Scripts
19
+
20
+ ### Rust Proxy Build Commands:
21
+
22
+ ```bash
23
+ # Production build (optimized)
24
+ npm run build-proxy
25
+
26
+ # Development build (faster compilation)
27
+ npm run build-proxy-dev
28
+
29
+ # Windows-specific build (uses build-windows.bat)
30
+ npm run build-proxy-windows
31
+
32
+ # Check code without building
33
+ npm run check-proxy
34
+
35
+ # Clean build artifacts
36
+ npm run clean-proxy
37
+
38
+ # Run tests
39
+ npm run test-proxy
40
+
41
+ # Format code
42
+ npm run fmt-proxy
43
+
44
+ # Run linter
45
+ npm run clippy-proxy
46
+
47
+ # Run proxy directly (for testing)
48
+ npm run run-proxy
49
+ ```
50
+
51
+ ### Combined Commands:
52
+
53
+ ```bash
54
+ # Build and run (development)
55
+ npm run proxy:dev
56
+
57
+ # Build and run (production)
58
+ npm run proxy:prod
59
+
60
+ # Full build (includes pre-build checks)
61
+ npm run build
62
+ ```
63
+
64
+ ## Architecture
65
+
66
+ - **TypeScript CLI** (`src/cli.ts`): Orchestrates Caddy and Rust proxy
67
+ - **Rust Proxy** (`rs/proxy.rs`): High-performance HTTP/WebSocket proxy using Hyper
68
+ - **Caddy Server**: Handles TLS termination and domain routing
69
+
70
+ ## Development Workflow
71
+
72
+ ### First Time Setup:
73
+
74
+ ```bash
75
+ # 1. Install dependencies
76
+ npm install
77
+
78
+ # 2. Build the Rust proxy
79
+ npm run build-proxy
80
+
81
+ # 3. Start development
82
+ npm run dev
83
+ ```
84
+
85
+ ### Daily Development:
86
+
87
+ ```bash
88
+ # Quick development cycle
89
+ npm run proxy:dev
90
+
91
+ # Or step by step:
92
+ npm run build-proxy-dev # Fast Rust build
93
+ npm run dev # Start with auto-reload
94
+ ```
95
+
96
+ ### Before Committing:
97
+
98
+ ```bash
99
+ npm run fmt-proxy # Format Rust code
100
+ npm run clippy-proxy # Check Rust linting
101
+ npm run check-proxy # Verify compilation
102
+ npm run test-proxy # Run tests
103
+ ```
104
+
105
+ ### Production Build:
106
+
107
+ ```bash
108
+ npm run build # Full optimized build
109
+ npm run proxy:prod # Build and run production
110
+ ```
111
+
112
+ ## Prerequisites
113
+
114
+ - **Rust**: Install from https://rustup.rs/
115
+ - **Caddy**: Web server for TLS termination
116
+ - **Bun**: Runtime for TypeScript CLI
117
+
118
+ ## feats
119
+
120
+ 1. Port Forwarder, https://[port].fbi.com proxies to http://localhost:[port]
121
+ 2. Host Forwarder, https://[*].[host].fbi.com proxies to [host] with url https://[*].fbi.com
122
+ 3. Host:Port forwarder https://[host]--[port].fbi.com proxies to http://[host]:[port]
123
+ 4. Configurable host alias
124
+
125
+ ## ...
126
+
127
+ configurable local Proxy generator
128
+
129
+ Environment Defaults:
130
+
131
+ ```env
132
+ LOCALHOST="fbi.com"
133
+ SERVICES="localhost:5600"
134
+ ```
135
+
136
+ activitywatch=3000
137
+ activitywatch=3000
138
+ activitywatch=3000
139
+ activitywatch=3000
140
+
141
+ ```
142
+
143
+ # https://activitywatch.fbi.com -> localhost:5600
144
+ activitywatch: :5600
145
+
146
+ # https://aw.fbi.com -> localhost:5600
147
+ aw: :5600
148
+
149
+ # https://calibre.fbi.com -> localhost:7250
150
+ calibre: :7250
151
+
152
+ # https://everything.fbi.com -> localhost:2489
153
+ everything: :2489
154
+
155
+ # https://vscode.fbi.com -> localhost:8000
156
+ vscode: :8000
157
+
158
+ ```
package/RUST_PROXY.md ADDED
@@ -0,0 +1,85 @@
1
+ # Rust Proxy Migration
2
+
3
+ The proxy functionality has been migrated from TypeScript/Bun to Rust for better performance and reliability.
4
+
5
+ ## Architecture
6
+
7
+ - **TypeScript (`src/cli.ts`)**: Main entry point that:
8
+ - Checks for Rust and Caddy installation
9
+ - Launches the Rust proxy server
10
+ - Starts Caddy with the appropriate configuration
11
+ - **Rust (`rs/proxy.rs`)**: High-performance proxy server that:
12
+ - Handles HTTP requests and WebSocket upgrades
13
+ - Processes host header port encoding (e.g., `example.com--3000` → `example.com:3000`)
14
+ - Forwards requests to local services
15
+ - Runs on port 24306
16
+
17
+ ## Building
18
+
19
+ ### Using npm/bun scripts:
20
+
21
+ ```bash
22
+ # Build release version
23
+ bun run build-proxy
24
+
25
+ # Build development version
26
+ bun run build-proxy-dev
27
+ ```
28
+
29
+ ### Manual build:
30
+
31
+ ```bash
32
+ cd rs
33
+ cargo build --release
34
+ ```
35
+
36
+ ### Platform-specific build scripts:
37
+
38
+ ```bash
39
+ # Linux/macOS
40
+ ./build-proxy.sh
41
+
42
+ # Windows
43
+ build-proxy.bat
44
+ ```
45
+
46
+ ## Dependencies
47
+
48
+ ### System Requirements:
49
+
50
+ - Rust (install from https://rustup.rs/)
51
+ - Caddy web server
52
+ - Bun runtime
53
+
54
+ ### Rust Dependencies:
55
+
56
+ - `hyper` - HTTP server and client
57
+ - `tokio` - Async runtime
58
+ - `tokio-tungstenite` - WebSocket support
59
+ - `futures-util` - Stream utilities
60
+ - `url` - URL parsing
61
+ - `regex` - Pattern matching
62
+
63
+ ## Features
64
+
65
+ - **High Performance**: Native Rust implementation for better speed and memory usage
66
+ - **WebSocket Support**: Full WebSocket proxying capabilities
67
+ - **Port Encoding**: Supports special host header format for port specification
68
+ - **Error Handling**: Robust error handling and logging
69
+ - **Hot Reloading**: Development-friendly with auto-restart capabilities
70
+
71
+ ## Usage
72
+
73
+ ```bash
74
+ # Start the full proxy system
75
+ bun start
76
+
77
+ # Development mode with hot reloading
78
+ bun run dev
79
+ ```
80
+
81
+ The proxy will:
82
+
83
+ 1. Start the Rust proxy server on port 24306
84
+ 2. Launch Caddy with the configured Caddyfile
85
+ 3. Handle all incoming requests and forward them to local services
@@ -0,0 +1,15 @@
1
+ @echo off
2
+
3
+ REM Build script for the Rust proxy
4
+ echo Building Rust proxy...
5
+
6
+ cd rs
7
+ cargo build --release
8
+
9
+ if %errorlevel% equ 0 (
10
+ echo ✅ Rust proxy built successfully
11
+ echo Binary location: rs\target\release\proxy.exe
12
+ ) else (
13
+ echo ❌ Failed to build Rust proxy
14
+ exit /b 1
15
+ )
package/build-proxy.sh ADDED
@@ -0,0 +1,15 @@
1
+ #!/bin/bash
2
+
3
+ # Build script for the Rust proxy
4
+ echo "Building Rust proxy..."
5
+
6
+ cd rs
7
+ cargo build --release
8
+
9
+ if [ $? -eq 0 ]; then
10
+ echo "✅ Rust proxy built successfully"
11
+ echo "Binary location: rs/target/release/proxy"
12
+ else
13
+ echo "❌ Failed to build Rust proxy"
14
+ exit 1
15
+ fi