Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature tcp custom response #135

merged 15 commits into from Mar 21, 2020

Feature tcp custom response #135

merged 15 commits into from Mar 21, 2020


Copy link

strictlymike commented Jan 7, 2020

Added custom responses for TCP and UDP listeners to bridge the gap for the most common customization other than HTTP (i.e. custom binary protocols)

Addition of TCP and UDP custom responses entailed nomenclature changes

  • Renamed to
  • Renamed fakenet_http.ini to custom_responses.ini under test/
  • Renamed sample_http_custom.ini to sample_custom_response.ini under fakenet/configs/
  • Renamed HandleRequest callback to HandleHttp (but I check for and use the legacy callback name if it's there)
  • Changed MatchURIs and MatchHosts to HttpURIs and HttpHosts to clarify that they are specific to HTTP custom responses and not applicable to e.g. TCP or UDP custom responses

To reduce file sprawl, I kept it down to a single outboard INI file (e.g. custom_responses.ini) to specify all of the custom responses for HTTP, TCP, and/or UDP. I likewise made it possible to use a single Python file (e.g. to codify all the user-implemented callbacks.

I moved the files pointed to by custom INI files (raw response files and Python scripts) to the configs/ directory by the following rationale:
1.) The defaultFiles webroot directory doesn't have any analogous TCP/UDP equivalent
2.) It doesn't make sense to allow e.g. user-implemented Python callbacks to be able to be retrieved via HTTP, or more dangerously, modified via FTP

The moved files included:

  • sample_raw_response.txt
  • now named


  • ListenerType and InstanceName custom response specifications to control which listeners/instances adopt which custom responses
  • TcpStaticBase64, TcpStaticString, TcpRawFile, TcpDynamic, and all analogous UdpXxx counterparts to configure custom responses for TCP and UDP
  • HandleTcp and HandleUdp example callbacks to sample files
  • Increased tests for HTTP custom responses
  • sample_raw_tcp_response.txt


  • - updated socket server tests to allow for cases where the received data is expected to deviate from the transmitted data (i.e. for custom responses)
  • default.ini - added commented-out Custom example lines to TCP and UDP listener configs
  • - Documentation
@strictlymike strictlymike merged commit 85da811 into master Mar 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

1 participant
You can’t perform that action at this time.