{"id":338,"date":"2014-12-26T17:00:23","date_gmt":"2014-12-26T16:00:23","guid":{"rendered":"https:\/\/blogs.gentoo.org\/mgorny\/?p=338"},"modified":"2014-12-26T18:54:14","modified_gmt":"2014-12-26T17:54:14","slug":"pshs-the-awesome-file-sharing-tool","status":"publish","type":"post","link":"https:\/\/blogs.gentoo.org\/mgorny\/2014\/12\/26\/pshs-the-awesome-file-sharing-tool\/","title":{"rendered":"pshs \u2014 the\u00a0awesome file sharing tool"},"content":{"rendered":"<p>For a\u00a0long time I lacked a\u00a0proper tool to quickly share a\u00a0few files for a\u00a0short time. The\u00a0tools I was able to find either required some setup, installing client counterparts or\u00a0sending my files to a\u00a0third-party host. So I felt the\u00a0need to write something new.<\/p>\n<p>The\u00a0HTTP protocol seemed an\u00a0obvious choice. Relatively simple, efficient, with some client software installed almost everywhere. So I took <a rel=\"external\" href=\"http:\/\/search.cpan.org\/dist\/HTTP-Server-Simple\/\">HTTP::Server::Simple<\/a> (I think) and\u00a0wrote the\u00a0first version of <em>publish.pl<\/em> script. I added a\u00a0few features to that script but it never felt good enough\u2026<\/p>\n<p>So back in\u00a02011 I decided to reboot the\u00a0project. This time I decided to use C and\u00a0<a rel=\"external\" href=\"http:\/\/libevent.org\/\">libevent<\/a>, and\u00a0that&#8217;s how <a rel=\"external\" href=\"https:\/\/bitbucket.org\/mgorny\/pshs\/\">pshs<\/a> came into being. With some development occuring in\u00a0the\u00a0last three years, lately I started adding new features aiming to turn it into something really awesome.<\/p>\n<p><!--more--><\/p>\n<p>So what pshs is? It&#8217;s a\u00a0simple, zero-configuration command-line HTTP server to share files. You pass a\u00a0list of\u00a0files and\u00a0it lets you share them.<\/p>\n<p>\n\t<a href=\"http:\/\/dev.gentoo.org\/~mgorny\/articles\/pshs-screenshot.png\" rel=\"external\"><br \/>\n\t\t<img alt=\"Screenshot of pshs\" src=\"http:\/\/dev.gentoo.org\/~mgorny\/articles\/pshs-screenshot.png\" \/><br \/>\n\t<\/a>\n<\/p>\n<p>But what really makes pshs special are the features:<\/p>\n<ol>\n<li>it shares only the\u00a0files specified on the\u00a0command-line \u2014 no need for extra configuration, moving files to separate directories etc. It simply returns 404 for any path not specified on the\u00a0command-line, whether it exists or not.<\/li>\n<li>Full, working Range support. You can resume interrupted downloads and\u00a0seek freely. Confirmed that playing a\u00a0movie remotely works just fine.<\/li>\n<li>Unless told otherwise, it chooses a\u00a0random port to use. You don&#8217;t have to decide on one, you have use pshs alongside regular HTTP servers and\u00a0other services, and\u00a0you can freely run multiple instances of\u00a0pshs if you need to. TODO: perform port search until free port is found on\u00a0the\u00a0interface having external IP.<\/li>\n<li>Netlink and\u00a0UPnP support provide the\u00a0best means to obtain the\u00a0external IP. If\u00a0you have one on\u00a0local interface, pshs will find and\u00a0print it. If\u00a0you don&#8217;t, it will try to\u00a0enable port forwarding using UPnP and\u00a0obtain the\u00a0external IP from a\u00a0UPnP-compliant router.<\/li>\n<li>QRCode printing (idea copied from systemd). Want to text a\u00a0link to your files? Just scan the\u00a0code!<\/li>\n<li>MIME-type guessing. Well, it&#8217;s not that special but makes sure your images show up as imagines in\u00a0a\u00a0web browser rather than opaque files that can only be saved.<\/li>\n<li>Zero-configuration SSL\/TLS support \u2014 the\u00a0keys and\u00a0a\u00a0self-signed certificate with correct public IP are generated at\u00a0startup. While this is far from perfect (think of all the\u00a0browsers complaining about self-signed certificates), it at\u00a0least gives you the\u00a0possibility of\u00a0using encryption. It also prints the\u00a0certificate fingerprint if you&#8217;d like to verify the\u00a0authenticity.<\/li>\n<\/ol>\n<p>I have also a few nice ideas in\u00a0TODO, yet unsure which of\u00a0them will be\u00a0actually implemented:<\/p>\n<ol>\n<li>HTTP digest authentication support \u2014 in\u00a0case you wanted some real security on\u00a0the\u00a0files you share.<\/li>\n<li>Download progress reporting \u2014 to let you know if and\u00a0for how long do you need to keep the\u00a0server up. Sadly, this does not look easy given the\u00a0current libevent design.<\/li>\n<li>ncurses UI \u2014 to provide visual means for\u00a0progress reporting :). Additional possibilities include keeping server URL on\u00a0screen, a\u00a0status line, and\u00a0possibly scrolling logs.<\/li>\n<li>GTK+ UI with a\u00a0tray icon and\u00a0notification daemon support \u2014 to provide better desktop integration for\u00a0sharing files from\u00a0your favorite file manager.<\/li>\n<li>Recursive directory sharing \u2014 currently you have to list all files explicitly. This may include better directory indexes since currently pshs creates only one index of all files.<\/li>\n<\/ol>\n<p>Which of\u00a0those features would you find useful? What other features you&#8217;d like to see in\u00a0pshs?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>For a\u00a0long time I lacked a\u00a0proper tool to quickly share a\u00a0few files for a\u00a0short time. The\u00a0tools I was able to find either required some setup, installing client counterparts or\u00a0sending my files to a\u00a0third-party host. So I felt the\u00a0need to write something new. The\u00a0HTTP protocol seemed an\u00a0obvious choice. Relatively simple, efficient, with some client software installed &hellip; <a href=\"https:\/\/blogs.gentoo.org\/mgorny\/2014\/12\/26\/pshs-the-awesome-file-sharing-tool\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;pshs \u2014 the\u00a0awesome file sharing tool&#8221;<\/span><\/a><\/p>\n","protected":false},"author":137,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[3],"tags":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/blogs.gentoo.org\/mgorny\/wp-json\/wp\/v2\/posts\/338"}],"collection":[{"href":"https:\/\/blogs.gentoo.org\/mgorny\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.gentoo.org\/mgorny\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.gentoo.org\/mgorny\/wp-json\/wp\/v2\/users\/137"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.gentoo.org\/mgorny\/wp-json\/wp\/v2\/comments?post=338"}],"version-history":[{"count":5,"href":"https:\/\/blogs.gentoo.org\/mgorny\/wp-json\/wp\/v2\/posts\/338\/revisions"}],"predecessor-version":[{"id":344,"href":"https:\/\/blogs.gentoo.org\/mgorny\/wp-json\/wp\/v2\/posts\/338\/revisions\/344"}],"wp:attachment":[{"href":"https:\/\/blogs.gentoo.org\/mgorny\/wp-json\/wp\/v2\/media?parent=338"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/mgorny\/wp-json\/wp\/v2\/categories?post=338"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/mgorny\/wp-json\/wp\/v2\/tags?post=338"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}