mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-28 06:13:31 +01:00
add a RESETCONF controller command, and make setconf with a null
option actually mean to set it to "" svn:r4916
This commit is contained in:
parent
0a8a8ba546
commit
08348ae66e
@ -94,7 +94,7 @@ $Id$
|
|||||||
; body of the data. Leading periods on lines in the data are escaped with
|
; body of the data. Leading periods on lines in the data are escaped with
|
||||||
; an additional leading period as in RFC2821 section 4.5.2
|
; an additional leading period as in RFC2821 section 4.5.2
|
||||||
Data = *DataLine "." CRLF
|
Data = *DataLine "." CRLF
|
||||||
DataLine = CRLF / "." 1*LineItem CRLF/ NonDotItem *LineItem CRLF
|
DataLine = CRLF / "." 1*LineItem CRLF / NonDotItem *LineItem CRLF
|
||||||
LineItem = NonCR / 1*CR NonCRLF
|
LineItem = NonCR / 1*CR NonCRLF
|
||||||
NonDotItem = NonDotCR / 1*CR NonCRLF
|
NonDotItem = NonDotCR / 1*CR NonCRLF
|
||||||
|
|
||||||
@ -126,10 +126,16 @@ $Id$
|
|||||||
SETCONF command arrives containing a single ORBindAddress value, the new
|
SETCONF command arrives containing a single ORBindAddress value, the new
|
||||||
command's value replaces the two old values.
|
command's value replaces the two old values.
|
||||||
|
|
||||||
To _remove_ all settings for a given option entirely (and go back to its
|
3.2. RESETCONF
|
||||||
default value), send a single line containing the key and no value.
|
|
||||||
|
|
||||||
3.2. GETCONF
|
Remove all settings for a given configuration option entirely, and go
|
||||||
|
back to its default value. The syntax is:
|
||||||
|
|
||||||
|
"RESETCONF" 1*(SP keyword) CRLF
|
||||||
|
|
||||||
|
Otherwise it behaves like SETCONF above.
|
||||||
|
|
||||||
|
3.3. GETCONF
|
||||||
|
|
||||||
Request the value of a configuration variable. The syntax is:
|
Request the value of a configuration variable. The syntax is:
|
||||||
|
|
||||||
@ -154,7 +160,7 @@ $Id$
|
|||||||
virtual keyword to get all HiddenServiceDir, HiddenServicePort,
|
virtual keyword to get all HiddenServiceDir, HiddenServicePort,
|
||||||
HiddenServiceNodes, and HiddenServiceExcludeNodes option settings.
|
HiddenServiceNodes, and HiddenServiceExcludeNodes option settings.
|
||||||
|
|
||||||
3.3. SETEVENTS
|
3.4. SETEVENTS
|
||||||
|
|
||||||
Request the server to inform the client about interesting events. The
|
Request the server to inform the client about interesting events. The
|
||||||
syntax is:
|
syntax is:
|
||||||
@ -171,7 +177,7 @@ $Id$
|
|||||||
Unrecognized event" reply if one of the event codes isn't recognized. (On
|
Unrecognized event" reply if one of the event codes isn't recognized. (On
|
||||||
error, the list of active event codes isn't changed.)
|
error, the list of active event codes isn't changed.)
|
||||||
|
|
||||||
3.4. AUTHENTICATE
|
3.5. AUTHENTICATE
|
||||||
|
|
||||||
Sent from the client to the server. The syntax is:
|
Sent from the client to the server. The syntax is:
|
||||||
"AUTHENTICATE" [ SP 1*HEXDIG / QuotedString ] CRLF
|
"AUTHENTICATE" [ SP 1*HEXDIG / QuotedString ] CRLF
|
||||||
@ -186,7 +192,7 @@ $Id$
|
|||||||
AUTHENTICATE message, Tor sends a "514 authentication required" reply to
|
AUTHENTICATE message, Tor sends a "514 authentication required" reply to
|
||||||
any other kind of message.
|
any other kind of message.
|
||||||
|
|
||||||
3.5. SAVECONF
|
3.6. SAVECONF
|
||||||
|
|
||||||
Sent from the client to the server. The syntax is:
|
Sent from the client to the server. The syntax is:
|
||||||
"SAVECONF" CRLF
|
"SAVECONF" CRLF
|
||||||
@ -195,7 +201,7 @@ $Id$
|
|||||||
returns "250 OK" if successful, or "551 Unable to write configuration
|
returns "250 OK" if successful, or "551 Unable to write configuration
|
||||||
to disk" if it can't write the file or some other error occurs.
|
to disk" if it can't write the file or some other error occurs.
|
||||||
|
|
||||||
3.6. SIGNAL
|
3.7. SIGNAL
|
||||||
|
|
||||||
Sent from the client to the server. The syntax is:
|
Sent from the client to the server. The syntax is:
|
||||||
|
|
||||||
@ -219,7 +225,7 @@ $Id$
|
|||||||
closes the socket if it was asked to close immediately), or "552
|
closes the socket if it was asked to close immediately), or "552
|
||||||
Unrecognized signal" if the signal is unrecognized.
|
Unrecognized signal" if the signal is unrecognized.
|
||||||
|
|
||||||
3.7. MAPADDRESS
|
3.8. MAPADDRESS
|
||||||
|
|
||||||
Sent from the client to the server. The syntax is:
|
Sent from the client to the server. The syntax is:
|
||||||
|
|
||||||
@ -273,7 +279,7 @@ $Id$
|
|||||||
a certain time, then it must explicitly un-map the address when that
|
a certain time, then it must explicitly un-map the address when that
|
||||||
time has elapsed.
|
time has elapsed.
|
||||||
|
|
||||||
3.8. GETINFO
|
3.9. GETINFO
|
||||||
|
|
||||||
Sent from the client to the server. The syntax is as for GETCONF:
|
Sent from the client to the server. The syntax is as for GETCONF:
|
||||||
"GETINFO" 1*(SP keyword) CRLF
|
"GETINFO" 1*(SP keyword) CRLF
|
||||||
@ -374,7 +380,7 @@ $Id$
|
|||||||
S: 250-version=Tor 0.1.1.0-alpha-cvs
|
S: 250-version=Tor 0.1.1.0-alpha-cvs
|
||||||
S: 250 OK
|
S: 250 OK
|
||||||
|
|
||||||
3.9. EXTENDCIRCUIT
|
3.10. EXTENDCIRCUIT
|
||||||
|
|
||||||
Sent from the client to the server. The format is:
|
Sent from the client to the server. The format is:
|
||||||
"EXTENDCIRCUIT" SP CircuitID SP ServerID *("," ServerID) CRLF
|
"EXTENDCIRCUIT" SP CircuitID SP ServerID *("," ServerID) CRLF
|
||||||
@ -389,7 +395,7 @@ $Id$
|
|||||||
body consisting of the Circuit ID of the (maybe newly created) circuit.
|
body consisting of the Circuit ID of the (maybe newly created) circuit.
|
||||||
The syntax is "250" SP "EXTENDED" SP CircuitID CRLF.
|
The syntax is "250" SP "EXTENDED" SP CircuitID CRLF.
|
||||||
|
|
||||||
3.10. ATTACHSTREAM
|
3.11. ATTACHSTREAM
|
||||||
|
|
||||||
Sent from the client to the server. The syntax is:
|
Sent from the client to the server. The syntax is:
|
||||||
"ATTACHSTREAM" SP StreamID SP CircuitID CRLF
|
"ATTACHSTREAM" SP StreamID SP CircuitID CRLF
|
||||||
@ -414,7 +420,7 @@ $Id$
|
|||||||
via TC when "__LeaveStreamsUnattached" is false may cause a race between
|
via TC when "__LeaveStreamsUnattached" is false may cause a race between
|
||||||
Tor and the controller, as both attempt to attach streams to circuits.}
|
Tor and the controller, as both attempt to attach streams to circuits.}
|
||||||
|
|
||||||
3.11. POSTDESCRIPTOR
|
3.12. POSTDESCRIPTOR
|
||||||
|
|
||||||
Sent from the client to the server. The syntax is:
|
Sent from the client to the server. The syntax is:
|
||||||
"+POSTDESCRIPTOR" CRLF Descriptor CRLF "." CRLF
|
"+POSTDESCRIPTOR" CRLF Descriptor CRLF "." CRLF
|
||||||
@ -430,7 +436,7 @@ $Id$
|
|||||||
why the server was not added. If the descriptor is added, Tor replies with
|
why the server was not added. If the descriptor is added, Tor replies with
|
||||||
"250 OK".
|
"250 OK".
|
||||||
|
|
||||||
3.12. REDIRECTSTREAM
|
3.13. REDIRECTSTREAM
|
||||||
|
|
||||||
Sent from the client to the server. The syntax is:
|
Sent from the client to the server. The syntax is:
|
||||||
"REDIRECTSTREAM" SP StreamID SP Address CRLF
|
"REDIRECTSTREAM" SP StreamID SP Address CRLF
|
||||||
@ -444,7 +450,7 @@ $Id$
|
|||||||
|
|
||||||
Tor replies with "250 OK" on success.
|
Tor replies with "250 OK" on success.
|
||||||
|
|
||||||
3.13. CLOSESTREAM
|
3.14. CLOSESTREAM
|
||||||
|
|
||||||
Sent from the client to the server. The syntax is:
|
Sent from the client to the server. The syntax is:
|
||||||
|
|
||||||
@ -455,7 +461,7 @@ $Id$
|
|||||||
not used currently; Tor servers SHOULD ignore unrecognized flags. Tor may
|
not used currently; Tor servers SHOULD ignore unrecognized flags. Tor may
|
||||||
hold the stream open for a while to flush any data that is pending.
|
hold the stream open for a while to flush any data that is pending.
|
||||||
|
|
||||||
3.14. CLOSECIRCUIT
|
3.15. CLOSECIRCUIT
|
||||||
|
|
||||||
The syntax is:
|
The syntax is:
|
||||||
CLOSECIRCUIT SP CircuitID *(SP Flag) CRLF
|
CLOSECIRCUIT SP CircuitID *(SP Flag) CRLF
|
||||||
@ -467,7 +473,7 @@ $Id$
|
|||||||
Other flags may be defined in the future; Tor SHOULD ignore unrecognized
|
Other flags may be defined in the future; Tor SHOULD ignore unrecognized
|
||||||
flags.
|
flags.
|
||||||
|
|
||||||
3.15. QUIT
|
3.16. QUIT
|
||||||
|
|
||||||
Tells the server to hang up on this controller connection. This command
|
Tells the server to hang up on this controller connection. This command
|
||||||
can be used before authenticating.
|
can be used before authenticating.
|
||||||
|
@ -143,6 +143,8 @@ static void send_control1_event(uint16_t event, const char *format, ...)
|
|||||||
CHECK_PRINTF(2,3);
|
CHECK_PRINTF(2,3);
|
||||||
static int handle_control_setconf(connection_t *conn, uint32_t len,
|
static int handle_control_setconf(connection_t *conn, uint32_t len,
|
||||||
char *body);
|
char *body);
|
||||||
|
static int handle_control_resetconf(connection_t *conn, uint32_t len,
|
||||||
|
char *body);
|
||||||
static int handle_control_getconf(connection_t *conn, uint32_t len,
|
static int handle_control_getconf(connection_t *conn, uint32_t len,
|
||||||
const char *body);
|
const char *body);
|
||||||
static int handle_control_setevents(connection_t *conn, uint32_t len,
|
static int handle_control_setevents(connection_t *conn, uint32_t len,
|
||||||
@ -602,10 +604,11 @@ get_stream(const char *id)
|
|||||||
return conn;
|
return conn;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Called when we receive a SETCONF message: parse the body and try
|
/** Helper for setconf and resetconf. Acts like setconf, except
|
||||||
* to update our configuration. Reply with a DONE or ERROR message. */
|
* it passes <b>reset</b> on to options_trial_assign().
|
||||||
|
*/
|
||||||
static int
|
static int
|
||||||
handle_control_setconf(connection_t *conn, uint32_t len, char *body)
|
control_setconf_helper(connection_t *conn, uint32_t len, char *body, int reset)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
config_line_t *lines=NULL;
|
config_line_t *lines=NULL;
|
||||||
@ -663,7 +666,7 @@ handle_control_setconf(connection_t *conn, uint32_t len, char *body)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((r=options_trial_assign(lines, 1)) < 0) {
|
if ((r=options_trial_assign(lines, reset)) < 0) {
|
||||||
log_fn(LOG_WARN,"Controller gave us config lines that didn't validate.");
|
log_fn(LOG_WARN,"Controller gave us config lines that didn't validate.");
|
||||||
if (r==-1) {
|
if (r==-1) {
|
||||||
if (v0)
|
if (v0)
|
||||||
@ -685,6 +688,24 @@ handle_control_setconf(connection_t *conn, uint32_t len, char *body)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Called when we receive a SETCONF message: parse the body and try
|
||||||
|
* to update our configuration. Reply with a DONE or ERROR message. */
|
||||||
|
static int
|
||||||
|
handle_control_setconf(connection_t *conn, uint32_t len, char *body)
|
||||||
|
{
|
||||||
|
return control_setconf_helper(conn, len, body, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Called when we receive a RESETCONF message: parse the body and try
|
||||||
|
* to update our configuration. Reply with a DONE or ERROR message. */
|
||||||
|
static int
|
||||||
|
handle_control_resetconf(connection_t *conn, uint32_t len, char *body)
|
||||||
|
{
|
||||||
|
int v0 = STATE_IS_V0(conn->state);
|
||||||
|
tor_assert(!v0);
|
||||||
|
return control_setconf_helper(conn, len, body, 1);
|
||||||
|
}
|
||||||
|
|
||||||
/** Called when we receive a GETCONF message. Parse the request, and
|
/** Called when we receive a GETCONF message. Parse the request, and
|
||||||
* reply with a CONFVALUE or an ERROR message */
|
* reply with a CONFVALUE or an ERROR message */
|
||||||
static int
|
static int
|
||||||
@ -1979,6 +2000,9 @@ connection_control_process_inbuf_v1(connection_t *conn)
|
|||||||
if (!strcasecmp(conn->incoming_cmd, "SETCONF")) {
|
if (!strcasecmp(conn->incoming_cmd, "SETCONF")) {
|
||||||
if (handle_control_setconf(conn, data_len, args))
|
if (handle_control_setconf(conn, data_len, args))
|
||||||
return -1;
|
return -1;
|
||||||
|
} else if (!strcasecmp(conn->incoming_cmd, "RESETCONF")) {
|
||||||
|
if (handle_control_resetconf(conn, data_len, args))
|
||||||
|
return -1;
|
||||||
} else if (!strcasecmp(conn->incoming_cmd, "GETCONF")) {
|
} else if (!strcasecmp(conn->incoming_cmd, "GETCONF")) {
|
||||||
if (handle_control_getconf(conn, data_len, args))
|
if (handle_control_getconf(conn, data_len, args))
|
||||||
return -1;
|
return -1;
|
||||||
|
Loading…
Reference in New Issue
Block a user