forked from hyperledger/indy-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
INDY-1087: re-organise indy iptables scripts for ease of use. (hyperl…
…edger#523) * INDY-1087: re-organise indy iptables scripts for ease of use. Signed-off-by: Sergey Shilov <[email protected]> * Add setup iptables instruction to start-nodes.md Signed-off-by: Sergey Shilov <[email protected]>
- Loading branch information
1 parent
e92c731
commit b86c430
Showing
5 changed files
with
64 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,14 @@ | ||
#!/bin/bash | ||
|
||
if [ $# -lt 2 ]; then | ||
echo "" | ||
echo "Usage: $0 client_port connlimit"; | ||
echo " client_port - node client port"; | ||
echo " connlimit - clients connections limit"; | ||
echo "" | ||
exit 1; | ||
fi | ||
GENERAL_CONFIG_DIR="/etc/indy" | ||
|
||
ENVFILE=$GENERAL_CONFIG_DIR/indy.env | ||
|
||
# Check whether iptables installed and works | ||
dpkg -s iptables 2>/dev/null 1>&2 && iptables -L 2>/dev/null 1>&2 | ||
if [ $? -eq 0 ]; then | ||
# Add iptables rule to limit the number of simultaneous clients connections | ||
iptables -I INPUT -p tcp --syn --dport $1 \\ | ||
-m connlimit --connlimit-above $2 --connlimit-mask 0 \\ | ||
-j REJECT --reject-with tcp-reset | ||
if [ -f $ENVFILE ]; then | ||
source $ENVFILE | ||
else | ||
echo "Warning: iptables is not installed or permission denied, clients connections limit is not set." | ||
echo "Indy-node environment file does not exist ($ENVFILE), run init_indy_node first." | ||
exit 1 | ||
fi | ||
|
||
/usr/local/bin/setup_iptables $NODE_CLIENT_PORT $CLIENT_CONNECTIONS_LIMIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/bash | ||
|
||
if [ $# -lt 2 ]; then | ||
echo "" | ||
echo "Usage: $0 client_port connlimit"; | ||
echo " client_port - node client port"; | ||
echo " connlimit - clients connections limit"; | ||
echo "" | ||
exit 1; | ||
fi | ||
|
||
# Check whether iptables installed and works | ||
dpkg -s iptables 2>/dev/null 1>&2 && iptables -L 2>/dev/null 1>&2 | ||
if [ $? -eq 0 ]; then | ||
# Add iptables rule to limit the number of simultaneous clients connections | ||
iptables -I INPUT -p tcp --syn --dport $1 \\ | ||
-m connlimit --connlimit-above $2 --connlimit-mask 0 \\ | ||
-j REJECT --reject-with tcp-reset | ||
else | ||
echo "Warning: iptables is not installed or permission denied, clients connections limit is not set." | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters