docker – Blame information for rev 9
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
9 | office | 1 | #!/usr/bin/expect -f |
2 | ########################################################################### |
||
3 | ## Copyright (C) Wizardry and Steamworks 2024 - License: MIT ## |
||
4 | ########################################################################### |
||
5 | # This is an "expect" script that checks whether tor has established a # |
||
6 | # circuit and sets the return status depending on whether it has or not. # |
||
7 | # # |
||
8 | # In other words, iff. the script returns 0, then tor has an established # |
||
9 | # circuit; otherwise no circuit has been established. # |
||
10 | # # |
||
11 | # Requirements: # |
||
12 | # * expect (TCL program) # |
||
13 | # * tor must expose a control port and must have a control password # |
||
14 | # # |
||
15 | # In order to generate a control password, issue: tor --hash-password PWD # |
||
16 | # where PWD is the desired control port password. After that, amend the # |
||
17 | # tor configuration file to set the control port address, port and pass: # |
||
18 | # # |
||
19 | # ControlPort 0.0.0.0:8051 # |
||
20 | # HashedControlPassword 16:A482ADEAAWF43EE... # |
||
21 | # # |
||
22 | # Running: ./this-script ADDRESS PORT PASSWORD # |
||
23 | # where: # |
||
24 | # * ADDRESS is the tor listening control address, # |
||
25 | # * PORT is the tor listening control port, # |
||
26 | # * PASSWORD is the plaintext control password # |
||
27 | # # |
||
28 | # after which the return status can be checked on the shell with: # |
||
29 | # echo $? # |
||
30 | ########################################################################### |
||
31 | |||
32 | set address [lindex $argv 0]; |
||
33 | set port [lindex $argv 1]; |
||
34 | set password [lindex $argv 2]; |
||
35 | |||
36 | set timeout 5 |
||
37 | spawn telnet $address $port |
||
38 | |||
39 | send "AUTHENTICATE \"$password\"\n" |
||
40 | expect "250 OK\r\n" |
||
41 | send "GETINFO status/circuit-established\n" |
||
42 | expect { |
||
43 | timeout { |
||
44 | exit 1 |
||
45 | } |
||
46 | -ex "250-status/circuit-established=1\r\n250 OK\r\n" |
||
47 | } |