Skip to content

Commit bf64d96

Browse files
authored
Merge pull request #39 from hoytech/master
[pull] master from hoytech:master
2 parents a131ce6 + de1fee8 commit bf64d96

File tree

6 files changed

+26
-4
lines changed

6 files changed

+26
-4
lines changed

CHANGES

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ NEXT
1313
* Improvement to config file inline docs (n7ekb)
1414
* Added a new deployment script: `scripts/idempotent-vps-deploy.sh` (chr15m)
1515
* Better error reporting/handling when strfry.conf is malformed.
16+
* Print ANSI strfry logo when strfry is run with no arguments.
17+
Artwork thanks to Zen GT.
18+
* Serve a strfry logo for /favicon.ico
1619

1720
1.0.4
1821
* New config: maxReqFilterSize. This allows REQs with many more filters (jb55)

golpe

src/apps/relay/Favicon.h

Lines changed: 8 additions & 0 deletions
Large diffs are not rendered by default.

src/apps/relay/RelayWebsocket.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,18 @@
22

33
#include "StrfryTemplates.h"
44
#include "app_git_version.h"
5+
#include "Favicon.h"
56

67

78

8-
static std::string preGenerateHttpResponse(const std::string &contentType, const std::string &content) {
9+
static std::string preGenerateHttpResponse(const std::string &contentType, const std::string &content, const std::string &extraHeaders = "") {
910
std::string output = "HTTP/1.1 200 OK\r\n";
1011
output += std::string("Content-Type: ") + contentType + "\r\n";
1112
output += "Access-Control-Allow-Origin: *\r\n";
1213
output += "Connection: keep-alive\r\n";
1314
output += "Server: strfry\r\n";
1415
output += std::string("Content-Length: ") + std::to_string(content.size()) + "\r\n";
16+
output += extraHeaders;
1517
output += "\r\n";
1618
output += content;
1719
return output;
@@ -174,6 +176,8 @@ void RelayServer::runWebsocket(ThreadPool<MsgWebsocket>::Thread &thr) {
174176
return std::string_view(rendered); // memory only valid until next call
175177
};
176178

179+
std::string faviconResponse = preGenerateHttpResponse("image/x-icon", favicon(), "Cache-Control: public, max-age=31536000\r\n");
180+
177181

178182
{
179183
int extensionOptions = 0;
@@ -202,6 +206,8 @@ void RelayServer::runWebsocket(ThreadPool<MsgWebsocket>::Thread &thr) {
202206
} else if (url == "/nodeinfo/2.1") {
203207
auto nodeInfo = getNodeInfo21HttpResponse();
204208
res->write(nodeInfo.data(), nodeInfo.size());
209+
} else if (url == "/favicon.ico") {
210+
res->write(faviconResponse.data(), faviconResponse.size());
205211
} else if (req.getHeader("accept").toStringView() == "application/nostr+json") {
206212
auto info = getServerInfoHttpResponse();
207213
res->write(info.data(), info.size());

src/apps/relay/cmd_relay.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,12 @@ void RelayServer::run() {
7676
configFileChangeWatcher.setDebounce(100);
7777

7878
configFileChangeWatcher.run([&](){
79-
loadConfig(configFile);
80-
checkConfig();
79+
try {
80+
loadConfig(configFile);
81+
checkConfig();
82+
} catch (std::exception &e) {
83+
LE << "Error parsing config file, continuing with previous config: " << e.what();
84+
}
8185
});
8286

8387

src/tmpls/landing.tmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@
102102
padding: 8px 5px 8px 5px;
103103
}
104104
</style>
105+
<link rel="icon" href="/favicon.ico" type="image/x-icon">
105106
</head>
106107

107108
<body>

0 commit comments

Comments
 (0)