Giter Club home page Giter Club logo

Comments (2)

tmpgithubissue102 avatar tmpgithubissue102 commented on July 1, 2024 1

This is a temporary patch for the case ADDR_TYPE_TOR_V3: switch case at https://github.com/ElementsProject/lightning/blob/v23.08.1/connectd/connectd.c#L827 that allowed me to run my node as intended:

		case ADDR_TYPE_TOR_V3:
			if (use_proxy) /* hand it to the proxy */
				break;
			if (!use_dns) {  /* ignore DNS when we can't use it */
				tal_append_fmt(&connect->errors,
					       "%s: dns disabled. ",
					       type_to_string(tmpctx,
							      struct wireaddr_internal,
							      addr));
				goto next;
			}
			/* Resolve with getaddrinfo */
			memset(&hints, 0, sizeof(hints));
			hints.ai_socktype = SOCK_STREAM;
			hints.ai_family = AF_UNSPEC;
			hints.ai_protocol = 0;
			hints.ai_flags = AI_ADDRCONFIG;
			gai_err =  getaddrinfo(fmt_wireaddr_without_port(tmpctx, &addr->u.wireaddr.wireaddr), // use fmt_wireaddr_without_port() to extract the .onion hostname
					      tal_fmt(tmpctx, "%d",
						      addr->u.wireaddr.wireaddr.port),
					      &hints, &ais); 
			if (gai_err != 0) {
				tal_append_fmt(&connect->errors,
					       "%s: getaddrinfo error '%s'. ",
					       type_to_string(tmpctx,
							      struct wireaddr_internal,
							      addr),
					       gai_strerror(gai_err));
				goto next;
			}
			/* create new addrhints on-the-fly per result ... */
			for (aii = ais; aii; aii = aii->ai_next) {
				addrhint.itype = ADDR_INTERNAL_WIREADDR;
				addrhint.u.wireaddr.is_websocket = false;
				if (aii->ai_family == AF_INET) {
					sa4 = (struct sockaddr_in *) aii->ai_addr;
					wireaddr_from_ipv4(&addrhint.u.wireaddr.wireaddr,
							   &sa4->sin_addr,
							   addr->u.wireaddr.wireaddr.port);
				} else if (aii->ai_family == AF_INET6) {
					sa6 = (struct sockaddr_in6 *) aii->ai_addr;
					wireaddr_from_ipv6(&addrhint.u.wireaddr.wireaddr,
							   &sa6->sin6_addr,
							   addr->u.wireaddr.wireaddr.port);
				} else {
					/* skip unsupported ai_family */
					continue;
				}
				tal_arr_expand(&connect->addrs, addrhint);
				/* don't forget to update convenience pointer */
				addr = &connect->addrs[connect->addrnum];
			}
			freeaddrinfo(ais);
			goto next;

The code was copied from the case ADDR_TYPE_DNS: switch case (https://github.com/ElementsProject/lightning/blob/v23.08.1/connectd/connectd.c#L836) and modified to resolve the .onion domain instead.

Running a patched node for a week with some open channels without any connectivity issues, having both clearnet and Tor connections to peers.

Not closing the issue because the main CLN's repository continues with a broken logic for handling .onion addresses in connectd.c and I expect some maintainer/contributor to make a cleaner patch. Note that always-use-proxy should determine whether to enforce use-proxy or not in that particular situation.

from lightning.

marcovelon avatar marcovelon commented on July 1, 2024

I wanted to try Lightning and came across this issue here.

First of all, thank you @tmpgithubissue102 for providing a patch that helped me to avoid wasting time on debugging the issue myself. It works as expected.

Secondly, I am not sure why the 'bug' tag wasn't assigned yet, since it's not about personal preferences here but about how software is supposed to work by default - without assuming there is a need of a proxy if we need to resolve an .onion address, since Tor instance is capable of being a standalone router and has appropriate configurations for routing the network traffic through itself.

Core Lightning refuses to resolve .onion addresses if there is no proxy specified, which is a bug.

@cdecker @rustyrussell @vincenzopalazzo hope you can clarify this.

from lightning.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.