Skip to content

Commit

Permalink
open several variables to config file
Browse files Browse the repository at this point in the history
  • Loading branch information
kewlfft committed Mar 21, 2021
1 parent a3b1d11 commit 16dc7e1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ maxretain=2
```
minreliability=2
```
* The initial DNS server used for name resolution is the OpenNIC anycast 185.121.177.177, it can be changed:
```
initdns=1.1.1.1
```

[0]: https://www.opennicproject.org
[1]: https://www.archlinux.org
[2]: https://aur.archlinux.org/packages/opennic-up
Expand Down
26 changes: 12 additions & 14 deletions opennic-up
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
script="opennic-up"
version="0.98"
version="0.99"

resolvconf="/etc/resolv.conf"
usefile=0
Expand Down Expand Up @@ -74,19 +74,6 @@ for needed in $neededlist; do
exit 1
done

anycast="185.121.177.177"

# wait for network up 20s*4
log 'Checking network is up'
fping -q -t 20000 "$anycast"

# find out what the IP address of api is, fallback static IP address configured
apihost=api.opennic.org
apiip=$(dnslookup "$anycast" "$apihost")
echo $apiip
apiip=${apiip:-"116.203.98.109"}
log "Using $apiip as API host"

# source opennic-up config
configpathlist=(/etc ~/.config/opennic-up)
for p in "${configpathlist[@]}"; do
Expand All @@ -96,6 +83,17 @@ for p in "${configpathlist[@]}"; do
fi
done

initdns=${initdns:-"185.121.177.177"}
apihost=${apihost:-"api.opennic.org"}
# wait for network up 20000 = 20s*4
log "Waiting for $initdns"
if fping -q -t 20000 "$initdns"; then
# find out what the IP address of api is, fallback static IP address configured
apiip=$(dnslookup "$initdns" "$apihost")
fi
apiip=${apiip:-"116.203.98.109"}
log "Using $apiip as API host"

# record my IP in whitelist if my account login parameters have been provided
if [ -n "$user" -a -n "$auth" ]; then
logn "Updating whitelist with IP for user: $user "
Expand Down

0 comments on commit 16dc7e1

Please sign in to comment.