Re: [tor-dev] channel_t to IP Address

2014-07-24 Thread Andrea Shepard
On Thu, Jul 24, 2014 at 01:55:43PM +0100, Gareth Owen wrote:
> Andrea
> 
> Thanks for taking the time to reply and for the advice.  I have just this
> second discovered this method:
> 
> TO_OR_CIRCUIT(circ)->p_chan->get_remote_descr(TO_OR_CIRCUIT(circ)->p_chan,
> 0)
> 
> which returns the endpoint as a string.  I wonder, is this safer/future
> proof or should this approach be discouraged?

Don't call channel methods directly like that.  Do call something like
channel_get_actual_remote_descr(), channel_get_actual_remote_address(),
or channel_get_canonical_remote_descr() (see code in channel.c for
differences among them) on TO_OR_CIRCUIT(circ)->p_chan.

Note: only do this if you want a string to show the user or something like
that.  If you're going to parse it, it's very much brittle and not future-
proof.


-- 
Andrea Shepard

PGP fingerprint (ECC): BDF5 F867 8A52 4E4A BECF  DE79 A4FF BC34 F01D D536
PGP fingerprint (RSA): 3611 95A4 0740 ED1B 7EA5  DF7E 4191 13D9 D0CF BDA5


pgp8LTosxltAG.pgp
Description: PGP signature
___
tor-dev mailing list
tor-dev@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-dev


Re: [tor-dev] channel_t to IP Address

2014-07-24 Thread Gareth Owen
Andrea

Thanks for taking the time to reply and for the advice.  I have just this
second discovered this method:

TO_OR_CIRCUIT(circ)->p_chan->get_remote_descr(TO_OR_CIRCUIT(circ)->p_chan,
0)

which returns the endpoint as a string.  I wonder, is this safer/future
proof or should this approach be discouraged?

Best
Gareth


On 24 July 2014 12:20, Gareth Owen  wrote:

> Hi all
>
> Quick question, how does one turn channel_t into an IP address, e.g. given
> a circuit_t how do I get the IP address of the previous and next hop
> (noting that they might not be in the consensus so I cant use the identity
> hash).  I can see the information is in the connection_t struct but I don't
> know how to get that from the channel/circuit.
>
> Any help appreciated.
>
> Thanks
> Gareth
>
> --
> Dr Gareth Owen
> Senior Lecturer
> School of Computing, University of Portsmouth
>
> Tel: 02392 846423
> Web: ghowen.me
>



-- 
Dr Gareth Owen
Senior Lecturer
School of Computing, University of Portsmouth

Tel: 02392 846423
Web: ghowen.me
___
tor-dev mailing list
tor-dev@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-dev


Re: [tor-dev] channel_t to IP Address

2014-07-24 Thread Andrea Shepard
On Thu, Jul 24, 2014 at 12:20:52PM +0100, Gareth Owen wrote:
> Hi all
> 
> Quick question, how does one turn channel_t into an IP address, e.g. given
> a circuit_t how do I get the IP address of the previous and next hop
> (noting that they might not be in the consensus so I cant use the identity
> hash).  I can see the information is in the connection_t struct but I don't
> know how to get that from the channel/circuit.

The IP address (and the fact that the channel_t even is over IP) are
specific to particular transport; you'll have to downcast it to a
channel_tls_t using the BASE_CHAN_TO_TLS macro and then look at the
or_connection_t pointer in that structure.

-- 
Andrea Shepard

PGP fingerprint (ECC): BDF5 F867 8A52 4E4A BECF  DE79 A4FF BC34 F01D D536
PGP fingerprint (RSA): 3611 95A4 0740 ED1B 7EA5  DF7E 4191 13D9 D0CF BDA5


pgpD4i2EOymVx.pgp
Description: PGP signature
___
tor-dev mailing list
tor-dev@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-dev


[tor-dev] channel_t to IP Address

2014-07-24 Thread Gareth Owen
Hi all

Quick question, how does one turn channel_t into an IP address, e.g. given
a circuit_t how do I get the IP address of the previous and next hop
(noting that they might not be in the consensus so I cant use the identity
hash).  I can see the information is in the connection_t struct but I don't
know how to get that from the channel/circuit.

Any help appreciated.

Thanks
Gareth

-- 
Dr Gareth Owen
Senior Lecturer
School of Computing, University of Portsmouth

Tel: 02392 846423
Web: ghowen.me
___
tor-dev mailing list
tor-dev@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-dev