]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - udp_send.c
udp: integrate resolve hook
[paraslash.git] / udp_send.c
index adac6a8db1e8e66bb2e68441c870390f59756324..b542f5a9534fe73953f49ff73e2f62eedc2f05bd 100644 (file)
@@ -324,12 +324,9 @@ fail:
 
 static void udp_add_target(struct sender_command_data *scd)
 {
-       int ret, port = scd->port > 0 ? scd->port : conf.udp_default_port_arg;
+       int ret;
        struct udp_target *ut = para_calloc(sizeof(*ut));
 
-       strncpy(ut->host, scd->host, sizeof(ut->host));
-       ut->port = scd->port > 0 ? scd->port : conf.udp_default_port_arg;
-
        ut->fcp.slices_per_group      = scd->slices_per_group;
        ut->fcp.data_slices_per_group = scd->data_slices_per_group;
        ut->fcp.max_slice_bytes       = scd->max_slice_bytes;
@@ -339,7 +336,7 @@ static void udp_add_target(struct sender_command_data *scd)
        ut->sc = para_calloc(sizeof(*ut->sc));
        ut->sc->private_data = ut;
        ut->sc->fd = -1;
-       ret = para_connect_simple(IPPROTO_UDP, scd->host, port);
+       ret = para_connect_simple(IPPROTO_UDP, scd->host, scd->port);
        if (ret < 0)
                goto err;
        ut->sc->fd = ret;
@@ -357,8 +354,8 @@ static void udp_add_target(struct sender_command_data *scd)
 err:
        if (ut->sc->fd >= 0)
                close(ut->sc->fd);
-       PARA_NOTICE_LOG("failed to set up %s#%d (%s)- not adding it\n",
-               scd->host, port, para_strerror(-ret));
+       PARA_NOTICE_LOG("failed to set up %s:%d (%s)- not adding it\n",
+                       scd->host, scd->port, para_strerror(-ret));
        free(ut->sc);
        free(ut);
 }
@@ -407,12 +404,11 @@ static void udp_init_target_list(void)
 
        INIT_LIST_HEAD(&targets);
        for (i = 0; i < conf.udp_target_given; i++) {
-               if (parse_fec_url(conf.udp_target_arg[i], &scd) < 0) {
-                       PARA_CRIT_LOG("syntax error for udp target option "
-                               "#%d, ignoring\n", i);
-                       continue;
-               }
-               udp_add_target(&scd);
+               if (udp_resolve_target(conf.udp_target_arg[i], &scd) < 0)
+                       PARA_CRIT_LOG("not adding requested target '%s'\n",
+                                       conf.udp_target_arg[i]);
+               else
+                       udp_add_target(&scd);
        }
 }