support building as libshadowsocks

This commit is contained in:
clowwindy
2014-10-17 00:03:48 +08:00
parent 5d7dd372fc
commit 039e90df96
22 changed files with 3315 additions and 2300 deletions
+8 -1
View File
@@ -10,7 +10,7 @@ SS_COMMON_LIBS = $(top_builddir)/libev/libev.la \
$(top_builddir)/libipset/libipset.la \
$(top_builddir)/libcork/libcork.la \
$(INET_NTOP_LIB)
bin_PROGRAMS = ss-local ss-tunnel
if !BUILD_WINCOMPAT
@@ -66,3 +66,10 @@ ss_redir_SOURCES = utils.c \
ss_redir_LDADD = $(SS_COMMON_LIBS)
endif
if BUILD_LIB
lib_LTLIBRARIES = libshadowsocks.la
libshadowsocks_la_SOURCES = $(ss_local_SOURCES)
libshadowsocks_la_CFLAGS = $(ss_local_CFLAGS) -DLIB_ONLY
libshadowsocks_la_LIBADD = $(ss_local_LDADD)
endif
+559 -290
View File
File diff suppressed because it is too large Load Diff
+6 -2
View File
@@ -75,11 +75,13 @@ int verbose = 0;
int udprelay = 0;
static int fast_open = 0;
#ifdef HAVE_SETRLIMIT
#ifndef LIB_ONLY
static int nofile = 0;
#endif
#endif
#ifndef __MINGW32__
static int setnonblocking(int fd)
int setnonblocking(int fd)
{
int flags;
if (-1 ==(flags = fcntl(fd, F_GETFL, 0)))
@@ -909,7 +911,7 @@ static struct remote* connect_to_remote(struct listen_ctx *listener,
}
static void accept_cb (EV_P_ ev_io *w, int revents)
void accept_cb (EV_P_ ev_io *w, int revents)
{
struct listen_ctx *listener = (struct listen_ctx *)w;
int serverfd = accept(listener->fd, NULL, NULL);
@@ -931,6 +933,7 @@ static void accept_cb (EV_P_ ev_io *w, int revents)
ev_io_start(EV_A_ &server->recv_ctx->io);
}
#ifndef LIB_ONLY
int main (int argc, char **argv)
{
@@ -1154,4 +1157,5 @@ int main (int argc, char **argv)
return 0;
}
#endif
+3 -1
View File
@@ -86,9 +86,11 @@ struct remote
struct addrinfo *addr_info;
};
// exported for library use
int create_and_bind(const char *addr, const char *port);
void accept_cb (EV_P_ ev_io *w, int revents);
static struct remote* connect_to_remote(struct listen_ctx *listener, const char *host, const char *port);
static void accept_cb (EV_P_ ev_io *w, int revents);
static void server_recv_cb (EV_P_ ev_io *w, int revents);
static void server_send_cb (EV_P_ ev_io *w, int revents);
static void remote_recv_cb (EV_P_ ev_io *w, int revents);