diff options
Diffstat (limited to 'src/common/socket.c')
-rw-r--r-- | src/common/socket.c | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/src/common/socket.c b/src/common/socket.c index f67c3d074..10712c78b 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -25,6 +25,7 @@ #include "common/HPM.h" #include "common/cbasetypes.h" +#include "common/conf.h" #include "common/db.h" #include "common/memmgr.h" #include "common/mmo.h" @@ -76,11 +77,11 @@ struct socket_interface *sockt; struct socket_data **session; #ifdef SEND_SHORTLIST - // Add a fd to the shortlist so that it'll be recognized as a fd that needs - // sending done on it. - void send_shortlist_add_fd(int fd); - // Do pending network sends (and eof handling) from the shortlist. - void send_shortlist_do_sends(); +// Add a fd to the shortlist so that it'll be recognized as a fd that needs +// sending done on it. +void send_shortlist_add_fd(int fd); +// Do pending network sends (and eof handling) from the shortlist. +void send_shortlist_do_sends(void); #endif ///////////////////////////////////////////////////////////////////// @@ -624,7 +625,7 @@ int make_connection(uint32 ip, uint16 port, struct hSockOpt *opt) { remote_address.sin_port = htons(port); if( !( opt && opt->silent ) ) - ShowStatus("Connecting to %d.%d.%d.%d:%i\n", CONVIP(ip), port); + ShowStatus("Connecting to %u.%u.%u.%u:%i\n", CONVIP(ip), port); result = sConnect(fd, (struct sockaddr *)(&remote_address), sizeof(struct sockaddr_in)); if( result == SOCKET_ERROR ) { @@ -757,7 +758,7 @@ int wfifoset(int fd, size_t len) if (s->wdata_size+len > s->max_wdata) { // actually there was a buffer overflow already uint32 ip = s->client_addr; - ShowFatalError("WFIFOSET: Write Buffer Overflow. Connection %d (%d.%d.%d.%d) has written %u bytes on a %u/%u bytes buffer.\n", fd, CONVIP(ip), (unsigned int)len, (unsigned int)s->wdata_size, (unsigned int)s->max_wdata); + ShowFatalError("WFIFOSET: Write Buffer Overflow. Connection %d (%u.%u.%u.%u) has written %u bytes on a %u/%u bytes buffer.\n", fd, CONVIP(ip), (unsigned int)len, (unsigned int)s->wdata_size, (unsigned int)s->max_wdata); ShowDebug("Likely command that caused it: 0x%x\n", (*(uint16*)(s->wdata + s->wdata_size))); // no other chance, make a better fifo model exit(EXIT_FAILURE); @@ -767,7 +768,7 @@ int wfifoset(int fd, size_t len) { // dynamic packets allow up to UINT16_MAX bytes (<packet_id>.W <packet_len>.W ...) // all known fixed-size packets are within this limit, so use the same limit - ShowFatalError("WFIFOSET: Packet 0x%x is too big. (len=%u, max=%u)\n", (*(uint16*)(s->wdata + s->wdata_size)), (unsigned int)len, 0xFFFF); + ShowFatalError("WFIFOSET: Packet 0x%x is too big. (len=%u, max=%u)\n", (*(uint16*)(s->wdata + s->wdata_size)), (unsigned int)len, 0xFFFFU); exit(EXIT_FAILURE); } else if( len == 0 ) @@ -984,7 +985,7 @@ static int connect_check(uint32 ip) { int result = connect_check_(ip); if( access_debug ) { - ShowInfo("connect_check: Connection from %d.%d.%d.%d %s\n", CONVIP(ip),result ? "allowed." : "denied!"); + ShowInfo("connect_check: Connection from %u.%u.%u.%u %s\n", CONVIP(ip),result ? "allowed." : "denied!"); } return result; } @@ -1004,7 +1005,7 @@ static int connect_check_(uint32 ip) for( i=0; i < access_allownum; ++i ){ if (SUBNET_MATCH(ip, access_allow[i].ip, access_allow[i].mask)) { if( access_debug ){ - ShowInfo("connect_check: Found match from allow list:%d.%d.%d.%d IP:%d.%d.%d.%d Mask:%d.%d.%d.%d\n", + ShowInfo("connect_check: Found match from allow list:%u.%u.%u.%u IP:%u.%u.%u.%u Mask:%u.%u.%u.%u\n", CONVIP(ip), CONVIP(access_allow[i].ip), CONVIP(access_allow[i].mask)); @@ -1017,7 +1018,7 @@ static int connect_check_(uint32 ip) for( i=0; i < access_denynum; ++i ){ if (SUBNET_MATCH(ip, access_deny[i].ip, access_deny[i].mask)) { if( access_debug ){ - ShowInfo("connect_check: Found match from deny list:%d.%d.%d.%d IP:%d.%d.%d.%d Mask:%d.%d.%d.%d\n", + ShowInfo("connect_check: Found match from deny list:%u.%u.%u.%u IP:%u.%u.%u.%u Mask:%u.%u.%u.%u\n", CONVIP(ip), CONVIP(access_deny[i].ip), CONVIP(access_deny[i].mask)); @@ -1064,7 +1065,7 @@ static int connect_check_(uint32 ip) hist->tick = timer->gettick(); if( ++hist->count >= ddos_count ) {// DDoS attack detected hist->ddos = 1; - ShowWarning("connect_check: DDoS Attack detected from %d.%d.%d.%d!\n", CONVIP(ip)); + ShowWarning("connect_check: DDoS Attack detected from %u.%u.%u.%u!\n", CONVIP(ip)); return (connect_ok == 2 ? 1 : 0); } return connect_ok; @@ -1103,7 +1104,7 @@ static int connect_check_clear(int tid, int64 tick, int id, intptr_t data) { clear++; } list++; - } + } dbi_destroy(iter); if( access_debug ){ @@ -1152,7 +1153,7 @@ int access_ipmask(const char* str, AccessControl* acc) } } if( access_debug ){ - ShowInfo("access_ipmask: Loaded IP:%d.%d.%d.%d mask:%d.%d.%d.%d\n", CONVIP(ip), CONVIP(mask)); + ShowInfo("access_ipmask: Loaded IP:%u.%u.%u.%u mask:%u.%u.%u.%u\n", CONVIP(ip), CONVIP(mask)); } acc->ip = ip; acc->mask = mask; @@ -1428,7 +1429,7 @@ void socket_init(void) timer->add_interval(timer->gettick()+1000, connect_check_clear, 0, 0, 5*60*1000); #endif - ShowInfo("Server supports up to '"CL_WHITE"%"PRId64""CL_RESET"' concurrent connections.\n", rlim_cur); + ShowInfo("Server supports up to '"CL_WHITE"%"PRIu64""CL_RESET"' concurrent connections.\n", rlim_cur); } bool session_is_valid(int fd) @@ -1570,7 +1571,7 @@ void send_shortlist_add_fd(int fd) } // Do pending network sends and eof handling from the shortlist. -void send_shortlist_do_sends() +void send_shortlist_do_sends(void) { int i; @@ -1686,7 +1687,7 @@ bool socket_trusted_ip_check(uint32 ip) * @param[in] groupname Current group name, for output/logging reasons. * @return The amount of entries read, zero in case of errors. */ -int socket_net_config_read_sub(config_setting_t *t, struct s_subnet_vector *list, const char *filename, const char *groupname) +int socket_net_config_read_sub(struct config_setting_t *t, struct s_subnet_vector *list, const char *filename, const char *groupname) { int i, len; char ipbuf[64], maskbuf[64]; @@ -1722,11 +1723,11 @@ int socket_net_config_read_sub(config_setting_t *t, struct s_subnet_vector *list */ void socket_net_config_read(const char *filename) { - config_t network_config; + struct config_t network_config; int i; nullpo_retv(filename); - if (libconfig->read_file(&network_config, filename)) { + if (!libconfig->load_file(&network_config, filename)) { ShowError("LAN Support configuration file is not found: '%s'. This server won't be able to accept connections from any servers.\n", filename); return; } |