hashbang / hashbang.sh

Public facing website on hashbang.sh with embedded user creation script.
http://hashbang.sh
MIT License
141 stars 22 forks source link

"Choose a server" table is misformatted #117

Closed sersorrel closed 7 years ago

sersorrel commented 7 years ago

There's no column for coordinates in the table, so it looks a little broken currently:

 Please choose a server to create your account on.

-------------------------------------------------------------------------
  # | Host | Location                             | Users    | Latency 
-------------------------------------------------------------------------
  1 | ny1  | New York City, New York, USA         | 793/500|{'lat': 40.7, 'lon': -74} | 88.0 ms 
  2 | to1  | Toronto, Ontario, Canada             | 368/500|{'lat': 43.7, 'lon': -79.4} | 97.1 ms 
  3 | da1  | Dallas, Texas, USA                   | 299/500|{'lat': 32.8, 'lon': -96.8} | 131 ms  
  4 | sf1  | San Francisco, California, USA       | 443/500|{'lat': 37.8, 'lon': -122.4} | 168 ms  
-------------------------------------------------------------------------

$host_data currently looks like this:

ny1.hashbang.sh|45.58.35.111|New York City, New York, USA|793|500|{'lat': 40.7, 'lon': -74}

and I suspect that line 283 of hashbang.sh

while IFS="|" read -r host _ location current_users max_users; do

should look more like

while IFS="|" read -r host _ location current_users max_users _; do

In other words, please apply the following patch:

--- a/hashbang.sh       2017-09-03 11:42:37.255250144 +0100
+++ b/hashbang.sh       2017-09-03 11:45:29.901432710 +0100
@@ -280,7 +280,7 @@
 printf -- '  %-1s | %-4s | %-36s | %-8s | %-8s\n' \
        "#" "Host" "Location" "Users" "Latency"
 printf -- ' %72s\n' | tr ' ' -;
-while IFS="|" read -r host _ location current_users max_users; do
+while IFS="|" read -r host _ location current_users max_users _; do
        host=$(echo "$host" | sed 's/\([a-z0-9]\+\)\..*/\1/g')
        latency=$(ping -c 1 "${host}.hashbang.sh" | awk -F'=' '/time=[0-9]+/ { print $NF }')
        n=$((n+1))

Disclaimer: this works on my machine, but may not be POSIX, may explode violently in shells other than bash, etc. etc.

KellerFuchs commented 7 years ago

Oops, thanks for the patch. ( FWIW, you can also submit pull requests on any of our repos ;) )