Skip to content

Commit ba4823e

Browse files
BertBert
authored andcommitted
Merge branch 'master' into GH-598
2 parents 009e9a2 + cbbd79f commit ba4823e

File tree

95 files changed

+9382
-708
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+9382
-708
lines changed

.githooks/pre-commit

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
# File to check (relative to repo root)
4+
FILENAME="ip_country/src/dbip_country.rs"
5+
6+
if ! git diff --cached --name-only | grep -q "^$FILENAME$"; then
7+
exit 0
8+
fi
9+
10+
# find 'Nonexistents' country in dbip_country.rs
11+
@cat "$FILENAME" | grep '("NOEX", "Nonexistent")'
12+
NONEXISTENT=$?
13+
14+
# Get local file size (staged version, not working copy)
15+
LOCAL_SIZE=$(git ls-files --stage | grep "$FILENAME" | awk '{print $2}' | xargs git cat-file -s)
16+
17+
if [[ $LOCAL_SIZE -gt 1000000 || NONEXISTENT -gt 0 ]]; then
18+
if [[ $LOCAL_SIZE -gt 1000000 ]]; then
19+
echo "❌ Commit blocked: $FILENAME size it not dev version, we want to keep dev version under 1 MB."
20+
echo " Local file size: $LOCAL_SIZE bytes"
21+
fi
22+
if [[ $NONEXISTENT -gt 0 ]]; then
23+
echo "❌ Commit blocked: Dev file must contain '(\"NOEX\", \"Nonexistents\")' country"
24+
fi
25+
echo ""
26+
echo " ⚡ Please sync the file with the remote before committing using:"
27+
echo " git checkout HEAD -- ip_country/src/dbip_country.rs"
28+
exit 1
29+
fi
30+
31+
# All good
32+
exit 0

.github/workflows/ci-matrix.yml

Lines changed: 41 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
name: Build node on ${{ matrix.target.os }}
2121
runs-on: ${{ matrix.target.os }}
2222
steps:
23-
- uses: actions/checkout@v3
23+
- uses: actions/checkout@v4
2424
with:
2525
ref: ${{ github.event.pull_request.head.sha }}
2626

@@ -36,7 +36,8 @@ jobs:
3636
toolchain: 1.63.0
3737
components: rustfmt, clippy
3838
override: true
39-
- uses: actions/cache@v3
39+
40+
- uses: actions/cache@v4
4041
with:
4142
path: |
4243
~/.cargo/bin/
@@ -45,10 +46,13 @@ jobs:
4546
~/.cargo/registry/cache/
4647
~/.cargo/git/db/
4748
target/
48-
key: ${{ runner.os }}-cargo
49+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
50+
restore-keys: |
51+
${{ runner.os }}-cargo-
4952
5053
- name: Build ${{ matrix.target.os }}
5154
run: |
55+
git fetch
5256
./ci/all.sh
5357
./ci/multinode_integration_test.sh
5458
./ci/collect_results.sh
@@ -59,49 +63,59 @@ jobs:
5963
with:
6064
name: Node-${{ matrix.target.name }}
6165
path: results
62-
66+
- name: diagnostics
67+
if: failure()
68+
run: |
69+
echo "final disc diagnostics ------>"
70+
df -h /Users/runner/work/Node/Node/node/target/release
6371
deploy_to_s3:
6472
needs: build
73+
if: success() && (startsWith(github.head_ref, 'GH') || startsWith(github.head_ref, 'v'))
6574
strategy:
6675
matrix:
67-
os: [linux, macos, windows]
68-
runs-on: ubuntu-22.04
76+
os: [linux, macos, windows]
77+
runs-on: ubuntu-latest
6978
steps:
70-
- uses: actions/checkout@v3
79+
- uses: actions/checkout@v4
7180
with:
7281
ref: ${{ github.event.pull_request.head.sha }}
82+
fetch-depth: 1
7383

7484
- name: Download artifacts
7585
uses: actions/download-artifact@v4
7686

7787
- name: Display structure of downloaded files
7888
run: ls -R
7989

