Skip to content
This repository has been archived by the owner on Jan 13, 2020. It is now read-only.

Replace server_hostname with server_url. #125

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ If you have any problems installing OpenWebRX, you should check out the <a href=

Sometimes the actual error message is not at the end of the terminal output, you may have to look at the whole output to find it.

If you want to run OpenWebRX on a remote server instead of *localhost*, do not forget to set *server_hostname* in `config_webrx.py`.
If you want to run OpenWebRX on a remote server instead of *localhost*, do not forget to set *server_url* in `config_webrx.py`.

## Licensing

Expand Down
19 changes: 15 additions & 4 deletions config_webrx.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,18 @@

# ==== Server settings ====
web_port=8073
server_hostname="localhost" # If this contains an incorrect value, the web UI may freeze on load (it can't open websocket)

# Set server_url to the (externally-visible) URL of the service,
# without a method (ie, without http://)
# (this need not have a trailing slash, though having it does no harm).
#
# When running locally, this will be simply localhost+port, but if the
# service is running behind a reverse proxy, this must be the
# externally visible URI.
#
# If this contains an incorrect value, the web UI may freeze on load (it can't open websocket)
server_url="localhost:" + web_port

max_clients=20

# ==== Web GUI configuration ====
Expand Down Expand Up @@ -207,10 +218,10 @@

nmux_memory = 50 #in megabytes. This sets the approximate size of the circular buffer used by nmux.

#Look up external IP address automatically from icanhazip.com, and use it as [server_hostname]
#Look up external IP address automatically from icanhazip.com, and use it as [server_url]
"""
print "[openwebrx-config] Detecting external IP address..."
import urllib2
server_hostname=urllib2.urlopen("http://icanhazip.com").read()[:-1]
print "[openwebrx-config] External IP address detected:", server_hostname
server_url=urllib2.urlopen("http://icanhazip.com").read()[:-1]
print "[openwebrx-config] External IP address detected:", server_url
"""
11 changes: 6 additions & 5 deletions htdocs/openwebrx.js
Original file line number Diff line number Diff line change
Expand Up @@ -1692,11 +1692,12 @@ String.prototype.startswith=function(str){ return this.indexOf(str) == 0; }; //h

function open_websocket()
{
//if(ws_url.startswith("ws://localhost:")&&window.location.hostname!="127.0.0.1"&&window.location.hostname!="localhost")
//{
//divlog("Server administrator should set <em>server_hostname</em> correctly, because it is left as <em>\"localhost\"</em>. Now guessing hostname from page URL.",1);
ws_url="ws://"+(window.location.origin.split("://")[1])+"/ws/"; //guess automatically -> now default behaviour
//}
// Determine the home URL based on the current location
ws_url = "ws://" + window.location.host + window.location.pathname + "ws/";
// We would like something like the following, but the URL() constructor doesn't
// do any useful URL normalisation.
//ws_url = new URL("ws/", "ws://" + window.location.host + window.location.pathname);

if (!("WebSocket" in window))
divlog("Your browser does not support WebSocket, which is required for WebRX to run. Please upgrade to a HTML5 compatible browser.");
ws = new WebSocket(ws_url+client_id);
Expand Down
4 changes: 2 additions & 2 deletions openwebrx.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ def proc_read_thread():
def send_302(self,what):
self.send_response(302)
self.send_header('Content-type','text/html')
self.send_header("Location", "http://{0}:{1}/{2}".format(cfg.server_hostname,cfg.web_port,what))
self.send_header("Location", "http://{0}/{1}".format(cfg.server_url,what))
self.end_headers()
self.wfile.write("<html><body><h1>Object moved</h1>Please <a href=\"/{0}\">click here</a> to continue.</body></html>".format(what))

Expand Down Expand Up @@ -670,7 +670,7 @@ def do_GET(self):
replace_dictionary=(
("%[RX_PHOTO_DESC]",cfg.photo_desc),
("%[CLIENT_ID]", generate_client_id(self.client_address[0])) if "%[CLIENT_ID]" in data else "",
("%[WS_URL]","ws://"+cfg.server_hostname+":"+str(cfg.web_port)+"/ws/"),
("%[WS_URL]","ws://"+cfg.server_url+"/ws/"),
("%[RX_TITLE]",cfg.receiver_name),
("%[RX_LOC]",cfg.receiver_location),
("%[RX_QRA]",cfg.receiver_qra),
Expand Down
2 changes: 1 addition & 1 deletion sdrhu.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def run(continuously=True):
if not cfg.sdrhu_key: return
firsttime="(Your receiver is soon getting listed on sdr.hu!)"
while True:
cmd = "wget --timeout=15 -4qO- https://sdr.hu/update --post-data \"url=http://"+cfg.server_hostname+":"+str(cfg.web_port)+"&apikey="+cfg.sdrhu_key+"\" 2>&1"
cmd = "wget --timeout=15 -4qO- https://sdr.hu/update --post-data \"url=http://"+cfg.server_url+"&apikey="+cfg.sdrhu_key+"\" 2>&1"
print "[openwebrx-sdrhu]", cmd
returned=subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE).communicate()
returned=returned[0]
Expand Down