polish up tailscale scripts
This commit is contained in:
parent
dc3a2105c4
commit
92e6f5f0f2
3 changed files with 62 additions and 47 deletions
|
|
@ -31,7 +31,7 @@ alias jp = jj git push
|
||||||
alias js = jj status
|
alias js = jj status
|
||||||
alias jw = jj workspace update-stale
|
alias jw = jj workspace update-stale
|
||||||
|
|
||||||
def jm [...rest] {
|
def jm [-r: string = "@"] {
|
||||||
jj bookmark set main ...$rest
|
jj bookmark set main -r $r
|
||||||
jj git push
|
jj git push
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
alias nd = nix develop
|
alias nd = nix develop
|
||||||
|
|
||||||
def ns [package] {
|
def ns [package] {
|
||||||
nix shell $"nixpkgs#($package)"
|
nix shell $"nixpkgs#($package)"
|
||||||
}
|
}
|
||||||
|
|
||||||
def nr [package] {
|
def nr [package] {
|
||||||
nix search nixpkgs $package
|
nix search nixpkgs $package
|
||||||
}
|
}
|
||||||
|
|
@ -17,11 +19,13 @@ def rebuild --wrapped [subcommand, --builders: string, ...rest] {
|
||||||
}
|
}
|
||||||
toastify send rebuild done!
|
toastify send rebuild done!
|
||||||
}
|
}
|
||||||
|
|
||||||
def post-rebuild [] {
|
def post-rebuild [] {
|
||||||
rm -r ~/.config/helix/runtime/grammars/
|
rm -r ~/.config/helix/runtime/grammars/
|
||||||
hx --grammar fetch; hx --grammar build
|
hx --grammar fetch; hx --grammar build
|
||||||
rustup update
|
rustup update
|
||||||
}
|
}
|
||||||
|
|
||||||
def bump --wrapped [...rest] {
|
def bump --wrapped [...rest] {
|
||||||
cd /home/tao/projects/NOflake/
|
cd /home/tao/projects/NOflake/
|
||||||
jj new -m "bump"
|
jj new -m "bump"
|
||||||
|
|
@ -31,6 +35,7 @@ def bump --wrapped [...rest] {
|
||||||
rebuild boot ...$rest
|
rebuild boot ...$rest
|
||||||
jj new
|
jj new
|
||||||
}
|
}
|
||||||
|
|
||||||
alias rb = rebuild boot
|
alias rb = rebuild boot
|
||||||
alias rs = rebuild switch
|
alias rs = rebuild switch
|
||||||
alias gc = nh clean all
|
alias gc = nh clean all
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,18 @@
|
||||||
|
# see if others see us connecting from a mullvad exit node
|
||||||
def check-mullvad [] {
|
def check-mullvad [] {
|
||||||
loop {
|
print -n "checking mullvad status"
|
||||||
print "checking connection status"
|
mut check = false
|
||||||
http get https://am.i.mullvad.net/json
|
mut j = null
|
||||||
| if $in.mullvad_exit_ip == true {break} else {print $in}
|
while not $check {
|
||||||
sleep 1sec
|
print -n "."
|
||||||
|
$j = (http get https://am.i.mullvad.net/json)
|
||||||
|
$check = $j.mullvad_exit_ip
|
||||||
}
|
}
|
||||||
|
print ""
|
||||||
|
print $"connected to ($j.city), ($j.country)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# switch to a specific exit node, or none
|
||||||
def tse [exit_node: string = ""] {
|
def tse [exit_node: string = ""] {
|
||||||
if ($exit_node | is-empty) and (ps | find deluge | is-not-empty) {
|
if ($exit_node | is-empty) and (ps | find deluge | is-not-empty) {
|
||||||
return "stop summoning first!"
|
return "stop summoning first!"
|
||||||
|
|
@ -17,49 +24,52 @@ def tse [exit_node: string = ""] {
|
||||||
}
|
}
|
||||||
return "exit node set"
|
return "exit node set"
|
||||||
}
|
}
|
||||||
def tsp [] {
|
|
||||||
tailscale exit-node list
|
# list all mullvad exit nodes
|
||||||
| split row "\n"
|
def tsx [] {
|
||||||
| each {str trim}
|
tailscale exit-node list
|
||||||
| filter {is-not-empty}
|
| detect columns --guess
|
||||||
| skip 1
|
| drop 3
|
||||||
| last 19
|
| skip 1
|
||||||
| first 17
|
| where HOSTNAME =~ mullvad
|
||||||
| split column -r '\s{2,}'
|
| reject STATUS
|
||||||
| reject column5 column3
|
|
||||||
| rename ip addr city
|
|
||||||
| par-each {
|
|
||||||
insert ping {
|
|
||||||
|row| $row.addr
|
|
||||||
| str replace "mullvad.ts.net" "relays.mullvad.net"
|
|
||||||
| ping -c5 -q $in
|
|
||||||
| split row "\n"
|
|
||||||
| last
|
|
||||||
| split column "/"
|
|
||||||
| get column6?
|
|
||||||
| get 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
| sort-by ping -n -r
|
|
||||||
}
|
|
||||||
def tsr [] {
|
|
||||||
tailscale status --json
|
|
||||||
| from json
|
|
||||||
| get Peer
|
|
||||||
| transpose nodekey node
|
|
||||||
| get node
|
|
||||||
| filter {$in.Location?.Country == USA}
|
|
||||||
| get TailscaleIPs
|
|
||||||
| each {get 0}
|
|
||||||
| select (random int 0..($in | length))
|
|
||||||
| tse $in.0
|
|
||||||
# tailscale status
|
|
||||||
check-mullvad
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# sort mullvad exit nodes by fastest ping
|
||||||
|
def tsp [] {
|
||||||
|
tsx
|
||||||
|
| where COUNTRY == USA
|
||||||
|
| par-each {
|
||||||
|
insert ping {
|
||||||
|
$in.HOSTNAME
|
||||||
|
| str replace "mullvad.ts.net" "relays.mullvad.net"
|
||||||
|
| try {
|
||||||
|
print $"pinging ($in)"
|
||||||
|
ping -c5 -q $in
|
||||||
|
| lines
|
||||||
|
| last
|
||||||
|
| split row ' '
|
||||||
|
| get 3
|
||||||
|
| split row '/'
|
||||||
|
| get 1
|
||||||
|
| into float
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
| sort-by ping
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# switch to a random mullvad exit node
|
||||||
|
def tsr [] {
|
||||||
|
tsx
|
||||||
|
| get (random int 0..($in | length))
|
||||||
|
| tse $in.IP
|
||||||
|
}
|
||||||
|
|
||||||
alias ts = tailscale
|
alias ts = tailscale
|
||||||
alias tss = tailscale status
|
alias tss = tailscale status
|
||||||
alias tsu = tailscale up
|
alias tsu = tailscale up
|
||||||
alias tsd = tailscale down
|
alias tsd = tailscale down
|
||||||
alias tsx = tailscale exit-node list
|
|
||||||
alias tsa = tailscale exit-node suggest
|
alias tsa = tailscale exit-node suggest
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue