Commit b47776fc authored by Max Lv's avatar Max Lv

fix endian bugs on mips

parent 036a34d7
No preview for this file type
......@@ -2,10 +2,7 @@
#include "android.h"
#include <openssl/md5.h>
typedef unsigned char uint8_t;
typedef unsigned int uint32_t;
typedef unsigned long long uint64_t;
#include <endian.h>
static int random_compare(const void *_x, const void *_y) {
uint32_t i = _i;
......@@ -150,9 +147,8 @@ int recv_decrypt(int sock, char *buf, int len, int flags) {
void get_table(const char* key) {
uint8_t *table = encrypt_table;
uint8_t *tmp_hash;
tmp_hash = MD5((const uint8_t*)key, strlen(key), NULL);
_a = *(uint64_t *)tmp_hash;
uint8_t *tmp_hash = MD5((const uint8_t*)key, strlen(key), NULL);
_a = htole64(*(uint64_t *)tmp_hash);
uint32_t i;
for(i = 0; i < 256; ++i) {
......
......@@ -508,7 +508,8 @@ static void accept_cb (EV_P_ ev_io *w, int revents)
if (sockfd < 0) {
perror("socket");
close(sockfd);
free_server(server);
close_and_free_server(EV_A_ server);
freeaddrinfo(res);
continue;
}
setnonblocking(sockfd);
......@@ -630,7 +631,11 @@ int main (int argc, char **argv)
setnonblocking(listenfd);
struct listen_ctx listen_ctx;
listen_ctx.fd = listenfd;
struct ev_loop *loop = EV_DEFAULT;
struct ev_loop *loop = ev_default_loop(EVBACKEND_EPOLL | EVFLAG_NOENV);
if (!loop) {
LOGE("no epoll found here, maybe it hides under your chair");
return 1;
}
ev_io_init (&listen_ctx.io, accept_cb, listenfd, EV_READ);
ev_io_start (loop, &listen_ctx.io);
ev_run (loop, 0);
......
No preview for this file type
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment