Package: sdsu
Skim milk. Gummy bears. Pure genius.ContentsQuick StartOverviewsecurityRootstaticRootwssHandlerClsWebSocket ClientQuick Start> python -c "import sdsu; sdsu.main()"Note that, for Tornado-based servers, Windows users stop the service usingCRTL + PAUSE/BREAK.OverviewThe Secure, Dual-use Server Utility, or SDSU, provides:A preconfigured, multi-handler, Tornado-based web serverStatic file hosting from the/staticsubdirectorySSL encryption using the certificates stored in/securityLogin protection (including address whitelisting) from the credentials in/securitySecure WebSocket exchange on the same port service as static file hosting,
using the/wsspath.Thesdsu.main()method takes three parameters that allow users to customize
the configuration of a SDSU server before it launches:securityRoot,staticRoot, andwssHandlerCls.securityRootBy default, the/securitysubdirectory contains three files:certificate.pemdefines the server’s SSL certificatecredentials.csvdefines the user table. Each user is defined by an email
address (“email”), password (“password”), and whitelist mask (CIDR-style,
IPv6 preferred but IPv4 will be translated automatically with a “2002:”
prefix.) Password and whitelist mask will be used by theSplashHandler.post()method when verifying credential submissions.key.pemdefines the server’s private SSL key.Users can customize security configurations by creating a new copy of this
directory, modifying it’s contents, and passing the new absolute path tosdsu.main()as thesecurityRootparameter. For example, you arestronglyencouraged to use your own certificates.staticRootThe/staticsubdirectory contains static files that will be served to satisfy
HTTP requests. Except forsplash.html, all static files are protected by
authentication restrictions. Default contents of/staticinclude:index.css, a stylesheet used byindex.htmland placed here to demonstrate
and verify protection of static file contents.index.html, the default landing page for authenticated users.splash.html, which defines the login page for users that have not yet been
authenticated. This also serves as a logout page, as upon accessing this
resource any existing sessions are cleared.Users can customize static file contents (and therefore the bulk of their web
applications) by creating a new copy of this directory, modifying it’s
contents, and passing the new absolute path tosdsu.main()as thestaticRootparameter.wssHandlerClsThe classsdsu.WssHandlerdefines the default behavior for secure WebSocket
interaction mounted by the server to the path “/wss”. Users can customize
WebSocket behaviors by inheriting from this class, then pass the new child
class tosdsu.main()as thewssHandlerClsparameter. Typical usage will
override one or more of the following methods:on_open()on_message()(by default, simply echoes the message back to the client)on_close()See class method documentation for more details, including method signatures.
Keep in mind that each instance of the WebSocker handler class is unique to
a specific client connection; state is not shared between clients.WebSocket ClientOnce a server is running, connection via WebSocket is trivial:> var wss = new WebSocket("wss://" + window.location.host + "/wss");
> wss.addEventListener("message", console.log);
> wss.send("0");