Skip to content

Commit

Permalink
Merge branch 'release/0.3.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
lparam committed Oct 8, 2015
2 parents de19b4a + ca30ebc commit 85f84df
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 15 deletions.
2 changes: 1 addition & 1 deletion 3rd/c-ares
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
v0.3.1 (2015-10-8)
-----------
* Fix: Close remote


v0.3.0 (2015-10-1)
-----------
* Feature: Support ACL
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MAJOR = 0
MINOR = 3
PATCH = 0
PATCH = 1
NAME = xsocks

ifdef O
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:=xsocks
PKG_VERSION:=0.3.0
PKG_VERSION:=0.3.1
PKG_RELEASE=

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
Expand Down
2 changes: 1 addition & 1 deletion src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "uv.h"
#include "socks.h"

#define XSOCKS_VERSION "0.3.0"
#define XSOCKS_VERSION "0.3.1"

struct server_context {
int index;
Expand Down
11 changes: 7 additions & 4 deletions src/xsocks_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ new_client() {

static void
free_client(struct client_context *client) {
if (client->remote != NULL) {
client->remote = NULL;
}
client->remote = NULL;
free(client);
}

Expand Down Expand Up @@ -117,6 +115,7 @@ request_ack(struct client_context *client, enum s5_rep rep) {
memcpy(buf + 4, &addr6->sin6_addr, 16); /* BND.ADDR */
memcpy(buf + 20, &addr6->sin6_port, 2); /* BND.PORT */
buflen = 22;

} else {
buf[3] = 0x01; /* ATYP - IPv4. */
const struct sockaddr_in *addr4 = (const struct sockaddr_in *)&addr;
Expand All @@ -128,9 +127,11 @@ request_ack(struct client_context *client, enum s5_rep rep) {
if (rep == S5_REP_SUCCESSED) {
if (client->cmd == S5_CMD_CONNECT) {
client->stage = XSTAGE_FORWARD;

} else {
client->stage = XSTAGE_UDP_RELAY;
}

} else {
client->stage = XSTAGE_TERMINATE;
}
Expand Down Expand Up @@ -342,8 +343,10 @@ client_recv_cb(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf) {
logger_log(LOG_ERR, "encrypt failed");
close_client(client);
close_remote(remote);

} else {
forward_to_remote(remote, c, clen);
}
forward_to_remote(remote, c, clen);
}

break;
Expand Down
5 changes: 2 additions & 3 deletions src/xsocks_remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ new_remote(uint16_t timeout, struct sockaddr *addr) {

static void
free_remote(struct remote_context *remote) {
if (remote->client != NULL) {
remote->client = NULL;
}
remote->client = NULL;
free(remote);
}

Expand All @@ -90,6 +88,7 @@ remote_close_cb(uv_handle_t *handle) {

void
close_remote(struct remote_context *remote) {
if (remote == NULL) return;
assert(uv_is_closing(&remote->handle.handle) == 0);

remote->timer->data = NULL;
Expand Down
2 changes: 1 addition & 1 deletion src/xsocks_udprelay.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ server_recv_cb(uv_udp_t *handle, ssize_t nread, const uv_buf_t *buf, const struc
char dst[INET6_ADDRSTRLEN + 1] = {0};
uint16_t dst_port = 0;
dst_port = ip_name(&client->addr, dst, sizeof dst);
logger_log(LOG_INFO, "%s -> %s:%d", client->target_addr, dst, dst_port);
logger_log(LOG_INFO, "%s <- %s:%d", dst, dst_port, client->target_addr);
}

forward_to_client(client, m , mlen);
Expand Down
4 changes: 2 additions & 2 deletions src/xsocksd_udprelay.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ target_recv_cb(uv_udp_t *handle, ssize_t nread, const uv_buf_t *buf, const struc
char dst[INET6_ADDRSTRLEN + 1] = {0};
uint16_t src_port = 0, dst_port = 0;
src_port = ip_name(addr, src, sizeof src);
dst_port = ip_name(&target->dest_addr, dst, sizeof dst);
logger_log(LOG_INFO, "%s:%d -> %s:%d", src, src_port, dst, dst_port);
dst_port = ip_name(&target->client_addr, dst, sizeof dst);
logger_log(LOG_INFO, "%s:%d <- %s:%d", dst, dst_port, src, src_port);
}
forward_to_client(target, c, clen);
}
Expand Down

0 comments on commit 85f84df

Please sign in to comment.