mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2025-02-25 15:10:48 +01:00
Make a channel getter method to retrieve transport names.
This commit is contained in:
parent
0ec4e5a698
commit
e765d6ed84
3 changed files with 36 additions and 2 deletions
|
@ -2379,9 +2379,14 @@ channel_do_open_actions(channel_t *chan)
|
|||
/* only report it to the geoip module if it's not a known router */
|
||||
if (!router_get_by_id_digest(chan->identity_digest)) {
|
||||
if (channel_get_addr_if_possible(chan, &remote_addr)) {
|
||||
/* XXXX 5040/4773 : Is this 'NULL' right? */
|
||||
geoip_note_client_seen(GEOIP_CLIENT_CONNECT, &remote_addr, NULL,
|
||||
char *transport_name = NULL;
|
||||
if (chan->get_transport_name(chan, &transport_name) < 0)
|
||||
transport_name = NULL;
|
||||
|
||||
geoip_note_client_seen(GEOIP_CLIENT_CONNECT,
|
||||
&remote_addr, transport_name,
|
||||
now);
|
||||
tor_free(transport_name);
|
||||
}
|
||||
/* Otherwise the underlying transport can't tell us this, so skip it */
|
||||
}
|
||||
|
|
|
@ -84,6 +84,8 @@ struct channel_s {
|
|||
* available.
|
||||
*/
|
||||
int (*get_remote_addr)(channel_t *, tor_addr_t *);
|
||||
int (*get_transport_name)(channel_t *chan, char **transport_out);
|
||||
|
||||
#define GRD_FLAG_ORIGINAL 1
|
||||
#define GRD_FLAG_ADDR_ONLY 2
|
||||
/*
|
||||
|
|
|
@ -55,6 +55,8 @@ static void channel_tls_close_method(channel_t *chan);
|
|||
static const char * channel_tls_describe_transport_method(channel_t *chan);
|
||||
static int
|
||||
channel_tls_get_remote_addr_method(channel_t *chan, tor_addr_t *addr_out);
|
||||
static int
|
||||
channel_tls_get_transport_name_method(channel_t *chan, char **transport_out);
|
||||
static const char *
|
||||
channel_tls_get_remote_descr_method(channel_t *chan, int flags);
|
||||
static int channel_tls_has_queued_writes_method(channel_t *chan);
|
||||
|
@ -114,6 +116,7 @@ channel_tls_common_init(channel_tls_t *tlschan)
|
|||
chan->describe_transport = channel_tls_describe_transport_method;
|
||||
chan->get_remote_addr = channel_tls_get_remote_addr_method;
|
||||
chan->get_remote_descr = channel_tls_get_remote_descr_method;
|
||||
chan->get_transport_name = channel_tls_get_transport_name_method;
|
||||
chan->has_queued_writes = channel_tls_has_queued_writes_method;
|
||||
chan->is_canonical = channel_tls_is_canonical_method;
|
||||
chan->matches_extend_info = channel_tls_matches_extend_info_method;
|
||||
|
@ -405,6 +408,30 @@ channel_tls_get_remote_addr_method(channel_t *chan, tor_addr_t *addr_out)
|
|||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the pluggable transport used by a channel_tls_t.
|
||||
*
|
||||
* This implements the get_transport_name for channel_tls_t. If the
|
||||
* channel uses a pluggable transport, copy its name to
|
||||
* <b>transport_out</b> and return 0. If the channel did not use a
|
||||
* pluggable transport, return -1. */
|
||||
|
||||
static int
|
||||
channel_tls_get_transport_name_method(channel_t *chan, char **transport_out)
|
||||
{
|
||||
channel_tls_t *tlschan = BASE_CHAN_TO_TLS(chan);
|
||||
|
||||
tor_assert(tlschan);
|
||||
tor_assert(transport_out);
|
||||
tor_assert(tlschan->conn);
|
||||
|
||||
if (!tlschan->conn->ext_or_transport)
|
||||
return -1;
|
||||
|
||||
*transport_out = tor_strdup(tlschan->conn->ext_or_transport);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get endpoint description of a channel_tls_t
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue