implement ROS_IP=localhost behavior for roscpp, and for outbound rospy connections

The wiki doc for ROS_IP:  http://wiki.ros.org/ROS/EnvironmentVariables    says that setting ROS_IP=localhost will "prevent remote components from being able to talk to your local component." This can be useful in some settings. However, this behavior was previously only implemented for inbound rospy topic connections and services. This pull request implements it for inbound and outbound roscpp connections, and for outbound rospy connections.
The tradeoff with caching the valid hostnames is that (I assume) it will
break ABI compatibility. Maybe that's OK. I wasn't sure how much that
mattered.

In any event, this branch only executes during the connect phase, and only
on nodes with ROS_HOSTNAME set to localhost, so I don't see it as much of a
performance issue, but i agree it is a code ugliness issue.
On Jun 29, 2014 11:33 AM, "gerkey" <notifications@github.com> wrote:

> In clients/roscpp/src/libros/transport/transport_tcp.cpp:
>
> > @@ -211,6 +211,28 @@ void TransportTCP::setKeepAlive(bool use, uint32_t idle, uint32_t interval, uint
> >
> >  bool TransportTCP::connect(const std::string& host, int port)
> >  {
> > +  char *ros_ip_env = NULL;
>
> It seems wasteful to redo this lookup logic on every attempted connect.
> Perhaps somewhere else, during initialization, we can build up the list of
> host/address strings that we're willing to match, then here we just match
> against that list.
>
> Same for the UDP case below.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/ros/ros_comm/pull/452/files#r14330703>.
>