Play P2P Windows games without forwarding ports
Find a file
Maxim Mikhailov ca06e12e8c
Add INI-based config support
Signed-off-by: Maxim Mikhailov <darkness9724@gmail.com>
2026-01-31 23:38:51 +01:00
address Update README.md 2026-01-31 15:50:07 +01:00
doc initial commit 2019-06-08 22:06:53 +08:00
inject Add INI-based config support 2026-01-31 23:38:51 +01:00
loader Update README.md 2026-01-31 15:50:07 +01:00
packer Update README.md 2026-01-31 15:50:07 +01:00
relay Update README.md 2026-01-31 15:50:07 +01:00
update Update README.md 2026-01-31 15:50:07 +01:00
.clang-format Change code style 2026-01-31 15:31:35 +01:00
.clangd Change code style 2026-01-31 15:31:35 +01:00
.editorconfig Convert tabs to spaces 2026-01-26 22:33:01 +01:00
.gitignore Update README.md 2026-01-31 15:50:07 +01:00
.gitmodules Remove "autopunch-" prefix 2026-01-31 10:55:23 +01:00
LICENSE Update README.md 2026-01-31 15:50:07 +01:00
README.md Update README.md 2026-01-31 15:50:07 +01:00

autopunch

This program lets you host & connect to friends to play peer-to-peer games without having to open or redirect any port. This does not add any latency to the connection compared to redirecting ports manually.

You can play with users that don't use autopunch without compability issues and can always leave it enabled. However, the tool will only do its magic if both peers use autopunch.

Technical details: autopunch injects itself into a process and detours some winsock calls (sendto, recvfrom, ...) to rewrite addresses so that they appear to be internal ports rather than external ports. It additionally performs hole punching by using a STUN-like relay which helps know internal ports of other users.

How to use

  • Download the latest version: for Windows 64 bits or Windows 32 bits (use one of these links, not any other download button)
  • Start your peer-to-peer game
  • Double-click the downloaded executable file to run it; there is no setup or anything so put the file somewhere you'll remember (doesn't have to be in the game folder)
  • If a Windows Defender SmartScreen popup appears, click on "More information", then click on "Run anyway"
  • If a Windows Firewall popup appears, check the "Private networks" and "Public networks" checkboxes, then click on "Allow access"
  • If prompted for an update, just wait, everything will be updated and restart automatically
  • Click on the game you wish to play in the list, then click "Punch!"; the window will close and "autopunch" will appear in the game window title
  • Play! Host on any port, or connect to the IP and port the host gives you just as usual.
  • You can host and connect to peer with or without using autopunch: no compatibility issues, you can always leave it running.
  • However, if a host didn't forward its ports, both peers will need autopunch, not just the one hosting!

Troubleshooting

  • Keep in mind that UDP hole punching does not work with symmetric NAT, which is common in corporate networks and with some mobile operators. With symmetric NAT, the mapping created for the STUN server only allows traffic from that server, so the discovered external port is not usable by peers.
  • If you experience issues when using autopunch, make sure both peers are running autopunch and are using the same relay host. Also try switching who hosts.
  • If you have any other issue or feedback, open an issue. When doing that, please attach the log file using Debug release.

Building

For build instructions, go to the specific component and open its README.md.

Quick overview of the components of the project:

  • inject: the core autopunch DLL, that is injected into a game; has both 32 and 64 bit versions, release and debug versions;
  • address: a tiny program to get the address of the LoadLibraryW function of the WoW Kernel32 module; this works because ASLR is only done once per reboot;
  • loader: the program that has the GUI and autoupdates, and starts the injection of the autopunch DLL; the final executable packs the 4 autopunch DLLs, the address executable, and a Win32 app manifest.
  • packer: a tiny program to pack a binary file as a string in a Go source file so that it can be included in an executable;
  • relay: the STUN-like relay used by autopunch;
  • update: serves the specified file (e.g., autopunch.dll) so it can be updated automatically.