Make crypo a per fd feature
[paraslash.git] / client.c
index b77a2f6..0380d56 100644 (file)
--- a/client.c
+++ b/client.c
@@ -131,10 +131,6 @@ static void rc4_recv(unsigned long len, const unsigned char *indata,
        RC4(&pcd->rc4_recv_key, len, indata, outdata);
 }
 
-void (*crypt_function_recv)(unsigned long len, const unsigned char *indata, unsigned char *outdata);
-void (*crypt_function_send)(unsigned long len, const unsigned char *indata, unsigned char *outdata);
-
-
 static void append_str(char **data, const char* append)
 {
        if (*data) {
@@ -197,8 +193,6 @@ int main(int argc, char *argv[])
        /* concat args */
        for (i = 0; i < pcd->conf.inputs_num; i++)
                append_str(&command, pcd->conf.inputs[i]);
-       crypt_function_recv = NULL;
-       crypt_function_send = NULL;
        /* get the host info */
        PARA_NOTICE_LOG("getting host info of %s\n",
                pcd->conf.hostname_arg);
@@ -269,10 +263,9 @@ int main(int argc, char *argv[])
                        goto out;
                RC4_set_key(&pcd->rc4_send_key, RC4_KEY_LEN, rc4_buf);
                RC4_set_key(&pcd->rc4_recv_key, RC4_KEY_LEN, rc4_buf + RC4_KEY_LEN);
-               PARA_INFO_LOG("rc4 encrytion activated: %x:%x:%x:%x\n",
+               PARA_INFO_LOG("rc4 encryption activated: %x:%x:%x:%x\n",
                        rc4_buf[0], rc4_buf[1], rc4_buf[2], rc4_buf[3]);
-               crypt_function_recv = rc4_recv;
-               crypt_function_send = rc4_send;
+               enable_crypt(pcd->fd, rc4_recv, rc4_send);
        }
        /* send command */
        PARA_INFO_LOG("--> %s\n", command);