From 3ec1df3cb1680504b73fa5bb67f862b7ce0c69a0 Mon Sep 17 00:00:00 2001 From: clowwindy Date: Thu, 6 Jun 2013 02:21:49 +0800 Subject: [PATCH] works --- ShadowWeb/encrypt.c | 2 +- ShadowWeb/local.m | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ShadowWeb/encrypt.c b/ShadowWeb/encrypt.c index 150fb3f..7f6bf9c 100755 --- a/ShadowWeb/encrypt.c +++ b/ShadowWeb/encrypt.c @@ -74,7 +74,7 @@ void decrypt_buf(struct encryption_ctx *ctx, char *buf, int *len) { unsigned char *cipher_text = malloc(out_len); EVP_CipherUpdate(ctx->ctx, cipher_text, &out_len, buf + iv_len, *len - iv_len); memcpy(buf, cipher_text, out_len); - *len = out_len - iv_len; + *len = out_len; free(cipher_text); } else { int out_len = *len + EVP_CIPHER_CTX_block_size(ctx->ctx); diff --git a/ShadowWeb/local.m b/ShadowWeb/local.m index 4d29ce9..8552228 100644 --- a/ShadowWeb/local.m +++ b/ShadowWeb/local.m @@ -6,7 +6,6 @@ #include "local.h" #include "socks5.h" #include "table.h" -#include "encrypt.h" #define ADDR_STR_LEN 512 @@ -304,7 +303,7 @@ static void remote_recv_cb (EV_P_ ev_io *w, int revents) { return; } while (1) { - ssize_t r = recv(remote->fd, server->buf, BUF_SIZE, 0); + int r = recv(remote->fd, server->buf, BUF_SIZE, 0); if (r == 0) { // connection closed @@ -327,6 +326,7 @@ static void remote_recv_cb (EV_P_ ev_io *w, int revents) { } } decrypt_buf(&(remote->recv_encryption_ctx), server->buf, &r); + NSLog(@"%@", [NSString stringWithCString:server->buf length:r]); int w = send(server->fd, server->buf, r, 0); if(w == -1) { if (errno == EAGAIN) {