Skip to content

Commit

Permalink
Merge pull request #210 from shadowsocks/v2.0.2-int
Browse files Browse the repository at this point in the history
Fix issues with MinGW
  • Loading branch information
madeye committed Jan 10, 2015
2 parents 18fc175 + c2d1911 commit 860bbdc
Show file tree
Hide file tree
Showing 23 changed files with 158 additions and 97 deletions.
4 changes: 0 additions & 4 deletions Makefile.am
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
if BUILD_WINCOMPAT
SUBDIRS = libsodium libcork libipset libev src
else
SUBDIRS = libsodium libcork libipset libudns libev src
endif

ACLOCAL_AMFLAGS = -I m4
man_MANS = shadowsocks-libev.8
Expand Down
5 changes: 2 additions & 3 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
distdir dist dist-all distcheck
ETAGS = etags
CTAGS = ctags
DIST_SUBDIRS = libsodium libcork libipset libudns libev src
DIST_SUBDIRS = $(SUBDIRS)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
distdir = $(PACKAGE)-$(VERSION)
top_distdir = $(distdir)
Expand Down Expand Up @@ -295,8 +295,7 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
@BUILD_WINCOMPAT_FALSE@SUBDIRS = libsodium libcork libipset libudns libev src
@BUILD_WINCOMPAT_TRUE@SUBDIRS = libsodium libcork libipset libev src
SUBDIRS = libsodium libcork libipset libudns libev src
ACLOCAL_AMFLAGS = -I m4
man_MANS = shadowsocks-libev.8
pkgconfiglibdir = $(libdir)/pkgconfig
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ It is a port of [shadowsocks](https://github.com/shadowsocks/shadowsocks)
created by [@clowwindy](https://github.com/clowwindy) maintained by
[@madeye](https://github.com/madeye) and [@linusyang](https://github.com/linusyang).

Current version: 2.0.1 | [![Build Status](https://travis-ci.org/shadowsocks/shadowsocks-libev.png?branch=master)](https://travis-ci.org/shadowsocks/shadowsocks-libev) | [Changelog](Changes)
Current version: 2.0.2 | [![Build Status](https://travis-ci.org/shadowsocks/shadowsocks-libev.png?branch=master)](https://travis-ci.org/shadowsocks/shadowsocks-libev) | [Changelog](Changes)

Features
--------
Expand Down
20 changes: 10 additions & 10 deletions configure
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for shadowsocks-libev 2.0.1.
# Generated by GNU Autoconf 2.69 for shadowsocks-libev 2.0.2.
#
# Report bugs to <[email protected]>.
#
Expand Down Expand Up @@ -590,8 +590,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='shadowsocks-libev'
PACKAGE_TARNAME='shadowsocks-libev'
PACKAGE_VERSION='2.0.1'
PACKAGE_STRING='shadowsocks-libev 2.0.1'
PACKAGE_VERSION='2.0.2'
PACKAGE_STRING='shadowsocks-libev 2.0.2'
PACKAGE_BUGREPORT='[email protected]'
PACKAGE_URL=''

Expand Down Expand Up @@ -1336,7 +1336,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures shadowsocks-libev 2.0.1 to adapt to many kinds of systems.
\`configure' configures shadowsocks-libev 2.0.2 to adapt to many kinds of systems.

Usage: $0 [OPTION]... [VAR=VALUE]...

Expand Down Expand Up @@ -1407,7 +1407,7 @@ fi

if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of shadowsocks-libev 2.0.1:";;
short | recursive ) echo "Configuration of shadowsocks-libev 2.0.2:";;
esac
cat <<\_ACEOF

Expand Down Expand Up @@ -1528,7 +1528,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
shadowsocks-libev configure 2.0.1
shadowsocks-libev configure 2.0.2
generated by GNU Autoconf 2.69

Copyright (C) 2012 Free Software Foundation, Inc.
Expand Down Expand Up @@ -2051,7 +2051,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.

It was created by shadowsocks-libev $as_me 2.0.1, which was
It was created by shadowsocks-libev $as_me 2.0.2, which was
generated by GNU Autoconf 2.69. Invocation command line was

$ $0 $@
Expand Down Expand Up @@ -2872,7 +2872,7 @@ fi

# Define the identity of the package.
PACKAGE='shadowsocks-libev'
VERSION='2.0.1'
VERSION='2.0.2'


cat >>confdefs.h <<_ACEOF
Expand Down Expand Up @@ -15636,7 +15636,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by shadowsocks-libev $as_me 2.0.1, which was
This file was extended by shadowsocks-libev $as_me 2.0.2, which was
generated by GNU Autoconf 2.69. Invocation command line was

CONFIG_FILES = $CONFIG_FILES
Expand Down Expand Up @@ -15702,7 +15702,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
shadowsocks-libev config.status 2.0.1
shadowsocks-libev config.status 2.0.2
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"

Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
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([shadowsocks-libev], [2.0.1], [[email protected]])
AC_INIT([shadowsocks-libev], [2.0.2], [[email protected]])
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
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
shadowsocks-libev (2.0.2-1) unstable; urgency=low

* Fix issues with MinGW.

-- Max Lv <[email protected]> Sat, 10 Jan 2015 15:17:10 +0800

shadowsocks-libev (2.0.1-1) unstable; urgency=low

* Implement a real asynchronous DNS resolver.
Expand Down
4 changes: 2 additions & 2 deletions libudns/dnsget.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef WINDOWS
#ifdef __MINGW32__
#include <windows.h>
#include <winsock2.h>
#else
Expand Down Expand Up @@ -301,7 +301,7 @@ printrr(const struct dns_parse *p, struct dns_rr *rr) {
if (verbose > 0) putchar('"');
c = printtxt(c);
if (verbose > 0) putchar('"');
}
}
printf(" %s.", dns_dntosp(dn));
break;

Expand Down
12 changes: 3 additions & 9 deletions libudns/inet_XtoX.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,6 @@ struct in_addr;
# undef inet_XtoX_no_ntop
# undef inet_XtoX_no_pton

#else /* !TEST */

struct in_addr { /* declare it here to avoid messing with headers */
unsigned char x[4];
};

#endif /* TEST */

#endif /* inet_XtoX_prototypes */
Expand All @@ -60,7 +54,7 @@ struct in_addr { /* declare it here to avoid messing with headers */
# define inet_XtoX_prefix inet_
#endif
#ifndef inet_XtoX_decl
# define inet_XtoX_decl /*empty*/
# define inet_XtoX_decl /* empty */
#endif

#define cc2_(x,y) cc2__(x,y)
Expand All @@ -70,7 +64,7 @@ struct in_addr { /* declare it here to avoid messing with headers */
#ifndef inet_XtoX_no_ntop

inet_XtoX_decl const char *
fn(ntop)(int af, const void *src, char *dst, unsigned size);
fn(ntop)(int af, const void *src, char *dst, int size);

#ifndef inet_XtoX_prototypes

Expand Down Expand Up @@ -147,7 +141,7 @@ static int mjt_ntop6(const void *_src, char *dst, int size) {
}

inet_XtoX_decl const char *
fn(ntop)(int af, const void *src, char *dst, unsigned size) {
fn(ntop)(int af, const void *src, char *dst, int size) {
switch(af) {
/* don't use AF_*: don't mess with headers */
case 2: /* AF_INET */ if (mjt_ntop4(src, dst, size)) return dst; break;
Expand Down
2 changes: 1 addition & 1 deletion libudns/rblcheck.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef WINDOWS
#ifdef __MINGW32__
# include <winsock2.h>
#else
# include <unistd.h>
Expand Down
2 changes: 1 addition & 1 deletion libudns/udns.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

#define UDNS_VERSION "0.4"

#ifdef WINDOWS
#ifdef __MINGW32__
# ifdef UDNS_DYNAMIC_LIBRARY
# ifdef DNS_LIBRARY_BUILD
# define UDNS_API __declspec(dllexport)
Expand Down
13 changes: 11 additions & 2 deletions libudns/udns_XtoX.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,30 @@
#endif
#include "udns.h"

#if HAVE_DECL_INET_NTOP == 1

#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>

#ifdef HAVE_DECL_INET_NTOP
const char *dns_ntop(int af, const void *src, char *dst, int size) {
return inet_ntop(af, src, dst, size);
}

int dns_pton(int af, const char *src, void *dst) {
return inet_pton(af, src, dst);
}

#else

#define inet_XtoX_prefix udns_
#include <winsock2.h> /* includes <windows.h> */
#include <ws2tcpip.h> /* needed for struct in6_addr */

#ifndef EAFNOSUPPORT
#define EAFNOSUPPORT WSAEAFNOSUPPORT
#endif

#define inet_XtoX_prefix dns_
#include "inet_XtoX.c"

#endif
16 changes: 8 additions & 8 deletions libudns/udns_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef WINDOWS
#ifdef __MINGW32__
# include <winsock2.h> /* includes <windows.h> */
# include <iphlpapi.h> /* for dns server addresses etc */
#else
# include <sys/types.h>
# include <unistd.h>
# include <fcntl.h>
#endif /* !WINDOWS */
#endif /* !__MINGW32__ */

#include <stdlib.h>
#include <string.h>
Expand All @@ -53,7 +53,7 @@ static void dns_set_srch_internal(struct dns_ctx *ctx, char *srch) {
dns_add_srch(ctx, srch);
}

#ifdef WINDOWS
#ifdef __MINGW32__

#ifndef NO_IPHLPAPI
/* Apparently, some systems does not have proper headers for IPHLPAIP to work.
Expand Down Expand Up @@ -139,7 +139,7 @@ static int dns_initns_registry(struct dns_ctx *ctx) {
return 0;
}

#else /* !WINDOWS */
#else /* !__MINGW32__ */

static int dns_init_resolvconf(struct dns_ctx *ctx) {
char *v;
Expand Down Expand Up @@ -210,19 +210,19 @@ static int dns_init_resolvconf(struct dns_ctx *ctx) {
return 0;
}

#endif /* !WINDOWS */
#endif /* !__MINGW32__ */

int dns_init(struct dns_ctx *ctx, int do_open) {
if (!ctx)
ctx = &dns_defctx;
dns_reset(ctx);

#ifdef WINDOWS
#ifdef __MINGW32__
if (dns_initns_iphlpapi(ctx) != 0)
dns_initns_registry(ctx);
/*XXX WINDOWS: probably good to get default domain and search list too...
/*XXX __MINGW32__: probably good to get default domain and search list too...
* And options. Something is in registry. */
/*XXX WINDOWS: maybe environment variables are also useful? */
/*XXX __MINGW32__: maybe environment variables are also useful? */
#else
dns_init_resolvconf(ctx);
#endif
Expand Down
14 changes: 7 additions & 7 deletions libudns/udns_resolver.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef WINDOWS
#ifdef __MINGW32__
# include <winsock2.h> /* includes <windows.h> */
# include <ws2tcpip.h> /* needed for struct in6_addr */
#else
Expand All @@ -45,7 +45,7 @@
# include <sys/times.h>
# endif
# define closesocket(sock) close(sock)
#endif /* !WINDOWS */
#endif /* !__MINGW32__ */

#include <stdlib.h>
#include <string.h>
Expand Down Expand Up @@ -392,7 +392,7 @@ dns_set_tmcbck(struct dns_ctx *ctx, dns_utm_fn *fn, void *data) {
}

static unsigned dns_nonrandom_32(void) {
#ifdef WINDOWS
#ifdef __MINGW32__
FILETIME ft;
GetSystemTimeAsFileTime(&ft);
return ft.dwLowDateTime;
Expand Down Expand Up @@ -551,22 +551,22 @@ int dns_open(struct dns_ctx *ctx) {
ctx->dnsc_qstatus = DNS_E_TEMPFAIL;
return -1;
}
#ifdef WINDOWS
#ifdef __MINGW32__
{ unsigned long on = 1;
if (ioctlsocket(sock, FIONBIO, &on) == SOCKET_ERROR) {
closesocket(sock);
ctx->dnsc_qstatus = DNS_E_TEMPFAIL;
return -1;
}
}
#else /* !WINDOWS */
#else /* !__MINGW32__ */
if (fcntl(sock, F_SETFL, fcntl(sock, F_GETFL) | O_NONBLOCK) < 0 ||
fcntl(sock, F_SETFD, FD_CLOEXEC) < 0) {
closesocket(sock);
ctx->dnsc_qstatus = DNS_E_TEMPFAIL;
return -1;
}
#endif /* WINDOWS */
#endif /* __MINGW32__ */
/* allocate the packet buffer */
if ((ctx->dnsc_pbuf = malloc(ctx->dnsc_udpbuf)) == NULL) {
closesocket(sock);
Expand Down Expand Up @@ -991,7 +991,7 @@ void dns_ioevent(struct dns_ctx *ctx, time_t now) {
* or remote. On local errors, we should stop, while
* remote errors should be ignored (for now anyway).
*/
#ifdef WINDOWS
#ifdef __MINGW32__
if (WSAGetLastError() == WSAEWOULDBLOCK)
#else
if (errno == EAGAIN)
Expand Down
2 changes: 1 addition & 1 deletion libudns/udns_rr_a.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#ifndef WINDOWS
#ifndef __MINGW32__
# include <sys/types.h>
# include <netinet/in.h>
#endif
Expand Down
2 changes: 1 addition & 1 deletion openwrt/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk

PKG_NAME:=shadowsocks-libev
PKG_VERSION:=2.0.1
PKG_VERSION:=2.0.2
PKG_RELEASE=$(PKG_SOURCE_VERSION)

PKG_SOURCE_URL:=https://github.com/shadowsocks/shadowsocks-libev/archive
Expand Down
Loading

0 comments on commit 860bbdc

Please sign in to comment.