mirror of https://github.com/vacp2p/10ksim.git
Add accelerated deployment initial script
This commit is contained in:
parent
bff7ea07c2
commit
13ac9c44a7
|
@ -0,0 +1,13 @@
|
|||
FROM alpine:latest
|
||||
|
||||
# Update the package repository and install bind-tools and wget
|
||||
RUN apk update && \
|
||||
apk add bind-tools wget bash && \
|
||||
# Create /app directory
|
||||
mkdir /app
|
||||
|
||||
ADD getenr.sh /app/getenr.sh
|
||||
|
||||
RUN chmod +x /app/getenr.sh
|
||||
|
||||
ENTRYPOINT ["/app/getenr.sh"]
|
|
@ -0,0 +1,50 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Find the IPv4 IPs of "zerotesting-service.zerotesting" using nslookup
|
||||
readarray -t pod_ips < <(nslookup zerotesting-service.zerotesting | awk '/^Address: / { print $2 }' | head -n 3)
|
||||
|
||||
# Prepare the directory for ENR data
|
||||
mkdir -p /etc/enr
|
||||
enr_file="/etc/enr/enr.env"
|
||||
> "$enr_file" # Clear the file to start fresh
|
||||
|
||||
# Function to validate ENR
|
||||
validate_enr() {
|
||||
if [[ $1 =~ ^enr:- ]]; then
|
||||
return 0 # Valid
|
||||
else
|
||||
return 1 # Invalid
|
||||
fi
|
||||
}
|
||||
|
||||
# Counter for valid ENRs
|
||||
valid_enr_count=0
|
||||
|
||||
# Get and validate the ENR data from up to three IPs
|
||||
for pod_ip in "${pod_ips[@]}"; do
|
||||
echo "Querying IP: $pod_ip"
|
||||
enr=$(wget -O - --post-data='{"jsonrpc":"2.0","method":"get_waku_v2_debug_v1_info","params":[],"id":1}' --header='Content-Type:application/json' "$pod_ip:8545" 2>/dev/null | sed -n 's/.*"enrUri":"\([^"]*\)".*/\1/p')
|
||||
|
||||
# Validate the ENR
|
||||
validate_enr "$enr"
|
||||
if [ $? -eq 0 ]; then
|
||||
# Save the valid ENR to the file
|
||||
((valid_enr_count++))
|
||||
echo "export ENR$valid_enr_count='$enr'" >> "$enr_file"
|
||||
if [ $valid_enr_count -eq 3 ]; then
|
||||
break # Exit loop after 3 valid ENRs
|
||||
fi
|
||||
else
|
||||
echo "Invalid ENR data received from IP $pod_ip"
|
||||
fi
|
||||
done
|
||||
|
||||
# Check if we got at least one valid ENR
|
||||
if [ $valid_enr_count -eq 0 ]; then
|
||||
echo "No valid ENR data received from any IPs"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Output for debugging
|
||||
echo "ENR data saved successfully:"
|
||||
cat "$enr_file"
|
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import socket
|
||||
import time
|
||||
import argparse
|
||||
from itertools import cycle
|
||||
|
||||
|
@ -39,15 +40,14 @@ def main(dns_servers):
|
|||
|
||||
# Print counts every iteration to show progress
|
||||
print(f"Processed {i + 1}/{args.nodes} hostnames, Success: {success_count}, Failures: {fail_count}")
|
||||
|
||||
# Print totals after every N attempts
|
||||
print(f"Round completed. Total successful DNS lookups: {success_count}, Total failed DNS lookups: {fail_count}")
|
||||
time.sleep(args.delay)
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description="Perform DNS lookups with specified target DNS server or system default")
|
||||
parser.add_argument("--target", help="IP address of the target DNS server", nargs='*', default=[])
|
||||
parser.add_argument("--accept-input", action="store_true", help="Accept a list of IP addresses from user input")
|
||||
parser.add_argument("--nodes", help="Number of nodes to resolve", type=int, default=1000)
|
||||
parser.add_argument("--delay", help="Delay in seconds", type=float, default=0.4)
|
||||
args = parser.parse_args()
|
||||
|
||||
dns_servers = args.target
|
||||
|
@ -60,3 +60,4 @@ if __name__ == "__main__":
|
|||
print("No specific DNS servers provided; using system default DNS settings.")
|
||||
|
||||
main(dns_servers)
|
||||
|
||||
|
|
Loading…
Reference in New Issue