Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

Mausoleum: The final and funniest folly of the rich. -- Ambrose Bierce


computers / Tor / Re: How to correctly read the control port when Tor is started with `--ControlPort a

SubjectAuthor
* How to correctly read the control port when Tor is started withAnonymous
+- How to correctly read the control port when Tor is started withAnonymous
+- How to correctly read the control port when Tor is started with `--ControlPort aMarc SCHAEFER
`- How to correctly read the control port when Tor is started withAnonymous

1
How to correctly read the control port when Tor is started with `--ControlPort a

<d077bc596be22882d372f71d7293f3ff@news.novabbs.org>

 copy mid

https://news.novabbs.org/computers/article-flat.php?id=213&group=rocksolid.shared.tor#213

 copy link   Newsgroups: rocksolid.shared.tor
Path: i2pn2.org!.POSTED.10.136.143.187!not-for-mail
From: Anonymous@news.novabbs.org (Anonymous)
Newsgroups: rocksolid.shared.tor
Subject: How to correctly read the control port when Tor is started with
`--ControlPort a
Date: Tue, 11 May 2021 08:09:29 +0000
Organization: Rocksolid Light
Message-ID: <d077bc596be22882d372f71d7293f3ff@news.novabbs.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: i2pn2.org; posting-account="retrobbs1"; posting-host="10.136.143.187";
logging-data="1689"; mail-complaints-to="usenet@i2pn2.org"
User-Agent: Rocksolid Light (news.novabbs.com/getrslight)
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on novabbs.org
X-Rslight-Site: $2y$10$UTOS0ngWrNBUYAYmhvwtaemO1TryU/f7BOTCWzP8zCpnnaQY97XN2
 by: Anonymous - Tue, 11 May 2021 08:09 UTC

It is possible to start Tor with the following arguments (or parameters in Tor's config file):

--ControlPort auto --ControlPortWriteToFile <TEMPORARY_FILE_PATH>>

So Tor [writes][1] to `<TEMPORARY_FILE_PATH>` file the following:

PORT=127.0.0.1:58771

and you just read it in your program. This sounds obvious but if I'm not missing something it is not.

So I think the following steps are necessary to read the correct port number:

1. Make sure that `<TEMPORARY_FILE_PATH>` does not exist [to eliminate risk that you read some old value].
1. Start Tor process with the arguments
1. Wait until `<TEMPORARY_FILE_PATH>` file exists [the file may exist but its content may not be flushed just yet now]
1. Repeat
* Open `<TEMPORARY_FILE_PATH>` file for reading and read a single line (ending with `n`)
* When the line starts with `PORT=`, you can parse the port -> success & break from loop.

I'm aware that you can start Tor and just wait few hunder milliseconds, read the file and you'll get *most likely* the correct port number. However, I want to read always the correct port number.

My question is: What is the recommended (and correct) procedure to read the control port number?

[1]: https://github.com/torproject/tor/blob/1d18ecbc5f74e8aba8096e9bfd851ff775bbce0d/src/feature/control/control.c#L134
--
Posted on Rocksolid Light

Re: How to correctly read the control port when Tor is started with `--ControlPort a

<b83b6c2b53e414d998649d6021f1159a@news.novabbs.org>

 copy mid

https://news.novabbs.org/computers/article-flat.php?id=214&group=rocksolid.shared.tor#214

 copy link   Newsgroups: rocksolid.shared.tor
Path: i2pn2.org!.POSTED.10.136.143.187!not-for-mail
From: Anonymous@news.novabbs.org (Anonymous)
Newsgroups: rocksolid.shared.tor
Subject: Re: How to correctly read the control port when Tor is started with
`--ControlPort a
Date: Tue, 11 May 2021 08:26:53 +0000
Organization: Rocksolid Light
Message-ID: <b83b6c2b53e414d998649d6021f1159a@news.novabbs.org>
References: <d077bc596be22882d372f71d7293f3ff@news.novabbs.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: i2pn2.org; posting-account="retrobbs1"; posting-host="10.136.143.187";
logging-data="5211"; mail-complaints-to="usenet@i2pn2.org"
User-Agent: Rocksolid Light (news.novabbs.com/getrslight)
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on novabbs.org
X-Rslight-Site: $2y$10$IxNWKBSTfXGkh2jngbXa4O/wLObB9LsdLkZFWYkCiJgxNYWQ7ggJu
 by: Anonymous - Tue, 11 May 2021 08:26 UTC

Anonymous wrote:

> It is possible to start Tor with the following arguments (or parameters in Tor's config file):

> --ControlPort auto --ControlPortWriteToFile <TEMPORARY_FILE_PATH>>

> So Tor [writes][1] to `<TEMPORARY_FILE_PATH>` file the following:

> PORT=127.0.0.1:58771

> and you just read it in your program. This sounds obvious but if I'm not missing something it is not.

> ...

> I'm aware that you can start Tor and just wait few hunder milliseconds, read the file and you'll get *most likely* the correct port number. However, I want to read always the correct port number.

Is the concern that you may read an old file? The steps you list sound correct and it should work. Maybe test the mtime (file modification time) to see if is a new file or not before using the info.
--
Posted on Rocksolid Light

Re: How to correctly read the control port when Tor is started with `--ControlPort a

