Skip to content
This repository has been archived by the owner on Oct 31, 2022. It is now read-only.

Commit

Permalink
Merge pull request #8 from shadowsocks/master
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
imgk committed Nov 17, 2017
2 parents 5115e8d + e2f9a4d commit 24eb521
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 16 deletions.
6 changes: 6 additions & 0 deletions Changes
@@ -1,3 +1,9 @@
simple-obfs (0.0.5-1) unstable; urgency=medium

* Fix the building issue on Windows.

-- Max Lv <max.c.lv@gmail.com> Thu, 16 Nov 2017 18:04:07 +0800

simple-obfs (0.0.4-1) unstable; urgency=medium

* Minor bug fixes.
Expand Down
8 changes: 4 additions & 4 deletions README.md
Expand Up @@ -4,21 +4,21 @@

Simple-obfs is a simple obfusacting tool, designed as plugin server of shadowsocks.

Current version: 0.0.4 | [Changelog](Changes)
Current version: 0.0.5 | [Changelog](Changes)

## Build
For Unix-like systems, especially Debian-based systems,
e.g. Ubuntu, Debian or Linux Mint, you can build the binary like this:

```bash
# Debian / Ubuntu
sudo apt-get install --no-install-recommends build-essential autoconf libtool libssl-dev libpcre3-dev libc-ares-dev libev-dev asciidoc xmlto automake
sudo apt-get install --no-install-recommends build-essential autoconf libtool libssl-dev libpcre3-dev libev-dev asciidoc xmlto automake
# CentOS / Fedora / RHEL
sudo yum install gcc autoconf libtool automake make zlib-devel openssl-devel asciidoc xmlto c-ares-devel
sudo yum install gcc autoconf libtool automake make zlib-devel openssl-devel asciidoc xmlto
# Arch
sudo pacman -Syu gcc autoconf libtool automake make zlib openssl asciidoc xmlto
# Alpine
apk add gcc autoconf make libtool automake zlib-devel openssl asciidoc xmlto libpcre32 libev-dev c-ares-dev g++ linux-headers
apk add gcc autoconf make libtool automake zlib-devel openssl asciidoc xmlto libpcre32 libev-dev g++ linux-headers

git clone https://github.com/shadowsocks/simple-obfs.git
cd simple-obfs
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Expand Up @@ -2,7 +2,7 @@ dnl -*- Autoconf -*-
dnl Process this file with autoconf to produce a configure script.

AC_PREREQ([2.67])
AC_INIT([simple-obfs], [0.0.4], [max.c.lv@gmail.com])
AC_INIT([simple-obfs], [0.0.5], [max.c.lv@gmail.com])
AC_CONFIG_SRCDIR([src/encrypt.c])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_AUX_DIR(auto)
Expand Down
6 changes: 6 additions & 0 deletions debian/changelog
@@ -1,3 +1,9 @@
simple-obfs (0.0.5-1) unstable; urgency=medium

* Fix the building issue on Windows.

-- Max Lv <max.c.lv@gmail.com> Thu, 16 Nov 2017 18:04:07 +0800

simple-obfs (0.0.4-1) unstable; urgency=medium

* Minor bug fixes.
Expand Down
29 changes: 18 additions & 11 deletions src/local.c
Expand Up @@ -51,6 +51,9 @@

#ifdef __MINGW32__
#include "win32.h"
#define __ev_io_init(a, b, c, d) ev_io_init(a, b, _open_osfhandle(c, 0), d)
#else
#define __ev_io_init(a, b, c, d) ev_io_init(a, b, c, d)
#endif

#include "netutils.h"
Expand Down Expand Up @@ -104,7 +107,9 @@ static void server_send_cb(EV_P_ ev_io *w, int revents);
static void remote_recv_cb(EV_P_ ev_io *w, int revents);
static void remote_send_cb(EV_P_ ev_io *w, int revents);
static void accept_cb(EV_P_ ev_io *w, int revents);
#ifndef __MINGW32__
static void signal_cb(EV_P_ ev_signal *w, int revents);
#endif

static int create_and_bind(const char *addr, const char *port);
#ifdef HAVE_LAUNCHD
Expand Down Expand Up @@ -667,8 +672,8 @@ new_remote(int fd, int timeout)
remote->recv_ctx->remote = remote;
remote->send_ctx->remote = remote;

ev_io_init(&remote->recv_ctx->io, remote_recv_cb, fd, EV_READ);
ev_io_init(&remote->send_ctx->io, remote_send_cb, fd, EV_WRITE);
__ev_io_init(&remote->recv_ctx->io, remote_recv_cb, fd, EV_READ);
__ev_io_init(&remote->send_ctx->io, remote_send_cb, fd, EV_WRITE);
ev_timer_init(&remote->send_ctx->watcher, remote_timeout_cb,
min(MAX_CONNECT_TIMEOUT, timeout), 0);
ev_timer_init(&remote->recv_ctx->watcher, remote_timeout_cb,
Expand Down Expand Up @@ -731,8 +736,8 @@ new_server(int fd)
memset(server->obfs, 0, sizeof(obfs_t));
}

ev_io_init(&server->recv_ctx->io, server_recv_cb, fd, EV_READ);
ev_io_init(&server->send_ctx->io, server_send_cb, fd, EV_WRITE);
__ev_io_init(&server->recv_ctx->io, server_recv_cb, fd, EV_READ);
__ev_io_init(&server->send_ctx->io, server_send_cb, fd, EV_WRITE);

cork_dllist_add(&connections, &server->entries);

Expand Down Expand Up @@ -822,21 +827,21 @@ create_remote(listen_ctx_t *listener,
return remote;
}

#ifndef __MINGW32__
static void
signal_cb(EV_P_ ev_signal *w, int revents)
{
if (revents & EV_SIGNAL) {
switch (w->signum) {
case SIGINT:
case SIGTERM:
#ifndef __MINGW32__
case SIGUSR1:
#endif
keep_resolving = 0;
ev_unloop(EV_A_ EVUNLOOP_ALL);
}
}
}
#endif

void
accept_cb(EV_P_ ev_io *w, int revents)
Expand Down Expand Up @@ -1202,19 +1207,21 @@ main(int argc, char **argv)
listen_ctx.iface = iface;
listen_ctx.mptcp = mptcp;

#ifndef __MINGW32__
// Setup signal handler
struct ev_signal sigint_watcher;
struct ev_signal sigterm_watcher;
ev_signal_init(&sigint_watcher, signal_cb, SIGINT);
ev_signal_init(&sigterm_watcher, signal_cb, SIGTERM);
ev_signal_start(EV_DEFAULT, &sigint_watcher);
ev_signal_start(EV_DEFAULT, &sigterm_watcher);
#endif

ev_timer parent_watcher;
#ifndef __MINGW32__
ev_timer parent_watcher;
ev_timer_init(&parent_watcher, parent_watcher_cb, 0, UPDATE_INTERVAL);
#endif
ev_timer_start(EV_DEFAULT, &parent_watcher);
#endif

struct ev_loop *loop = EV_DEFAULT;

Expand All @@ -1235,7 +1242,7 @@ main(int argc, char **argv)

listen_ctx.fd = listenfd;

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);

#ifdef HAVE_LAUNCHD
Expand Down Expand Up @@ -1279,10 +1286,10 @@ main(int argc, char **argv)

#ifdef __MINGW32__
winsock_cleanup();
#endif

#else
ev_signal_stop(EV_DEFAULT, &sigint_watcher);
ev_signal_stop(EV_DEFAULT, &sigterm_watcher);
#endif

return 0;
}

0 comments on commit 24eb521

Please sign in to comment.