Score:0

How to create TCP proxy that supports multiple hosts?

jp flag

I would like to create a TCP proxy that supports multiple hosts. The example I saw was where a DNS server was used to point a specific host to a TCP proxy which had the host hardcoded in it. The TCP proxy can not handle multiple hosts because if all hosts were routed to the TCP proxy, the proxy would not know where to send the data to. Are there any ways to get around this issue?

Michael Hampton avatar
cz flag
How could the proxy possibly know where to proxy to?
comctimert avatar
jp flag
Yes that is the question. I want to be able to use the TCP proxy like an HTTP proxy supporting all hosts and ports without knowing what they are beforehand. I was thinking of something like creating new servers on the fly on DNS lookup but I don't know if that is feasible.
Michael Hampton avatar
cz flag
You have to have some way to distinguish them!
Score:2
cn flag

TCP works over IP and IP has no notion of host(names) but only of IP addresses.

As such, TCP knows also only about IP addresses, not hostnames.

If you want to have something handling hostnames you need a protocol on top of TCP (ex: HTTP, SSH, etc.) or translate names to IP addresses before using TCP, as the DNS is typically providing.

Or you need your "TCP" proxy to listen on separate ports and proxy things depending on which port is accessed. However you still have the problem of mapping names to now not only an IP address (of the proxy) but its port too, which is possible but more difficult with DNS (if you control the client, you can do that using SRV records or in the future SVCB ones).

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.