-
Notifications
You must be signed in to change notification settings - Fork 13
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
auto-reroute is out of date #20
Comments
It as unfortunately been broken for a little while, but not for a lack of trying... See https://github.com/feralhosting/feralfilehosting/issues/74 |
I wrote this quick script to accomplish a similar task. Since the test files are not available, the approach is to download a test file via sftp and set the route via the best speed. I don't know if I am computing download speed correctly, I just did import sys
import os
import time
from bs4 import BeautifulSoup
import requests
import pysftp
USERNAME = 'USER'
PASSWORD = 'PASSWORD'
HOSTNAME = 'HOST'
REMOTEPATH = '/path/to/your/file'
LOCALPATH = '/download/file/path'
def get_download_speed():
try:
con = pysftp.Connection(HOSTNAME, username=USERNAME, password=PASSWORD)
size_mb = con.stat(REMOTEPATH).st_size / 1000000.0
t0 = time.time()
con.get(REMOTEPATH, localpath=LOCALPATH)
t1 = time.time()
os.remove(LOCALPATH)
except: raise
finally: con.close()
return size_mb / (t1-t0)
def make_soup():
res = requests.get('https://network.feral.io/reroute')
if res.status_code != 200:
raise Exception('The Feral reroute tool is unavailable at this time. Fuhgeddaboudit...')
return BeautifulSoup(res.content, "lxml")
def get_current_route_addr():
return (
make_soup()
.find('ul',{'class':'next_hops'})
.find('input', {'checked':'checked'})
['value']
)
def set_route(addr):
res = requests.post('https://network.feral.io/reroute', data=dict(nh=addr))
if '''<aside class="alert error">''' in res.content:
raise Exception('A valid next hop was not selected. Fuhgeddaboudit...')
return res
def get_current_routes():
reroute_ul = make_soup().find('ul',{'class':'next_hops'})
route_addrs = map(lambda x: x['value'], reroute_ul.findAll('input'))
route_names = map(lambda x: x.find('span').previous_element.strip(), reroute_ul.findAll('label'))
return zip(route_names, route_addrs)
def wait_for_change_to(addr, attempts=5, timeout=0.2):
for attempt in range(attempts):
current = get_current_route_addr()
if current==addr: return None
time.sleep(timeout)
s = 'Route did not change after {n} checks. Last route was: {curr} and you asked for {addr}.'
raise Exception(s.format(n=attempts, curr=current, addr=addr))
best_speed, best_route = -1.0, []
for name, addr in get_current_routes():
sys.stdout.write('\nTesting download speed from {name} ({addr})'.format(name=name, addr=addr))
sys.stdout.flush()
set_route(addr)
wait_for_change_to(addr)
mbps = get_download_speed()
sys.stdout.write(' ... {mbps:0.3f} MB/s.'.format(mbps=mbps))
sys.stdout.flush()
if mbps > best_speed:
best_route = (name, addr)
best_speed = mbps
# set best route
mbps = best_speed
name, addr = best_route
sys.stdout.write(
'\nThe best speed ({mbps:0.3f} MB/s) was obtained via {name} ({addr}). Setting that route...'
.format(name=name, addr=addr, mbps=mbps)
)
sys.stdout.flush()
set_route(addr)
wait_for_change_to(addr)
sys.stdout.write('Done!') |
You know what? The byte-sized app works for Feral, i tested it to confirm it updates the https://network.feral.io/reroute after running. https://bytesized-hosting.com/pages/rerouting (i used the x64 binary) It makes sense it would as they are running from Feral's network so in theory the the result should be the same. Try it and see for yourself. |
i put in a ticket with feral to see if they had any plans to re-enable the old speedtest files, then this will start working again |
I think the byte sized app has one file. It changes the route then downloads it, repeating until the test is complete. |
The routes are not up-to-date! So this no longer works. Output looks like this:
I am writing a Python version of this script that automagically grabs the relevant routes but I am not sure where you're finding the
test_files
. Would be glad to share my script when written, or to swap out your script (which is still run daily on my network) with updated values.The text was updated successfully, but these errors were encountered: