Subversion Repositories tpanel

Rev

Rev 130 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 130 Rev 134
Line 89... Line 89...
89
            ainfo = ainfo->ai_next;
89
            ainfo = ainfo->ai_next;
90
            continue;
90
            continue;
91
        }
91
        }
92
 
92
 
93
        MSG_DEBUG("[" << mHost << "] Socket successfully created.");
93
        MSG_DEBUG("[" << mHost << "] Socket successfully created.");
94
        struct in_addr  *addr;
-
 
95
 
-
 
96
        if (ainfo->ai_family == AF_INET)
-
 
97
        {
-
 
98
            struct sockaddr_in *ipv = (struct sockaddr_in *)ainfo->ai_addr;
-
 
99
            addr = &(ipv->sin_addr);
-
 
100
        }
-
 
101
        else
-
 
102
        {
-
 
103
            struct sockaddr_in6 *ipv6 = (struct sockaddr_in6 *)ainfo->ai_addr;
-
 
104
            addr = (struct in_addr *) &(ipv6->sin6_addr);
-
 
105
        }
-
 
106
 
-
 
107
        char buffer[100];
-
 
108
        // FIXME: This is the address where we connected to, but we need the
-
 
109
        //        address of the local network interface where the connection
-
 
110
        //        was initiated from.
-
 
111
        inet_ntop(ainfo->ai_family, addr, buffer, sizeof(buffer));
-
 
112
        mMyIP.assign(buffer);
-
 
113
        MSG_DEBUG("Client IP: " << mMyIP);
-
 
114
 
94
 
115
        struct timeval tv;
95
        struct timeval tv;
116
 
96
 
117
        // FIXME: Make the timeouts configurable!
97
        // FIXME: Make the timeouts configurable!
118
        tv.tv_sec = 10;
98
        tv.tv_sec = 10;
Line 161... Line 141...
161
            mConnected = true;
141
            mConnected = true;
162
            break;
142
            break;
163
        }
143
        }
164
    }
144
    }
165
 
145
 
-
 
146
    if (ainfo->ai_family == AF_INET)
-
 
147
    {
-
 
148
        char str[INET_ADDRSTRLEN];
-
 
149
        struct sockaddr_in addr;
-
 
150
        socklen_t len = sizeof(addr);
-
 
151
        getsockname(sock, (struct sockaddr *)&addr, &len);
-
 
152
        mMyIP.assign(inet_ntop(AF_INET, &(addr.sin_addr), str, INET_ADDRSTRLEN));
-
 
153
    }
-
 
154
    else
-
 
155
    {
-
 
156
        char str[INET6_ADDRSTRLEN];
-
 
157
        struct sockaddr_in6 addr;
-
 
158
        socklen_t len = sizeof(addr);
-
 
159
        getsockname(sock, (struct sockaddr *)&addr, &len);
-
 
160
        mMyIP.assign(inet_ntop(AF_INET6, &(addr.sin6_addr), str, INET6_ADDRSTRLEN));
-
 
161
    }
-
 
162
 
-
 
163
    MSG_DEBUG("Client IP: " << mMyIP);
-
 
164
 
166
    if (ainfo == nullptr)
165
    if (ainfo == nullptr)
167
    {
166
    {
168
        MSG_ERROR("[" << mHost << "] No network interface to connect to target was found!");
167
        MSG_ERROR("[" << mHost << "] No network interface to connect to target was found!");
169
        mConnected = false;
168
        mConnected = false;
170
        return false;
169
        return false;