refine
This commit is contained in:
Binary file not shown.
@@ -11,7 +11,7 @@ static int random_compare(const void *_x, const void *_y) {
|
||||
return (a % (x + i) - a % (y + i));
|
||||
}
|
||||
|
||||
static void md5(const unsigned char *text, unsigned char *digest) {
|
||||
static void md5(const uint8_t *text, uint8_t *digest) {
|
||||
md5_state_t state;
|
||||
md5_init(&state);
|
||||
md5_append(&state, text, strlen((char*)text));
|
||||
@@ -119,7 +119,7 @@ static void merge_sort(uint8_t array[], int length) {
|
||||
|
||||
void encrypt(char *buf, int len, struct rc4_state *ctx) {
|
||||
if (ctx != NULL) {
|
||||
rc4_crypt(ctx, (unsigned char*) buf, (unsigned char*) buf, len);
|
||||
rc4_crypt(ctx, (uint8_t*) buf, (uint8_t*) buf, len);
|
||||
} else {
|
||||
char *end = buf + len;
|
||||
while (buf < end) {
|
||||
@@ -131,7 +131,7 @@ void encrypt(char *buf, int len, struct rc4_state *ctx) {
|
||||
|
||||
void decrypt(char *buf, int len, struct rc4_state *ctx) {
|
||||
if (ctx != NULL) {
|
||||
rc4_crypt(ctx, (unsigned char*) buf, (unsigned char*) buf, len);
|
||||
rc4_crypt(ctx, (uint8_t*) buf, (uint8_t*) buf, len);
|
||||
} else {
|
||||
char *end = buf + len;
|
||||
while (buf < end) {
|
||||
@@ -150,7 +150,7 @@ void enc_ctx_init(struct rc4_state *ctx, int enc) {
|
||||
void enc_key_init(const char *pass) {
|
||||
enc_ctx.rc4.key_len = 16;
|
||||
enc_ctx.rc4.key = malloc(16);
|
||||
md5((const unsigned char*)pass, enc_ctx.rc4.key);
|
||||
md5((const uint8_t*)pass, enc_ctx.rc4.key);
|
||||
}
|
||||
|
||||
void get_table(const char *pass) {
|
||||
@@ -159,7 +159,7 @@ void get_table(const char *pass) {
|
||||
uint8_t digest[16];
|
||||
uint32_t i;
|
||||
|
||||
md5((const unsigned char*)pass, digest);
|
||||
md5((const uint8_t*)pass, digest);
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
_a += OFFSET_ROL(digest, i);
|
||||
|
||||
@@ -21,7 +21,7 @@ union {
|
||||
} table;
|
||||
|
||||
struct {
|
||||
unsigned char *key;
|
||||
uint8_t *key;
|
||||
int key_len;
|
||||
} rc4;
|
||||
} enc_ctx;
|
||||
|
||||
@@ -30,14 +30,14 @@ static char *_remote_port;
|
||||
static int _timeout;
|
||||
static char *_key;
|
||||
|
||||
int setnonblocking(int fd) {
|
||||
static int setnonblocking(int fd) {
|
||||
int flags;
|
||||
if (-1 ==(flags = fcntl(fd, F_GETFL, 0)))
|
||||
flags = 0;
|
||||
return fcntl(fd, F_SETFL, flags | O_NONBLOCK);
|
||||
}
|
||||
|
||||
int create_and_bind(const char *port) {
|
||||
static int create_and_bind(const char *port) {
|
||||
struct addrinfo hints;
|
||||
struct addrinfo *result, *rp;
|
||||
int s, listen_sock;
|
||||
@@ -178,7 +178,7 @@ static void server_recv_cb (EV_P_ ev_io *w, int revents) {
|
||||
}
|
||||
|
||||
char addr_to_send[256];
|
||||
unsigned char addr_len = 0;
|
||||
uint8_t addr_len = 0;
|
||||
addr_to_send[addr_len++] = request->atyp;
|
||||
|
||||
// get remote addr and port
|
||||
@@ -191,14 +191,14 @@ static void server_recv_cb (EV_P_ ev_io *w, int revents) {
|
||||
|
||||
} else if (request->atyp == 3) {
|
||||
// Domain name
|
||||
unsigned char name_len = *(unsigned char *)(server->buf + 4);
|
||||
uint8_t name_len = *(uint8_t *)(server->buf + 4);
|
||||
addr_to_send[addr_len++] = name_len;
|
||||
memcpy(addr_to_send + addr_len, server->buf + 4 + 1, name_len);
|
||||
addr_len += name_len;
|
||||
|
||||
// get port
|
||||
addr_to_send[addr_len++] = *(unsigned char *)(server->buf + 4 + 1 + name_len);
|
||||
addr_to_send[addr_len++] = *(unsigned char *)(server->buf + 4 + 1 + name_len + 1);
|
||||
addr_to_send[addr_len++] = *(uint8_t *)(server->buf + 4 + 1 + name_len);
|
||||
addr_to_send[addr_len++] = *(uint8_t *)(server->buf + 4 + 1 + name_len + 1);
|
||||
} else {
|
||||
LOGE("unsupported addrtype: %d\n", request->atyp);
|
||||
close_and_free_remote(EV_A_ remote);
|
||||
|
||||
Reference in New Issue
Block a user