- *salen = offsetof(union sockaddr_union, un.sun_path) + strlen(sa->un.sun_path);
-
- } else if (arg_remote_host[0] == '@') {
- sa->un.sun_family = AF_UNIX;
- sa->un.sun_path[0] = 0;
- strncpy(sa->un.sun_path+1, arg_remote_host+1, sizeof(sa->un.sun_path)-2);
- sa->un.sun_path[sizeof(sa->un.sun_path)-1] = 0;
-
- *salen = offsetof(union sockaddr_union, un.sun_path) + 1 + strlen(sa->un.sun_path + 1);
-
- } else {
- _cleanup_freeaddrinfo_ struct addrinfo *result = NULL;
- const char *node, *service;
-
- struct addrinfo hints = {
- .ai_family = AF_UNSPEC,
- .ai_socktype = SOCK_STREAM,
- .ai_flags = AI_ADDRCONFIG
- };
-
- service = strrchr(arg_remote_host, ':');
- if (service) {
- node = strndupa(arg_remote_host, service - arg_remote_host);
- service ++;
- } else {
- node = arg_remote_host;
- service = "80";
- }
-
- log_debug("Looking up address info for %s:%s", node, service);
- r = getaddrinfo(node, service, &hints, &result);
- if (r != 0) {
- log_error("Failed to resolve host %s:%s: %s", node, service, gai_strerror(r));
- return -EHOSTUNREACH;
- }
-
- assert(result);
- if (result->ai_addrlen > sizeof(union sockaddr_union)) {
- log_error("Address too long.");
- return -E2BIG;
- }
-
- memcpy(sa, result->ai_addr, result->ai_addrlen);
- *salen = result->ai_addrlen;
- }
-
- return 0;