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 @@ ...@@ -2,10 +2,7 @@
#include "android.h" #include "android.h"
#include <openssl/md5.h> #include <openssl/md5.h>
#include <endian.h>
typedef unsigned char uint8_t;
typedef unsigned int uint32_t;
typedef unsigned long long uint64_t;
static int random_compare(const void *_x, const void *_y) { static int random_compare(const void *_x, const void *_y) {
uint32_t i = _i; uint32_t i = _i;
...@@ -150,9 +147,8 @@ int recv_decrypt(int sock, char *buf, int len, int flags) { ...@@ -150,9 +147,8 @@ int recv_decrypt(int sock, char *buf, int len, int flags) {
void get_table(const char* key) { void get_table(const char* key) {
uint8_t *table = encrypt_table; uint8_t *table = encrypt_table;
uint8_t *tmp_hash; uint8_t *tmp_hash = MD5((const uint8_t*)key, strlen(key), NULL);
tmp_hash = MD5((const uint8_t*)key, strlen(key), NULL); _a = htole64(*(uint64_t *)tmp_hash);
_a = *(uint64_t *)tmp_hash;
uint32_t i; uint32_t i;
for(i = 0; i < 256; ++i) { for(i = 0; i < 256; ++i) {
......
...@@ -508,7 +508,8 @@ static void accept_cb (EV_P_ ev_io *w, int revents) ...@@ -508,7 +508,8 @@ static void accept_cb (EV_P_ ev_io *w, int revents)
if (sockfd < 0) { if (sockfd < 0) {
perror("socket"); perror("socket");
close(sockfd); close(sockfd);
free_server(server); close_and_free_server(EV_A_ server);
freeaddrinfo(res);
continue; continue;
} }
setnonblocking(sockfd); setnonblocking(sockfd);
...@@ -630,7 +631,11 @@ int main (int argc, char **argv) ...@@ -630,7 +631,11 @@ int main (int argc, char **argv)
setnonblocking(listenfd); setnonblocking(listenfd);
struct listen_ctx listen_ctx; struct listen_ctx listen_ctx;
listen_ctx.fd = listenfd; 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_init (&listen_ctx.io, accept_cb, listenfd, EV_READ);
ev_io_start (loop, &listen_ctx.io); ev_io_start (loop, &listen_ctx.io);
ev_run (loop, 0); 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