90+
- name: Check artifacts exist
91+
run: |
92+
if [ ! -d "Node-${{ matrix.os }}/generated/bin/" ]; then
93+
echo "Error: Build artifacts not found"
94+
exit 1
95+
fi
96+
97+
- name: Configure AWS Credentials
98+
uses: aws-actions/configure-aws-credentials@v4
99+
with:
100+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
101+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
102+
aws-region: us-west-2
103+
80104
- if: startsWith(github.head_ref, 'GH')
81105
name: Versioned S3 Sync
82-
uses: jakejarvis/s3-sync-action@v0.5.1
83-
with:
84-
args: --acl private --follow-symlinks --delete
85-
env:
86-
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
87-
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
88-
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
89-
AWS_REGION: 'us-west-2'
90-
DEST_DIR: 'Node/${{ github.head_ref }}/Node-${{ matrix.os }}'
91-
SOURCE_DIR: 'Node-${{ matrix.os }}/generated/bin/'
106+
run: |
107+
aws s3 sync "Node-${{ matrix.os }}/generated/bin/" "s3://${{ secrets.AWS_S3_BUCKET }}/Node/${{ github.head_ref }}/Node-${{ matrix.os }}" \
108+
--delete \
109+
--no-progress \
110+
--acl private
92111
93112
- if: startsWith(github.head_ref, 'v')
94113
name: Latest S3 Sync
95-
uses: jakejarvis/s3-sync-action@v0.5.1
96-
with:
97-
args: --acl private --follow-symlinks --delete
98-
env:
99-
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
100-
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
101-
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
102-
AWS_REGION: 'us-west-2'
103-
DEST_DIR: 'Node/latest/Node-${{ matrix.os }}'
104-
SOURCE_DIR: 'Node-${{ matrix.os }}/generated/bin/'
114+
run: |
115+
aws s3 sync "Node-${{ matrix.os }}/generated/bin/" "s3://${{ secrets.AWS_S3_BUCKET }}/Node/latest/Node-${{ matrix.os }}" \
116+
--delete \
117+
--no-progress \
118+
--acl private
105119
106120
- name: Invalidate Binaries CloudFront
107121
uses: chetan/invalidate-cloudfront-action@v2.4
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Download DBIP data and generate dbip_country.rs
2+
3+
on:
4+
schedule:
5+
- cron: "0 0 3 * *" # Runs at midnight on the 3rd of every month
6+
7+
env:
8+
TEMP_DIR: '/tmp'
9+
YEAR_MONTH: '01-9999'
10+
11+
permissions:
12+
contents: write
13+
14+
jobs:
15+
generate:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
21+
- name: Set up Rust
22+
uses: actions-rs/toolchain@v1
23+
with:
24+
toolchain: stable
25+
26+
- name: Download DBIP data in MMDB format
27+
run: |
28+
export YEAR_MONTH=$(date +%Y-%m)
29+
echo "TEMP_DIR=$(mktemp -d)" >> $GITHUB_ENV
30+
echo "YEAR_MONTH=$YEAR_MONTH" >> $GITHUB_ENV
31+
cd ip_country
32+
mkdir -p dbip-data
33+
curl -L -o dbip-data/dbip-country-lite.mmdb.gz "https://download.db-ip.com/free/dbip-country-lite-$YEAR_MONTH.mmdb.gz"
34+
gunzip dbip-data/dbip-country-lite.mmdb.gz
35+
36+
- name: Generate Rust source file
37+
run: |
38+
cd ip_country
39+
cargo run < "dbip-data/dbip-country-lite.mmdb" > "$TEMP_DIR"/dbip_country.rs
40+
ls "$TEMP_DIR"
41+
42+
- name: Commit and push generated file
43+
run: |
44+
git config user.name "github-actions[bot]"
45+
git config user.email "github-actions[bot]@users.noreply.github.com"
46+
git fetch
47+
BRANCH="$(git ls-remote --exit-code --heads origin generated-source 2>/dev/null || true)"
48+
if [[ "$BRANCH" == "" ]]
49+
then
50+
git checkout -B generated-source
51+
git rm -rf .
52+
mkdir -p ip_country/src
53+
else
54+
git checkout generated-source
55+
fi
56+
DIFF="$(diff "${TEMP_DIR}"/dbip_country.rs ip_country/src/dbip_country.rs || true)"
57+
if [[ "$DIFF" != "" || "$BRANCH" == "" ]]
58+
then
59+
mv "${TEMP_DIR}"/dbip_country.rs ip_country/src/dbip_country.rs
60+
git add ip_country/src/dbip_country.rs
61+
git commit -m "Update generated dbip_country ${YEAR_MONTH} Rust source file" || true
62+
git push -u origin HEAD
63+
fi

