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

Client connection under NAT (with empty addr list in adnl packet) drops #6

Open
andreypfau opened this issue Aug 29, 2024 · 4 comments

Comments

@andreypfau
Copy link

Requests to the node from clients that are behind NAT (with an empty addr list in adnl packets) are dropped by the node. Because of this, it is impossible to build custom applications on the ADNL protocol using this library.

@Rexagon
Copy link
Member

Rexagon commented Aug 29, 2024

I can forward the address from the received packet (Socket::recv_from returns it) and use it if the addr_list is empty. Is it some kind of defined/expected behavior of ADNL?

@andreypfau
Copy link
Author

andreypfau commented Aug 29, 2024

andreypfau@d733fad

I fixed it in my fork. TON vanilla behavior - if the list is empty (not null), then use the sender address from the socket

@Rexagon
Copy link
Member

Rexagon commented Aug 29, 2024

Can you please check if this branch https://github.com/broxus/everscale-network/tree/feature/use-packet-addr works for you (with use_packet_source_addr explicitly set to true)?And if everything is ok then I can publish it

@andreypfau
Copy link
Author

andreypfau commented Aug 29, 2024

Can you please check if this branch https://github.com/broxus/everscale-network/tree/feature/use-packet-addr works for you (with use_packet_source_addr explicitly set to true)?And if everything is ok then I can publish it

Not exactly, because in TON for resolving address by socket it MUST provide AdnlAddrList, but with empty list in schema itself.
This piece of code from my fork satisfies the requirement. (It's not exactly pretty, but it's a working example):

                let addr = match parse_address_list(list, self.options.clock_tolerance_sec) {
                    Ok(addr) => addr,
                    Err(e) => {
                        if let AdnlAddressListError::ListIsEmpty = e {
                            match raw_packet.socket_addr() {
                                SocketAddr::V4(addr) => addr,
                                SocketAddr::V6(_) => {
                                    // IPv6 is not supported
                                    return Err(e.into())
                                }
                            }
                        } else {
                            return Err(e.into());
                        }
                    }
                };

AddressList must provide reinit_date, expire_at but with empty address field.
This will make the code compatible with TON if the use_packet_source_addr option is enabled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants