diff --git a/targets.cc b/targets.cc index 91cde9547..0768da682 100644 --- a/targets.cc +++ b/targets.cc @@ -521,11 +521,6 @@ do { if (rnfo.direct_connect) { hs->hostbatch[hidx]->setDirectlyConnected(true); } else { - //if the user selected an interface with the -e command that has no route to their target - //this error message will catch it. - if(rnfo.nexthop.ss_family!=AF_INET || rnfo.nexthop.ss_family!=AF_INET6 ){ - fatal("%s: can not find route for non-directly conected device %s.", __func__, hs->hostbatch[hidx]->NameIP()); - } hs->hostbatch[hidx]->setDirectlyConnected(false); hs->hostbatch[hidx]->setNextHop(&rnfo.nexthop, sizeof(rnfo.nexthop)); diff --git a/tcpip.cc b/tcpip.cc index 82393e875..2e444fd2c 100644 --- a/tcpip.cc +++ b/tcpip.cc @@ -3097,7 +3097,7 @@ bool route_dst(const struct sockaddr_storage *const dst, struct route_nfo *rnfo) /* Look up the device corresponding to src IP, if any ... */ iface = getInterfaceByIP(&spoofss); } - } + } if (*o.device) { iface = getInterfaceByName(o.device); @@ -3124,10 +3124,14 @@ bool route_dst(const struct sockaddr_storage *const dst, struct route_nfo *rnfo) ifsin = (struct sockaddr_in *) &rnfo->nexthop; ifsin->sin_family = AF_INET; ifsin->sin_addr.s_addr = routes[i].gw.s_addr; + break; } } - } - memcpy(&rnfo->ii, iface, sizeof(rnfo->ii)); + if(i == numroutes){ + return false; + } + } + memcpy(&rnfo->ii, iface, sizeof(rnfo->ii)); if (o.spoofsource) memcpy(&rnfo->srcaddr, &spoofss, sizeof(rnfo->srcaddr)); else