.idea/modules.xml

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

USER-INTERFACE-INTERFACE.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,75 @@ descriptor (for example, if it's still waiting on the router to get a public IP
590590
Node descriptor (for example, if its neighborhood mode is not Standard), the `nodeDescriptorOpt`
591591
field will be null or absent.
592592

593+
#### `exit-location`
594+
##### Direction: Request
595+
##### Correspondent: Node
596+
##### Layout:
597+
```
598+
"payload": {
599+
"fallbackRouting": <boolean>,
600+
"exitLocations": [
601+
{
602+
"countryCodes": [string, ..],
603+
"priority": <positive integer>
604+
},
605+
],
606+
"showCountries": <boolean>
607+
}
608+
```
609+
##### Description:
610+
This command requests information about the countries available for exit in our neighborhood and allows us to set up the
611+
desired locations with their priority. The priority provides the node's perspective on how important a particular country
612+
is for our preferences.
613+
614+
This command can be used in two ways which can't be combined:
615+
1. If we use the command with showCountries set to true.
616+
2. If we want to set an exit location.
617+
618+
In case 1. it retrieves information about the available countries in our neighborhood. Other parameters are
619+
ignored.
620+
621+
In case 2. we must set showCountries to false and then configure fallbackRouting and exitLocations with our preferences.
622+
623+
The `fallbackRouting` parameter is defaulted as `false`, if not provided. Determines whether we want to block exit for a particular
624+
country. If parameter is `false` and requested country is no longer available, the route to exit will fail during construction.
625+
If is set to `true`, we can exit through any available country if none of our specified exitLocations are accessible.
626+
627+
Priorities are used to determine the preferred exit countries. Priority 1 is the highest, while higher numbers indicate
628+
lower priority. For example, if we specify DE with priority 1 and FR with priority 2, then an exit through France will
629+
only be used if a German exit is unavailable or significantly more expensive.
630+
631+
#### `exit-location`
632+
##### Direction: Response
633+
##### Correspondent: UI
634+
##### Layout:
635+
636+
```
637+
"payload": {
638+
"fallbackRouting": <boolean>,
639+
"exitCountrySelection": <[
640+
{
641+
"countryCodes": [string, ..],
642+
"priority": <positive integer>
643+
},
644+
]>,
645+
"missingCountries": <[string, ..]>
646+
"exitCountries": <optional[string, ..]>
647+
}
648+
```
649+
##### Description:
650+
In response, the Node sends a payload to the UI that contains either the Exit Location settings (which may include missing
651+
countries) or a list of exit countries.
652+
653+
Exit Location settings consist of fallbackRouting, exitCountrySelection, and missingCountries, where:
654+
1. fallbackRouting is a boolean representing the user's choice to enable or disable fallback routing within the neighborhood.
655+
2. exitCountrySelection is an array of objects, where each object represents a set of country codes along with their assigned priority.
656+
3. missingCountries is an array of strings representing a list of countries that are currently unavailable in the Node's Neighborhood Database.
657+
658+
Exit Countries (or exitCountries) is an optional array containing ISO country code strings. These represent the countries
659+
currently available in the Node's Neighborhood Database. The user can select from these countries to configure the Exit
660+
Location settings.
661+
593662
#### `financials`
594663
##### Direction: Request
595664
##### Correspondent: Node

0 commit comments

Comments
 (0)