about summary refs log tree commit diff stats
path: root/src/local/client.nim
Commit message (Collapse)AuthorAgeFilesLines
* timeout: accept err stream as parambptato2024-09-301-6/+3
| | | | | gets rid of a todo. (not sure why I thought this was important, but it sure looks nicer)
* select: use a separate module (again)bptato2024-09-241-0/+2
| | | | | | | | | Now we dispatch to select objects from the pager object too, just to make things even more confusing. Well, it works better than the previous arrangement, in that trying to use unimplemented movements now just throws instead of moving around the container. Yay for OOP (?)
* Replace std/selectors with pollbptato2024-09-231-57/+73
| | | | | | | | | | | | std/selectors uses OS-specific selector APIs, which sounds good in theory (faster than poll!), but sucks for portability in practice. Sure, you can fix portability bugs, but who knows how many there are on untested platforms... poll is standard, so if it works on one computer it should work on all other ones. (I hope.) As a bonus, I rewrote the timeout API for poll, which incidentally fixes setTimeout across forks. Also, SIGWINCH should now work on all platforms (as we self-pipe instead of signalfd/kqueue magic).
* client, forkserver, dynstream: misc refactorings, fixesbptato2024-09-231-59/+66
| | | | | | * fix broken int conversion in dynstream * fix EPIPE handling in forkserver * merge fdmap and connectingContainers into loader map
* loader: mmap intermediate image files, misc refactoringbptato2024-09-221-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | * refactor parseHeader * optimize response blob() * add direct "to cache" mode for loader requests which sets stdout to a file, and use it for image processing * move image resizing into a separate process * mmap cache files in between processing steps when possible At last, resize is no longer a part of image decoding. Also, it feels much nicer to keep encoded image data in the same cache as everything else. The mmap operations *should* be more efficient than copying the whole RGBA data through a pipe. In practice, it only makes a difference for loading (well, now just mmapping) the encoded image into the pager, where it singlehandedly speeds up image display by 10x on my test image. For the other steps, the unfortunate fact that "tocache" must delay the next fork/exec in the pipeline until the entire image is processed seems to equal out any wins we might have gotten from skipping a single raw RGBA copy. I have tried moving the delay before the exec (it's possible with yet another pipe), but it didn't help much and made the code much uglier. (Not that tocache didn't, but I can live with this...)
* client: seqify fdmapbptato2024-09-221-4/+6
|
* loader: refactor/move around some procsbptato2024-09-151-1/+2
| | | | | | | | | | | | | | Module boundaries didn't make much sense here either. Specifically: * loader/cgi was originally just one of the many "real" protocols supported by loader, so it was in a separate module (like the other ones). Now it's mostly an "internal" protocol, and it was getting cumbersome to pass all required loader state to loadCGI. * The loader interface has grown quite large, but there is no need for (or advantage in) putting it in the same module as the implementation. Now CGI is handled by loader, and the interface is in the new module "loaderiface".
* loader: improve map interfacebptato2024-09-141-1/+1
| | | | directly accessing map was a bit too error prone
* loader: refactor, misc optimizations & fixesbptato2024-09-141-11/+6
| | | | | | | | * factor out input/output handle tables; use a seq instead * add possibility to directly open cached items onto stdin (mainly an optimization for reading images, which are always cached) * close used handles on local CGI execution * make clone during load work again
* loader, client, buffer: use selectInto (not select)bptato2024-09-031-4/+6
| | | | select allocates. (makes sense, but I never realized...)
* dom: remove generic JS bindingsbptato2024-08-111-1/+1
| | | | Dispatch manually with fromJS instead.
* Update monouchabptato2024-08-091-6/+6
|
* console, client: optimize console.log (etc.)bptato2024-07-301-2/+2
| | | | use JSValue varargs instead
* Fixes for Nim 2.2bptato2024-07-291-4/+0
| | | | | | | | | * xmlhttprequest: fix missing import * painter: generic tuple workaround * dynstream: merge module with implementations (so it will work with vtables) Not enabling vtables yet since it doesn't work with refc.
* buffer, pager, config: add meta-refresh + misc fixesbptato2024-07-281-0/+1
| | | | | | | | | * buffer, pager, config: add meta-refresh value, which makes it possible to follow http-equiv=refresh META tags. * config: clean up redundant format mode parser * timeout: accept varargs for params to pass on to functions * pager: add "options" dict to JS gotoURL * twtstr: remove redundant startsWithNoCase
* client, sandbox: fix termux buildbptato2024-07-241-5/+8
| | | | | Still not perfect, because it crashes on missing /tmp dir so you have to manually set it...
* loader: copy cached items on buffer cloningbptato2024-07-201-1/+2
| | | | | This fixes a bug where cloning buffers with images would crash the browser.
* client: remove redundant global functionsbptato2024-07-161-22/+0
| | | | these are already defined on Window
* timeout: simplify, misc fixesbptato2024-07-161-7/+7
| | | | | | Merge timeout & interval code paths. This fixes clearTimeout not clearing intervals.
* 32-bit compilation fixesbptato2024-07-131-1/+1
| | | | | | | | It seems registerHandle/unregister doesn't accept cint as handles. Not sure why it even works on 64-bit targets... (maybe some converter weirdness?) Seems best to explicitly cast it away.
* timeout: fix jsvalue leakbptato2024-07-101-0/+1
|
* main, forkserver: optimize startupbptato2024-07-061-9/+2
| | | | | Merge "load config" with "fork loader", so that the loader process gets forked one packet earlier.
* config: fix JS command definitionsbptato2024-06-231-2/+3
|
* misc cleanupsbptato2024-06-221-1/+1
|
* pager: refactor drawing codebptato2024-06-221-16/+10
| | | | | | | * merge select into container * avoid unnecessary redraws in draw() for parts of the screen that haven't been updated * various image redraw fixes
* client, pager: fix cached item refcounting bugsbptato2024-06-211-5/+13
|
* img, loader: separate out png codec into cgi, misc improvementsbptato2024-06-201-2/+2
| | | | | | | | | | | | | | | * multi-processed and sandboxed PNG decoding & encoding (through local CGI) * improved request body passing (including support for output id as response body) * simplified & faster blob()/text() - now every request starts suspended, and OngoingData.buf has been replaced with loader's buffering capability * image caching: we no longer pull bitmaps from the container after every single getLines call Next steps: replace our bespoke PNG decoder with something more usable, add other decoders, and make them stream.
* dom: simplify window.loaderbptato2024-06-091-4/+1
| | | | the Option setup hasn't made much sense for a long time now
* Move JS wrapper into Monouchabptato2024-06-031-9/+9
| | | | Operation "modularize Chawan somewhat" part 3
* client: fix double click on double width charsbptato2024-05-231-7/+7
| | | | | This is not a perfect solution, but it's still better than not being able to double click on CJK links correctly.
* html: improve Request, derive Client from Windowbptato2024-05-201-20/+17
| | | | | | | * make Client an instance of Window (for less special casing) * misc work on Request & fetch * improve origin comparison (opaque origins of same URLs are now considered the same)
* config: separate tmp dir for sockets, usersbptato2024-05-161-4/+5
| | | | | | | * add $LOGNAME to the tmp directory name, so that tmpdirs of separate users don't conflict * use separate directory for sockets, so that we do not have to give buffers access to all cached pages
* client, pager: remove unnecessary std/streamsbptato2024-05-111-3/+1
|
* buffer: fix multipart formsbptato2024-05-111-5/+6
| | | | | | | | | * fix enctype not getting picked up * fix form data constructor requiring open() syscall (which gets blocked by our seccomp filter) * add closing boundary to multipart end * pass fds instead of path names through WebFile/Blob and send those through bufwriter/bufreader
* js: refactorbptato2024-05-081-6/+11
| | | | | | | * prefix to-be-separated modules with js * remove dynstreams dependency * untangle from EmptyPromise * move typeptr into tojs
* js: fix compilation on 1.6.14bptato2024-05-061-1/+1
| | | | | | | | | * resolve empty promises without params, not a single undefined param (we can't just unsafeAddr constants on 1.6.14, and I don't see why we need to pass undefined?) * same in client with InternalError * explicitly convert static `asglobal' to bool (1.6.14 turns unquoted enums into ints...)
* Use isSome instead of isOkbptato2024-05-051-1/+1
| | | | no point in having identical overloads
* client: make quit() actually quit, misc fixesbptato2024-05-041-33/+42
| | | | | | | * unwind the QJS stack with an uncatchable exception when quit is called * clean up JS references in JSRuntime free even when the Nim counterparts are still alive * simplify some tests
* js: fix various leaks etc.bptato2024-05-031-32/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | Previously we didn't actually free the main JS runtime, probably because you can't do this without first waiting for JS to unwind the stack. (This has the unfortunate effect that code now *can* run after quit(). TODO: find a fix for this.) This isn't a huge problem per se, we only have one of these and the OS can clean it up. However, it also disabled the JS_FreeRuntime leak check, which resulted in sieve-like behavior (manual refcounting is a pain). So now we choose the other tradeoff: quit no longer runs exitnow, but it waits for the event loop to run to the end and only then exits the browser. Then, before exit we free the JS context & runtime, and also all JS values allocated by config. Fixes: * fix `ad' flag not being set for just one siteconf/omnirule * fix various leaks (since leak check is enabled now) * use ptr UncheckedArray[JSValue] for QJS bindings that take an array * allow JSAtom in jsgetprop etc., also disallow int types other than uint32 * do not set a destructor for globals
* sandbox: seccomp support on Linuxbptato2024-04-181-0/+4
| | | | | | | | | | | | | | | | | We use libseccomp, which is now a semi-mandatory dependency on Linux. (You can still build without it, but only if you pass a scary long flag to make.) For this to work I had to disable getTimezoneOffset, which would otherwise call localtime_r which in turn reads in some files from /usr/share/zoneinfo. To allow this we would have to give unrestricted openat(2) access to buffer processes, which is unacceptable. (Giving websites access to the local timezone is a fingerprinting vector so if this ever gets fixed then it should be an opt-in config setting.) This patch also includes misc fixes to buffer cloning, and fixes the LIBEXECDIR override in the makefile so that it is actually useful.
* Update code stylebptato2024-04-171-28/+26
| | | | | | * separate params with ; (semicolon) instead of , (colon) * reduce screaming snake case use * wrap long lines
* Add capsicum supportbptato2024-03-281-2/+5
| | | | | | | | | | | | | It's the sandboxing system of FreeBSD. Quite pleasant to work with. (Just trying to figure out the basics with this one before tackling the abomination that is seccomp.) Indeed, the only non-trivial part was getting newSelector to work with Capsicum. Long story short it doesn't, so we use an ugly pointer cast + assignment. But even that is stdlib's "fault", not Capsicum's. This also gets rid of that ugly SocketPath global.
* config: improve input systembptato2024-03-261-8/+10
| | | | as described in <https://todo.sr.ht/~bptato/chawan/6>
* client, forkserver: remove useless codebptato2024-03-241-1/+0
|
* buffer: fix clonebptato2024-03-241-3/+3
|
* io: derive DynStream from RootObj (not Stream)bptato2024-03-241-26/+29
| | | | | | | | This way they are no longer compatible, but we no longer need them to be compatible anyway. (This also forces us to throw out the old serialize module, and use packet writers everywhere.)
* io: add bufreaderbptato2024-03-211-1/+1
| | | | analogous to bufwriter
* buffer: also buffer input readsbptato2024-03-211-1/+5
| | | | this is buffer reading from pager
* client: fix dump detectionbptato2024-03-201-7/+7
| | | | it wouldn't start dump mode if stdout was not a tty but stdin was.
* pager: add "save link", "save source"; change & document some keybindingsbptato2024-03-201-2/+2
| | | | | | | | | * `s{Enter}' now saves link, and `sS' saves source. * Changed ;, +, @ to g0, g$, gc so that it's somewhat consistent with vim (and won't conflict with ; for "repeat jump to char") * Changed (, ) to -, + so that it doesn't conflict with vi's "previous/next sentence" (once we have it...) * Add previously missing keybindings to about:chawan