M .hgsubstate +1 -1
@@ 1,4 1,4 @@
-c4ece8002e54388119bb11f2b39eb3fea2a652a7 library
+a0e003e939c69544c83ea22663ea8f76d78a0e02 library
1aa74e6d37b2cf853cb27aa192403846ca9f9143 src/lithe
5a97797856da2c6b1a18bf9fe591a64d58b04e19 src/pad
29a29937ee1095e5ddf1655902f1ed09c810bbf3 src/paf
M src/driver/krpcsrv.cpp +10 -0
@@ 118,6 118,14 @@ int main(int argn, const char* carg[]) {
std::stringstream config;
auto io = IO::CreateCompositeIO();
+ std::cout <<
+ "KRPCSRV; Kronos " KRONOS_PACKAGE_VERSION " Websocket REPL\n"
+ "(c)2017 - " KRONOS_BUILD_YEAR " Vesa Norilo, University of Arts Helsinki\n\n";
+
+ std::cout
+ << "Listening on port " << CL::port() << " for "
+ << (CL::wideopen() ? "!!!REMOTE!!!" : "local") << " connections\n";
+
Serve(CL::port(), CL::wideopen(), Route({
{ "echo", Responders::Websocket([](Responders::IWebsocketStream& wss) {
std::vector<char> buf;
@@ 131,6 139,8 @@ int main(int argn, const char* carg[]) {
Responders::Websocket([&](Responders::IWebsocketStream& wss) {
std::vector<char> buf;
+ std::cout << "[" << wss.GetHttpRequest().Peer << "] <- " << wss.GetHttpRequest().Uri << "\n";
+
auto cx = Kronos::CreateContext(Packages::CloudClient::ResolverCallback, &bbClient);
cx.SetAssetLinker(CachedAssetProvider, nullptr);
std::string coreRepo, coreVersion;
M src/network/http.h +1 -0
@@ 11,6 11,7 @@ namespace Sxx {
std::string Uri;
std::unordered_map<std::string, std::string> Headers;
std::vector<char> Body;
+ std::string Peer;
};
struct Response {
M src/network/router.cpp +8 -3
@@ 25,6 25,7 @@ namespace Sxx {
http::Response response;
auto uri = request.Uri.empty() ? "" : request.Uri.substr(1);
+ request.Peer = s.GetName();
r(s, http::UrlDecode(uri), request, response);
clientStream << response;
@@ 48,9 49,9 @@ namespace Sxx {
}
struct WebsocketStream : public IWebsocketStream {
- std::thread serverThread;
std::iostream& sock;
- WebsocketStream(std::iostream& s) :sock(s) {}
+ const http::Request& req;
+ WebsocketStream(const http::Request& req, std::iostream& s) :sock(s),req(req) {}
const char *Read(std::vector<char>& read) override {
return read_websocket(sock, read);
@@ 63,6 64,10 @@ namespace Sxx {
bool IsGood() override {
return sock.good() && !sock.eof();
}
+
+ const http::Request& GetHttpRequest() const {
+ return req;
+ }
};
Responder Websocket(std::function<void(IWebsocketStream&)> client) {
@@ 70,7 75,7 @@ namespace Sxx {
SocketBuffer sbuf(s);
std::iostream socketStream(&sbuf);
if (upgrade_websocket(req.Headers, socketStream)) {
- WebsocketStream wss(socketStream);
+ WebsocketStream wss{ req, socketStream };
client(wss);
}
};
M src/network/router.h +1 -0
@@ 18,6 18,7 @@ namespace Sxx {
virtual const char* Read(std::vector<char>&) = 0;
virtual void Write(const void*, size_t sz) = 0;
virtual bool IsGood() = 0;
+ virtual const http::Request& GetHttpRequest() const = 0;
};
Responder Websocket(std::function<void(IWebsocketStream&)>);
M src/website/md2json.cpp +1 -1
@@ 535,7 535,7 @@ int compile_page(const char *in, const c
auto md_str = md.str();
auto grammar = mini_markdown();
#ifndef NDEBUG
- lithe::trace = true;
+// lithe::trace = true;
#endif
auto parse = grammar->parse(md_str);
if (parse.is_error()) {
M version.txt +1 -1
@@ 1,1 1,1 @@
-0.14.3
No newline at end of file
+0.14.4
No newline at end of file