commit fd2e4fca7a267b3c1023db5f808f53bc35f3948d Author: George Kadianakis desnacked@riseup.net Date: Wed Apr 11 22:00:38 2012 +0200
Indent obfs2 argument parsing. --- src/protocols/obfs2.c | 96 ++++++++++++++++++++++++------------------------ 1 files changed, 48 insertions(+), 48 deletions(-)
diff --git a/src/protocols/obfs2.c b/src/protocols/obfs2.c index 2528205..59c3d55 100644 --- a/src/protocols/obfs2.c +++ b/src/protocols/obfs2.c @@ -178,65 +178,65 @@ parse_and_set_options(int n_options, const char *const *options,
/* Now parse the optional arguments */ while (!strncmp(*options,"--",2)) { - if (!strncmp(*options,"--dest=",7)) { - if (got_dest) - return -1; - cfg->target_addr = - resolve_address_port(*options+7, 1, 0, NULL); - if (!cfg->target_addr) - return -1; - got_dest=1; - } else if (!strncmp(*options,"--shared-secret=",16)) { - digest_t *c; - if (got_ss) - return -1; - - c = digest_new(); - digest_update(c, (uchar*)*options+16, strlen(*options+16)); - digest_getdigest(c, cfg->shared_secret, SHARED_SECRET_LENGTH); - digest_free(c); - - got_ss=1; - } else { - log_warn("obfs2: Unknown argument '%s'.", *options); + if (!strncmp(*options,"--dest=",7)) { + if (got_dest) return -1; - } - options++; - } + cfg->target_addr = + resolve_address_port(*options+7, 1, 0, NULL); + if (!cfg->target_addr) + return -1; + got_dest=1; + } else if (!strncmp(*options,"--shared-secret=",16)) { + digest_t *c; + if (got_ss) + return -1; + + c = digest_new(); + digest_update(c, (uchar*)*options+16, strlen(*options+16)); + digest_getdigest(c, cfg->shared_secret, SHARED_SECRET_LENGTH); + digest_free(c);
- if (!strcmp(*options, "client")) { - defport = "48988"; /* bf5c */ - cfg->mode = LSN_SIMPLE_CLIENT; - } else if (!strcmp(*options, "socks")) { - defport = "23548"; /* 5bf5 */ - cfg->mode = LSN_SOCKS_CLIENT; - } else if (!strcmp(*options, "server")) { - defport = "11253"; /* 2bf5 */ - cfg->mode = LSN_SIMPLE_SERVER; + got_ss=1; } else { - log_warn("obfs2: only client/socks/server modes supported."); + log_warn("obfs2: Unknown argument '%s'.", *options); return -1; } options++; + }
- cfg->listen_addr = resolve_address_port(*options, 1, 1, defport); - if (!cfg->listen_addr) - return -1; + if (!strcmp(*options, "client")) { + defport = "48988"; /* bf5c */ + cfg->mode = LSN_SIMPLE_CLIENT; + } else if (!strcmp(*options, "socks")) { + defport = "23548"; /* 5bf5 */ + cfg->mode = LSN_SOCKS_CLIENT; + } else if (!strcmp(*options, "server")) { + defport = "11253"; /* 2bf5 */ + cfg->mode = LSN_SIMPLE_SERVER; + } else { + log_warn("obfs2: only client/socks/server modes supported."); + return -1; + } + options++;
- /* Validate option selection. */ - if (got_dest && (cfg->mode == LSN_SOCKS_CLIENT)) { - log_warn("obfs2: You can't be on socks mode and have --dest."); - return -1; - } + cfg->listen_addr = resolve_address_port(*options, 1, 1, defport); + if (!cfg->listen_addr) + return -1;
- if (!got_dest && (cfg->mode != LSN_SOCKS_CLIENT)) { - log_warn("obfs2: client/server mode needs --dest."); - return -1; - } + /* Validate option selection. */ + if (got_dest && (cfg->mode == LSN_SOCKS_CLIENT)) { + log_warn("obfs2: You can't be on socks mode and have --dest."); + return -1; + } + + if (!got_dest && (cfg->mode != LSN_SOCKS_CLIENT)) { + log_warn("obfs2: client/server mode needs --dest."); + return -1; + }
- log_debug("obfs2: Parsed options nicely!"); + log_debug("obfs2: Parsed options nicely!");
- return 0; + return 0; }