-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/actions crawler #1
Open
meowsbits
wants to merge
3
commits into
ethereum:master
Choose a base branch
from
etclabscore:feat/actions-crawler
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh | ||
|
||
devp2p discv4 crawl -timeout "$ETH_DNS_DISCV4_CRAWLTIME" all.json |
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,20 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
proto_groups=(all les) | ||
|
||
for network in "$@"; do | ||
|
||
echo "Deploy: $network" | ||
|
||
for p in "${proto_groups[@]}"; do | ||
echo -n "Deploy: ${p}.${network}.${ETH_DNS_DISCV4_PARENT_DOMAIN}" | ||
|
||
# Ensure that we actually have a nodeset to deploy to DNS. | ||
[[ ! -d ${p}.${network}.${ETH_DNS_DISCV4_PARENT_DOMAIN} ]] || [[ ! -f ${p}.${network}.${ETH_DNS_DISCV4_PARENT_DOMAIN}/nodes.json ]] && { echo " | DNE, skipping"; continue; } | ||
|
||
echo | ||
devp2p dns to-cloudflare --zoneid "$ETH_DNS_CLOUDFLARE_ZONEID" "${p}.${network}.${ETH_DNS_DISCV4_PARENT_DOMAIN}" | ||
done | ||
done |
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,38 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
# Check programs we depend on. | ||
command -v devp2p >/dev/null 2>&1 && echo "OK: devp2p command in PATH" || { echo "Please install devp2p"; exit 1; } | ||
command -v ethkey >/dev/null 2>&1 && echo "OK: ethkey command in PATH" || { echo "Please install ethkey"; exit 1; } | ||
|
||
# Check that we have key and keypass file. | ||
if [ ! -f $ETH_DNS_DISCV4_KEY_PATH ] || [ ! -f $ETH_DNS_DISCV4_KEYPASS_PATH ]; then | ||
echo " | ||
No key found at key file path or no password file found at ${ETH_DNS_DISCV4_KEYPASS_PATH}. | ||
Use 'ethkey generate ${ETH_DNS_DISCV4_KEY_PATH}' | ||
Save the password in plaintext in ${ETH_DNS_DISCV4_KEYPASS_PATH} | ||
" | ||
exit 1 | ||
else | ||
echo "OK: Key and password file exist." | ||
fi | ||
|
||
# Check that we have deploy variables set. | ||
if [ -z $CLOUDFLARE_API_TOKEN ]; then | ||
echo "Missing CLOUDFLARE_API_TOKEN env var" | ||
exit 1 | ||
else | ||
echo "OK: environment variable CLOUDFLARE_API_TOKEN is not empty." | ||
fi | ||
|
||
# I'm not sure why I couldn't get devp2p to work without using the --zoneid flag; kept getting 403 bad perms. | ||
# Using the flag seems to fix it, and this var gets set as the value for that flag. | ||
# It's associated with the specific domain name that Cloudflare is managing and that we want to deploy to. | ||
if [ -z $ETH_DNS_CLOUDFLARE_ZONEID ]; then | ||
echo "Missing ETH_DNS_CLOUDFLARE_ZONEID env var" | ||
exit 1 | ||
else | ||
echo "OK: environment variable ETH_DNS_CLOUDFLARE_ZONEID is not empty." | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
proto_groups=(all les) | ||
|
||
for network in "$@"; do | ||
|
||
echo "Filter: $network" | ||
|
||
mkdir -p "all.${network}.${ETH_DNS_DISCV4_PARENT_DOMAIN}" | ||
devp2p nodeset filter all.json -eth-network "$network" >"all.${network}.${ETH_DNS_DISCV4_PARENT_DOMAIN}/nodes.json" | ||
|
||
mkdir -p "les.${network}.${ETH_DNS_DISCV4_PARENT_DOMAIN}" | ||
devp2p nodeset filter all.json -les-server -eth-network "$network" >"les.${network}.${ETH_DNS_DISCV4_PARENT_DOMAIN}/nodes.json" | ||
|
||
|
||
echo "Sign: $network" | ||
|
||
for p in "${proto_groups[@]}"; do | ||
echo -n "Sign: ${p}.${network}.${ETH_DNS_DISCV4_PARENT_DOMAIN}" | ||
|
||
# Ensure that we actually have a nodeset to sign. | ||
[ ! -d ${p}.${network}.${ETH_DNS_DISCV4_PARENT_DOMAIN} ] || [ ! -f ${p}.${network}.${ETH_DNS_DISCV4_PARENT_DOMAIN}/nodes.json ] && { echo " | DNE, skipping"; continue; } | ||
|
||
echo | ||
cat "${ETH_DNS_DISCV4_KEYPASS_PATH}" | devp2p dns sign "${p}.${network}.${ETH_DNS_DISCV4_PARENT_DOMAIN}" "${ETH_DNS_DISCV4_KEY_PATH}" && echo "OK" | ||
|
||
done | ||
|
||
done |
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,71 @@ | ||
name: Discv4 Crawl and DNS Update | ||
on: | ||
schedule: | ||
- cron: '0 */2 * * *' | ||
jobs: | ||
build: | ||
if: github.repository == 'ethereum/discv4-dns-lists' | ||
name: Discv4-DNS-Crawler | ||
runs-on: ubuntu-latest | ||
env: | ||
ETH_DNS_DISCV4_CRAWLTIME: 30m | ||
ETH_DNS_DISCV4_PARENT_DOMAIN: ethdisco.net | ||
ETH_DNS_DISCV4_KEY_PATH: ./secrets/dnskey.json | ||
ETH_DNS_DISCV4_KEYPASS_PATH: ./secrets/dnskey_password.txt | ||
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
ETH_DNS_CLOUDFLARE_ZONEID: ${{ secrets.ETH_DNS_CLOUDFLARE_ZONEID }} | ||
ETH_DNS_DISCV4_KEY: ${{ secrets.ETH_DNS_DISCV4_KEY }} | ||
ETH_DNS_DISCV4_KEYPASS: ${{ secrets.ETH_DNS_DISCV4_KEYPASS }} | ||
|
||
|
||
steps: | ||
- name: Set up Go | ||
uses: actions/setup-go@v2-beta | ||
with: | ||
go-version: 1.13.8 | ||
id: go | ||
|
||
- run: go version | ||
|
||
- name: Check out code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install dependencies | ||
run: | | ||
go get -u github.com/ethereum/go-ethereum/cmd/devp2p | ||
go get -u github.com/ethereum/go-ethereum/cmd/ethkey | ||
|
||
- name: Setup secrets | ||
run: | | ||
mkdir secrets | ||
echo "$ETH_DNS_DISCV4_KEY" > "$ETH_DNS_DISCV4_KEY_PATH" | ||
echo "$ETH_DNS_DISCV4_KEYPASS" > "$ETH_DNS_DISCV4_KEYPASS_PATH" | ||
|
||
- name: Check env and secrets | ||
run: | | ||
./.ci/deps.sh | ||
|
||
- name: Crawl | ||
run: | | ||
./.ci/crawl.sh | ||
|
||
- name: Filter and sign | ||
run: | | ||
./.ci/filter_and_sign.sh mainnet ropsten rinkeby goerli | ||
|
||
- name: Commit and Push | ||
env: | ||
GITHUB_USER: FIXME | ||
GITHUB_PAT: FIXME | ||
run: | | ||
git config --local user.name 'crawler' | ||
git config --local user.email '[email protected]' | ||
git add all* les* | ||
git commit --author 'crawler <>' -m "automatic update: crawl time ${ETH_DNS_DISCV4_CRAWLTIME} ci ${GITHUB_RUN_ID}:${GITHUB_RUN_NUMBER}" | ||
git remote set-url origin https://${GITHUB_USER}:${GITHUB_PAT}@github.com/${GITHUB_REPOSITORY}.git | ||
git push origin master | ||
Comment on lines
+65
to
+66
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Theoretically |
||
|
||
- name: Deploy to DNS | ||
run: | | ||
./.ci/deploy.sh mainnet ropsten rinkeby goerli | ||
|
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 @@ | ||
secrets/ |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will need to be changed if you're not using Cloudflare. Also, I was hitting a
quota exceeded
error when I had more than 1000 records, so some kind of error handling here might be needed.