Skip to content

New formats and examples - #197

Merged
kpdyer merged 13 commits into
masterfrom
new-formats-and-examples
Jan 11, 2026
Merged

New formats and examples#197
kpdyer merged 13 commits into
masterfrom
new-formats-and-examples

Conversation

@kpdyer

@kpdyer kpdyer commented Jan 11, 2026

Copy link
Copy Markdown
Owner

This PR adds comprehensive format definitions and examples to fteproxy.

New format definitions (20260110.json):

  • 24 regex formats including lowercase, uppercase, words, hex, binary,
    base64, csv, ip-address, domain, email, url-path, sentences, and more
  • Protocol formats: SSH, TLS (SNI), SMTP, FTP

New examples:

  • basic/: Quick start scripts
  • formats/: Side-by-side format comparison demos
  • programmatic/: Python API examples (encoder, wrap_socket, file transfer)
  • integration/: SSH tunnel, web proxy, secure chat
  • netcat/: Simple demo

Other improvements:

  • Add main.py for "python -m fteproxy" invocation
  • Bump CI test timeouts to prevent flaky failures
  • Comprehensive README with ASCII diagrams and code examples

Kevin P. Dyer added 7 commits January 10, 2026 16:20
New format definitions (20260110.json):
- 20+ regex formats including: lowercase, uppercase, words, hex,
  binary, base64, alphanumeric, csv, ip-address, domain, email,
  url-path, key-value, timestamp, http-simple, and sentences
- Each format includes both request and response variants
- All formats tested and verified

New format tests (test_formats.py):
- 43 comprehensive tests for all formats
- Tests for encoding, decoding, and roundtrip verification
- Tests for edge cases and various input sizes
- Tests for legacy format compatibility

New examples:
- basic/: Getting started scripts and documentation
- formats/: Demonstrations of different output formats
  - comparison_demo.py: Side-by-side format comparison
  - words_demo.py: Space-separated word output
  - http_demo.py: HTTP-like output format
- programmatic/: Python API usage examples
  - simple_encoder.py: Direct FTE encoding without sockets
  - echo_server.py/echo_client.py: FTE-wrapped sockets
  - format_demo.py: All formats demonstration
  - custom_format.py: Creating custom regex formats
  - file_transfer.py: File transfer over FTE
- integration/: Integration with other tools
  - ssh_tunnel.sh: SSH over FTE
  - web_proxy.sh: Web proxy over FTE
  - secure_chat.py: Encrypted chat application

All 62 tests pass.
New protocol formats in 20260110.json:
- ssh-request/response: SSH-2.0 protocol banner (e.g., SSH-2.0-OpenSSH_8.4)
- tls-sni-request/response: TLS Server Name Indication style (subdomain.domain.tld)
- smtp-request/response: SMTP EHLO command and 250 response
- ftp-request/response: FTP USER command and welcome banner

Added corresponding tests in test_formats.py:
- Individual tests for each protocol format
- Parameterized tests for protocol request formats
- All 50 format tests pass
- System tests: 120s -> 300s (5 minutes)
- Relay tests: 60s -> 180s (3 minutes)
- Remove GMP installation steps (no longer needed with fte 0.2.1)
- Add fteproxy/__main__.py to enable 'python -m fteproxy' invocation
- Update all shell scripts to use 'python -m fteproxy' instead of './bin/fteproxy'
- This is more canonical as it works regardless of installation method

Users can now run fteproxy via:
- python -m fteproxy  (works after pip install or from source)
- fteproxy            (works after pip install, via entry_points)
Replace netcat_simple.sh and netcat_verbose.sh with a single demo.sh that:
- Has proper cleanup (trap to kill background processes on exit)
- Waits for servers to start before netcat binds
- Uses nc (more portable than netcat)
- Shows clear ASCII diagram of traffic flow
- Provides copy-pasteable command for testing
- Has informative startup messages

Added README.md with documentation and traffic flow diagram.
- Complete rewrite of examples/README.md with:
  - ASCII art showing what fteproxy does
  - Directory structure with emoji icons
  - Detailed section for each example category
  - Code snippets and usage instructions
  - Traffic flow diagrams
  - Available formats table
  - Use cases section

- Updated chat/README to README.md with:
  - Traffic flow diagram
  - Code snippets showing wrap_socket usage
  - Format table
  - Customization examples
- Replace box-drawing characters with ASCII art (+, -, |, =)
- Replace emoji checkmarks with [OK], [ERROR], [FAIL]
- Remove emoji icons from headers and directory listings
- Use plain ASCII throughout for maximum compatibility
@kpdyer
kpdyer force-pushed the new-formats-and-examples branch from 3dfae80 to 6b67e77 Compare January 11, 2026 00:20
Kevin P. Dyer added 6 commits January 10, 2026 16:22
The bin/fteproxy script is no longer needed because:
- fteproxy/__main__.py enables 'python -m fteproxy'
- entry_points in setup.py/pyproject.toml creates 'fteproxy' command after pip install
- The py2exe 'frozen' code path was obsolete
The wrapper now delegates setsockopt and getsockopt to the underlying
socket, allowing code like:

    s = fteproxy.wrap_socket(s, ...)
    s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

Also fixed chat/server.py example to call setsockopt before wrap_socket
(works either way now).
- Server and client now have a scripted 10-round conversation
- Each side sends predefined messages about FTE
- Updated README with sample output and wire format examples
- Shows how traffic looks different on the wire vs what apps see
Migrated versioning to the more Pythonic approach:
- Added __version__ = '0.2.19' to fteproxy/__init__.py
- Updated cli.py to import version from fteproxy.__version__
- Updated setup.py to parse version from __init__.py
- Updated pyproject.toml to use {attr = 'fteproxy.__version__'}
- Updated MANIFEST.in to remove VERSION
- Updated GitHub Actions to use fteproxy.__version__
- Deleted fteproxy/VERSION file
…proxy

The get_fteproxy_cmd() function was trying to use bin/fteproxy which was
deleted. Updated to use the canonical 'python -m fteproxy' approach.
- Created fteproxy/tests/test_examples.py to test all examples
- Updated all example scripts to use sys.exit() with proper return codes
- Added [OK]/[FAIL] indicators to all examples for verification
- Added 'example-tests' job to GitHub Actions workflow
- Self-contained examples (formats, simple_encoder, etc.) tested directly
- Client/server examples (chat, echo) tested by spawning both processes
- file_transfer.py now has a self-test mode when run without arguments

All 9 example tests pass locally.
@kpdyer
kpdyer merged commit a783148 into master Jan 11, 2026
23 checks passed
@kpdyer
kpdyer deleted the new-formats-and-examples branch January 11, 2026 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant