removed trailing whitespaces
authorFelix Morgner <felix.morgner@gmail.com>
Thu, 16 Jan 2014 15:54:14 +0000 (16:54 +0100)
committerFelix Morgner <felix.morgner@gmail.com>
Thu, 16 Jan 2014 15:54:14 +0000 (16:54 +0100)
12 files changed:
src/ban.c
src/channel.c
src/client.c
src/conf.c
src/crypt.c
src/log.c
src/main.c
src/messagehandler.c
src/messages.c
src/pds.c
src/ssl.c
src/voicetarget.c

index b02d92116a3518c0da418ab74d50d9fc188a8ca2..e1855de2cb830be0c4d9ff12ab15c8031c90d6a9 100644 (file)
--- a/src/ban.c
+++ b/src/ban.c
@@ -56,10 +56,10 @@ void Ban_init(void)
 
 void Ban_deinit(void)
 {
-       /* Save banlist */      
+       /* Save banlist */
        if (getStrConf(BANFILE) != NULL)
                Ban_saveBanFile();
-               
+
        Ban_clearBanList();
 }
 
@@ -72,7 +72,7 @@ void Ban_UserBan(client_t *client, char *reason)
        if (ban == NULL)
                Log_fatal("Out of memory");
        memset(ban, 0, sizeof(ban_t));
-       
+
        memcpy(ban->hash, client->hash, 20);
        memcpy(&ban->address, &client->remote_tcp.sin_addr, sizeof(in_addr_t));
        ban->mask = 128;
@@ -86,7 +86,7 @@ void Ban_UserBan(client_t *client, char *reason)
        banlist_changed = true;
        if(getBoolConf(SYNC_BANFILE))
                Ban_saveBanFile();
-       
+
        SSLi_hash2hex(ban->hash, hexhash);
        Log_info_client(client, "User kickbanned. Reason: '%s' Hash: %s IP: %s Banned for: %d seconds",
                        ban->reason, hexhash, inet_ntoa(*((struct in_addr *)&ban->address)), ban->duration);
@@ -99,7 +99,7 @@ void Ban_pruneBanned()
        ban_t *ban;
        char hexhash[41];
        uint64_t bantime_long;
-               
+
        list_iterate(itr, &banlist) {
                ban = list_get_entry(itr, ban_t, node);
                bantime_long = ban->duration * 1000000LL;
@@ -129,11 +129,11 @@ bool_t Ban_isBanned(client_t *client)
        ban_t *ban;
        list_iterate(itr, &banlist) {
                ban = list_get_entry(itr, ban_t, node);
-               if (memcmp(ban->hash, client->hash, 20) == 0) 
+               if (memcmp(ban->hash, client->hash, 20) == 0)
                        return true;
        }
        return false;
-       
+
 }
 
 bool_t Ban_isBannedAddr(in_addr_t *addr)
@@ -142,7 +142,7 @@ bool_t Ban_isBannedAddr(in_addr_t *addr)
        ban_t *ban;
        int mask;
        in_addr_t tempaddr1, tempaddr2;
-       
+
        list_iterate(itr, &banlist) {
                ban = list_get_entry(itr, ban_t, node);
                mask = ban->mask - 96;
@@ -152,7 +152,7 @@ bool_t Ban_isBannedAddr(in_addr_t *addr)
                        tempaddr1 &= (2 ^ mask) - 1;
                        tempaddr2 &= (2 ^ mask) - 1;
                }
-               if (memcmp(&tempaddr1, &tempaddr2, sizeof(in_addr_t)) == 0) 
+               if (memcmp(&tempaddr1, &tempaddr2, sizeof(in_addr_t)) == 0)
                        return true;
        }
        return false;
@@ -173,7 +173,7 @@ message_t *Ban_getBanList(void)
        char timestr[32];
        char hexhash[41];
        uint8_t address[16];
-       
+
        msg = Msg_banList_create(bancount);
        list_iterate(itr, &banlist) {
                ban = list_get_entry(itr, ban_t, node);
@@ -212,7 +212,7 @@ void Ban_putBanList(message_t *msg, int n_bans)
        char *hexhash, *name, *reason, *start;
        uint32_t duration, mask;
        uint8_t *address;
-       
+
        for (i = 0; i < n_bans; i++) {
                Msg_banList_getEntry(msg, i, &address, &mask, &name, &hexhash, &reason, &start, &duration);
                ban = malloc(sizeof(ban_t));
@@ -297,7 +297,7 @@ static void Ban_readBanFile(void)
                p = strtok(NULL, "\n");
                if (p == NULL) break;
                reason = p;
-               
+
                ban = malloc(sizeof(ban_t));
                if (ban == NULL)
                        Log_fatal("Out of memory");
index 5ac6924ab3f970c06a8a528775ab4ea0ee1e72cb..54b57a27a21421da214b04d53c8c3d7b05c28af3 100644 (file)
@@ -93,7 +93,7 @@ static channel_t *next_channel(channel_t *ch)
        if (list_get_next(&ch->node) == &list_get_entry(&ch->node, channel_t, node)->parent->subs)
                return NULL;
        else
-               return list_get_entry(list_get_next(&ch->node), channel_t, node);       
+               return list_get_entry(list_get_next(&ch->node), channel_t, node);
 }
 #endif
 
@@ -134,7 +134,7 @@ channel_t *Chan_iterate_siblings(channel_t *parent, channel_t **channelpptr)
        *channelpptr = ch;
        return ch;
 }
