Skip to content

(RFC) WebUI mod - #1467

Merged
vanosg merged 94 commits into
eggheads:developfrom
michaelortmann:webui.mod
Dec 14, 2025
Merged

(RFC) WebUI mod#1467
vanosg merged 94 commits into
eggheads:developfrom
michaelortmann:webui.mod

Conversation

@michaelortmann

@michaelortmann michaelortmann commented Aug 31, 2023

Copy link
Copy Markdown
Member

Found by: michaelortmann
Patch by: michaelortmann
Fixes:

One-line summary:
WebUI mod adds webinterface to eggdrop

Additional description (if needed):
Screenshot desktop firefox: https://imgur.com/a/WONc3dR
Screenshot iOS safari: https://imgur.com/a/AQwxNgs (the imgur content detection/warning, is ridiculous ;)
Reuses eggdrops telnet interface
Adds minimal http/websocket
The html and vanilla js (best js framework ;) code is handcrafted
It sends our eggman as favicon :)
Work in progress, but already working for me
Eggdrops make install doesnt automatically copy from module to text directory, so you have to cp src/mod/webui.mod/webui.html ~/eggdrop/text/ manually for now
Add to config:

loadmodule webui
listen 8080 webui
listen +8443 webui

Yes, the + means it already supports https

Test cases demonstrating functionality (if applicable):
Tested with destop firefox, desktop brave (based on chromium) and iphone iOS safari

@vanosg

vanosg commented May 15, 2024

Copy link
Copy Markdown
Member
18:05:47] Telnet connection: localhost/46032
[18:05:47] TLS: handshake successful. Secure connection established.
[18:05:47] TLS: peer did not present a certificate
[18:05:47] Denied telnet: *, No Access

Thread 1 "eggdrop" received signal SIGSEGV, Segmentation fault.
0x00007ffff7d81aca in ?? () from /lib/x86_64-linux-gnu/libssl.so.3
(gdb) bt
#0  0x00007ffff7d81aca in ?? () from /lib/x86_64-linux-gnu/libssl.so.3
#1  0x00007ffff7d81cb7 in SSL_read () from /lib/x86_64-linux-gnu/libssl.so.3
#2  0x00007ffff76b33b5 in webui_http_activity (idx=7, 
    buf=0x7fffffffbde1 "P/7Es4T4NIGlFL7i8kbrrw==\r\nConnection: keep-alive, Upgrade\r\nCookie: csrftoken=JEqDnapUmFU1zeZwSab3r0uzcb885hlU; sessionid=kexs0xja1ymwhumezcss3p4doaabi42s; messages=W1siX19qc2", len=511) at .././webui.mod/webui.c:333

and a second one with debug enabled

<snip web code>
[18:11:59] flags 1026
[18:11:59] webui: webui_http_activity(): idx 6 len 511
[18:11:59] webui: http()
[18:11:59] webui: GET /w
[18:11:59] webui: server requests websocket upgrade
[18:11:59] webui: tputs(): >>>HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: ljLkHJvOkjthVo/X5aPf0zQd3MM=

<<< 129
[18:11:59] webui: unset flag SOCK_BINARY sock 18

[18:11:59] webui: set flag SOCK_WS socklist 6 idx 6 sock 18 status 0

[18:11:59] webui: found (webui) dcc

[18:11:59] Denied telnet: *, No Access
[18:11:59] Received close notify warning during write
[18:11:59] webui: CHANGEOVER -> idx 6 sock -1


Thread 1 "eggdrop" received signal SIGSEGV, Segmentation fault.
0x00007ffff7d81aca in ?? () from /lib/x86_64-linux-gnu/libssl.so.3
(gdb) bt
#0  0x00007ffff7d81aca in ?? () from /lib/x86_64-linux-gnu/libssl.so.3
#1  0x00007ffff7d81cb7 in SSL_read () from /lib/x86_64-linux-gnu/libssl.so.3
#2  0x00007ffff76b33b5 in webui_http_activity (idx=6, 
    buf=0x7fffffffbde1 "iqubpCvpepPdkRKCJVsTIw==\r\nConnection: keep-alive, Upgrade\r\nCookie: csrftoken=JEqDnapUmFU1zeZwSab3r0uzcb885hlU; sessionid=kexs0xja1ymwhumezcss3p4doaabi42s; messages=W1siX19qc2", len=511) at .././webui.mod/webui.c:333
