proxy
Flight SSH proxy functionality.
FlightProxy ¶
FlightProxy(url, backend_url, proxy_map, **kwargs)
Bases: FlightServerBase
Transparent Flight proxy that rewrites endpoint URIs based on mapping.
Rewrites FlightInfo endpoint location URIs on GetFlightInfo responses; all other read RPC methods are forwarded to the backend unchanged. This is useful for proxying a remote Flight server through SSH port forwards.
Write RPCs (DoPut/DoExchange) are intentionally not supported, so publishing through the proxy is not possible.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
URL to listen for queries. |
required |
backend_url
|
str
|
URL of remote info server to proxy. |
required |
proxy_map
|
dict[str, str]
|
Dictionary mapping of endpoint locations to be replaced. It should be keyed on OLD_HOST:PORT with value as NEW_HOST:PORT. The URL scheme will be preserved. |
required |
Source code in arrakis/proxy.py
91 92 93 94 95 96 97 98 99 100 101 102 | |
SSHConnection ¶
SSHConnection(destination)
Manage a background SSH connection
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
destination
|
str
|
SSH destination (see ssh(1) for form). |
required |
Source code in arrakis/proxy.py
189 190 191 192 193 194 195 196 197 | |
close ¶
close()
Close the connection
Source code in arrakis/proxy.py
292 293 294 295 296 | |
connect ¶
connect()
connect to the ssh destination
Source code in arrakis/proxy.py
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | |
exec ¶
exec(ssh_cmd=None, shell_cmd=None, **kwargs)
exec ssh command on control master
Source code in arrakis/proxy.py
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | |
forward_port ¶
forward_port(remote_hostport, local_port=None, *, wait=False, timeout=10)
initiate a local port forward to remote location
Source code in arrakis/proxy.py
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 | |
ssh_proxy ¶
ssh_proxy(ssh_dest, arrakis_server=None, bind_address=None, connection_factory=SSHConnection)
Create Flight proxy server over SSH.
This is done by:
- Make SSH connection to the remote host.
- Determine initial Flight info server URL on the remote side.
- Retrieve all known endpoints from the remote info server.
- Set up local ssh port forwards to all endpoints.
- Launch Flight proxy server that rewrites endpoints to point to the local port forwards.
This should always be used as a context manager so that all connections are closed when done.
Note that publishing is not supported through the proxy; see
FlightProxy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ssh_dest
|
str
|
Remote SSH destination (see ssh(1) for form). |
required |
arrakis_server
|
str | None
|
Remote Arrakis info server URL. If not specified it will be determined from the ARRAKIS_SERVER env var on the remote side. |
None
|
bind_address
|
str
|
Flight proxy server HOST:PORT. Defaults to "localhost:0" (random open port chosen on localhost). |
None
|
connection_factory
|
Callable[[str], SSHConnectionLike]
|
Factory producing the SSH connection for the given destination. Intended for substituting a fake connection in tests. |
SSHConnection
|
Source code in arrakis/proxy.py
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 | |