detect public vs private connection

I’m curious if there is a reliable way to detect if an incoming connection to a Fly machine is from another Fly machine or the public internet. I know that Fly does a lot of fancy things with 6pn addresses, so I am sorta hoping I can use address semantics to figure this out.

Thanks!

Oh, and I’m using 6pn addresses for my internal connections between nodes if that helps.

Take a look at our recent Fly-Src feature, Fly-Src: Authenticating HTTP requests between Fly Apps. It requires routing requests though out proxy via flycast so that may not work for your specific design/need.

Thanks for the tip! Unfortunately my use case involves raw TCP connections using a custom protocol. For now I’m going to be detecting internal vs external via my protocol’s header, however it would be very convenient if there were docs on interpreting incoming addrs.

Actually… I just realized, if I connect machine → machine directly, the ip that the receiving machine sees should be the 6pn address of the sending machine right? If so, can’t I detect this via just checking that the first 4 bytes of the address is equal to the receiving machine’s address? Accoridng to the docs the first four bytes should be my organization address right? I assume that connections from the fly proxy will have a different organization address

Yes, if you’re doing machine to machine communication, the address would be the 6PN of the sender. We’ve documented the parts of the address, Private Networking · Fly Docs and hopefully provides what you’re looking for.

Yup, I got this working yesterday and it seems to work great! Thanks :slight_smile:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.