<s7dfbu$go2$1@shakotay.alphanet.ch>

 copy mid

https://news.novabbs.org/computers/article-flat.php?id=215&group=rocksolid.shared.tor#215

 copy link   Newsgroups: rocksolid.shared.tor
Path: i2pn2.org!i2pn.org!news.nntp4.net!usenet.pasdenom.info!news.alphanet.ch!alphanet.ch!.POSTED.localhost!not-for-mail
From: schaefer@alphanet.ch (Marc SCHAEFER)
Newsgroups: rocksolid.shared.tor
Subject: Re: How to correctly read the control port when Tor is started with `--ControlPort a
Date: Tue, 11 May 2021 08:30:54 -0000 (UTC)
Organization: Posted through ALPHANET (https://news.alphanet.ch/)
Message-ID: <s7dfbu$go2$1@shakotay.alphanet.ch>
References: <d077bc596be22882d372f71d7293f3ff@news.novabbs.org>
Injection-Date: Tue, 11 May 2021 08:30:54 -0000 (UTC)
Injection-Info: shakotay.alphanet.ch; posting-host="localhost:127.0.0.1";
logging-data="17154"; mail-complaints-to="usenet@alphanet.ch"
User-Agent: tin/2.4.3-20181224 ("Glen Mhor") (UNIX) (Linux/4.19.0-16-amd64 (x86_64))
Cancel-Lock: sha256:/az9TkWqeEiRYFdfPV3ZWhIX6Kwc6fHM5FuI6LFzxTU=
 by: Marc SCHAEFER - Tue, 11 May 2021 08:30 UTC

Anonymous <Anonymous@news.novabbs.org> wrote:
> My question is: What is the recommended (and correct) procedure to read the control port number?

Set it statically with:

ControlPort

in the configuration?

Re: How to correctly read the control port when Tor is started with `--ControlPort a

<064598470550395f99912f6d8763c16b@news.novabbs.org>

 copy mid

https://news.novabbs.org/computers/article-flat.php?id=216&group=rocksolid.shared.tor#216

 copy link   Newsgroups: rocksolid.shared.tor
Path: i2pn2.org!.POSTED.10.136.143.187!not-for-mail
From: Anonymous@news.novabbs.org (Anonymous)
Newsgroups: rocksolid.shared.tor
Subject: Re: How to correctly read the control port when Tor is started with
`--ControlPort a
Date: Wed, 12 May 2021 02:44:34 +0000
Organization: Rocksolid Light
Message-ID: <064598470550395f99912f6d8763c16b@news.novabbs.org>
References: <d077bc596be22882d372f71d7293f3ff@news.novabbs.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: i2pn2.org; posting-account="retrobbs1"; posting-host="10.136.143.187";
logging-data="17274"; mail-complaints-to="usenet@i2pn2.org"
User-Agent: Rocksolid Light (news.novabbs.com/getrslight)
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on novabbs.org
X-Rslight-Site: $2y$10$zPvwxAXnNN9jx1mYEu//Ee85LItQLafGSPNNp9cd/Vttno.kxueWG
 by: Anonymous - Wed, 12 May 2021 02:44 UTC

Anonymous wrote:

> It is possible to start Tor with the following arguments (or parameters in Tor's config file):

> --ControlPort auto --ControlPortWriteToFile <TEMPORARY_FILE_PATH>>

> So Tor [writes][1] to `<TEMPORARY_FILE_PATH>` file the following:

> PORT=127.0.0.1:58771

> and you just read it in your program. This sounds obvious but if I'm not missing something it is not.

If the control port is set only when Tor starts, you could use a script to modify torrc at each start with a new port number. You would create the port number randomly in your script. Then there is no need to read the log, you know the port number that the script generated.
--
Posted on Rocksolid Light

1
server_pubkey.txt

rocksolid light 0.9.7
clearnet tor