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
164
165
166
167
168
169
170
171
172
173
174
175
// SPDX-License-Identifier: MIT OR Apache-2.0
//! Proxy application for exfiltrate.
//!
//! This binary provides a standalone proxy server that bridges different transport
//! protocols for the exfiltrate system. It creates a transit proxy that can handle
//! JSON-RPC messages and forward them between different clients and servers.
//!
//! # Overview
//!
//! The proxy application serves as an intermediary for JSON-RPC communication,
//! allowing different components to communicate through a central hub. This is
//! particularly useful for:
//! - Debugging distributed systems
//! - Bridging different transport protocols (HTTP, stdio, WebSocket)
//! - Logging and monitoring RPC traffic
//! - Implementing the Model Context Protocol (MCP) server
//!
//! # Configuration
//!
//! The proxy can be configured to use different transport mechanisms:
//! - **HTTP Server**: Listens on a TCP port (default: 127.0.0.1:1984)
//! - **Stdio Server**: Communicates via standard input/output
//!
//! # Usage
//!
//! Run the proxy with:
//! ```bash
//! cargo run --bin proxy --features transit
//! ```
//!
//! The proxy will start an HTTP server on port 1984 by default. To use stdio
//! mode instead, uncomment the stdio line and comment out the HTTP line.
//!
//! # Examples
//!
//! ## Creating a transit proxy
//!
//! ```
//! # // Mock types for documentation
//! # mod transit {
//! # pub mod transit_proxy {
//! # pub struct TransitProxy;
//! # impl TransitProxy {
//! # pub fn new() -> Self { TransitProxy }
//! # }
//! # }
//! # pub mod http {
//! # use super::transit_proxy::TransitProxy;
//! # pub struct Server;
//! # impl Server {
//! # pub fn new(_addr: &str, _proxy: TransitProxy) -> Self { Server }
//! # }
//! # }
//! # pub mod stdio {
//! # use super::transit_proxy::TransitProxy;
//! # pub struct Server;
//! # impl Server {
//! # pub fn new(_proxy: TransitProxy) -> Self { Server }
//! # }
//! # }
//! # }
//! # use transit::transit_proxy::TransitProxy;
//!
//! // Create a transit proxy for routing messages
//! let transit_proxy = TransitProxy::new();
//!
//! // The proxy can be used with different server types
//! # // Note: In actual usage, you would keep the server alive
//! ```
//!
//! ## HTTP server configuration
//!
//! ```
//! # mod transit {
//! # pub mod transit_proxy {
//! # pub struct TransitProxy;
//! # impl TransitProxy {
//! # pub fn new() -> Self { TransitProxy }
//! # }
//! # }
//! # pub mod http {
//! # use super::transit_proxy::TransitProxy;
//! # pub struct Server;
//! # impl Server {
//! # pub fn new(_addr: &str, _proxy: TransitProxy) -> Self { Server }
//! # }
//! # }
//! # }
//! # use transit::transit_proxy::TransitProxy;
//! # use transit::http::Server;
//!
//! let transit_proxy = TransitProxy::new();
//!
//! // Configure HTTP server with custom address
//! let server = Server::new("127.0.0.1:8080", transit_proxy);
//!
//! // Server runs on background threads
//! // In production, you would keep the main thread alive
//! ```
//!
//! ## Stdio server configuration
//!
//! ```
//! # mod transit {
//! # pub mod transit_proxy {
//! # pub struct TransitProxy;
//! # impl TransitProxy {
//! # pub fn new() -> Self { TransitProxy }
//! # }
//! # }
//! # pub mod stdio {
//! # use super::transit_proxy::TransitProxy;
//! # pub struct Server;
//! # impl Server {
//! # pub fn new(_proxy: TransitProxy) -> Self { Server }
//! # }
//! # }
//! # }
//! # use transit::transit_proxy::TransitProxy;
//! # use transit::stdio::Server;
//!
//! let transit_proxy = TransitProxy::new();
//!
//! // Configure stdio server for IPC communication
//! let server = Server::new(transit_proxy);
//!
//! // Server communicates via stdin/stdout
//! // In production, you would keep the main thread alive
//! ```
//!
//! # Architecture
//!
//! The proxy uses a multi-threaded architecture without async runtimes:
//! - Each connection is handled in its own thread
//! - Message routing is performed by the TransitProxy
//! - The main thread is parked to keep the application running
//!
//! # Features
//!
//! This binary requires the `transit` feature to be enabled, which includes:
//! - HTTP server support
//! - Stdio communication support
//! - WebSocket support
//! - Message routing and forwarding
use TransitProxy;
/// Main entry point for the exfiltrate proxy server.
///
/// Creates a transit proxy and starts an HTTP server listening on port 1984.
/// The server runs on background threads, so the main thread is parked to
/// keep the application alive.
///
/// # Configuration Options
///
/// The function includes commented code for alternative transport modes:
/// - HTTP server mode (default): Listens on 127.0.0.1:1984
/// - Stdio mode: Communicates via standard input/output
///
/// To switch modes, comment/uncomment the appropriate lines.
///
/// # Panics
///
/// The application will panic if:
/// - The specified port is already in use
/// - The server fails to start
/// - Network permissions are insufficient