13 Commits

Author SHA1 Message Date
Eric Callahan
432a3a653a
application: log http API request exceptions in verbose mode
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2025-01-23 08:11:41 -05:00
Eric Callahan
4e00a0760e application: verify upload filename
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-10-22 05:37:30 -04:00
Eric Callahan
0ff1d79b5b server: improve add_warning method
Add an exc_info parameter that optionally takes an
exception that is passed to the logging function. This
will log the traceback without an additional logging call.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-07-24 07:37:08 -04:00
Eric Callahan
bb0266f5c4 app: replace dict with UserInfo throughout Moonraker
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-05-21 06:18:46 -04:00
Eric Callahan
531028ef4f history: report user in job history
When possible record the name of the user that requested the
job.  The klippy_api's component now takes an optional user
argument in its "start_print" method.  This user is broadcast
in an event after a print request successfully returns.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-05-04 08:16:37 -04:00
Eric Callahan
52ebc2b404
application: fix cors check
It is necessary to perform a cors check before authenticating
the user to make sure that the headers are set if authentication
fails.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-01-27 17:04:39 -05:00
Eric Callahan
d1f97f2658
authorization: fix blocking call to socket.getfqdn()
If the upstream DNS server is not available the call to socket.getfqdn()
will block until a timeout occurs.  This blocks Moonraker's event loop,
resulting in carnage.

Call getfqdn() in a thread with a timeout of 5 seconds.  In addition,
only request the fqdn if the user has one or more trusted domains
configured.  Finally, cache resolved  FQDNs for 24 hours to limit
repeated DNS queries.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-01-22 12:03:01 -05:00
Eric Callahan
619a588683
application: add error handling to listen()
It is possible that Moonraker cannot bind to an address if its
already in use.  Handle bind errors and warn/log when they are
encountered.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-01-15 08:17:35 -05:00
Eric Callahan
7beca7a1a3
application: refactor HTTP routing
Moonraker dynamically registers its routes, so we cannot easily
use the routers provided by tornado.Application.  Previously
all routes went through tornado.Application, then went to
our mutable router.  This refactor avoids that by having our
mutable router contain the tornadoapp instance, only using
it to provide the application delegate.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-01-15 08:17:34 -05:00
Eric Callahan
35785be5dc
application: remove direct websockets import
Provide a method for websocket handler registration.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-01-15 06:03:43 -05:00
Eric Callahan
ddd735feba
refactor: convert klippy_connection into a component
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-01-13 15:15:15 -05:00
Eric Callahan
a88468eb79
refactor: convert websockets into a component
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-01-13 15:15:15 -05:00
Eric Callahan
d506c9241f
refactor: convert application into a component
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-01-13 15:15:14 -05:00