Permalink
Browse files

Whitespace fixes.

  • Loading branch information...
darkk committed Jul 13, 2008
1 parent 10f87b1 commit 66d9d1cf83fbf0b72ccb2aea8e0a033ba2998dcf
Showing with 154 additions and 122 deletions.
  1. +14 −16 base.c
  2. +2 −1 base.h
  3. +11 −8 http-connect.c
  4. +16 −13 http-relay.c
  5. +1 −1 list.h
  6. +3 −5 log.c
  7. +1 −1 log.h
  8. +3 −5 main.c
  9. +0 −1 main.h
  10. +12 −14 parser.c
  11. +0 −1 parser.h
  12. +3 −5 reddns.c
  13. +70 −38 redsocks.c
  14. +4 −3 redsocks.h
  15. +6 −4 socks4.c
  16. +8 −6 socks5.c
View
30 base.c
@@ -1,5 +1,3 @@
-/* $Id$ */
-
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
@@ -118,7 +116,7 @@ static int getdestaddr_ipf(int fd, const struct sockaddr_in *client, const struc
}
#endif
if (x < 0) {
- if (errno != ESRCH)
+ if (errno != ESRCH)
log_errno(LOG_WARNING, "ioctl(SIOCGNATL)\n");
return -1;
} else {
@@ -196,7 +194,7 @@ int getdestaddr(int fd, const struct sockaddr_in *client, const struct sockaddr_
return instance.redirector->getdestaddr(fd, client, bindaddr, destaddr);
}
-static redirector_subsys redirector_subsystems[] =
+static redirector_subsys redirector_subsystems[] =
{
#ifdef __FreeBSD__
{ .name = "ipf", .init = redir_init_ipf, .fini = redir_close_private, .getdestaddr = getdestaddr_ipf },
@@ -213,7 +211,7 @@ static redirector_subsys redirector_subsystems[] =
/***********************************************************************
* `base` config parsing
*/
-static parser_entry base_entries[] =
+static parser_entry base_entries[] =
{
{ .key = "chroot", .type = pt_pchar, .addr = &instance.chroot },
{ .key = "user", .type = pt_pchar, .addr = &instance.user },
@@ -239,7 +237,7 @@ static int base_onenter(parser_section *section)
static int base_onexit(parser_section *section)
{
const char *err = NULL;
-
+
if (instance.redirector_name) {
redirector_subsys *ss;
FOREACH(ss, redirector_subsystems) {
@@ -255,7 +253,7 @@ static int base_onexit(parser_section *section)
else {
err = "no `redirector` set";
}
-
+
if (err)
parser_error(section->context, err);
@@ -265,11 +263,11 @@ static int base_onexit(parser_section *section)
return err ? -1 : 0;
}
-static parser_section base_conf_section =
-{
- .name = "base",
- .entries = base_entries,
- .onenter = base_onenter,
+static parser_section base_conf_section =
+{
+ .name = "base",
+ .entries = base_entries,
+ .onenter = base_onenter,
.onexit = base_onexit
};
@@ -286,7 +284,7 @@ static int base_init()
log_error(LOG_ERR, "there is no configured instance of `base`, check config file");
return -1;
}
-
+
if (instance.redirector->init && instance.redirector->init() < 0)
return -1;
@@ -309,8 +307,8 @@ static int base_init()
}
if (log_preopen(
- instance.log_name ? instance.log_name : instance.daemon ? "syslog:daemon" : "stderr",
- instance.log_debug,
+ instance.log_name ? instance.log_name : instance.daemon ? "syslog:daemon" : "stderr",
+ instance.log_debug,
instance.log_info
) < 0 ) {
goto fail;
@@ -392,7 +390,7 @@ static int base_init()
return -1;
}
-app_subsys base_subsys =
+app_subsys base_subsys =
{
.init = base_init,
.conf_section = &base_conf_section,
View
3 base.h
@@ -1,7 +1,8 @@
#ifndef BASE_H_SUN_JUN__3_20_15_57_2007
#define BASE_H_SUN_JUN__3_20_15_57_2007
-/* $Id$ */
+
int getdestaddr(int fd, const struct sockaddr_in *client, const struct sockaddr_in *bindaddr, struct sockaddr_in *destaddr);
+
/* vim:set tabstop=4 softtabstop=4 shiftwidth=4: */
/* vim:set foldmethod=marker foldlevel=32 foldmarker={,}: */
#endif /* BASE_H_SUN_JUN__3_20_15_57_2007 */
View
@@ -1,5 +1,4 @@
/** http-connect upstream module for redsocks
- * $Id$
*/
#include <assert.h>
@@ -26,10 +25,10 @@ static void httpc_client_init(redsocks_client *client)
{
if (client->instance->config.login)
redsocks_log_error(client, LOG_WARNING, "login is ignored for http-connect connections");
-
+
if (client->instance->config.password)
redsocks_log_error(client, LOG_WARNING, "password is ignored for http-connect connections");
-
+
client->state = httpc_new;
}
@@ -41,6 +40,8 @@ static void httpc_read_cb(struct bufferevent *buffev, void *_arg)
assert(client->state >= httpc_request_sent);
+ redsocks_touch_client(client);
+
if (client->state == httpc_request_sent) {
size_t len = EVBUFFER_LENGTH(buffev->input);
char *line = evbuffer_readline(buffev->input);
@@ -66,7 +67,7 @@ static void httpc_read_cb(struct bufferevent *buffev, void *_arg)
if (dropped)
return;
-
+
while (client->state == httpc_reply_came) {
char *line = evbuffer_readline(buffev->input);
if (line) {
@@ -96,16 +97,16 @@ static struct evbuffer *httpc_mkconnect(redsocks_client *client)
goto fail;
}
- len = evbuffer_add_printf(buff,
- "CONNECT %s:%u HTTP/1.0\r\n\r\n",
+ len = evbuffer_add_printf(buff,
+ "CONNECT %s:%u HTTP/1.0\r\n\r\n",
inet_ntoa(client->destaddr.sin_addr),
ntohs(client->destaddr.sin_port)
);
if (len < 0) {
redsocks_log_errno(client, LOG_ERR, "evbufer_add_printf");
goto fail;
}
-
+
retval = buff;
buff = NULL;
@@ -120,6 +121,8 @@ static void httpc_write_cb(struct bufferevent *buffev, void *_arg)
{
redsocks_client *client = _arg;
+ redsocks_touch_client(client);
+
if (client->state == httpc_new) {
redsocks_write_helper_ex(
buffev, client,
@@ -132,7 +135,7 @@ static void httpc_write_cb(struct bufferevent *buffev, void *_arg)
}
-relay_subsys http_connect_subsys =
+relay_subsys http_connect_subsys =
{
.name = "http-connect",
.payload_len = 0,
View
@@ -1,5 +1,4 @@
/** http-relay upstream module for redsocks
- * $Id$
*/
#include <assert.h>
@@ -27,10 +26,10 @@ static void httpr_client_init(redsocks_client *client)
if (client->instance->config.login)
redsocks_log_error(client, LOG_WARNING, "login is ignored for http-relay connections");
-
+
if (client->instance->config.password)
redsocks_log_error(client, LOG_WARNING, "password is ignored for http-relay connections");
-
+
client->state = httpr_new;
memset(httpr, 0, sizeof(*httpr));
}
@@ -53,6 +52,8 @@ static void httpr_relay_write_cb(struct bufferevent *buffev, void *_arg)
assert(httpr->buff);
+ redsocks_touch_client(client);
+
len = bufferevent_write_buffer(client->relay, httpr->buff);
// free is done either at _start_relay or at _drop_client
@@ -87,7 +88,7 @@ static char *fmt_http_host(struct sockaddr_in addr)
if (ntohs(addr.sin_port) == 80)
return inet_ntoa(addr.sin_addr);
else {
- snprintf(host, sizeof(host),
+ snprintf(host, sizeof(host),
"%s:%u",
inet_ntoa(addr.sin_addr),
ntohs(addr.sin_port)
@@ -102,11 +103,11 @@ static int httpr_toss_http_firstline(redsocks_client *client)
char *uri = NULL;
struct evbuffer *buff = NULL;
char *host = fmt_http_host(client->destaddr);
-
+
assert(httpr->firstline);
-
+
uri = strchr(httpr->firstline, ' ');
- if (uri)
+ if (uri)
uri += 1; // one char further
else {
redsocks_log_error(client, LOG_NOTICE, "malformed request came");
@@ -135,7 +136,7 @@ static int httpr_toss_http_firstline(redsocks_client *client)
evbuffer_free(httpr->buff);
httpr->buff = buff;
return 0;
-
+
addition_fail:
redsocks_log_error(client, LOG_ERR, "evbuffer_add");
fail:
@@ -150,7 +151,9 @@ static void httpr_client_read_cb(struct bufferevent *buffev, void *_arg)
httpr_client *httpr = (void*)(client +1);
char *line = NULL;
int connect_relay = 0;
-
+
+ redsocks_touch_client(client);
+
while ( (line = evbuffer_readline(buffev->input)) && !connect_relay) {
int skip_line = 0;
int do_drop = 0;
@@ -200,15 +203,15 @@ static void httpr_client_read_cb(struct bufferevent *buffev, void *_arg)
if (line && !skip_line)
if (httpr_append_header(client, line) < 0)
do_drop = 1;
-
+
free(line);
if (do_drop) {
redsocks_drop_client(client);
return;
}
}
-
+
if (connect_relay)
redsocks_connect_relay(client);
}
@@ -223,7 +226,7 @@ static void httpr_connect_relay(redsocks_client *client)
redsocks_log_errno(client, LOG_ERR, "evbuffer_new");
redsocks_drop_client(client);
}
-
+
client->client->readcb = httpr_client_read_cb;
error = bufferevent_enable(client->client, EV_READ);
if (error) {
@@ -232,7 +235,7 @@ static void httpr_connect_relay(redsocks_client *client)
}
}
-relay_subsys http_relay_subsys =
+relay_subsys http_relay_subsys =
{
.name = "http-relay",
.payload_len = sizeof(httpr_client),
View
2 list.h
@@ -1,7 +1,7 @@
#ifndef _LINUX_LIST_H
#define _LINUX_LIST_H
/** That's taken from linux-2.6.18.2 source tree with light modifications
- * I don't know what copyright to place here but that's GPLv2 code so
+ * I don't know what copyright to place here but that's GPLv2 code so
* I assume I'm free to reuse it.
*/
#include "utils.h" // container_of
View
8 log.c
@@ -1,5 +1,3 @@
-/* $Id$ */
-
#include <stdio.h>
#include <string.h>
#include <errno.h>
@@ -60,7 +58,7 @@ int log_preopen(const char *dst, bool log_debug, bool log_info)
{ "local7", LOG_LOCAL7 },
};
- FOREACH(ptpl, tpl)
+ FOREACH(ptpl, tpl)
if (strcmp(facility_name, ptpl->name) == 0) {
facility = ptpl->value;
break;
@@ -71,7 +69,7 @@ int log_preopen(const char *dst, bool log_debug, bool log_info)
}
openlog("redsocks", LOG_NDELAY | LOG_PID, facility);
-
+
logmask = setlogmask(0);
if (!log_debug)
logmask &= ~(LOG_MASK(LOG_DEBUG));
@@ -104,7 +102,7 @@ void _log_vwrite(const char *file, int line, const char *func, int do_errno, int
evbuffer_add_vprintf(buff, fmt, ap);
message = buff->buffer;
}
- else
+ else
message = lowmem;
log_msg(file, line, func, priority, message, do_errno ? strerror(saved_errno) : NULL);
View
2 log.h
@@ -1,6 +1,6 @@
#ifndef LOG_H_WED_JAN_24_18_21_27_2007
#define LOG_H_WED_JAN_24_18_21_27_2007
-/* $Id$ */
+
#include <stdarg.h>
#include <stdbool.h>
#include <syslog.h>
View
8 main.c
@@ -1,5 +1,3 @@
-/* $Id$ */
-
#include <sys/time.h>
#include <sys/types.h>
#include <stdlib.h>
@@ -44,14 +42,14 @@ int main(int argc, char **argv)
return EXIT_FAILURE;
}
}
-
+
FILE *f = fopen(confname, "r");
if (!f) {
perror("Unable to open config file");
return EXIT_FAILURE;
}
-
+
parser_context* parser = parser_start(f, NULL);
if (!parser) {
perror("Not enough memory for parser");
@@ -83,7 +81,7 @@ int main(int argc, char **argv)
return EXIT_FAILURE;
}
}
-
+
log_error(LOG_NOTICE, "redsocks started");
event_dispatch();
View
1 main.h
@@ -1,6 +1,5 @@
#ifndef MAIN_H_TUE_JAN_23_15_38_25_2007
#define MAIN_H_TUE_JAN_23_15_38_25_2007
-/* $Id$ */
#include "parser.h"
Oops, something went wrong.

0 comments on commit 66d9d1c

Please sign in to comment.