Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Silvio Rhatto
Onionmine
Commits
91a2203a
Verified
Commit
91a2203a
authored
May 16, 2022
by
Silvio Rhatto
Browse files
Feat(test-keys): use a UNIX socket
parent
6722a9e3
Changes
2
Hide whitespace changes
Inline
Side-by-side
bin/params
View file @
91a2203a
...
...
@@ -39,7 +39,7 @@ ENV_LOCAL="$POOL/local.conf"
DEPENDENCIES
=
"gcc libsodium-dev make autoconf libpcre2-dev"
# Tor daemon, to test the generated keys
DEPENDENCIES
=
"
$DEPENDENCIES
tor netcat"
DEPENDENCIES
=
"
$DEPENDENCIES
tor netcat
-openbsd
"
# For HARICA's onion-csr
DEPENDENCIES
=
"
$DEPENDENCIES
ruby-dev build-essential"
...
...
bin/test-keys
View file @
91a2203a
...
...
@@ -25,9 +25,13 @@ source $DIRNAME/params
# Additional parameters
CANDIDATE
=
"
$2
"
PORT
=
"
${
3
:-
8080
}
"
WAIT
=
"
${
4
:-
60
}
"
WAIT
=
"
${
3
:-
60
}
"
NOUNCE
=
"
$(
echo
$RANDOM
|
sha512sum
|
awk
'{ print $1 }'
)
"
DAEMON_DIR
=
"
$POOL
/daemon"
SOCKET
=
"
$DAEMON_DIR
/nc.socket"
# Use a random TCP port for the Onion Service
PORT
=
"
$(
echo
$RANDOM
)
"
# Teardown procedure
function
teardown
()
{
...
...
@@ -41,18 +45,19 @@ function teardown() {
rm
-f
"
$TMPFILE
"
fi
rm
-f
$SOCKET
exit
$1
}
function
usage
()
{
echo
"usage:
$BASENAME
<pool> <candidate>
[port]
[wait]"
echo
"usage:
$BASENAME
<pool> <candidate> [wait]"
echo
""
echo
"Test an Onion Service keypair candidate mined in a pool"
echo
""
echo
" pool: the mining pool to operate on"
echo
" candidate: which candidate in the pool to test"
echo
" port: TCP port to bind the test web server, defaults to
$PORT
"
echo
" wait: how many seconds to wait for service bootstrap and checking, defaults to
$WAIT
"
echo
" wait: how many seconds to wait between service bootstrap and checking, defaults to
$WAIT
"
}
# Check for a config
...
...
@@ -83,14 +88,21 @@ if ! which tor &> /dev/null; then
exit
1
fi
# Create a folder where the daemon will run
# Create a folder where the daemon
s
will run
mkdir
-p
$POOL
/daemon
cd
$POOL
/daemon
# Launch a one-time minimal web server
# Invoking netcat with -q 1 to ensure it serves only a single request
echo
"Launching a minimal web server listening on
$SOCKET
..."
TMPFILE
=
"
`
mktemp
`
"
echo
-e
"HTTP/1.1 200 OK
\n\n
$NOUNCE
"
>
$TMPFILE
cat
$TMPFILE
| nc
-l
-q
1
-U
$SOCKET
&
# Launch Tor
echo
"Launching the Tor daemon with
$CANDIDATE
Onion Service..."
echo
"Launching the Tor daemon with
$CANDIDATE
Onion Service
listening on port
$PORT
..."
tor
--SocksPort
0
--RunAsDaemon
0
--HiddenServiceDir
$CANDIDATES
/
$CANDIDATE
\
--HiddenServicePort
"
$PORT
127.0.0.1:
$PORT
"
&
# --Log "info-err stdout"
--HiddenServicePort
"
$PORT
unix:
$SOCKET
"
&
# Waiting
echo
"Sleeping
$WAIT
seconds while the Onion Service is bootstrapped..."
...
...
@@ -98,12 +110,6 @@ sleep $WAIT
PIDS
=
"
$!
"
#echo "Background tasks: $PIDS"
# Launch a one-time minimal web server
echo
"Launching a minimal web server or port
$PORT
..."
TMPFILE
=
"
`
mktemp
`
"
echo
-e
"HTTP/1.1 200 OK
\n\n
$NOUNCE
"
>
$TMPFILE
cat
$TMPFILE
| nc
-l
-q
1
-p
$PORT
&
# Try to get the secret
echo
"Trying to fetch the secret random value
$NOUNCE
from the Onion Service..."
NOUNCE_OFFERED
=
"
`
torify curl
--no-progress-meter
--connect-timeout
$WAIT
http://
$CANDIDATE
:
$PORT
`
"
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment