|
| 1 | +# dotNET Tor Spectator |
| 2 | + |
| 3 | +This is a small bot to have fun with several things: |
| 4 | + - Tor daemon interaction |
| 5 | + - Mastodon posting |
| 6 | + |
| 7 | +This small thing starts and tries to get service descriptors for sites mentioned in `sites.txt`. If hidden service descriptor received - the site is marked as up. Else - down. That's simple. |
| 8 | + |
| 9 | +## Where is the bot |
| 10 | + |
| 11 | +Follow the bot on mastodon. Staging account is [[email protected]](https://botsin.space/@devmacaca) |
| 12 | + |
| 13 | +## Prerequisites |
| 14 | + |
| 15 | +There are some prerequisites for set up. You need Tor deamon running to request hidden service descriptors, you will need a mastodon account to post collected statuses and you'd better have Seq to collect logs from application. |
| 16 | + |
| 17 | +### Tor daemon |
| 18 | + |
| 19 | +Setup tor according to tor manual, configure bridges if connection to tor network fails or is unstable. Tor deamon is communicated through unix domain socket, typically located at `/run/tor/control`. You will also need an auth cookie to execute commands, so you should also be able to read cookie from `/run/tor/control.authcookie`. |
| 20 | + |
| 21 | +### Mastodon account |
| 22 | + |
| 23 | +Get a bot account on some mastodon instance, where you would like to post your statuses. Do respect instance policies for bots and automated posts. |
| 24 | +Register application and save API token. You'll need it. |
| 25 | +Also, save information on toot length on this instance. It will be used in configuration. |
| 26 | + |
| 27 | +### Seq |
| 28 | + |
| 29 | +Logging to console is great, but i prefer seq for pet projects. It is small, fast, reliable, painless log collector. The Seq Serilog sink is already built in NTorSpectator, pointing to `http://seq:5341` |
| 30 | + |
| 31 | +## Setup |
| 32 | + |
| 33 | +The best way to run applications is docker compose. So the sample file looks like this: |
| 34 | + |
| 35 | +```yaml |
| 36 | +version: "3" |
| 37 | + |
| 38 | +services: |
| 39 | + tor_spectator: |
| 40 | + image: ghcr.io/zetroot/ntorspectator:latest |
| 41 | + platform: linux/arm64 |
| 42 | + restart: always |
| 43 | + depends_on: |
| 44 | + seq: |
| 45 | + condition: service_started |
| 46 | + container_name: ntorspectator |
| 47 | + environment: |
| 48 | + - ASPNETCORE_ENVIRONMENT=Production # this is production environment, is not it? |
| 49 | + volumes: |
| 50 | + - "./sites.txt:/app/sites.txt" # mount file with site list into application folder |
| 51 | + - "./appsettings.Production.json:/app/appsettings.Production.json" # mount production config into app folder |
| 52 | + - "/run/tor/control:/run/tor/control" # also mount tor unix-socket |
| 53 | + - "/run/tor/control.authcookie:/run/tor/control.authcookie" # and not forget about auth cookie |
| 54 | + |
| 55 | + seq: |
| 56 | + image: datalust/seq:latest |
| 57 | + container_name: seq_torspec |
| 58 | + hostname: seq |
| 59 | + restart: unless-stopped |
| 60 | + volumes: |
| 61 | + - "./seq_data:/data" # persist logs to disk |
| 62 | + ports: |
| 63 | + - "8081:80" |
| 64 | + - "5342:5341" |
| 65 | + environment: |
| 66 | + - ACCEPT_EULA=Y |
| 67 | +``` |
| 68 | +
|
| 69 | +`Sites.txt` is a file with tor onion links, one at a line: |
| 70 | +``` |
| 71 | +he5dybnt7sr6cm32.........tm65flqy6irivtflruqfc5ep7eiodiad.onion |
| 72 | +ho2hua2hfduv6f7h.........qdn4szgyy2jjnx545v4z3epq7uyrscid.onion |
| 73 | +hqfld5smkr4b4xrj.........oqhuuoehjdvoin755iytmpk4sm7cbwad.onion |
| 74 | +hxuzjtocnzvv5g2r.........bupmk7rclb6lly3fo4tvqkk5oyrv3nid.onion |
| 75 | +hzwjmjimhr7bdmfv.........ibt5ojjmpo3pbp5ctwcg37n3hyk7qzid.onion |
| 76 | +``` |
| 77 | +
|
| 78 | +And provide production config in `appsettings.Production.json`: |
| 79 | +```json |
| 80 | +{ |
| 81 | + "MastodonSettings" : { |
| 82 | + "Instance" : "https://your.cool.mastodon.instance.prod", |
| 83 | + "Token": "YourSuperSecretApiTokenGoesHere" |
| 84 | + }, |
| 85 | + "SpectatorSettings": { |
| 86 | + "CooldownInterval":"01:00:00" <<== this is the interval to cool down tor network |
| 87 | + } |
| 88 | +} |
| 89 | +``` |
| 90 | + |
| 91 | +And then just `docker compose pull && docker compose up -d`. You are amazing! |
0 commit comments