diff options
author | onefang | 2020-02-27 11:18:47 +1000 |
---|---|---|
committer | onefang | 2020-02-27 11:18:47 +1000 |
commit | 34c5ee4c2a489a506e93d5b303fbc80b263747f0 (patch) | |
tree | 53e5f29e16929503a1171a0e251249c0396c5f50 /src/NOTES.txt | |
parent | Add a default gloebit config file, coz it doesn't like it if it doesn't exist. (diff) | |
download | opensim-SC-34c5ee4c2a489a506e93d5b303fbc80b263747f0.zip opensim-SC-34c5ee4c2a489a506e93d5b303fbc80b263747f0.tar.gz opensim-SC-34c5ee4c2a489a506e93d5b303fbc80b263747f0.tar.bz2 opensim-SC-34c5ee4c2a489a506e93d5b303fbc80b263747f0.tar.xz |
The new sledjchisl binary, to replace the management scripts and web stuff.
Diffstat (limited to 'src/NOTES.txt')
-rw-r--r-- | src/NOTES.txt | 183 |
1 files changed, 183 insertions, 0 deletions
diff --git a/src/NOTES.txt b/src/NOTES.txt new file mode 100644 index 0000000..1758ac8 --- /dev/null +++ b/src/NOTES.txt | |||
@@ -0,0 +1,183 @@ | |||
1 | I'm re-purposing this for SledjHamr https://sledjhamr.org/git/docs/index.html | ||
2 | |||
3 | The general structure of SledjHamr is a bunch of servers talking to each | ||
4 | other via Internet (or just local) connections. One of them is a web | ||
5 | server for assets, world data, and inventory. | ||
6 | |||
7 | Originally I didn't think using a web based world client was a good idea, | ||
8 | however it might be better to have one, for reasons. Now I need a web | ||
9 | management console that can do all the things the current tmux console | ||
10 | can, including OpenSim console and commands. Plus account management for | ||
11 | users. I can also use a web based Jabber / XMPP front end to chat, IM, | ||
12 | and group chatter, which would run in the normal viewers web browser. | ||
13 | This provides a doorway into putting SledjHamr stuff in existing viewers | ||
14 | without needing them to support it. So a web based viewer now makes more | ||
15 | sense, and also means we can get away with not needing a viewer at all. | ||
16 | |||
17 | Toybox itself doesn't include a web server, and I don't think there is | ||
18 | one on the roadmap. So we have to use an external web server, which was | ||
19 | a design goal of SledjHamr in the first place, using existing mature | ||
20 | HTTP infrastructure, coz that's already solved problems for a bunch of | ||
21 | things that plague OS/SL to this day. Clear your cache! Pffft. | ||
22 | |||
23 | So sledjchisl.c will be the "love world server", though initially it just | ||
24 | drives OpenSim_SC in tmux via tmux commands to send keys and read output. | ||
25 | Later it might run opensim_SC directly and use STDIN and STDOUT to do | ||
26 | everything. It'll also provide the text management front end that runs | ||
27 | in the left tmux panel of the first window, which is why it's based on | ||
28 | boxes in the first place. Later still it can take over opensim_SC | ||
29 | functions as I move them out of mono. | ||
30 | |||
31 | We will need a text, web, and GUI version of this management front end. | ||
32 | Hmmm, maybe don't need a GUI version, GUI users can just run a terminal. | ||
33 | |||
34 | After much research, FastCGI / FCGI seems to be the most portable way of | ||
35 | interfacing with existing web servers. FCGI protocol closes STDERR and | ||
36 | STDOUT, and uses STDIN as it's two way communications channel to the web | ||
37 | server, so our FCGI module can't be used as the text management front | ||
38 | end. This is probably a good idea to keep them seperate anyway, for | ||
39 | security, coz the web server is exposed to the world, the console isn't. | ||
40 | |||
41 | Currently sledjchisl.c tests to see if it's running in tmux already, if | ||
42 | it isn't it starts up tmux runs itself into this new tmux, then exits. | ||
43 | So it could also test if it's running from FCGI, and switch to web mode, | ||
44 | then it'll need to find the tmuxed instance to send commands to it. | ||
45 | Either via nails connection, or sending tmux commands via shell. | ||
46 | |||
47 | FCGI has methods of dealing with auth and templates. B-) | ||
48 | |||
49 | So for now I think I'll have the text and web management front ends in | ||
50 | sledjchisl.c, and the love world server as well. I can split them up | ||
51 | later if I need to. | ||
52 | |||
53 | |||
54 | |||
55 | |||
56 | I has Apache 2.4.25-3+deb9u9 | ||
57 | MariaDB 10.1.44-MariaDB | ||
58 | |||
59 | |||
60 | https://gist.github.com/dermesser/e2f9b66457ae19ebd116 | ||
61 | Multithreaded example in C. | ||
62 | |||
63 | |||
64 | ------------------------------------------------------------------- | ||
65 | |||
66 | Apache doesn't seem to support FCGI filter role, so I might have to do | ||
67 | without. Might be better anyway. | ||
68 | |||
69 | |||
70 | "A Filter is similar in functionality to a Responder that takes a data | ||
71 | file as a parameter. The difference is that with a Filter, both the data | ||
72 | file and the Filter itself can be access controlled using the Web | ||
73 | server's access control mechanisms, while a Responder that takes the name | ||
74 | of a data file as a parameter must perform its own access control checks | ||
75 | on the data file." | ||
76 | |||
77 | Which is fine, our access control checks will be "Is this database | ||
78 | defined user already logged on via our FCGI script?". We should have | ||
79 | total control over that. I was planning on using the FCGI auth | ||
80 | mechanism anyway. | ||
81 | |||
82 | |||
83 | RESPONDER | ||
84 | web server sends FCGI_PARAMS | ||
85 | CONTENT_LENGTH | ||
86 | web server sends input body FCGI_STDIN | ||
87 | fcgi app sends result data over FCGI_STDOUT and error messages over FCGI_STDERR | ||
88 | it has to finish reading FCGI_PARAMS first | ||
89 | fcgi app sends FCGI_END_REQUEST(protocolStatus = FCGI_REQUEST_COMPLETE) | ||
90 | |||
91 | |||
92 | FILTER | ||
93 | filtered file has last modified time | ||
94 | web server sets FCGI_DATA_LAST_MOD accordingly | ||
95 | web server sends FCGI_PARAMS | ||
96 | CONTENT_LENGTH FCGI_DATA_LAST_MOD FCGI_DATA_LENGTH | ||
97 | web server sends input body FCGI_STDIN | ||
98 | web servers sends file over FCGI_DATA | ||
99 | fcgi app can ignore FCGI_DATA and use it's own cached copy based on FCGI_DATA_LAST_MOD | ||
100 | fcgi app sends result data over FCGI_STDOUT and error messages over FCGI_STDERR | ||
101 | it has to finish reading FCGI_STDIN first, but not FCGI_DATA | ||
102 | fcgi app sends FCGI_END_REQUEST(protocolStatus = FCGI_REQUEST_COMPLETE) | ||
103 | |||
104 | |||
105 | Soooo, FILTER might be slower anyway if we are caching the filtered file, | ||
106 | or mmapping it, coz filter has to start sending the filtered file, even | ||
107 | if it's to be served from cache. Plus no need to wait for FCGI_STDIN | ||
108 | before spewing it out. | ||
109 | |||
110 | |||
111 | PLAN - | ||
112 | . add "webRoot" to the config, point it at /opt/opensim_SC/web | ||
113 | . /opt/opensim_SC/web/fcgi-bin/sledjchisl.fcgi a symlink to /opt/opensim_SC/bin/sledjchisl | ||
114 | . /opt/opensim_SC/web/html/ the static web files and templates. | ||
115 | . https://localhost/opensim_SC/fcgi-bin/sledjchisl.fcgi/foo.html | ||
116 | . check the if modified since bit against the replaceable bits last fetch time / /opt/opensim_SC/web/html/foo.html last modified time | ||
117 | . check if /opt/opensim_SC/web/html/foo.html is cached, or if it's been modified since last cache. | ||
118 | . mmap /opt/opensim_SC/web/html/foo.html | ||
119 | . put it in a cache | ||
120 | . scan through it looking for the replacable bits | ||
121 | . store pointers to them | ||
122 | . check if the replaceable bits need refreshing | ||
123 | . loop through the pointers to the cache | ||
124 | . spew out the non replacable bits | ||
125 | . spew out the replacements for the replacable bits | ||
126 | . repeat until done | ||
127 | |||
128 | Last update time for parameters, plus an update frequency. Once a minute. | ||
129 | Hash of page file names | ||
130 | . last modified time for file | ||
131 | Linked list of page fragments -> array (qlibc can convert a linked list into an array?), or try the growable thingy. | ||
132 | . struct | ||
133 | . enum telling us what this bit is | ||
134 | . bit of verbatim text | ||
135 | . replaceable parameter, pointer to the data that is also stored in the ssi hash, so that changes propogate | ||
136 | . <!--#echo var="???" --> | ||
137 | bit of Lua | ||
138 | |||
139 | NOTE - SSI is a bit more complex than what I'm currently using. | ||
140 | https://en.wikipedia.org/wiki/Server_Side_Includes | ||
141 | <!--#include virtual="menu.cgi" --> | ||
142 | <!--#include file="footer.html" --> | ||
143 | <!--#exec cgi="/cgi-bin/foo.cgi" --> | ||
144 | <!--#exec cmd="ls -l" --> | ||
145 | . <!--#echo var="REMOTE_ADDR" --> | ||
146 | <!--#config timefmt="%y %m %d" --> | ||
147 | <!--#config sizefmt="bytes" --> | ||
148 | <!--#config errmsg="SSI command failed!" --> | ||
149 | <!--#flastmod virtual="index.html" --> | ||
150 | <!--#fsize file="script.pl" --> | ||
151 | <!--#if expr="${Sec_Nav}" --> | ||
152 | <!--#include virtual="secondary_nav.txt" --> | ||
153 | <!--#elif expr="${Pri_Nav}" --> | ||
154 | <!--#include virtual="primary_nav.txt" --> | ||
155 | <!--#else --> | ||
156 | <!--#include virtual="article.txt" --> | ||
157 | <!--#endif --> | ||
158 | <!--#set var="foo" value="bar" --> | ||
159 | <!--#printenv --> | ||
160 | https://www.w3.org/Jigsaw/Doc/User/SSI.html | ||
161 | Adds lots of others, including Java stuff. | ||
162 | Mine | ||
163 | <!--#lua lua="print(table[key])" --> | ||
164 | <!--#lua file="/path/to/script.lua" --> | ||
165 | <!--#lua virtual="https://example.com/script.lua" --> | ||
166 | |||
167 | BTW - /opt/opensim_SC/web/html/foo.html should have it's image URLS and other | ||
168 | static data set to https://localhost/opensim_SC/SledjHamr.png, which | ||
169 | would map to /opt/opensim_SC/web/html/SledjHamr.png and be treated as ordinary | ||
170 | static files by the web server. | ||
171 | |||
172 | ALSO - when spewing results, we have to manually send the headers first | ||
173 | our selves, this should include the HTTP status code and string, content | ||
174 | type, cookies, etc. | ||
175 | |||
176 | ------------------------------------------------------------------- | ||
177 | |||
178 | https://project-awesome.org/aleksandar-todorovic/awesome-c | ||
179 | A curated list of C good stuff. | ||
180 | |||
181 | https://wolkykim.github.io/qdecoder/ | ||
182 | CGI library made by the qlibc guy, does support FCGI. | ||
183 | Might be a wrapper around the fcgi_stdio stuff I'm already using? | ||