diff options
author | Yawning Angel <yawning@schwanenlied.me> | 2015-05-20 17:41:27 +0000 |
---|---|---|
committer | Yawning Angel <yawning@schwanenlied.me> | 2015-05-20 17:41:27 +0000 |
commit | 712bf069781d7a6336501aab628f62ada4f4c4d7 (patch) | |
tree | 103291e345c2a2c03859ab20456c012d88652086 /src/or/control.c | |
parent | db7bde08be59398488624bc377d1d5318182ee45 (diff) | |
download | tor-712bf069781d7a6336501aab628f62ada4f4c4d7.tar.gz tor-712bf069781d7a6336501aab628f62ada4f4c4d7.zip |
Add support for 'HiddenServiceMaxStream' to 'ADD_ONION'.
Done as a separate commit to ease backporting the tunables to 0.2.6.x.
Diffstat (limited to 'src/or/control.c')
-rw-r--r-- | src/or/control.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/or/control.c b/src/or/control.c index 4eeb897afa..746dfff921 100644 --- a/src/or/control.c +++ b/src/or/control.c @@ -3566,9 +3566,12 @@ handle_control_add_onion(control_connection_t *conn, smartlist_t *port_cfgs = smartlist_new(); int discard_pk = 0; int detach = 0; + int max_streams = 0; + int max_streams_close_circuit = 0; for (size_t i = 1; i < arg_len; i++) { static const char *port_prefix = "Port="; static const char *flags_prefix = "Flags="; + static const char *max_s_prefix = "MaxStreams="; const char *arg = smartlist_get(args, i); if (!strcasecmpstart(arg, port_prefix)) { @@ -3582,15 +3585,27 @@ handle_control_add_onion(control_connection_t *conn, goto out; } smartlist_add(port_cfgs, cfg); + } else if (!strcasecmpstart(arg, max_s_prefix)) { + /* "MaxStreams=[0..65535]". */ + const char *max_s_str = arg + strlen(max_s_prefix); + int ok = 0; + max_streams = (int)tor_parse_long(max_s_str, 10, 0, 65535, &ok, NULL); + if (!ok) { + connection_printf_to_buf(conn, "512 Invalid MaxStreams\r\n"); + goto out; + } } else if (!strcasecmpstart(arg, flags_prefix)) { /* "Flags=Flag[,Flag]", where Flag can be: * * 'DiscardPK' - If tor generates the keypair, do not include it in * the response. * * 'Detach' - Do not tie this onion service to any particular control * connection. + * * 'MaxStreamsCloseCircuit' - Close the circuit if MaxStreams is + * exceeded. */ static const char *discard_flag = "DiscardPK"; static const char *detach_flag = "Detach"; + static const char *max_s_close_flag = "MaxStreamsCloseCircuit"; smartlist_t *flags = smartlist_new(); int bad = 0; @@ -3607,6 +3622,8 @@ handle_control_add_onion(control_connection_t *conn, discard_pk = 1; } else if (!strcasecmp(flag, detach_flag)) { detach = 1; + } else if (!strcasecmp(flag, max_s_close_flag)) { + max_streams_close_circuit = 1; } else { connection_printf_to_buf(conn, "512 Invalid 'Flags' argument: %s\r\n", @@ -3652,7 +3669,9 @@ handle_control_add_onion(control_connection_t *conn, * regardless of success/failure. */ char *service_id = NULL; - int ret = rend_service_add_ephemeral(pk, port_cfgs, &service_id); + int ret = rend_service_add_ephemeral(pk, port_cfgs, max_streams, + max_streams_close_circuit, + &service_id); port_cfgs = NULL; /* port_cfgs is now owned by the rendservice code. */ switch (ret) { case RSAE_OKAY: |