Browse Source

Fix #819

pull/824/head
Max Lv 8 years ago
parent
commit
e3f0429ab3
1 changed files with 4 additions and 10 deletions
  1. 14
      src/udprelay.c

14
src/udprelay.c

@ -214,16 +214,11 @@ construct_udprealy_header(const struct sockaddr_storage *in_addr,
static int static int
parse_udprealy_header(const char *buf, const size_t buf_len, parse_udprealy_header(const char *buf, const size_t buf_len,
int *auth, char *host, char *port,
struct sockaddr_storage *storage)
char *host, char *port, struct sockaddr_storage *storage)
{ {
const uint8_t atyp = *(uint8_t *)buf; const uint8_t atyp = *(uint8_t *)buf;
int offset = 1; int offset = 1;
if (auth != NULL) {
*auth |= (atyp & ONETIMEAUTH_FLAG);
}
// get remote addr and port // get remote addr and port
if ((atyp & ADDRTYPE_MASK) == 1) { if ((atyp & ADDRTYPE_MASK) == 1) {
// IP V4 // IP V4
@ -699,14 +694,14 @@ remote_recv_cb(EV_P_ ev_io *w, int revents)
#ifdef MODULE_REDIR #ifdef MODULE_REDIR
struct sockaddr_storage dst_addr; struct sockaddr_storage dst_addr;
memset(&dst_addr, 0, sizeof(struct sockaddr_storage)); memset(&dst_addr, 0, sizeof(struct sockaddr_storage));
int len = parse_udprealy_header(buf->array, buf->len, NULL, NULL, NULL, &dst_addr);
int len = parse_udprealy_header(buf->array, buf->len, NULL, NULL, &dst_addr);
if (dst_addr.ss_family != AF_INET && dst_addr.ss_family != AF_INET6) { if (dst_addr.ss_family != AF_INET && dst_addr.ss_family != AF_INET6) {
LOGI("[udp] ss-redir does not support domain name"); LOGI("[udp] ss-redir does not support domain name");
goto CLEAN_UP; goto CLEAN_UP;
} }
#else #else
int len = parse_udprealy_header(buf->array, buf->len, NULL, NULL, NULL, NULL);
int len = parse_udprealy_header(buf->array, buf->len, NULL, NULL, NULL);
#endif #endif
if (len == 0) { if (len == 0) {
@ -1028,8 +1023,7 @@ server_recv_cb(EV_P_ ev_io *w, int revents)
memset(&dst_addr, 0, sizeof(struct sockaddr_storage)); memset(&dst_addr, 0, sizeof(struct sockaddr_storage));
int addr_header_len = parse_udprealy_header(buf->array + offset, buf->len - offset, int addr_header_len = parse_udprealy_header(buf->array + offset, buf->len - offset,
&server_ctx->auth, host, port,
&dst_addr);
host, port, &dst_addr);
if (addr_header_len == 0) { if (addr_header_len == 0) {
// error in parse header // error in parse header
goto CLEAN_UP; goto CLEAN_UP;

Loading…
Cancel
Save