-                       
+
 void Chan_init()
 {
        int i;
@@ -143,7 +143,7 @@ void Chan_init()
        const char *defaultChannelName;
 
        defaultChannelName = getStrConf(DEFAULT_CHANNEL);
-       
+
        for (i = 0; ; i++) {
                if (Conf_getNextChannel(&chdesc, i) < 0) {
                        if (i == 0)
@@ -165,18 +165,18 @@ void Chan_init()
                        ch->position = chdesc.position;
                        ch->silent = chdesc.silent;
                        if (chdesc.password) {
-                               Log_info("Setting password on channel '%s'", ch->name); 
+                               Log_info("Setting password on channel '%s'", ch->name);
                                ch->password = strdup(chdesc.password);
                        }
                        if (strcmp(defaultChannelName, chdesc.name) == 0) {
-                               Log_info("Setting default channel '%s'", ch->name); 
+                               Log_info("Setting default channel '%s'", ch->name);
                                defaultChan = ch;
                        }
-                       
+
                        do {
                                Chan_iterate(&ch_itr);
                        } while (ch_itr != NULL && strcmp(ch_itr->name, chdesc.parent) != 0);
-                       
+
                        if (ch_itr == NULL)
                                Log_fatal("Error in channel configuration: parent '%s' not found", chdesc.parent);
                        else {
@@ -187,7 +187,7 @@ void Chan_init()
        }
        if (defaultChan == NULL)
                defaultChan = rootChan;
-       
+
        if (defaultChan->noenter)
                Log_fatal("Error in channel configuration: default channel is marked as noenter");
        if (defaultChan->password)
@@ -210,8 +210,8 @@ void Chan_init()
                                          chlink.source);
                else
                        ch_src = ch_itr;
-               
-               ch_itr = NULL;          
+
+               ch_itr = NULL;
                do {
                        Chan_iterate(&ch_itr);
                } while (ch_itr != NULL && strcmp(ch_itr->name, chlink.destination) != 0);
@@ -220,7 +220,7 @@ void Chan_init()
                                          chlink.destination);
                else
                        ch_dst = ch_itr;
-               
+
                list_add_tail(&ch_dst->link_node, &ch_src->channel_links);
                ch_src->linkcount++;
                Log_info("Adding channel link '%s' -> '%s'", ch_src->name, ch_dst->name);
@@ -231,7 +231,7 @@ void Chan_free()
 {
        struct dlist *itr, *save;
        channel_t *ch;
-       
+
        list_iterate_safe(itr, save, &channels) {
                ch = list_get_entry(itr, channel_t, flatlist_node);
                Log_debug("Free channel '%s'", ch->name);
@@ -271,7 +271,7 @@ int Chan_userLeave(client_t *client)
 {
        channel_t *leaving = NULL;
        int leaving_id = -1;
-       
+
        if (client->channel) {
                list_del(&client->chan_node);
                leaving = (channel_t *)client->channel;
@@ -290,8 +290,8 @@ int Chan_userJoin(channel_t *ch, client_t *client)
        /* Do nothing if user already is in this channel */
        if ((channel_t *)client->channel == ch)
                return 0;
-       
-       Log_debug("Add user %s to channel %s", client->username, ch->name); 
+
+       Log_debug("Add user %s to channel %s", client->username, ch->name);
        /* Only allowed in one channel at a time */
        leaving_id = Chan_userLeave(client);
        list_add_tail(&client->chan_node, &ch->clients);
@@ -310,7 +310,7 @@ int Chan_userJoin_id(int channelid, client_t *client)
                return -1;
        }
        else
-               return Chan_userJoin(ch_itr, client);   
+               return Chan_userJoin(ch_itr, client);
 }
 
 channelJoinResult_t Chan_userJoin_id_test(int channelid, client_t *client)
@@ -369,7 +369,7 @@ void Chan_buildTreeList(channel_t *ch, struct dlist *head)
        channellist_t *chl;
        struct dlist *itr;
        channel_t *sub;
-       
+
        chl = malloc(sizeof(channellist_t));
        chl->chan = ch;
        init_list_entry(&chl->node);
index 37bdb370ee53c27f07a8b9eb4be9b96792598790..f7d2b709d35255a996d21541f20620f16ea6a7f7 100644 (file)
@@ -101,7 +101,7 @@ void Client_janitor()
                c->availableBandwidth += maxBandwidth;
                if (c->availableBandwidth > bwTop)
                        c->availableBandwidth = bwTop;
-               
+
                if (Timer_isElapsed(&c->lastActivity, 1000000LL * INACTIVITY_TIMEOUT)) {
                        /* No activity from client - assume it is lost and close. */
                        Log_info_client(c, "Timeout, closing.");
@@ -136,7 +136,7 @@ codec_t *Client_codec_iterate(client_t *client, codec_t **codec_itr)
 
        if (list_empty(&client->codecs))
                return NULL;
-       
+
        if (cd == NULL) {
                cd = list_get_entry(list_get_first(&client->codecs), codec_t, node);
        } else {
@@ -170,7 +170,7 @@ bool_t Client_token_match(client_t *client, char *str)
 {
        token_t *token;
        struct dlist *itr;
-       
+
        if (list_empty(&client->tokens))
                return false;
        list_iterate(itr, &client->tokens) {
@@ -185,7 +185,7 @@ void Client_token_free(client_t *client)
 {
        struct dlist *itr, *save;
        token_t *token;
-       
+
        list_iterate_safe(itr, save, &client->tokens) {
                token = list_get_entry(itr, token_t, node);
                list_del(&token->node);
@@ -210,13 +210,13 @@ void recheckCodecVersions(client_t *connectingClient)
        bool_t enableOpus;
 
        init_list_entry(&codec_list);
-       
+
        while (Client_iterate(&client_itr) != NULL) {
                codec_itr = NULL;
                if (client_itr->codec_count == 0 && !client_itr->bOpus)
                        continue;
                while (Client_codec_iterate(client_itr, &codec_itr) != NULL) {
-                       found = false;                      
+                       found = false;
                        list_iterate(itr, &codec_list) {
                                cd = list_get_entry(itr, codec_t, node);
                                if (cd->codec == codec_itr->codec) {
@@ -239,7 +239,7 @@ void recheckCodecVersions(client_t *connectingClient)
                if (client_itr->bOpus)
                        opus++;
        }
-       if (users == 0) 
+       if (users == 0)
                return;
 
        enableOpus = ((opus * 100 / users) >= getIntConf(OPUS_THRESHOLD));
@@ -266,7 +266,7 @@ void recheckCodecVersions(client_t *connectingClient)
                        bPreferAlpha = true;
                else
                        bPreferAlpha = !bPreferAlpha;
-               
+
                if (bPreferAlpha)
                        iCodecAlpha = version;
                else
@@ -285,7 +285,7 @@ void recheckCodecVersions(client_t *connectingClient)
        sendmsg->payload.codecVersion->opus = enableOpus;
 
        Client_send_message_except(NULL, sendmsg);
-       
+
        if (enableOpus && !bOpus) {
                client_itr = NULL;
                while (Client_iterate(&client_itr) != NULL) {
@@ -294,9 +294,9 @@ void recheckCodecVersions(client_t *connectingClient)
                                Client_textmessage(client_itr, OPUS_WARN_SWITCHING);
                        }
                }
-               Log_info("OPUS codec %s", bOpus ? "enabled" : "disabled");      
+               Log_info("OPUS codec %s", bOpus ? "enabled" : "disabled");
        }
-       
+
        bOpus = enableOpus;
 }
 
@@ -347,17 +347,17 @@ int Client_add(int fd, struct sockaddr_in *remote)
        newclient->sessionId = findFreeSessionId();
        if (newclient->sessionId < 0)
                Log_fatal("Could not find a free session ID");
-       
+
        init_list_entry(&newclient->txMsgQueue);
        init_list_entry(&newclient->chan_node);
        init_list_entry(&newclient->node);
        init_list_entry(&newclient->voicetargets);
        init_list_entry(&newclient->codecs);
        init_list_entry(&newclient->tokens);
-       
+
        list_add_tail(&newclient->node, &clients);
        clientcount++;
-       
+
        /* Send version message to client */
        sendmsg = Msg_create(Version);
        sendmsg->payload.version->has_version = true;
@@ -395,7 +395,7 @@ void Client_free(client_t *client)
        Client_codec_free(client);
        Voicetarget_free_all(client);
        Client_token_free(client);
-       
+
        list_del(&client->node);
        if (client->ssl)
                SSLi_free(client->ssl);
@@ -404,9 +404,9 @@ void Client_free(client_t *client)
        if (client->release)
                free(client->release);
        if (client->os)
-               free(client->os);                       
+               free(client->os);
        if (client->os_version)
-               free(client->os_version);                       
+               free(client->os_version);
        if (client->username)
                free(client->username);
        if (client->context)
@@ -426,7 +426,7 @@ void Client_close(client_t *client)
 void Client_disconnect_all()
 {
        struct dlist *itr, *save;
-       
+
        list_iterate_safe(itr, save, &clients) {
                Client_free(list_get_entry(itr, client_t, node));
        }
@@ -436,7 +436,7 @@ int Client_read_fd(int fd)
 {
        struct dlist *itr;
        client_t *client = NULL;
-       
+
        list_iterate(itr, &clients) {
                if (fd == list_get_entry(itr, client_t, node)->tcpfd) {
                        client = list_get_entry(itr, client_t, node);
@@ -454,13 +454,13 @@ int Client_read(client_t *client)
        int rc;
 
        Timer_restart(&client->lastActivity);
-       
+
        if (client->writeBlockedOnRead) {
                client->writeBlockedOnRead = false;
                Log_debug("Client_read: writeBlockedOnRead == true");
                return Client_write(client);
        }
-       
+
        if (client->shutdown_wait) {
                Client_free(client);
                return 0;
@@ -476,7 +476,7 @@ int Client_read(client_t *client)
 
        do {
                errno = 0;
-               if (!client->msgsize) 
+               if (!client->msgsize)
                        rc = SSLi_read(client->ssl, &client->rxbuf[client->rxcount], 6 - client->rxcount);
                else
                        rc = SSLi_read(client->ssl, &client->rxbuf[client->rxcount], client->msgsize);
@@ -514,7 +514,7 @@ int Client_read(client_t *client)
                                client->readBlockedOnWrite = true;
                                return 0;
                        }
-                       else if (SSLi_get_error(client->ssl, rc) == SSLI_ERROR_ZERO_RETURN || 
+                       else if (SSLi_get_error(client->ssl, rc) == SSLI_ERROR_ZERO_RETURN ||
                                 SSLi_get_error(client->ssl, rc) == 0) {
                                Log_info_client(client, "Connection closed by peer");
                                Client_close(client);
@@ -524,7 +524,7 @@ int Client_read(client_t *client)
                                        if (errno == 0)
                                                Log_info_client(client, "Connection closed by peer");
                                        else
-                                               Log_info_client(client,"Error: %s  - Closing connection (code %d)", 
+                                               Log_info_client(client,"Error: %s  - Closing connection (code %d)",
                                                                strerror(errno));
                                }
                                else if (SSLi_get_error(client->ssl, rc) == SSLI_ERROR_CONNRESET) {
@@ -538,7 +538,7 @@ int Client_read(client_t *client)
                        }
                }
        } while (SSLi_data_pending(client->ssl));
-       
+
        return 0;
 }
 
@@ -546,7 +546,7 @@ int Client_write_fd(int fd)
 {
        struct dlist *itr;
        client_t *client = NULL;
-       
+
        list_iterate(itr, &clients) {
                if(fd == list_get_entry(itr, client_t, node)->tcpfd) {
                        client = list_get_entry(itr, client_t, node);
@@ -562,7 +562,7 @@ int Client_write_fd(int fd)
 int Client_write(client_t *client)
 {
        int rc;
-       
+
        if (client->readBlockedOnWrite) {
                client->readBlockedOnWrite = false;
                Log_debug("Client_write: readBlockedOnWrite == true");
@@ -650,7 +650,7 @@ client_t *Client_iterate(client_t **client_itr)
 
        if (list_empty(&clients))
                return NULL;
-       
+
        if (c == NULL) {
                c = list_get_entry(list_get_first(&clients), client_t, node);
        } else {
@@ -689,7 +689,7 @@ int Client_send_message_except(client_t *client, message_t *msg)
 {
        client_t *itr = NULL;
        int count = 0;
-       
+
        Msg_inc_ref(msg); /* Make sure a reference is held during the whole iteration. */
        while (Client_iterate(&itr) != NULL) {
                if (itr != client) {
@@ -700,11 +700,11 @@ int Client_send_message_except(client_t *client, message_t *msg)
                }
        }
        Msg_free(msg); /* Free our reference to the message */
-       
+
        if (count == 0)
                Msg_free(msg); /* If only 1 client is connected then no message is passed
                                                * to Client_send_message(). Free it here. */
-               
+
        return 0;
 }
 
@@ -712,7 +712,7 @@ int Client_send_message_except_ver(client_t *client, message_t *msg, uint32_t ve
 {
        client_t *itr = NULL;
        int count = 0;
-       
+
        Msg_inc_ref(msg); /* Make sure a reference is held during the whole iteration. */
        while (Client_iterate(&itr) != NULL) {
                if (itr != client) {
@@ -723,11 +723,11 @@ int Client_send_message_except_ver(client_t *client, message_t *msg, uint32_t ve
                }
        }
        Msg_free(msg); /* Free our reference to the message */
-       
+
        if (count == 0)
                Msg_free(msg); /* If only 1 client is connected then no message is passed
                                                * to Client_send_message(). Free it here. */
-               
+
        return 0;
 }
 
@@ -741,9 +741,9 @@ static bool_t checkDecrypt(client_t *client, const uint8_t *encrypted, uint8_t *
                if (Timer_elapsed(&client->cryptState.tLastRequest) > 5000000ULL) {
                        message_t *sendmsg;
                        Timer_restart(&client->cryptState.tLastRequest);
-                       
+
                        sendmsg = Msg_create(CryptSetup);
-                       Log_info_client(client, "Requesting voice channel crypt resync");               
+                       Log_info_client(client, "Requesting voice channel crypt resync");
                        Client_send_message(client, sendmsg);
                }
        }
@@ -759,7 +759,7 @@ int Client_read_udp()
        uint64_t key;
        client_t *itr;
        UDPMessageType_t msgType;
-       
+
 #if defined(__LP64__)
        uint8_t encbuff[UDP_PACKET_SIZE + 8];
        uint8_t *encrypted = encbuff + 4;
@@ -767,7 +767,7 @@ int Client_read_udp()
        uint8_t encrypted[UDP_PACKET_SIZE];
 #endif
        uint8_t buffer[UDP_PACKET_SIZE];
-       
+
        len = recvfrom(udpsock, encrypted, UDP_PACKET_SIZE, MSG_TRUNC, (struct sockaddr *)&from, &fromlen);
        if (len == 0) {
                return -1;
@@ -788,21 +788,21 @@ int Client_read_udp()
                ping[3] = htonl((uint32_t)clientcount);
                ping[4] = htonl((uint32_t)getIntConf(MAX_CLIENTS));
                ping[5] = htonl((uint32_t)getIntConf(MAX_BANDWIDTH));
-               
+
                sendto(udpsock, encrypted, 6 * sizeof(uint32_t), 0, (struct sockaddr *)&from, fromlen);
                return 0;
        }
-       
+
        key = (((uint64_t)from.sin_addr.s_addr) << 16) ^ from.sin_port;
        itr = NULL;
-       
+
        while (Client_iterate(&itr) != NULL) {
                if (itr->key == key) {
                        if (!checkDecrypt(itr, encrypted, buffer, len))
                                goto out;
                        break;
                }
-       }       
+       }
        if (itr == NULL) { /* Unknown peer */
                while (Client_iterate(&itr) != NULL) {
                        if (itr->remote_tcp.sin_addr.s_addr == from.sin_addr.s_addr) {
@@ -818,7 +818,7 @@ int Client_read_udp()
        if (itr == NULL) { /* Couldn't find this peer among connected clients */
                goto out;
        }
-       
+
        itr->bUDP = true;
        len -= 4; /* Adjust for crypt header */
        msgType = (UDPMessageType_t)((buffer[0] >> 5) & 0x7);
@@ -839,7 +839,7 @@ int Client_read_udp()
                Log_debug("Unknown UDP message type from %s port %d", inet_ntoa(from.sin_addr), ntohs(from.sin_port));
                break;
        }
-       
+
 out:
        return 0;
 }
@@ -851,7 +851,7 @@ static inline void Client_send_voice(client_t *src, client_t *dst, uint8_t *data
                        src->context != NULL && dst->context != NULL && /* ...both source and destination has context */
                        strcmp(src->context, dst->context) == 0) /* ...and the contexts match */
                        Client_send_udp(dst, data, len);
-               else 
+               else
                        Client_send_udp(dst, data, len - poslen);
        }
 }
@@ -867,21 +867,21 @@ int Client_voiceMsg(client_t *client, uint8_t *data, int len)
        unsigned int poslen, counter, size;
        int offset, packetsize;
        voicetarget_t *vt;
-       
+
        channel_t *ch = (channel_t *)client->channel;
        struct dlist *itr;
-       
+
        if (!client->authenticated || client->mute || client->self_mute || ch->silent)
                goto out;
-       
+
        packetsize = 20 + 8 + 4 + len;
        if (client->availableBandwidth - packetsize < 0)
                goto out; /* Discard */
        client->availableBandwidth -= packetsize;
-       
+
        Timer_restart(&client->idleTime);
        Timer_restart(&client->lastActivity);
-       
+
        counter = Pds_get_numval(pdi); /* step past session id */
        if ((type >> 5) != UDPVoiceOpus) {
                do {
@@ -892,22 +892,22 @@ int Client_voiceMsg(client_t *client, uint8_t *data, int len)
                size = Pds_get_numval(pdi);
                Pds_skip(pdi, size & 0x1fff);
        }
-               
+
        poslen = pdi->maxsize - pdi->offset; /* For stripping of positional info */
-       
+
        Pds_add_numval(pds, client->sessionId);
        Pds_append_data_nosize(pds, data + 1, len - 1);
-       
+
        if (target == 0x1f) { /* Loopback */
                buffer[0] = (uint8_t) type;
                Client_send_udp(client, buffer, pds->offset + 1);
        }
        else if (target == 0) { /* regular channel speech */
                buffer[0] = (uint8_t) type;
-               
+
                if (ch == NULL)
                        goto out;
-               
+
                list_iterate(itr, &ch->clients) {
                        client_t *c;
                        c = list_get_entry(itr, client_t, chan_node);
@@ -959,7 +959,7 @@ int Client_voiceMsg(client_t *client, uint8_t *data, int len)
                                }
                                Chan_freeTreeList(&chanlist);
                        }
-               }                       
+               }
                /* Sessions */
                for (i = 0; i < TARGET_MAX_SESSIONS && vt->sessions[i] != -1; i++) {
                        client_t *c;
@@ -976,7 +976,7 @@ int Client_voiceMsg(client_t *client, uint8_t *data, int len)
 out:
        Pds_free(pds);
        Pds_free(pdi);
-       
+
        return 0;
 }
 
@@ -995,11 +995,11 @@ static int Client_send_udp(client_t *client, uint8_t *data, int len)
 #endif
                if (mbuf == NULL)
                        Log_fatal("Out of memory");
-               
+
                CryptState_encrypt(&client->cryptState, data, buf, len);
-               
+
                sendto(udpsock, buf, len + 4, 0, (struct sockaddr *)&client->remote_udp, sizeof(struct sockaddr_in));
-               
+
                free(mbuf);
        } else {
                message_t *msg;
index 47504527158775e56f495cb239f39236a9e471b8..2c6f56f9ffa5fd404fd2f10618a241cf42488d6c 100644 (file)
@@ -84,7 +84,7 @@ const char *getStrConf(param_t param)
 {
        config_setting_t *setting = NULL;
        const char *strsetting = NULL;
-       
+
        switch (param) {
        case CERTIFICATE:
                setting = config_lookup(&configuration, "certificate");
@@ -228,7 +228,7 @@ const char *getStrConf(param_t param)
 int getIntConf(param_t param)
 {
        config_setting_t *setting = NULL;
-       
+
        switch (param) {
        case BINDPORT:
                setting = config_lookup(&configuration, "bindport");
@@ -278,7 +278,7 @@ int getIntConf(param_t param)
 bool_t getBoolConf(param_t param)
 {
        config_setting_t *setting = NULL;
-       
+
        switch (param) {
        case ALLOW_TEXTMESSAGE:
                setting = config_lookup(&configuration, "allow_textmessage");
@@ -311,47 +311,47 @@ int Conf_getNextChannel(conf_channel_t *chdesc, int index)
        config_setting_t *setting = NULL;
        int maxconfig = 64, ret = 0;
        char configstr[maxconfig];
-       
+
        ret = snprintf(configstr, maxconfig, "channels.[%d].name", index);
        setting = config_lookup(&configuration, configstr);
        if (ret >= maxconfig || ret < 0 || setting == NULL)
                return -1; /* Required */
        chdesc->name =  config_setting_get_string(setting);
-       
+
        ret = snprintf(configstr, maxconfig, "channels.[%d].parent", index);
        setting = config_lookup(&configuration, configstr);
        if (ret >= maxconfig || ret < 0 || setting == NULL)
                return -1; /* Required */
        chdesc->parent = config_setting_get_string(setting);
-       
+
        ret = snprintf(configstr, maxconfig, "channels.[%d].description", index);
        setting = config_lookup(&configuration, configstr);
        if (ret >= maxconfig || ret < 0 || setting == NULL) /* Optional */
                chdesc->description = NULL;
        else
                chdesc->description = config_setting_get_string(setting);
-       
+
        ret = snprintf(configstr, maxconfig, "channels.[%d].password", index);
        setting = config_lookup(&configuration, configstr);
        if (ret >= maxconfig || ret < 0 || setting == NULL) /* Optional */
                chdesc->password = NULL;
        else
                chdesc->password = config_setting_get_string(setting);
-       
+
        ret = snprintf(configstr, maxconfig, "channels.[%d].noenter", index);
        setting = config_lookup(&configuration, configstr);
        if (ret >= maxconfig || ret < 0 || setting == NULL) /* Optional */
                chdesc->noenter = false;
        else
                chdesc->noenter = config_setting_get_bool(setting);
-       
+
        ret = snprintf(configstr, maxconfig, "channels.[%d].silent", index);
        setting = config_lookup(&configuration, configstr);
        if (ret >= maxconfig || ret < 0 || setting == NULL) /* Optional */
                chdesc->silent = false;
        else
                chdesc->silent = config_setting_get_bool(setting);
-       
+
        ret = snprintf(configstr, maxconfig, "channels.[%d].position", index);
        setting = config_lookup(&configuration, configstr);
        if (ret >= maxconfig || ret < 0 || setting == NULL) /* Optional */
@@ -367,7 +367,7 @@ int Conf_getNextChannelLink(conf_channel_link_t *chlink, int index)
        config_setting_t *setting = NULL;
        int maxconfig = 64, ret = 0;
        char configstr[maxconfig];
-       
+
        ret = snprintf(configstr, maxconfig, "channel_links.[%d].source", index);
        setting = config_lookup(&configuration, configstr);
        if (ret >= maxconfig || ret < 0 || setting == NULL)
index 89fe19d246490eb291dc27f8ac78732a27ef9edd..ddf1f74af93dc9eff77e922e116555860aefbd79 100644 (file)
@@ -199,7 +199,7 @@ bool_t CryptState_decrypt(cryptState_t *cs, const unsigned char *source, unsigne
        CryptState_ocb_decrypt(cs, source+4, dst, plain_length, cs->decrypt_iv, tag);
 
        if (memcmp(tag, source+1, 3) != 0) {
-               memcpy(cs->decrypt_iv, saveiv, AES_BLOCK_SIZE);         
+               memcpy(cs->decrypt_iv, saveiv, AES_BLOCK_SIZE);
                return false;
        }
        cs->decrypt_history[cs->decrypt_iv[0]] = cs->decrypt_iv[1];
index 539dee53eb771d96838668d59a7c202775169adc..ebb5cd1c0ae1e4b4965da971df41a3484f538928 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -56,7 +56,7 @@ static void openlogfile(const char *logfilename)
        /* Set the stream as line buffered */
        if (setvbuf(logfile, NULL, _IOLBF, 0) < 0)
                Log_fatal("setvbuf() failed: %s\n", strerror(errno));
-       
+
        /* XXX - Is it neccessary/appropriate that logging to file is non-blocking?
         * If not, there's a risk that execution blocks, meaning that voice blocks
         * as well since uMurmur is single threaded by design. OTOH, what could
@@ -84,11 +84,11 @@ static char *timestring(void)
 void Log_init(bool_t terminal)
 {
        const char *logfilename;
-       
-       termprint = terminal;           
+
+       termprint = terminal;
        if (termprint)
                return;
-       
+
        logfilename = getStrConf(LOGFILE);
        if (logfilename != NULL) {
                openlogfile(logfilename);
@@ -103,14 +103,14 @@ void Log_free()
                return;
        else if (logfile)
                fclose(logfile);
-       else 
+       else
                closelog();
 }
-               
+
 void Log_reset()
 {
        const char *logfilename;
-       
+
        if (logfile) {
                logfilename = getStrConf(LOGFILE);
                fclose(logfile);
@@ -122,11 +122,11 @@ void logthis(const char *logstring, ...)
 {
        va_list argp;
        char buf[STRSIZE + 1];
-       
+
        va_start(argp, logstring);
        vsnprintf(&buf[0], STRSIZE, logstring, argp);
        va_end(argp);
-       
+
        if (termprint)
                fprintf(stderr, "%s\n", buf);
        else if (logfile)
@@ -140,14 +140,14 @@ void Log_warn(const char *logstring, ...)
        va_list argp;
        char buf[STRSIZE + 1];
        int offset = 0;
-       
+
        if (termprint || logfile)
                offset = sprintf(buf, "WARN: ");
-       
+
        va_start(argp, logstring);
        vsnprintf(&buf[offset], STRSIZE - offset, logstring, argp);
        va_end(argp);
-       
+
        if (termprint)
                fprintf(stderr, "%s\n", buf);
        else if (logfile)
@@ -161,14 +161,14 @@ void Log_info(const char *logstring, ...)
        va_list argp;
        char buf[STRSIZE + 1];
        int offset = 0;
-       
+
        if (termprint || logfile)
                offset = sprintf(buf, "INFO: ");
-       
-       va_start(argp, logstring);      
+
+       va_start(argp, logstring);
        vsnprintf(&buf[offset], STRSIZE - offset, logstring, argp);
        va_end(argp);
-       
+
        if (termprint)
                fprintf(stderr, "%s\n", buf);
        else if (logfile)
@@ -182,14 +182,14 @@ void Log_info_client(client_t *client, const char *logstring, ...)
        va_list argp;
        char buf[STRSIZE + 1];
        int offset = 0;
-       
+
        if (termprint || logfile)
                offset = sprintf(buf, "INFO: ");
 
        va_start(argp, logstring);
        offset += vsnprintf(&buf[offset], STRSIZE - offset, logstring, argp);
        va_end(argp);
-       
+
        offset += snprintf(&buf[offset], STRSIZE - offset, " - [%d] %s@%s:%d",
                                           client->sessionId,
                                           client->username == NULL ? "" : client->username,
@@ -209,11 +209,11 @@ void Log_debug(const char *logstring, ...)
        va_list argp;
        char buf[STRSIZE + 1];
        int offset = 0;
-       
+
        if (termprint || logfile)
                offset = sprintf(buf, "DEBUG: ");
-       
-       va_start(argp, logstring);      
+
+       va_start(argp, logstring);
        vsnprintf(&buf[offset], STRSIZE - offset, logstring, argp);
        va_end(argp);
        if (termprint)
@@ -230,20 +230,20 @@ void Log_fatal(const char *logstring, ...)
        va_list argp;
        char buf[STRSIZE + 1];
        int offset = 0;
-       
+
        if (termprint || logfile)
                offset = sprintf(buf, "FATAL: ");
-       
-       va_start(argp, logstring);      
+
+       va_start(argp, logstring);
        vsnprintf(&buf[offset], STRSIZE - offset, logstring, argp);
        va_end(argp);
-       
+
        if (termprint)
                fprintf(stderr, "%s\n", buf);
        else if (logfile)
                fprintf(logfile, "%s %s\n", timestring(), buf);
        else { /* If logging subsystem is not initialized, fall back to stderr +
-                       * syslog logging for fatal errors. 
+                       * syslog logging for fatal errors.
                        */
                if (!init) {
                        openlog("uMurmurd", LOG_PID, LOG_DAEMON);
@@ -251,6 +251,6 @@ void Log_fatal(const char *logstring, ...)
                }
                syslog(LOG_CRIT, "%s", buf);
        }
-       
+
        exit(1);
 }
index 234cc7f3e793fc6864796394de7bbbcfea9e4220..b169597a760b913ccc49c025b64f6a854782f136 100644 (file)
@@ -68,7 +68,7 @@ void lockfile(const char *pidfile)
         * unmodified if we cannot lock it.
         */
        lfp = open(pidfile, O_WRONLY|O_CREAT, 0640);
-       
+
        if (lfp < 0)
                Log_fatal("Cannot open PID-file %s for writing", pidfile);
 
@@ -152,12 +152,12 @@ static void switch_user(void)
 
        if (setuid(pwd->pw_uid))
                Log_fatal("setuid() failed: %s", strerror(errno));
-       
+
        if (!grp)
                grp = getgrgid(gid);
        if (!grp)
                Log_fatal("getgrgid() failed: %s", strerror(errno));
-       
+
        Log_info("Switch to user '%s' group '%s'", pwd->pw_name, grp->gr_name);
 }
 
@@ -178,7 +178,7 @@ void signal_handler(int sig)
 void daemonize()
 {
        int i;
-       
+
        if (getppid() == 1)
                return; /* already a daemon */
        i = fork();
@@ -188,19 +188,19 @@ void daemonize()
        }
        if ( i > 0)
                exit(0); /* parent exits */
-       
+
        /* child (daemon) continues */
        setsid(); /* obtain a new process group */
        for (i = getdtablesize(); i >= 0; --i)
                close(i); /* close all descriptors */
-       
+
        i = open("/dev/null",O_RDWR);
        (void)dup(i);
        (void)dup(i);
-       
+
        umask(027); /* set newly created file permissions */
        (void)chdir("/");
-               
+
 }
 
 #ifdef POSIX_PRIORITY_SCHEDULING
@@ -245,7 +245,7 @@ int main(int argc, char **argv)
        char *conffile = NULL, *pidfile = NULL;
        int c;
        struct utsname utsbuf;
-       
+
        /* Arguments */
 #ifdef POSIX_PRIORITY_SCHEDULING
        while ((c = getopt(argc, argv, "drp:c:a:b:ht")) != EOF) {
@@ -292,12 +292,12 @@ int main(int argc, char **argv)
                else
                        exit(0);
        }
-               
+
        /* Initialize the config subsystem early;
         * switch_user() will need to read some config variables as well as logging.
         */
        Conf_init(conffile);
-       
+
        /* Logging to terminal if not daemonizing, otherwise to syslog or log file.
         */
        if (!nodaemon) {
@@ -311,10 +311,10 @@ int main(int argc, char **argv)
                /* Reopen log file. If user switch results in access denied, we catch
                 * it early.
                 */
-               Log_reset(); 
+               Log_reset();
        }
        else Log_init(true);
-       
+
        signal(SIGCHLD, SIG_IGN); /* ignore child */
        signal(SIGTSTP, SIG_IGN); /* ignore tty signals */
        signal(SIGTTOU, SIG_IGN);
@@ -322,7 +322,7 @@ int main(int argc, char **argv)
        signal(SIGPIPE, SIG_IGN);
        signal(SIGHUP, signal_handler); /* catch hangup signal */
        signal(SIGTERM, signal_handler); /* catch kill signal */
-       
+
        /* Build system string */
        if (uname(&utsbuf) == 0) {
                snprintf(system_string, 64, "%s %s", utsbuf.sysname, utsbuf.machine);
@@ -332,7 +332,7 @@ int main(int argc, char **argv)
                snprintf(system_string, 64, "unknown unknown");
                snprintf(version_string, 64, "unknown");
        }
-       
+
        /* Initializing */
        SSLi_init();
        Chan_init();
@@ -343,17 +343,17 @@ int main(int argc, char **argv)
        if (realtime)
                setscheduler();
 #endif
-       
+
        Server_run();
-       
+
        Ban_deinit();
        SSLi_deinit();
        Chan_free();
        Log_free();
        Conf_deinit();
-       
+
        if (pidfile != NULL)
                unlink(pidfile);
-       
+
        return 0;
 }
index 849c55990526d270954149d815dd44d1c32d9279..f1a753f9e81495764d20f120f9e371ea51959b34 100644 (file)
@@ -61,7 +61,7 @@ static void sendServerReject(client_t *client, const char *reason, MumbleProto__
        msg->payload.reject->type = type;
        msg->payload.reject->has_type = true;
        Client_send_message(client, msg);
-       
+
        Log_info_client(client, "Server reject reason: %s", reason);
 }
 
@@ -85,7 +85,7 @@ static void addTokens(client_t *client, message_t *msg)
                                return;
                        }
                }
-               
+
                for (i = 0; i < msg->payload.authenticate->n_tokens; i++) {
                        Log_debug("Adding token '%s' to client '%s'", msg->payload.authenticate->tokens[i], client->username);
                        Client_token_add(client, msg->payload.authenticate->tokens[i]);
@@ -105,7 +105,7 @@ void Mh_handle_message(client_t *client, message_t *msg)
                                                                        msg->messageType == Version)) {
                goto out;
        }
-       
+
        switch (msg->messageType) {
        case UDPTunnel:
        case Ping:
@@ -117,31 +117,31 @@ void Mh_handle_message(client_t *client, message_t *msg)
        default:
                Timer_restart(&client->idleTime);
        }
-       
+
        switch (msg->messageType) {
        case Authenticate:
                Log_debug("Authenticate message received");
-               
+
                if (IS_AUTH(client) || !msg->payload.authenticate->username) {
                        /* Authenticate message might be sent when a tokens are changed by the user.*/
                        Client_token_free(client); /* Clear the token list */
                        if (msg->payload.authenticate->n_tokens > 0) {
                                Log_debug("Tokens in auth message from '%s'. n_tokens = %d", client->username,
                                          msg->payload.authenticate->n_tokens);
-                               addTokens(client, msg);                         
+                               addTokens(client, msg);
                        }
                        break;
                }
-               
+
                if (SSLi_getSHA1Hash(client->ssl, client->hash) && Ban_isBanned(client)) {
                        char hexhash[41];
                        SSLi_hash2hex(client->hash, hexhash);
                        Log_info("Client with hash '%s' is banned. Disconnecting", hexhash);
                        goto disconnect;
                }
-               
+
                client->authenticated = true;
-               
+
                client_itr = NULL;
                while (Client_iterate(&client_itr) != NULL) {
                        if (!IS_AUTH(client_itr))
@@ -152,7 +152,7 @@ void Mh_handle_message(client_t *client, message_t *msg)
                                Log_debug("Username already in use");
                                sendServerReject(client, buf, MUMBLE_PROTO__REJECT__REJECT_TYPE__UsernameInUse);
                                goto disconnect;
-                       }                               
+                       }
                }
                if (strlen(getStrConf(PASSPHRASE)) > 0) {
                        if (!msg->payload.authenticate->password ||
@@ -165,7 +165,7 @@ void Mh_handle_message(client_t *client, message_t *msg)
                                                  msg->payload.authenticate->password : "(null)");
                                goto disconnect;
                        }
-               }                               
+               }
                if (strlen(msg->payload.authenticate->username) == 0 ||
                        strlen(msg->payload.authenticate->username) >= MAX_USERNAME) { /* XXX - other invalid names? */
                        char buf[64];
@@ -173,7 +173,7 @@ void Mh_handle_message(client_t *client, message_t *msg)
                        Log_debug("Invalid username");
                        sendServerReject(client, buf, MUMBLE_PROTO__REJECT__REJECT_TYPE__InvalidUsername);
                        goto disconnect;
-               }                               
+               }
 
                if (Client_count() >= getIntConf(MAX_CLIENTS)) {
                        char buf[64];
@@ -181,21 +181,21 @@ void Mh_handle_message(client_t *client, message_t *msg)
                        sendServerReject(client, buf, MUMBLE_PROTO__REJECT__REJECT_TYPE__ServerFull);
                        goto disconnect;
                }
-               
+
                /* Name */
-               client->username = strdup(msg->payload.authenticate->username);                         
+               client->username = strdup(msg->payload.authenticate->username);
 
                /* Tokens */
                if (msg->payload.authenticate->n_tokens > 0)
                        addTokens(client, msg);
-               
+
                /* Check if admin PW among tokens */
                if (strlen(getStrConf(ADMIN_PASSPHRASE)) > 0 &&
                    Client_token_match(client, getStrConf(ADMIN_PASSPHRASE))) {
                        client->isAdmin = true;
                        Log_info_client(client, "User provided admin password");
                }
-               
+
                /* Setup UDP encryption */
                CryptState_init(&client->cryptState);
                CryptState_genKey(&client->cryptState);
@@ -214,20 +214,20 @@ void Mh_handle_message(client_t *client, message_t *msg)
                /* Channel stuff */
                Chan_userJoin(defaultChan, client); /* Join default channel */
 
-               /* Codec version */             
+               /* Codec version */
                Log_debug("Client %d has %d CELT codecs", client->sessionId,
                                  msg->payload.authenticate->n_celt_versions);
                if (msg->payload.authenticate->n_celt_versions > 0) {
                        int i;
                        codec_t *codec_itr;
                        client->codec_count = msg->payload.authenticate->n_celt_versions;
-                       
+
                        for (i = 0; i < client->codec_count; i++)
                        Client_codec_add(client, msg->payload.authenticate->celt_versions[i]);
                        codec_itr = NULL;
                        while (Client_codec_iterate(client, &codec_itr) != NULL)
                                Log_debug("Client %d CELT codec ver 0x%x", client->sessionId, codec_itr->codec);
-                               
+
                } else {
                        Client_codec_add(client, (int32_t)0x8000000b);
                        client->codec_count = 1;
@@ -235,9 +235,9 @@ void Mh_handle_message(client_t *client, message_t *msg)
                }
                if (msg->payload.authenticate->opus)
                        client->bOpus = true;
-               
+
                recheckCodecVersions(client);
-               
+
                sendmsg = Msg_create(CodecVersion);
                sendmsg->payload.codecVersion->alpha = iCodecAlpha;
                sendmsg->payload.codecVersion->beta = iCodecBeta;
@@ -268,7 +268,7 @@ void Mh_handle_message(client_t *client, message_t *msg)
                                sendmsg->payload.channelState->position = ch_itr->position;
                        }
                        Log_debug("Send channel info: %s", sendmsg->payload.channelState->name);
-                       Client_send_message(client, sendmsg);                   
+                       Client_send_message(client, sendmsg);
                }
 
                /* Iterate channels and send channel links info */
@@ -278,12 +278,12 @@ void Mh_handle_message(client_t *client, message_t *msg)
                                uint32_t *links;
                                int i = 0;
                                struct dlist *itr;
-                               
+
                                sendmsg = Msg_create(ChannelState);
                                sendmsg->payload.channelState->has_channel_id = true;
                                sendmsg->payload.channelState->channel_id = ch_itr->id;
                                sendmsg->payload.channelState->n_links = ch_itr->linkcount;
-                               
+
                                links = (uint32_t *)malloc(ch_itr->linkcount * sizeof(uint32_t));
                                list_iterate(itr, &ch_itr->channel_links) { /* Iterate links */
                                        channel_t *ch;
@@ -294,7 +294,7 @@ void Mh_handle_message(client_t *client, message_t *msg)
                                Client_send_message(client, sendmsg);
                        }
                }
-               
+
                /* Send user state for connecting user to other users */
                sendmsg = Msg_create(UserState);
                sendmsg->payload.userState->has_session = true;
@@ -358,7 +358,7 @@ void Mh_handle_message(client_t *client, message_t *msg)
                Client_send_message(client, sendmsg);
 
                /* Server config message */
-               sendmsg = Msg_create(ServerConfig);             
+               sendmsg = Msg_create(ServerConfig);
                sendmsg->payload.serverConfig->has_allow_html = true;
                sendmsg->payload.serverConfig->allow_html = true; /* Support this? */
                sendmsg->payload.serverConfig->has_message_length = true;
@@ -369,7 +369,7 @@ void Mh_handle_message(client_t *client, message_t *msg)
 
                Log_info_client(client, "User %s authenticated", client->username);
                break;
-               
+
        case Ping:
                if (msg->payload.ping->has_good)
                        client->cryptState.uiRemoteGood = msg->payload.ping->good;
@@ -384,14 +384,14 @@ void Mh_handle_message(client_t *client, message_t *msg)
                                  client->cryptState.uiRemoteGood, client->cryptState.uiRemoteLate,
                                  client->cryptState.uiRemoteLost, client->cryptState.uiRemoteResync
                        );
-               
+
                client->UDPPingAvg = msg->payload.ping->udp_ping_avg;
                client->UDPPingVar = msg->payload.ping->udp_ping_var;
                client->TCPPingAvg = msg->payload.ping->tcp_ping_avg;
                client->TCPPingVar = msg->payload.ping->tcp_ping_var;
                client->UDPPackets = msg->payload.ping->udp_packets;
                client->TCPPackets = msg->payload.ping->tcp_packets;
-               
+
                sendmsg = Msg_create(Ping);
 
                sendmsg->payload.ping->timestamp = msg->payload.ping->timestamp;
@@ -451,7 +451,7 @@ void Mh_handle_message(client_t *client, message_t *msg)
 
                if (target == NULL)
                        target = client;
-               
+
                msg->payload.userState->has_session = true;
                msg->payload.userState->session = target->sessionId;
                msg->payload.userState->has_actor = true;
@@ -492,7 +492,7 @@ void Mh_handle_message(client_t *client, message_t *msg)
                        client->recording = msg->payload.userState->recording;
                        char *message;
                        uint32_t *tree_id;
-                       
+
                        message = malloc(strlen(client->username) + 32);
                        if (!message)
                                Log_fatal("Out of memory");
@@ -560,19 +560,19 @@ void Mh_handle_message(client_t *client, message_t *msg)
                                Log_fatal("Out of memory");
                        memcpy(client->context, msg->payload.userState->plugin_context.data,
                                   msg->payload.userState->plugin_context.len);
-                       
+
                        break; /* Don't inform other users about this state */
                }
                /* Re-use message */
                Msg_inc_ref(msg);
-                               
+
                Client_send_message_except(NULL, msg);
 
                /* Need to send remove channel message _after_ UserState message */
                if (sendmsg != NULL)
                        Client_send_message_except(NULL, sendmsg);
                break;
-               
+
        case TextMessage:
                if (!getBoolConf(ALLOW_TEXTMESSAGE))
                        break;
@@ -584,7 +584,7 @@ void Mh_handle_message(client_t *client, message_t *msg)
                        sendPermissionDenied(client, "Tree message not supported");
                        break;
                }
-                       
+
                if (msg->payload.textMessage->n_channel_id > 0) { /* To channel */
                        int i;
                        channel_t *ch_itr;
@@ -668,12 +668,12 @@ void Mh_handle_message(client_t *client, message_t *msg)
                        Log_debug("Client release %s", client->release);
                }
                if (msg->payload.version->os) {
-                       if (client->os) free(client->os);                       
+                       if (client->os) free(client->os);
                        client->os = strdup(msg->payload.version->os);
                        Log_debug("Client OS %s", client->os);
                }
                if (msg->payload.version->os_version) {
-                       if (client->os_version) free(client->os_version);                       
+                       if (client->os_version) free(client->os_version);
                        client->os_version = strdup(msg->payload.version->os_version);
                        Log_debug("Client OS version %s", client->os_version);
                }
@@ -681,17 +681,17 @@ void Mh_handle_message(client_t *client, message_t *msg)
        case PermissionQuery:
                Msg_inc_ref(msg); /* Re-use message */
                msg->payload.permissionQuery->has_permissions = true;
-               
+
                if (client->isAdmin)
                        msg->payload.permissionQuery->permissions = PERM_ADMIN;
                else
                        msg->payload.permissionQuery->permissions = PERM_DEFAULT;
-               
+
                if (!getBoolConf(ALLOW_TEXTMESSAGE))
                        msg->payload.permissionQuery->permissions &= ~PERM_TEXTMESSAGE;
                if (!getBoolConf(ENABLE_BAN))
                        msg->payload.permissionQuery->permissions &= ~PERM_BAN;
-               
+
                Client_send_message(client, msg);
                break;
        case UDPTunnel:
@@ -701,7 +701,7 @@ void Mh_handle_message(client_t *client, message_t *msg)
        case ChannelState:
        {
                channel_t *ch_itr, *parent, *newchan;
-               int leave_id;           
+               int leave_id;
                /* Don't allow any changes to existing channels */
                if (msg->payload.channelState->has_channel_id) {
                        sendPermissionDenied(client, "Not supported by uMurmur");
@@ -727,7 +727,7 @@ void Mh_handle_message(client_t *client, message_t *msg)
                        sendPermissionDenied(client, "Channel name too long");
                        break;
                }
-                       
+
                parent = Chan_fromId(msg->payload.channelState->parent);
                if (parent == NULL)
                        break;
@@ -740,13 +740,13 @@ void Mh_handle_message(client_t *client, message_t *msg)
                }
                if (ch_itr != NULL)
                        break;
-               
+
                /* Disallow temporary channels as siblings to temporary channels */
                if (parent->temporary) {
                        sendPermissionDenied(client, "Parent channel is temporary channel");
                        break;
                }
-                       
+
                /* XXX - Murmur looks for "\\w" and sends perm denied if not found.
                 * I don't know why so I don't do that here...
                 */
@@ -785,7 +785,7 @@ void Mh_handle_message(client_t *client, message_t *msg)
                        sendmsg->payload.channelRemove->channel_id = leave_id;
                        Client_send_message_except(NULL, sendmsg);
                }
-       }               
+       }
        break;
 
        case UserStats:
@@ -794,10 +794,10 @@ void Mh_handle_message(client_t *client, message_t *msg)
                codec_t *codec_itr = NULL;
                int i;
                bool_t details = true;
-               
+
                if (msg->payload.userStats->has_stats_only)
                        details = !msg->payload.userStats->stats_only;
-               
+
                if (!msg->payload.userStats->has_session)
                        sendPermissionDenied(client, "Not supported by uMurmur");
                while (Client_iterate(&target) != NULL) {
@@ -808,13 +808,13 @@ void Mh_handle_message(client_t *client, message_t *msg)
                }
                if (!target) /* Not found */
                        break;
-               
+
                /*
                 * Differences from Murmur:
                 * o Ignoring certificates intentionally
                 * o Ignoring channel local determining
                 */
-               
+
                sendmsg = Msg_create(UserStats);
                sendmsg->payload.userStats->session = msg->payload.userStats->session;
                sendmsg->payload.userStats->from_client->has_good = true;
@@ -825,7 +825,7 @@ void Mh_handle_message(client_t *client, message_t *msg)
                sendmsg->payload.userStats->from_client->lost = target->cryptState.uiLost;
                sendmsg->payload.userStats->from_client->has_resync = true;
                sendmsg->payload.userStats->from_client->resync = target->cryptState.uiResync;
-               
+
                sendmsg->payload.userStats->from_server->has_good = true;
                sendmsg->payload.userStats->from_server->good = target->cryptState.uiRemoteGood;
                sendmsg->payload.userStats->from_server->has_late = true;
@@ -841,14 +841,14 @@ void Mh_handle_message(client_t *client, message_t *msg)
                sendmsg->payload.userStats->udp_ping_avg = target->UDPPingAvg;
                sendmsg->payload.userStats->has_udp_ping_var = true;
                sendmsg->payload.userStats->udp_ping_var = target->UDPPingVar;
-               
+
                sendmsg->payload.userStats->has_tcp_ping_avg = true;
                sendmsg->payload.userStats->tcp_ping_avg = target->TCPPingAvg;
                sendmsg->payload.userStats->has_tcp_ping_var = true;
                sendmsg->payload.userStats->tcp_ping_var = target->TCPPingVar;
                sendmsg->payload.userStats->has_tcp_packets = true;
                sendmsg->payload.userStats->tcp_packets = target->TCPPackets;
-               
+
                if (details) {
 
                        sendmsg->payload.userStats->version->has_version = true;
@@ -859,7 +859,7 @@ void Mh_handle_message(client_t *client, message_t *msg)
                                sendmsg->payload.userStats->version->os = strdup(target->os);
                        if (target->os_version)
                                sendmsg->payload.userStats->version->os_version = strdup(target->os_version);
-                       
+
                        sendmsg->payload.userStats->n_celt_versions = target->codec_count;
                        sendmsg->payload.userStats->celt_versions = malloc(sizeof(int32_t) * target->codec_count);
                        if (!sendmsg->payload.userStats->celt_versions)
@@ -885,13 +885,13 @@ void Mh_handle_message(client_t *client, message_t *msg)
                /* BW */
                sendmsg->payload.userStats->has_bandwidth = true;
                sendmsg->payload.userStats->bandwidth = target->availableBandwidth;
-               
+
                /* Onlinesecs */
                sendmsg->payload.userStats->has_onlinesecs = true;
-               sendmsg->payload.userStats->onlinesecs = Timer_elapsed(&target->connectTime) / 1000000LL;               
+               sendmsg->payload.userStats->onlinesecs = Timer_elapsed(&target->connectTime) / 1000000LL;
                /* Idlesecs */
                sendmsg->payload.userStats->has_idlesecs = true;
-               sendmsg->payload.userStats->idlesecs = Timer_elapsed(&target->idleTime) / 1000000LL;            
+               sendmsg->payload.userStats->idlesecs = Timer_elapsed(&target->idleTime) / 1000000LL;
                Client_send_message(client, sendmsg);
        }
        break;
@@ -925,7 +925,7 @@ void Mh_handle_message(client_t *client, message_t *msg)
                }
                /* Re-use message */
                Msg_inc_ref(msg);
-                               
+
                Client_send_message_except(NULL, msg);
                Client_close(target);
                break;
@@ -949,7 +949,7 @@ void Mh_handle_message(client_t *client, message_t *msg)
                        Ban_putBanList(msg, msg->payload.banList->n_bans);
                }
                break;
-               
+
                /* Permission denied for all these messages. Not implemented. */
        case ChannelRemove:
        case ContextAction:
@@ -959,7 +959,7 @@ void Mh_handle_message(client_t *client, message_t *msg)
        case QueryUsers:
                sendPermissionDenied(client, "Not supported by uMurmur");
                break;
-                               
+
        default:
                Log_warn("Message %d not handled", msg->messageType);
                break;
@@ -967,7 +967,7 @@ void Mh_handle_message(client_t *client, message_t *msg)
 out:
        Msg_free(msg);
        return;
-       
+
 disconnect:
        Msg_free(msg);
        Client_close(client);
index 944dcbaaecdd775885851c192aca16cb226b70f0..d621d4ed9b75f3124faf1a22c9aaec109d21594e 100644 (file)
 static message_t *Msg_create_nopayload(messageType_t messageType);
 
 static void Msg_addPreamble(uint8_t *buffer, uint16_t type, uint32_t len)
-{      
+{
        buffer[1] = (type) & 0xff;
        buffer[0] = (type >> 8) & 0xff;
-       
+
        buffer[5] = (len) & 0xff;
        buffer[4] = (len >> 8) & 0xff;
        buffer[3] = (len >> 16) & 0xff;
-       buffer[2] = (len >> 24) & 0xff; 
+       buffer[2] = (len >> 24) & 0xff;
 }
 
 static void Msg_getPreamble(uint8_t *buffer, int *type, int *len)
 {
        uint16_t msgType;
        uint32_t msgLen;
-       
+
        msgType = buffer[1] | (buffer[0] << 8);
        msgLen = buffer[5] | (buffer[4] << 8) | (buffer[3] << 16) | (buffer[2] << 24);
        *type = (int)msgType;
@@ -70,7 +70,7 @@ int Msg_messageToNetwork(message_t *msg, uint8_t *buffer)
 {
        int len;
        uint8_t *bufptr = buffer + PREAMBLE_SIZE;
-               
+
        Log_debug("To net: msg type %d", msg->messageType);
        switch (msg->messageType) {
        case Version:
@@ -227,7 +227,7 @@ int Msg_messageToNetwork(message_t *msg, uint8_t *buffer)
                mumble_proto__channel_remove__pack(msg->payload.channelRemove, bufptr);
                break;
        case UserStats:
-       {               
+       {
                len = mumble_proto__user_stats__get_packed_size(msg->payload.userStats);
                if (len > MAX_MSGSIZE) {
                        Log_warn("Too big tx message. Discarding");
@@ -281,7 +281,7 @@ message_t *Msg_create(messageType_t messageType)
 {
        message_t *msg = Msg_create_nopayload(messageType);
        int i;
-       
+
        switch (messageType) {
        case Version:
                msg->payload.version = malloc(sizeof(MumbleProto__Version));
@@ -354,7 +354,7 @@ message_t *Msg_create(messageType_t messageType)
        case UserStats:
                msg->payload.userStats = malloc(sizeof(MumbleProto__UserStats));
                mumble_proto__user_stats__init(msg->payload.userStats);
-               
+
                msg->payload.userStats->from_client = malloc(sizeof(MumbleProto__UserStats__Stats));
                mumble_proto__user_stats__stats__init(msg->payload.userStats->from_client);
 
@@ -363,7 +363,7 @@ message_t *Msg_create(messageType_t messageType)
 
                msg->payload.userStats->version = malloc(sizeof(MumbleProto__Version));
                mumble_proto__version__init(msg->payload.userStats->version);
-               
+
                if (!msg->payload.userStats || !msg->payload.userStats->from_client ||
                        !msg->payload.userStats->from_server || !msg->payload.userStats->version)
                        Log_fatal("Out of memory");
@@ -385,7 +385,7 @@ message_t *Msg_banList_create(int n_bans)
 {
        message_t *msg = Msg_create_nopayload(BanList);
        int i;
-       
+
        msg->payload.banList = malloc(sizeof(MumbleProto__BanList));
        if (msg->payload.banList == NULL)
                Log_fatal("Out of memory");
@@ -409,10 +409,10 @@ void Msg_banList_addEntry(message_t *msg, int index, uint8_t *address, uint32_t
                           char *name, char *hash, char *reason, char *start, uint32_t duration)
 {
        MumbleProto__BanList__BanEntry *entry = msg->payload.banList->bans[index];
-       
+
        entry->address.data = malloc(16);
        if (!entry->address.data)
-               Log_fatal("Out of memory");     
+               Log_fatal("Out of memory");
        memcpy(entry->address.data, address, 16);
        entry->address.len = 16;
        entry->mask = mask;
@@ -421,8 +421,8 @@ void Msg_banList_addEntry(message_t *msg, int index, uint8_t *address, uint32_t
        entry->reason = strdup(reason);
        entry->start = strdup(start);
        if (!entry->name || !entry->hash || !entry->reason || !entry->start)
-               Log_fatal("Out of memory");     
-               
+               Log_fatal("Out of memory");
+
        if (duration > 0) {
                entry->duration = duration;
                entry->has_duration = true;
@@ -456,7 +456,7 @@ void Msg_inc_ref(message_t *msg)
 void Msg_free(message_t *msg)
 {
        int i;
-       
+
        if (msg->refcount) msg->refcount--;
        if (msg->refcount > 0)
                return;
@@ -670,7 +670,7 @@ void Msg_free(message_t *msg)
 message_t *Msg_CreateVoiceMsg(uint8_t *data, int size)
 {
        message_t *msg = NULL;
-       
+
        msg = Msg_create_nopayload(UDPTunnel);
        msg->unpacked = false;
        msg->payload.UDPTunnel = malloc(sizeof(struct _MumbleProto__UDPTunnel));
@@ -694,7 +694,7 @@ message_t *Msg_networkToMessage(uint8_t *data, int size)
 
        Log_debug("Message type %d size %d", messageType, msgLen);
        //dumpmsg(data, size);
-       
+
        switch (messageType) {
        case Version:
        {
@@ -869,7 +869,7 @@ message_t *Msg_networkToMessage(uint8_t *data, int size)
                break;
        }
        return msg;
-       
+
 err_out:
        free(msg);
        return NULL;
index 60c17e4c6b68abc6b2df677a702bf8e2f033d2d7..066666f13b6c402ac4c684e3e321907246d9b3a6 100644 (file)
--- a/src/pds.c
+++ b/src/pds.c
@@ -102,7 +102,7 @@ int Pds_skip(pds_t *pds, int offset)
                pds->bOk = false;
                return 0;
        }
-       
+
 }
 
 static inline uint64_t next(pds_t *pds)
@@ -135,9 +135,9 @@ void Pds_free(pds_t *pds)
 void Pds_add_double(pds_t *pds, double value)
 {
        double64u_t u;
-       
+
        u.dval = value;
-       
+
        Pds_add_numval(pds, u.u64);
 }
 
@@ -150,7 +150,7 @@ double Pds_get_double(pds_t *pds)
 void Pds_add_numval(pds_t *pds, const uint64_t value)
 {
        uint64_t i = value;
-       
+
        if ((i & 0x8000000000000000LL) && (~i < 0x100000000LL)) {
                // Signed number.
                i = ~i;
@@ -200,12 +200,12 @@ void Pds_add_numval(pds_t *pds, const uint64_t value)
                append_val(pds, i & 0xFF);
        }
 }
-       
+
 uint64_t Pds_get_numval(pds_t *pds)
 {
        uint64_t i = 0;
        uint64_t v = next(pds);
-       
+
        if ((v & 0x80) == 0x00) {
                i=(v & 0x7F);
        } else if ((v & 0xC0) == 0x80) {
index 42385abd0b7f2cf34765a9609cdf0c83f7073a5a..62257d0c59667e130b99e68d71de1212f22966a0 100644 (file)
--- a/src/ssl.c
+++ b/src/ssl.c
@@ -73,7 +73,7 @@ static inline int x509parse_keyfile(rsa_context *rsa, const char *path,
 {
     int ret;
     pk_context pk;
-    
+
     pk_init(&pk);
     ret = pk_parse_keyfile(&pk, path, pwd);
     if (ret == 0 && !pk_can_do( &pk, POLARSSL_PK_RSA))
@@ -128,7 +128,7 @@ static void initTestCert()
 static void initTestKey()
 {
        int rc;
-       
+
        rc = x509parse_key_rsa(&key, (unsigned char *)test_srv_key,
                               strlen(test_srv_key), NULL, 0);
        if (rc != 0)
@@ -145,7 +145,7 @@ static void initCert()
 {
        int rc;
        char *crtfile = (char *)getStrConf(CERTIFICATE);
-       
+
        if (crtfile == NULL) {
 #ifdef USE_POLARSSL_TESTCERT
                Log_warn("No certificate file specified. Falling back to test certificate.");
@@ -177,7 +177,7 @@ static void initKey()
        char *keyfile = (char *)getStrConf(KEY);
 
        if (keyfile == NULL)
-               Log_fatal("No key file specified"); 
+               Log_fatal("No key file specified");
        rc = x509parse_keyfile(&key, keyfile, NULL);
        if (rc != 0)
                Log_fatal("Could not read RSA key file %s", keyfile);
@@ -187,7 +187,7 @@ static void initKey()
 int urandom_bytes(void *ctx, unsigned char *dest, size_t len)
 {
        int cur;
-       
+
        while (len) {
                cur = read(urandom_fd, dest, len);
                if (cur < 0)
@@ -208,7 +208,7 @@ static void pssl_debug(void *ctx, int level, const char *str)
 void SSLi_init(void)
 {
        char verstring[12];
-       
+
        initCert();
 #ifdef USE_POLARSSL_TESTCERT
        if (builtInTestCertificate) {
@@ -230,7 +230,7 @@ void SSLi_init(void)
     if (urandom_fd < 0)
            Log_fatal("Cannot open /dev/urandom");
 #endif
-    
+
     version_get_string(verstring);
     Log_info("PolarSSL library version %s initialized", verstring);
 }
@@ -239,7 +239,7 @@ void SSLi_deinit(void)
 {
 #ifdef POLARSSL_API_V1_3_ABOVE
        x509_crt_free(&certificate);
-#else  
+#else
        x509_free(&certificate);
 #endif
        rsa_free(&key);
@@ -260,37 +260,37 @@ bool_t SSLi_getSHA1Hash(SSL_handle_t *ssl, uint8_t *hash)
 #endif
        if (!cert) {
                return false;
-       }       
+       }
        sha1(cert->raw.p, cert->raw.len, hash);
        return true;
 }
-       
+
 SSL_handle_t *SSLi_newconnection(int *fd, bool_t *SSLready)
 {
        ssl_context *ssl;
        ssl_session *ssn;
        int rc;
-       
+
        ssl = malloc(sizeof(ssl_context));
        ssn = malloc(sizeof(ssl_session));
        if (!ssl || !ssn)
                Log_fatal("Out of memory");
        memset(ssl, 0, sizeof(ssl_context));
        memset(ssn, 0, sizeof(ssl_session));
-       
+
        rc = ssl_init(ssl);
        if (rc != 0 )
                Log_fatal("Failed to initialize: %d", rc);
-       
-       ssl_set_endpoint(ssl, SSL_IS_SERVER);   
+
+       ssl_set_endpoint(ssl, SSL_IS_SERVER);
        ssl_set_authmode(ssl, SSL_VERIFY_OPTIONAL);
-       
+
 #ifdef USE_POLARSSL_HAVEGE
        ssl_set_rng(ssl, HAVEGE_RAND, &hs);
 #else
        ssl_set_rng(ssl, urandom_bytes, NULL);
 #endif
-       
+
        ssl_set_dbg(ssl, pssl_debug, NULL);
        ssl_set_bio(ssl, net_recv, fd, net_send, fd);
 
@@ -301,7 +301,7 @@ SSL_handle_t *SSLi_newconnection(int *fd, bool_t *SSLready)
 #else
     ssl_set_session(ssl, 0, 0, ssn);
 #endif
-    
+
     ssl_set_ca_chain(ssl, &certificate, NULL, NULL);
 #ifdef POLARSSL_API_V1_3_ABOVE
        ssl_set_own_cert_rsa(ssl, &certificate, &key);
@@ -316,13 +316,13 @@ SSL_handle_t *SSLi_newconnection(int *fd, bool_t *SSLready)
 int SSLi_nonblockaccept(SSL_handle_t *ssl, bool_t *SSLready)
 {
        int rc;
-       
+
        rc = ssl_handshake(ssl);
        if (rc != 0) {
                if (rc == POLARSSL_ERR_NET_WANT_READ || rc == POLARSSL_ERR_NET_WANT_WRITE) {
                        return 0;
                } else if (rc == POLARSSL_ERR_X509_CERT_VERIFY_FAILED) { /* Allow this (selfsigned etc) */
-                       return 0;                       
+                       return 0;
                } else {
                        Log_warn("SSL handshake failed: %d", rc);
                        return -1;
@@ -345,7 +345,7 @@ int SSLi_read(SSL_handle_t *ssl, uint8_t *buf, int len)
 int SSLi_write(SSL_handle_t *ssl, uint8_t *buf, int len)
 {
        int rc;
-       
+
        rc = ssl_write(ssl, buf, len);
        if (rc == POLARSSL_ERR_NET_WANT_WRITE)
                return SSLI_ERROR_WANT_WRITE;
@@ -391,7 +391,7 @@ static X509 *x509;
 static RSA *rsa;
 static SSL_CTX *context;
 static EVP_PKEY *pkey;
+
 static int verify_callback(int preverify_ok, X509_STORE_CTX *ctx);
 
 static int SSL_add_ext(X509 * crt, int nid, char *value) {
@@ -412,17 +412,17 @@ static X509 *SSL_readcert(char *certfile)
 {
        FILE *fp;
        X509 *x509;
-                       
+
        /* open the certificate file */
        fp = fopen(certfile, "r");
        if (fp == NULL) {
                Log_warn("Unable to open the X509 file %s for reading.", certfile);
                return NULL;
        }
-       
-       /* allocate memory for the cert structure */    
+
+       /* allocate memory for the cert structure */
        x509 = X509_new();
-       
+
        if (PEM_read_X509(fp, &x509, NULL, NULL) == 0) {
                /* error reading the x509 information - check the error stack */
                Log_warn("Error trying to read X509 info.");
@@ -445,13 +445,13 @@ static RSA *SSL_readprivatekey(char *keyfile)
                Log_warn("Unable to open the private key file %s for reading.", keyfile);
                return NULL;
        }
-       
+
 /* allocate memory for the RSA structure */
        rsa = RSA_new();
-       
+
        /* assign a callback function for the password */
-       
-       /* read a private key from file */      
+
+       /* read a private key from file */
        if (PEM_read_RSAPrivateKey(fp, &rsa, NULL, NULL) <= 0) {
                /* error reading the key - check the error stack */
                Log_warn("Error trying to read private key.");
@@ -466,13 +466,13 @@ static RSA *SSL_readprivatekey(char *keyfile)
 static void SSL_writecert(char *certfile, X509 *x509)
 {
        FILE *fp;
-               
+
        /* open the private key file */
        fp = fopen(certfile, "w");
        if (fp == NULL) {
                Log_warn("Unable to open the X509 file %s for writing", certfile);
                return;
-       }               
+       }
        if (PEM_write_X509(fp, x509) == 0) {
                Log_warn("Error trying to write X509 info.");
        }
@@ -482,14 +482,14 @@ static void SSL_writecert(char *certfile, X509 *x509)
 static void SSL_writekey(char *keyfile, RSA *rsa)
 {
        FILE *fp;
-       
+
        /* open the private key file for reading */
        fp = fopen(keyfile, "w");
        if (fp == NULL) {
                Log_warn("Unable to open the private key file %s for writing.", keyfile);
                return;
        }
-       
+
        if (PEM_write_RSAPrivateKey(fp, rsa, NULL, NULL, 0, NULL, NULL) == 0) {
                Log_warn("Error trying to write private key");
        }
@@ -499,7 +499,7 @@ static void SSL_writekey(char *keyfile, RSA *rsa)
 static void SSL_initializeCert() {
 
        char *crt, *key, *pass;
-       
+
        crt = (char *)getStrConf(CERTIFICATE);
        key = (char *)getStrConf(KEY);
        pass = (char *)getStrConf(PASSPHRASE);
@@ -509,12 +509,12 @@ static void SSL_initializeCert() {
        if (rsa != NULL) {
                pkey = EVP_PKEY_new();
                EVP_PKEY_assign_RSA(pkey, rsa);
-       }               
+       }
+
 
-       
 #if 0
        /* Later ... */
-       if (key && !x509) {             
+       if (key && !x509) {
                qscCert = QSslCertificate(key);
                if (! qscCert.isNull()) {
                        logthis("Using certificate from key.");
@@ -542,35 +542,35 @@ static void SSL_initializeCert() {
 
        }
 #endif
-       
+
        if (!rsa || !x509) {
                Log_info("Generating new server certificate.");
 
-               
+
                CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
-                               
+
                x509 = X509_new();
                pkey = EVP_PKEY_new();
                rsa = RSA_generate_key(1024,RSA_F4,NULL,NULL);
                EVP_PKEY_assign_RSA(pkey, rsa);
-               
+
                X509_set_version(x509, 2);
                ASN1_INTEGER_set(X509_get_serialNumber(x509),1);
                X509_gmtime_adj(X509_get_notBefore(x509),0);
                X509_gmtime_adj(X509_get_notAfter(x509),60*60*24*365);
                X509_set_pubkey(x509, pkey);
-               
+
                X509_NAME *name=X509_get_subject_name(x509);
-               
+
                X509_NAME_add_entry_by_txt(name, "CN", MBSTRING_ASC, (const uint8_t *)"Murmur Autogenerated Certificate v2", -1, -1, 0);
                X509_set_issuer_name(x509, name);
                SSL_add_ext(x509, NID_basic_constraints, "critical,CA:FALSE");
                SSL_add_ext(x509, NID_ext_key_usage, "serverAuth,clientAuth");
                SSL_add_ext(x509, NID_subject_key_identifier, "hash");
                SSL_add_ext(x509, NID_netscape_comment, "Generated from umurmur");
-               
+
                X509_sign(x509, pkey, EVP_md5());
-               
+
                SSL_writecert(crt, x509);
                SSL_writekey(key, rsa);
        }
@@ -585,7 +585,7 @@ void SSLi_init(void)
        STACK_OF(SSL_CIPHER) *cipherlist = NULL, *cipherlist_new = NULL;
        SSL_CIPHER *cipher;
        char *cipherstring, tempstring[128];
-               
+
        SSL_library_init();
        OpenSSL_add_all_algorithms();           /* load & register all cryptos, etc. */
        SSL_load_error_strings();                       /* load all error messages */
@@ -597,13 +597,13 @@ void SSLi_init(void)
                ERR_print_errors_fp(stderr);
                abort();
        }
-       
+
        char* sslCAPath = getStrConf(CAPATH);
        if(sslCAPath != NULL)
        {
                SSL_CTX_load_verify_locations(context, NULL, sslCAPath);
        }
-       
+
        SSL_initializeCert();
        if (SSL_CTX_use_certificate(context, x509) <= 0)
                Log_fatal("Failed to initialize cert");
@@ -611,12 +611,12 @@ void SSLi_init(void)
                ERR_print_errors_fp(stderr);
                Log_fatal("Failed to initialize private key");
        }
-       
+
        /* Set cipher list */
-       ssl = SSL_new(context); 
+       ssl = SSL_new(context);
        cipherlist = (STACK_OF(SSL_CIPHER) *) SSL_get_ciphers(ssl);
        cipherlist_new = (STACK_OF(SSL_CIPHER) *) sk_SSL_CIPHER_new_null();
-       
+
        for ( i = 0; (cipher = sk_SSL_CIPHER_value(cipherlist, i)) != NULL; i++) {
                if (SSL_CIPHER_get_bits(cipher, NULL) >= 128) {
                        sk_SSL_CIPHER_push(cipherlist_new, cipher);
@@ -635,21 +635,21 @@ void SSLi_init(void)
                        offset += sprintf(cipherstring + offset, "%s:", SSL_CIPHER_get_name(cipher));
                }
        }
-       
+
        if (cipherlist_new)
                sk_SSL_CIPHER_free(cipherlist_new);
-       
+
        if (strlen(cipherstring) == 0)
                Log_fatal("No suitable ciphers found!");
-       
+
        if (SSL_CTX_set_cipher_list(context, cipherstring) == 0)
                Log_fatal("Failed to set cipher list!");
 
        free(cipherstring);
-       
+
        SSL_CTX_set_verify(context, SSL_VERIFY_PEER|SSL_VERIFY_CLIENT_ONCE,
-                          verify_callback);            
-       
+                          verify_callback);
+
        SSL_free(ssl);
        Log_info("OpenSSL library initialized");
 
@@ -682,7 +682,7 @@ int SSLi_nonblockaccept(SSL_handle_t *ssl, bool_t *SSLready)
 SSL_handle_t *SSLi_newconnection(int *fd, bool_t *SSLready)
 {
        SSL *ssl;
-       
+
        *SSLready = false;
        ssl = SSL_new(context);
        SSL_set_fd(ssl, *fd);
@@ -699,12 +699,12 @@ bool_t SSLi_getSHA1Hash(SSL_handle_t *ssl, uint8_t *hash)
        X509 *x509;
        uint8_t *buf, *p;
        int len;
-       
+
        x509 = SSL_get_peer_certificate(ssl);
        if (!x509) {
                return false;
-       }       
-       
+       }
+
        len = i2d_X509(x509, NULL);
        buf = malloc(len);
        if (buf == NULL) {
@@ -712,13 +712,13 @@ bool_t SSLi_getSHA1Hash(SSL_handle_t *ssl, uint8_t *hash)
        }
 
        p = buf;
-       i2d_X509(x509, &p);     
-       
+       i2d_X509(x509, &p);
+
        SHA1(buf, len, hash);
        free(buf);
        return true;
 }
+
 void SSLi_closeconnection(SSL_handle_t *ssl)
 {
        SSL_free(ssl);
@@ -760,14 +760,14 @@ static int verify_callback(int preverify_ok, X509_STORE_CTX *ctx)
        X509   *err_cert;
        int     err, depth;
        SSL    *ssl;
-    
+
     err_cert = X509_STORE_CTX_get_current_cert(ctx);
     err = X509_STORE_CTX_get_error(ctx);
     depth = X509_STORE_CTX_get_error_depth(ctx);
-    
+
     ssl = X509_STORE_CTX_get_ex_data(ctx, SSL_get_ex_data_X509_STORE_CTX_idx());
     X509_NAME_oneline(X509_get_subject_name(err_cert), buf, 256);
-        
+
     if (depth > 5) {
         preverify_ok = 0;
         err = X509_V_ERR_CERT_CHAIN_TOO_LONG;
@@ -787,5 +787,5 @@ static int verify_callback(int preverify_ok, X509_STORE_CTX *ctx)
     }
     return 1;
 }
+
 #endif
index e69e68cd90eec1fa07f2306fb55d915db9cf6cde..e2ed569c8f2db196c6d129404503a93355848e7d 100644 (file)
@@ -38,7 +38,7 @@ void Voicetarget_add_session(client_t *client, int targetId, int sessionId)
 {
        struct dlist *itr;
        voicetarget_t *vt;
-       
+
        list_iterate(itr, &client->voicetargets) {
                if (targetId == list_get_entry(itr, voicetarget_t, node)->id) {
                        int i;
@@ -59,7 +59,7 @@ void Voicetarget_add_channel(client_t *client, int targetId, int channelId,
 {
        struct dlist *itr;
        voicetarget_t *vt;
-       
+
        list_iterate(itr, &client->voicetargets) {
                if (targetId == list_get_entry(itr, voicetarget_t, node)->id) {
                        int i;
@@ -74,14 +74,14 @@ void Voicetarget_add_channel(client_t *client, int targetId, int channelId,
                                }
                        }
                }
-       }       
+       }
 }
 
 void Voicetarget_add_id(client_t *client, int targetId)
 {
        voicetarget_t *newtarget;
        int i;
-       
+
        Voicetarget_del_id(client, targetId);
        newtarget = malloc(sizeof(voicetarget_t));
        if (!newtarget)