| 721 |
} |
} |
| 722 |
else |
else |
| 723 |
{ |
{ |
| 724 |
ret = hash_dict_inc(hash_dict_sockaddr_count, (uint64_t)j, -1); |
ret = hash_dict_inc(hash_dict_sockaddr_count, (in_addr_t)j, -1); |
| 725 |
if (ret < 0) |
if (ret <= 0) |
| 726 |
{ |
{ |
| 727 |
log_error("hash_dict_inc(hash_dict_sockaddr_count, %d, -1) error\n", j); |
log_error("hash_dict_inc(hash_dict_sockaddr_count, %d, -1) error: %d\n", (in_addr_t)j, ret); |
| 728 |
} |
} |
| 729 |
|
|
| 730 |
ret = hash_dict_del(hash_dict_pid_sockaddr, (uint64_t)pid); |
ret = hash_dict_del(hash_dict_pid_sockaddr, (uint64_t)pid); |
| 948 |
|
|
| 949 |
if (j < BBS_max_client_per_ip) |
if (j < BBS_max_client_per_ip) |
| 950 |
{ |
{ |
|
log_common("Accept %s connection from %s:%d, already have %d connections\n", |
|
|
(SSH_v2 ? "SSH" : "telnet"), hostaddr_client, port_client, j); |
|
|
|
|
| 951 |
if ((pid = fork_server()) < 0) |
if ((pid = fork_server()) < 0) |
| 952 |
{ |
{ |
| 953 |
log_error("fork_server() error\n"); |
log_error("fork_server() error\n"); |
| 960 |
log_error("hash_dict_set(hash_dict_pid_sockaddr, %d, %s) error\n", pid, hostaddr_client); |
log_error("hash_dict_set(hash_dict_pid_sockaddr, %d, %s) error\n", pid, hostaddr_client); |
| 961 |
} |
} |
| 962 |
|
|
| 963 |
ret = hash_dict_inc(hash_dict_sockaddr_count, (uint64_t)sin.sin_addr.s_addr, 1); |
if (j == 0) |
| 964 |
if (ret < 0) |
{ |
| 965 |
|
// First connection from this IP |
| 966 |
|
log_common("Accept %s connection from %s:%d\n", |
| 967 |
|
(SSH_v2 ? "SSH" : "telnet"), hostaddr_client, port_client); |
| 968 |
|
|
| 969 |
|
ret = hash_dict_set(hash_dict_sockaddr_count, (uint64_t)sin.sin_addr.s_addr, 1); |
| 970 |
|
if (ret < 0) |
| 971 |
|
{ |
| 972 |
|
log_error("hash_dict_set(hash_dict_sockaddr_count, %s, 1) error\n", hostaddr_client); |
| 973 |
|
} |
| 974 |
|
} |
| 975 |
|
else |
| 976 |
{ |
{ |
| 977 |
log_error("hash_dict_inc(hash_dict_sockaddr_count, %s, 1) error\n", hostaddr_client); |
// Increase connection count from this IP |
| 978 |
|
log_common("Accept %s connection from %s:%d, already have %d connections\n", |
| 979 |
|
(SSH_v2 ? "SSH" : "telnet"), hostaddr_client, port_client, j); |
| 980 |
|
|
| 981 |
|
ret = hash_dict_inc(hash_dict_sockaddr_count, (uint64_t)sin.sin_addr.s_addr, 1); |
| 982 |
|
if (ret <= 0) |
| 983 |
|
{ |
| 984 |
|
log_error("hash_dict_inc(hash_dict_sockaddr_count, %s, 1) error: %d\n", hostaddr_client, ret); |
| 985 |
|
} |
| 986 |
} |
} |
| 987 |
} |
} |
| 988 |
} |
} |