mirror of
https://github.com/shadowsocks/shadowsocks-libev.git
synced 2026-10-28 19:53:46 +00:00
enable building shared library for #128
This commit is contained in:
+3
-3
@@ -1,3 +1,5 @@
|
||||
VERSION_INFO = 1:0:0
|
||||
|
||||
AM_CFLAGS = -g -O2 -Wall -Werror -Wno-deprecated-declarations -fno-strict-aliasing -std=gnu99 -D_GNU_SOURCE
|
||||
AM_CFLAGS += -I$(top_srcdir)/libev
|
||||
AM_CFLAGS += -I$(top_srcdir)/libasyncns
|
||||
@@ -66,11 +68,9 @@ 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_LDFLAGS = -version-info $(VERSION_INFO)
|
||||
libshadowsocks_la_LIBADD = $(ss_local_LDADD)
|
||||
include_HEADERS = shadowsocks.h
|
||||
endif
|
||||
|
||||
|
||||
+412
-331
File diff suppressed because it is too large
Load Diff
+1
-28
@@ -1166,35 +1166,8 @@ int main (int argc, char **argv)
|
||||
}
|
||||
#else
|
||||
|
||||
int start_ss_service(profile_t profile, int background)
|
||||
int start_ss_local_server(profile_t profile)
|
||||
{
|
||||
|
||||
#ifndef __MINGW32__
|
||||
if (background) {
|
||||
/* Our process ID and Session ID */
|
||||
pid_t pid;
|
||||
|
||||
/* Fork off the parent process */
|
||||
pid = fork();
|
||||
if (pid < 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* If we got a good PID, then
|
||||
we can exit the parent process. */
|
||||
if (pid > 0)
|
||||
{
|
||||
return pid;
|
||||
}
|
||||
|
||||
/* Close out the standard file descriptors */
|
||||
close(STDIN_FILENO);
|
||||
close(STDOUT_FILENO);
|
||||
close(STDERR_FILENO);
|
||||
}
|
||||
#endif
|
||||
|
||||
srand(time(NULL));
|
||||
|
||||
char *remote_host = profile.remote_host;
|
||||
|
||||
+7
-8
@@ -59,18 +59,17 @@ const profile_t EXAMPLE_PROFILE = {
|
||||
*/
|
||||
|
||||
/*
|
||||
* Create and start a shadowsocks service.
|
||||
* Create and start a shadowsocks local server.
|
||||
*
|
||||
* If background is set to true, the service will run in a child process and
|
||||
* return the pid if success. Otherwise, calling this function will block the
|
||||
* current thread forever.
|
||||
* Calling this function will block the current thread forever if the server
|
||||
* starts successfully.
|
||||
*
|
||||
* On Win32, background mode is invalid. This function will always block the
|
||||
* caller and never return.
|
||||
* Make sure start the server in a seperate process to avoid any potential
|
||||
* memory and socket leak.
|
||||
*
|
||||
* If failed, -1 is returned.
|
||||
* If failed, -1 is returned. Errors will output to the log file.
|
||||
*/
|
||||
int start_ss_service(profile_t profile, int background);
|
||||
int start_ss_local_server(profile_t profile);
|
||||
|
||||
// To stop the service on posix system, just kill the daemon process
|
||||
// kill(pid, SIGKILL);
|
||||
|
||||
@@ -44,6 +44,10 @@
|
||||
|
||||
#define INT_DIGITS 19 /* enough for 64 bit integer */
|
||||
|
||||
#ifdef LIB_ONLY
|
||||
FILE* logfile;
|
||||
#endif
|
||||
|
||||
#ifdef HAS_SYSLOG
|
||||
int use_syslog = 0;
|
||||
#endif
|
||||
|
||||
+2
-2
@@ -44,12 +44,12 @@
|
||||
|
||||
#ifdef LIB_ONLY
|
||||
|
||||
extern FILE* logfile;
|
||||
|
||||
#define TIME_FORMAT "%Y-%m-%d %H:%M:%S"
|
||||
|
||||
#define USE_SYSLOG(ident)
|
||||
|
||||
FILE *logfile;
|
||||
|
||||
#define USE_LOGFILE(ident) do {\
|
||||
if (ident != NULL) logfile = fopen(ident, "w+");}\
|
||||
while(0)
|
||||
|
||||
Reference in New Issue
Block a user