#3  0x00005555555a9f49 in mainloop (toplevel=1) at ./main.c:853

and a third non-crash, but still can't connect over a TLS port with https:

</html>
<<< 1539
[18:40:41] webui: SSL_read(): len 188
[18:40:41] webui: webui_http_activity(): user 0.108ms sys 0.100ms
[18:40:41] net: connect! sock 7
[18:40:41] sockread sock 7 return 4 >><< 0 binary? 0
[18:40:41] flags 4
[New Thread 0x7ffff6dff640 (LWP 2121829)]
[18:40:41] dcc_telnet_hostresolved()
[Thread 0x7ffff6dff640 (LWP 2121829) exited]
[18:40:41] Telnet connection: localhost/48796
[18:40:41] TLS: attempting SSL negotiation...
[18:40:41] TLS: state change: before SSL initialization
[18:40:41] TLS: state change: before SSL initialization
[18:40:41] TLS: awaiting more reads
[18:40:41] TLS: handshake in progress
[18:40:41] webui_dcc_telnet_hostresolved(6)
[18:40:41] TLS: state change: before SSL initialization
[18:40:41] TLS: alert during write: fatal (internal error).
[18:40:41] TLS: awaiting more writes
[18:40:41] net: sockread(): SSL_read() error = error:0A000115:SSL routines::session id context uninitialized (1)
[18:40:41] net: eof!(read) socket 11
[18:40:41] webui: webui_http_eof() idx 6 sock 11

@michaelortmann

michaelortmann commented May 27, 2024

Copy link
Copy Markdown
Member Author

@vanosg: The crash should be fixed now.

@vanosg

vanosg commented Jul 29, 2024

Copy link
Copy Markdown
Member

One more-
/home/runner/work/eggdrop/eggdrop/eggdrop/src/tls.c:233: undefined reference to `SSL_CTX_get0_certificate'
in OpenSSL 0.9.8

@michaelortmann

Copy link
Copy Markdown
Member Author

One more- /home/runner/work/eggdrop/eggdrop/eggdrop/src/tls.c:233: undefined reference to `SSL_CTX_get0_certificate' in OpenSSL 0.9.8

Yes, this is an unfinised block of code, waiting for #1411. Once #1411 is merged ill finish it. Until then, for now, i added an ifdef around it.

@vanosg vanosg added this to the v1.10.2 milestone Dec 14, 2025
@vanosg
vanosg merged commit 1104c64 into eggheads:develop Dec 14, 2025
24 of 26 checks passed
@michaelortmann
michaelortmann deleted the webui.mod branch May 17, 2026 00:58
vanosg pushed a commit that referenced this pull request May 23, 2026
This PR Fixes:

    Blocker — src/tls.c ssl_init() X509 use-after-free on error.
    Fix use after free / fingerprint logging, implemented a TODO left by (RFC) WebUI mod #1467
    Blocker — src/tcldcc.c webui listen type works even without the webui module.
    Init webui_dcc_telnet_hostresolved() hook to null_func instead of 0
    But we dont need any fix here, because the listen type webui is only set for webui listen ports to begin with.
    Should-fix — src/tls.c:1075-1104 HTTP-on-SSL handler hijacks every TLS listener, not just webui.
    Fixed SSL_R_HTTP_REQUEST logic to only apply to webui ports
    Response status HTTP 200 -> 400 for error msg "Error: HTTP request received on an SSL port, please try HTTPS"
    Leaking program name and version when stealth telnets is set to 1 is not a bug but a feature. nginx does the same.
    The write()/SSL_shutdown() was only suffering from a bad comment. I removed the comment, because the connection is properly closed with SO_LINGER + close(), verified with strace and tcpdump

    killsock(): dont kill stdout, so that we keep stdout logging until the very last cycle of .die waving killsock(), it just doesnt make sense to kill stdout.
    puts(): fix openssl error logging
    puts(): fix memleak
    Fix error logging for SSL_write() by doing ERR_clear_error() before that write call
    Stop writing to sock after close notify during write and enhance logging
    Fix fatal(): end all logging to dcc for killed sock
    Fix memleak by calling changeover_dcc() before dcc[i].u is reused. this bug existed since at least eggdrop 1.10.1.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants