]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - udp_send.c
sender: add a hook to resolve target names
[paraslash.git] / udp_send.c
index 24ebf5848ed3c2de5d671de98dab142ce9018581..adac6a8db1e8e66bb2e68441c870390f59756324 100644 (file)
@@ -187,6 +187,28 @@ static void udp_shutdown_targets(void)
                }
 }
 
+static int udp_resolve_target(const char *url, struct sender_command_data *scd)
+{
+       const char *result;
+       int ret, port;
+
+       ret = parse_fec_url(url, scd);
+       if (ret)
+               return ret;
+       port = scd->port > 0 ? scd->port : conf.udp_default_port_arg;
+
+       ret = para_connect_simple(IPPROTO_UDP, scd->host, port);
+       if (ret < 0)
+               return ret;
+
+       result = remote_name(ret);
+       close(ret);
+
+       if (!parse_url(result, scd->host, sizeof(scd->host), &scd->port))
+               return -E_ADDRESS_LOOKUP;
+       return 1;
+}
+
 static int udp_com_on(__a_unused struct sender_command_data *scd)
 {
        sender_status = SENDER_ON;
@@ -427,6 +449,7 @@ void udp_send_init(struct sender *s)
        s->pre_select = NULL;
        s->post_select = NULL;
        s->shutdown_clients = udp_shutdown_targets;
+       s->resolve_target = udp_resolve_target;
        s->client_cmds[SENDER_ON] = udp_com_on;
        s->client_cmds[SENDER_OFF] = udp_com_off;
        s->client_cmds[SENDER_DENY] = NULL;