docker – Blame information for rev 54
?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 | # # |
||
47 | office | 19 | # ControlPort 0.0.0.0:8050 # |
9 | office | 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 | ########################################################################### |
||
47 | office | 31 | log_user 0 |
9 | office | 32 | |
33 | set address [lindex $argv 0]; |
||
34 | set port [lindex $argv 1]; |
||
35 | set password [lindex $argv 2]; |
||
36 | |||
54 | office | 37 | set timeout 1 |
9 | office | 38 | spawn telnet $address $port |
39 | |||
40 | send "AUTHENTICATE \"$password\"\n" |
||
47 | office | 41 | expect { |
42 | -ex "250 OK\r\n" {} |
||
43 | -ex "515 Authentication failed: Password did not match HashedControlPassword value from configuration\r\n" { |
||
44 | log_user 1 |
||
45 | puts "0" |
||
46 | exit 1 |
||
47 | } |
||
48 | timeout { |
||
49 | log_user 1 |
||
50 | puts "0" |
||
51 | exit 1 |
||
52 | } |
||
53 | } |
||
9 | office | 54 | send "GETINFO status/circuit-established\n" |
55 | expect { |
||
56 | timeout { |
||
47 | office | 57 | log_user 1 |
58 | puts "0" |
||
9 | office | 59 | exit 1 |
60 | } |
||
61 | -ex "250-status/circuit-established=1\r\n250 OK\r\n" |
||
62 | } |
||
47 | office | 63 | log_user 1 |
64 | puts "100" |