From 2ae1313e9f89ba34103fee1400dc3d4222efd8c4 Mon Sep 17 00:00:00 2001 From: Advocaite Date: Sun, 8 Nov 2026 01:19:17 +0800 Subject: [PATCH] Support site: Breaking News box on the login and character screens With Forever Launcher 2.5.2 the client's Breaking News download comes to this site instead of Blizzard's: plain http on news_http_port (default 80, 0 = off), path /service/... It answers with breaking_news.html (sent as is) or breaking_news.txt (paragraphs) next to the script; no file or an empty one = no box. See breaking_news.html.example for what the game's SimpleHTML box renders. Also logs failed TLS handshakes on the main port (they were dropped silently). --- contrib/support_site/.gitignore | 2 + .../support_site/breaking_news.html.example | 12 ++++ .../support_site/breaking_news.txt.example | 6 ++ contrib/support_site/support_server.py | 70 ++++++++++++++++++- .../support_site/support_site.example.json | 1 + 5 files changed, 89 insertions(+), 2 deletions(-) create mode 100644 contrib/support_site/breaking_news.html.example create mode 100644 contrib/support_site/breaking_news.txt.example diff --git a/contrib/support_site/.gitignore b/contrib/support_site/.gitignore index 4d9e475d7a..b1a7d74614 100644 --- a/contrib/support_site/.gitignore +++ b/contrib/support_site/.gitignore @@ -1,2 +1,4 @@ support_site.json +breaking_news.html +breaking_news.txt __pycache__/ diff --git a/contrib/support_site/breaking_news.html.example b/contrib/support_site/breaking_news.html.example new file mode 100644 index 0000000000..35a5a9a53d --- /dev/null +++ b/contrib/support_site/breaking_news.html.example @@ -0,0 +1,12 @@ + + +

|cffffd100Welcome to our server!|r

+

|TInterface\Icons\INV_Misc_QuestionMark:20|t Server news goes here. |T134400:20|t

+

|cff1eff00Up|r: the realm is online.

+

Join us: |cff00ccff[Discord]|r

+ diff --git a/contrib/support_site/breaking_news.txt.example b/contrib/support_site/breaking_news.txt.example new file mode 100644 index 0000000000..4354b3c00b --- /dev/null +++ b/contrib/support_site/breaking_news.txt.example @@ -0,0 +1,6 @@ +Welcome to our WoW Forever server! + +Rename this file to breaking_news.txt and write your own news here; it shows in the +Breaking News box on the login and character screens. A blank line starts a new paragraph. +No breaking_news.txt (or an empty one) = no Breaking News box. +For headings, colours, links and icons use breaking_news.html instead (see breaking_news.html.example). diff --git a/contrib/support_site/support_server.py b/contrib/support_site/support_server.py index aecc0872df..bf6a36e7d3 100644 --- a/contrib/support_site/support_server.py +++ b/contrib/support_site/support_server.py @@ -632,6 +632,8 @@ class Handler(BaseHTTPRequestHandler): return self.armory(path) if path == '/favicon.ico': return self.send(404, b'', 'text/plain') + if path.startswith('/service/'): + return self.breaking_news() if not self.session: return self.page('Support', alert('info', 'Please open this page from the game: press Help (the question mark) ' 'in the main menu.'), status=403) @@ -645,6 +647,35 @@ class Handler(BaseHTTPRequestHandler): log('ERROR', traceback.format_exc()) self.page('Error', alert('bad', 'Something went wrong on our side. Please try again in a moment.'), status=500) + # The "Breaking News" box on the login and character screens. The client downloads it from + # https://breaking-news.support.blizzard.com/service////; the Forever Launcher (2.5.2+) + # points that URL at this site's plain http port (news_http_port, default 80: the download refuses our certificate). Answer + # like Blizzard's: "SERVERALERT:" and the message as HTML, from breaking_news.html or breaking_news.txt next to this file + # (read on every request, so editing needs no restart); missing or empty = no box. + def breaking_news(self): + log('breaking news requested:', self.path) + # breaking_news.html: sent as it is (the box is a game SimpleHTML frame, not a browser: see breaking_news.html.example) + try: + with open(os.path.join(HERE, 'breaking_news.html'), encoding='utf-8-sig') as f: + html = f.read().strip() + if html: + if not html.lower().startswith('%s

' % esc(p).replace('\n', '
') for p in text.replace('\r\n', '\n').split('\n\n') if p.strip()) + body = 'SERVERALERT:\n%s' % paragraphs + return self.send(200, body.encode('utf-8'), 'text/html; charset=UTF-8') + def send(self, status, body, content_type='text/html; charset=utf-8', headers=(), cache=False): self.send_response(status) self.send_header('Content-Type', content_type) @@ -2075,6 +2106,34 @@ def make_token(bnet_account_id, realm_id): urlencode({'token': token, 'ref': 'test'}))) +class NewsHandler(Handler): + """Plain HTTP (news_http_port, default 80): only the Breaking News; the game refuses certificates outside the Windows root store.""" + + def route(self, method): + if method == 'GET' and urlsplit(self.path).path.startswith('/service/'): + return self.breaking_news() + return self.send(404, b'', 'text/plain') + + +class TLSServer(ThreadingHTTPServer): + """TLS handshake per connection, in its thread: a failed handshake is logged (wrapping the listening socket drops it silently).""" + + def __init__(self, address, handler, ctx): + super().__init__(address, handler) + self.ctx = ctx + + def finish_request(self, request, client_address): + try: + conn = self.ctx.wrap_socket(request, server_side=True) + except (ssl.SSLError, OSError) as e: + log('TLS handshake from', client_address[0], 'failed:', e) + return + try: + super().finish_request(conn, client_address) + finally: + conn.close() + + def main(): args = sys.argv[1:] if args and args[0] == '--make-token': @@ -2084,8 +2143,15 @@ def main(): ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER) ctx.load_cert_chain(CFG['cert'], CFG['key']) threading.Thread(target=ensure_armory_export, daemon=True).start() - srv = ThreadingHTTPServer((CFG.get('listen', '0.0.0.0'), int(CFG.get('port', 443))), Handler) - srv.socket = ctx.wrap_socket(srv.socket, server_side=True) + srv = TLSServer((CFG.get('listen', '0.0.0.0'), int(CFG.get('port', 443))), Handler, ctx) + news_port = int(CFG.get('news_http_port', 80)) + if news_port: + try: + news = ThreadingHTTPServer((CFG.get('listen', '0.0.0.0'), news_port), NewsHandler) + threading.Thread(target=news.serve_forever, daemon=True).start() + log('breaking news (plain http) on port', news_port) + except OSError as e: + log('breaking news: port', news_port, 'not available:', e) log('support site on port', CFG.get('port', 443), '- RA', 'configured' if (CFG.get('ra') or {}).get('user') else 'not configured') srv.serve_forever() diff --git a/contrib/support_site/support_site.example.json b/contrib/support_site/support_site.example.json index beebb59c72..00140bdfd5 100644 --- a/contrib/support_site/support_site.example.json +++ b/contrib/support_site/support_site.example.json @@ -2,6 +2,7 @@ "server_name": "Forever", "listen": "0.0.0.0", "port": 443, + "news_http_port": 80, "public_host": "trinity.actual.battle.net", "cert": "F:/wow stuff/classic_re/certs/trinity_forever.cert.pem", "key": "F:/wow stuff/classic_re/certs/trinity_forever.key.pem",