jedisct1 / dsvpn

A Dead Simple VPN.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unused code?

MeteorsLiu opened this issue · comments

Hello,

recently, I am reading the dsvpn code to study network-related knowledge.

And i found that a part of code isn't used.

           if (2 + TAG_LEN + MAX_PACKET_LEN != len_with_header) {
                unsigned char *rbuf      = client_buf->len;
                size_t         remaining = client_buf->pos - len_with_header, i;
                for (i = 0; i < remaining; i++) {
                    rbuf[i] = rbuf[len_with_header + i];
                }
            }

I am confused.
What does the code use for?

It's not unused. It handles the case where the input buffer is not completely full, shifting the bytes to the beginning of the buffer for the next read.