# soheilhy/cmux

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/soheilhy-cmux).**

2,710 stars · 206 forks · Go · apache-2.0

## Links

- GitHub: https://github.com/soheilhy/cmux
- awesome-repositories: https://awesome-repositories.com/repository/soheilhy-cmux.md

## Description

cmux is a TCP connection multiplexer and layer four protocol dispatcher. It routes incoming network traffic to different backend handlers by analyzing the initial bytes of the payload, allowing multiple network protocols to share a single IP address and port.

The project identifies traffic using protocol signatures, byte-prefix matching, and header-value evaluation. It supports the detection of specific protocols including TLS, HTTP/1, and HTTP/2, and enables bidirectional handshaking where data can be sent back to a client during the matching phase.

The routing system includes a first-match dispatch priority and a catch-all fallback handler for connections that do not meet specific criteria. Traffic management capabilities include configurable read timeouts for initial payload inspection and custom error handling for listener failures.

## Tags

### Networking & Communication

- [Single-Port Multi-Protocol Support](https://awesome-repositories.com/f/networking-communication/single-port-multi-protocol-support.md) — Runs several different network services on one IP address and port without needing a dedicated port for each.
- [TCP Connection Multiplexers](https://awesome-repositories.com/f/networking-communication/tcp-connection-multiplexers.md) — Provides a TCP connection multiplexer that routes traffic to different listeners based on initial payload content. ([source](https://cdn.jsdelivr.net/gh/soheilhy/cmux@master/README.md))
- [TLS Handshake Detection](https://awesome-repositories.com/f/networking-communication/connection-handshake-protocols/tls-handshake-detection.md) — Identifies secure connections by matching the TLS handshake packet and filtering by protocol version. ([source](http://godoc.org/github.com/soheilhy/cmux))
- [Connection Multiplexing](https://awesome-repositories.com/f/networking-communication/connection-multiplexing.md) — Multiplexes multiple network protocols over one TCP port by analyzing the first packet of each connection.
- [HTTP/2 Protocol Detection](https://awesome-repositories.com/f/networking-communication/http-2-support/http-2-protocol-detection.md) — Detects HTTP/2 connections by analyzing the frame header within the initial data packet. ([source](http://godoc.org/github.com/soheilhy/cmux))
- [HTTP/1 Protocol Detection](https://awesome-repositories.com/f/networking-communication/http-traffic-inspection/http-1-protocol-detection.md) — Identifies HTTP/1 requests by parsing the method or first line of the connection payload for protocol dispatching. ([source](http://godoc.org/github.com/soheilhy/cmux))
- [Payload-Based Connection Routing](https://awesome-repositories.com/f/networking-communication/network-reliability-diagnostics/connection-session-management/connection-management/client-connection-inspections/tcp-connection-filtering/payload-based-connection-routing.md) — Provides the ability to route TCP connections to different backend handlers by inspecting initial payload bytes. ([source](http://godoc.org/github.com/soheilhy/cmux))
- [Network Traffic Routers](https://awesome-repositories.com/f/networking-communication/network-traffic-routers.md) — Inspects connection headers and byte prefixes to direct network traffic to specific backend listeners.
- [Single-Port Protocol Detection](https://awesome-repositories.com/f/networking-communication/network-transport-protocols/multi-protocol-routing/single-port-protocol-detection.md) — Acts as a layer four router that identifies protocols like HTTP, TLS, and HTTP/2 to share a single port.
- [Protocol Payload Inspectors](https://awesome-repositories.com/f/networking-communication/protocol-payload-inspectors.md) — Buffers the first few bytes of an incoming stream to analyze protocol signatures before handing off the connection.
- [Protocol Detection Forwarders](https://awesome-repositories.com/f/networking-communication/protocol-transparent-forwarding/protocol-detection-forwarders.md) — Identifies incoming traffic such as HTTP or TLS using packet signatures to direct connections to the appropriate backend handler.
- [Header-Based Routing](https://awesome-repositories.com/f/networking-communication/request-header-configuration/header-filters/header-based-routing.md) — Directs network traffic to specific listeners by parsing and evaluating request headers found in the initial payload.
- [Traffic Protocol Inspection](https://awesome-repositories.com/f/networking-communication/traffic-protocol-inspection.md) — Provides capabilities for detecting and managing network protocols by inspecting initial connection bytes. ([source](https://godoc.org/github.com/soheilhy/cmux))
- [Blocking Operation Timeouts](https://awesome-repositories.com/f/networking-communication/blocking-operation-timeouts.md) — Enforces a strict time limit on the initial read operation to prevent slow connections from blocking the multiplexer.
- [Connection Handshake Protocols](https://awesome-repositories.com/f/networking-communication/connection-handshake-protocols.md) — Sends data back to the client during the matching process to complete protocol handshakes before final hand-off. ([source](https://godoc.org/github.com/soheilhy/cmux))
- [Custom Handshake Responses](https://awesome-repositories.com/f/networking-communication/connection-handshake-protocols/custom-handshake-responses.md) — Sends specific data responses to clients during the connection phase before handing the session off to a final protocol handler.
- [Fallback Connection Routing](https://awesome-repositories.com/f/networking-communication/protocol-event-handlers/fallback-connection-routing.md) — Redirects connections that fail all specific protocol matches to a designated default handler.
- [Fallback Protocol Routing](https://awesome-repositories.com/f/networking-communication/protocol-event-handlers/fallback-protocol-routing.md) — Redirects connections to a fallback handler when no other specific protocol rules match the incoming traffic. ([source](http://godoc.org/github.com/soheilhy/cmux))

### Security & Cryptography

- [Payload-Based Traffic Filtering](https://awesome-repositories.com/f/security-cryptography/payload-based-traffic-filtering.md) — Inspects request headers and payload prefixes to decide which application logic should handle a network connection.
- [Concurrent Handshake Writes](https://awesome-repositories.com/f/security-cryptography/encryption-as-a-service/concurrent-handshake-writes.md) — Allows a response, such as a TLS handshake, to be sent to the client while simultaneously matching the connection. ([source](http://godoc.org/github.com/soheilhy/cmux))
- [Bidirectional Matching](https://awesome-repositories.com/f/security-cryptography/handshake-protocols/bidirectional-matching.md) — Provides the ability to send data back to the client while reading bytes to determine the protocol.

### Software Engineering & Architecture

- [Protocol Prefix Matching](https://awesome-repositories.com/f/software-engineering-architecture/byte-sequence-searching/protocol-prefix-matching.md) — Identifies target handlers by comparing the initial bytes of a TCP connection against predefined byte sequences.
- [Protocol Signature Matching](https://awesome-repositories.com/f/software-engineering-architecture/pattern-matching-libraries/regex-pattern-matchers/traffic-signature-matching/protocol-signature-matching.md) — Identifies incoming traffic using protocol signatures for HTTP or TLS to assign connections to the correct handler. ([source](http://godoc.org/github.com/soheilhy/cmux))
- [Payload](https://awesome-repositories.com/f/software-engineering-architecture/string-matching-algorithms/partial-string-matching/prefix-matching/payload.md) — Identifies incoming connections by comparing the initial bytes of the payload against predefined string prefixes. ([source](http://godoc.org/github.com/soheilhy/cmux))

### Data & Databases

- [Proxy Phase Timeouts](https://awesome-repositories.com/f/data-databases/proxy-timeout-managers/proxy-phase-timeouts.md) — Defines a time limit for the initial read operation that inspects the connection payload during the matching phase. ([source](http://godoc.org/github.com/soheilhy/cmux))

### Web Development

- [Header-Based Routing](https://awesome-repositories.com/f/web-development/backend-development/request-response-handling/http-utilities/http-header-manipulators/http-request-header-inspectors/header-based-routing.md) — Implements routing logic that directs connections based on specific values found in HTTP request headers. ([source](http://godoc.org/github.com/soheilhy/cmux))
- [Header Prefix Routing](https://awesome-repositories.com/f/web-development/backend-development/request-response-handling/http-utilities/http-header-manipulators/http-request-header-inspectors/header-prefix-routing.md) — Allows directing network connections based on whether an HTTP header value starts with a specific string. ([source](http://godoc.org/github.com/soheilhy/cmux))
- [Priority-Based Dispatch](https://awesome-repositories.com/f/web-development/routing-systems/routing/matching-algorithms/regex-based-url-dispatchers/handler-dispatchers/priority-based-dispatch.md) — Assigns connections to the first configured protocol listener that satisfies the matching criteria based on priority.

### Part of an Awesome List

- [Language Frameworks](https://awesome-repositories.com/f/awesome-lists/devtools/language-frameworks.md) — Connection multiplexer supporting gRPC.
