Skip to content

Commit

Permalink
link libuv
Browse files Browse the repository at this point in the history
  • Loading branch information
spacemeowx2 committed Sep 8, 2018
1 parent 565cb73 commit e447eec
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 7 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ set(SOURCE_FILES
)

add_executable (lan-play ${SOURCE_FILES})
target_link_libraries(lan-play lwip_lib ${PCAP_LIBRARY})
target_link_libraries(lan-play lwip_lib libuv.a ${PCAP_LIBRARY})
include_directories(lan-play ${PCAP_INCLUDE_DIR})
if (WIN32)
add_dependencies(lan-play winpcap)
target_link_libraries(lan-play ws2_32.lib iphlpapi.lib libwinpthread.a)
target_link_libraries(lan-play ws2_32.lib iphlpapi.lib libwinpthread.a psapi userenv.lib)
else()
target_link_libraries(lan-play pthread)
endif()
6 changes: 3 additions & 3 deletions docker/Dockerfile.linux
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM buildpack-deps:jessie
FROM buildpack-deps:bionic

RUN sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list && sed -i 's/security.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
RUN sed -i 's/archive.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list && sed -i 's/security.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list

RUN apt update
RUN apt install -y cmake make
RUN apt install -y libpcap0.8-dev
RUN apt install -y libpcap0.8-dev libuv1-dev
4 changes: 2 additions & 2 deletions docker/Dockerfile.win
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM buildpack-deps:jessie
FROM buildpack-deps:bionic

RUN sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list && sed -i 's/security.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
RUN sed -i 's/archive.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list && sed -i 's/security.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list

RUN apt update
RUN apt install -y cmake make
Expand Down
13 changes: 13 additions & 0 deletions src/proxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,17 @@ err_t listener_accept_func (void *arg, struct tcp_pcb *newpcb, err_t err)
return ERR_OK;
}

void *proxy_event_thread(void *data)
{
struct proxy *proxy = (struct proxy *)data;

uv_run(&proxy->loop, UV_RUN_DEFAULT);
uv_loop_close(&proxy->loop);
LLOG(LLOG_DEBUG, "uv_loop_close");

return NULL;
}

int proxy_init(struct proxy *proxy, send_packet_func_t send_packet, void *userdata)
{
struct netif *the_netif = &proxy->netif;
Expand Down Expand Up @@ -164,6 +175,8 @@ int proxy_init(struct proxy *proxy, send_packet_func_t send_packet, void *userda

LLOG(LLOG_DEBUG, "proxy init netif_list %p", netif_list);

uv_loop_init(&proxy->loop);

return 0;
fail:
exit(1);
Expand Down
2 changes: 2 additions & 0 deletions src/proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
#define _PROXY_H_

#include <lwip/netif.h>
#include <uv.h>

#define PROXY_BUFFER_SIZE 2000

typedef int (*send_packet_func_t)(void *userdata, const void *data, uint16_t len);
struct proxy {
struct netif netif;
uv_loop_t loop;
};
struct something {
int (*init)();
Expand Down

0 comments on commit e447eec

Please sign in to comment.