| 183 | } |
| 184 | |
| 185 | int |
| 186 | SocksEntry::startEvent(int event, void *data) |
| 187 | { |
| 188 | if (event == NET_EVENT_OPEN) { |
| 189 | netVConnection = static_cast<SocksNetVC *>(data); |
| 190 | |
| 191 | if (version == SOCKS5_VERSION) { |
| 192 | auth_handler = &socks5BasicAuthHandler; |
| 193 | } |
| 194 | |
| 195 | SET_HANDLER(&SocksEntry::mainEvent); |
| 196 | mainEvent(NET_EVENT_OPEN, data); |
| 197 | } else { |
| 198 | if (timeout) { |
| 199 | timeout->cancel(this); |
| 200 | timeout = nullptr; |
| 201 | } |
| 202 | |
| 203 | char buff[INET6_ADDRPORTSTRLEN]; |
| 204 | Dbg(dbg_ctl_Socks, "Failed to connect to %s", ats_ip_nptop(&server_addr.sa, buff, sizeof(buff))); |
| 205 | |
| 206 | findServer(); |
| 207 | |
| 208 | if (!ats_is_ip(&server_addr)) { |
| 209 | Dbg(dbg_ctl_Socks, "Unable to open connection to the SOCKS server"); |
| 210 | lerrno = ESOCK_NO_SOCK_SERVER_CONN; |
| 211 | free(); |
| 212 | return EVENT_CONT; |
| 213 | } |
| 214 | |
| 215 | if (timeout) { |
| 216 | timeout->cancel(this); |
| 217 | timeout = nullptr; |
| 218 | } |
| 219 | |
| 220 | if (netVConnection) { |
| 221 | netVConnection->do_io_close(); |
| 222 | netVConnection = nullptr; |
| 223 | } |
| 224 | |
| 225 | timeout = this_ethread()->schedule_in(this, HRTIME_SECONDS(netProcessor.socks_conf_stuff->server_connect_timeout)); |
| 226 | |
| 227 | write_done = false; |
| 228 | |
| 229 | NetVCOptions options; |
| 230 | options.socks_support = NO_SOCKS; |
| 231 | netProcessor.connect_re(this, &server_addr.sa, options); |
| 232 | } |
| 233 | |
| 234 | return EVENT_CONT; |
| 235 | } |
| 236 | |
| 237 | int |
| 238 | SocksEntry::mainEvent(int event, void *data) |
nothing calls this directly
no test coverage detected