Commit Graph

400 Commits

Author SHA1 Message Date
Seednode 8923a4c14d Fix validation of files when in cache/not cached mode 2023-09-14 19:10:55 -05:00
Seednode aaee51e9a4 Add syntax highlighting for code 2023-09-14 17:37:22 -05:00
Seednode 6b70741a68 Replace --refresh-interval flag with --refresh 2023-09-14 00:07:54 -05:00
Seednode 99ec1d7ebd Allow toggling of page refreshInterval 2023-09-14 00:01:50 -05:00
Seednode a94b7e208d Remove html from text handler, add yaml/toml/sh/ps1 2023-09-13 23:32:02 -05:00
Seednode fdd33376ce Add --prefix flag for easy reverse proxying 2023-09-13 23:24:29 -05:00
Seednode d612144be1 Fix handling directories with only one or two files 2023-09-13 22:08:01 -05:00
Seednode bfb04cab66 Remove unneeded(?) prepareDirectory() function 2023-09-13 20:45:28 -05:00
Seednode ce99374a9f Removed statistics (sorry) pending full rewrite 2023-09-13 17:02:43 -05:00
Seednode d2d9418b8b Replace user.Home() with os.HomeDir() to remove CGo dependency (hopefully) 2023-09-13 12:46:14 -05:00
Seednode 65b77f33cc Attempt to rework stats handling, add support for '~' in paths 2023-09-13 12:30:24 -05:00
Seednode 61f10a6f3c Split http handler registration into source files 2023-09-13 12:00:24 -05:00
Seednode 64639a87a3 Changed all variables to non-exported by default 2023-09-13 09:26:15 -05:00
Seednode d7bc6e2451 Total restructure, just look at the diffs at this point 2023-09-12 23:35:17 -05:00
Seednode cbf7218453 Added endpoints to view registered file formats 2023-09-12 22:35:15 -05:00
Seednode c77a151a24 Gonna be honest, guys, I don't think I know what an interface is 2023-09-12 20:56:39 -05:00
Seednode 62a8bde8ea Disable line-wrapping for text files 2023-09-12 19:55:54 -05:00
Seednode a7daf81754 Replace []string with map[string]string for extensions, to allow setting default MIME type values 2023-09-12 19:46:27 -05:00
Seednode 57bcd40c29 Enclose text content in readonly textarea to preserve formatting 2023-09-12 19:12:40 -05:00
Seednode cc00a1b63b Fixed Next button when serving SWF files 2023-09-12 18:51:40 -05:00
Seednode 3b4f8f7499 Change back from uint64 to uint32s because no filesystem ought to ever need over 2^32 files (ZFS? What's that?) 2023-09-12 16:46:58 -05:00
Seednode 732d944036 Rename formats package to types, replace Css string literal in type struct with func() string 2023-09-12 16:32:19 -05:00
Seednode 6fea978459 Updated readme to replace --debug with --index 2023-09-12 14:00:15 -05:00
Seednode c0265d2a6e Enable --images flag if nothing else is passed, to retain backward compatibility 2023-09-12 13:51:00 -05:00
Seednode d18dc9a41c Remove unused Name value from SupportedFormat structs 2023-09-12 13:19:24 -05:00
Seednode c996f3fc53 Serve ruffle from their CDN, instead of vendoring locally 2023-09-12 13:14:05 -05:00
Seednode a29390aa76 Added .swf support, fallback to filetype detection by extension if mime type detection fails 2023-09-12 13:06:45 -05:00
Seednode 7942ea85b5 Added .ogm as extension for Ogg videos 2023-09-11 22:02:56 -05:00
Seednode 2097a9ab13 Add looping and preload to audio and video files, add file types listed as supported by MDN 2023-09-11 21:22:26 -05:00
Seednode 04ef12c19a Replaced uint32 with uint64 2023-09-11 20:02:52 -05:00
Seednode 93799e16fe Replaced cssFunction with string literal, since no customization should be needed 2023-09-11 19:43:18 -05:00
Seednode 26bdedb5a2 Added UTF-8 validation for files when using --text 2023-09-11 19:38:38 -05:00
Seednode 3c21946351 Add --all flag to allow all supported file types at once; add --text flag 2023-09-11 19:11:45 -05:00
Seednode a3f8a85d28 Replaced h2non/filetype with net/http DetectContentType() 2023-09-11 16:05:38 -05:00
Seednode c06b536123 Added first/last buttons to debug pages 2023-09-11 14:37:59 -05:00
Seednode 189b7d269c Disable prev/next buttons when at beginning/end of debug lists 2023-09-11 14:09:12 -05:00
Seednode 51971feb87 Rearranged source files for consistency 2023-09-11 12:59:40 -05:00
Seednode 86184f26bf Split source into more files and fixed bug where images wouldn't display due to swapped parameter order 2023-09-11 12:09:08 -05:00
Seednode 951ff50f88 Moved types to their own package (formats) 2023-09-11 11:25:39 -05:00
Seednode ce89e24ec9 Moved fileType() function into types.go 2023-09-11 10:50:34 -05:00
Seednode e8ee96c7d6 First attempt at making format registrations modular 2023-09-11 10:43:09 -05:00
Seednode 26933dbe4f Fixed Windows builds after URI structure change 2023-09-10 21:51:58 -05:00
Seednode c7984d0743 Only remove file from cache after file has been removed from filesystem when --russian is passed 2023-09-10 21:28:27 -05:00
Seednode 494f9271f4 Updated readme 2023-09-10 21:08:51 -05:00
Seednode 2f1cfe28d0 Added support for toggling each of audio|image|video support 2023-09-10 21:05:35 -05:00
Seednode 32bd20522a Added audio file support 2023-09-10 21:02:03 -05:00
Seednode 8d0d271f79 Added mime type tags to <img> and <video> 2023-09-10 20:41:08 -05:00
Seednode 8fa4a7c652 Corrected all references to image->media/file 2023-09-10 20:29:11 -05:00
Seednode 928bbb8c53 Added video support 2023-09-10 20:23:48 -05:00
Seednode caf1b1889c Replaced math/rand with crypto/rand 2023-09-10 12:16:50 -05:00
Seednode d869a375ab Removed redundant isImage check 2023-09-10 11:27:55 -05:00
Seednode 30eead7e2f Cleaned up pagination calculations 2023-09-09 23:27:40 -05:00
Seednode 53d14ff279 Remove file from filesystem and cache at same time during serveStaticFile() 2023-09-09 21:17:17 -05:00
Seednode 26475ed491 Moved warning for --russian earlier in init process 2023-09-09 21:00:58 -05:00
Seednode 8bbfd36a09 Added --russian flag, fixed issue where last image in cache would never be served 2023-09-09 20:57:50 -05:00
Seednode e4a4cb6bcd Remove unused debug statement, update usage info for --page-length 2023-09-09 19:47:44 -05:00
Seednode 425857af84 Fixed pagination for stats, was using query parameter instead of httprouter parameter 2023-09-09 00:25:04 -05:00
Seednode e170990e83 Added pagination to debug and stats endpoints 2023-09-09 00:06:28 -05:00
Seednode 5d86be871f Added initial PGO test 2023-09-08 00:20:06 -05:00
Seednode fc0c9974b1 Simplified alphanumeric regex 2023-09-07 16:20:48 -05:00
Seednode 2e842e6a0a Rearranged ServePage() to be more intuitive in order of operations 2023-09-06 17:31:05 -05:00
Seednode 05f8084089 Removed unused Stat type, removed unused regex for durations, replaced strings.Builder with string constant for favicon html 2023-09-06 11:53:19 -05:00
Seednode de9bc0af97 Added --profile flag for net/http/pprof 2023-09-06 10:15:11 -05:00
Seednode ec8b5c9c7f Import net/http/pprof 2023-09-06 09:06:44 -05:00
Seednode 6ff79b1817 Added option to force refreshInterval from command line, and added minimum interval of 500ms 2023-08-21 15:38:56 -05:00
Seednode 9b250416d9 Reworked port uint16-to-string conversion 2023-08-13 18:07:45 -05:00
Seednode 6678d0af36 Completely broke serveStats, whoops 2023-08-13 17:43:35 -05:00
Seednode 01629da407 Replaced uint64 with uint32 2023-08-13 17:29:28 -05:00
Seednode 77f14ea71b Replaced atomic convenience wrappers with suggested versions 2023-08-13 17:02:09 -05:00
Seednode 172db15454 Updated transitive dependencies 2023-08-08 17:12:34 -05:00
Seednode 53ee79b87f Reworked favicon and error page handlers 2023-08-05 21:38:28 -05:00
Seednode 5901e7e1e6 Updated transitive dependencies 2023-08-05 10:31:34 -05:00
Seednode 526e8e15d6 Added --maximum-files and --minimum-files flags, changed structure for stats struct 2023-08-02 13:29:37 -05:00
Seednode 7c93fc8c37 Added explicit timezone loading 2023-07-17 07:41:32 -05:00
Seednode 830e661223 Removed explicit w.WriteHeader(http.StatusOK) calls in favor of implicit 2023-06-22 05:10:40 -05:00
Seednode 40ed9889f9 Added HTTP 500 response on all failed requests, instead of not sending any response 2023-06-20 10:24:12 -05:00
Seednode 7ca86c19fd Added strings.ToLower() to all stable sorts to ensure intuitive ordering 2023-06-20 09:02:13 -05:00
Seednode 780bed087d HTML debug sort is now case-insensitive 2023-06-19 14:34:30 -05:00
Seednode c5e6723bfa Added formatting to HTML debug page, for easier reading 2023-06-13 19:40:29 -05:00
Seednode 911708b95c Open files to export as O_WRONLY instead of O_RDWR 2023-06-13 08:50:13 -05:00
Seednode 9a23387a6b Added favicon to HTML debug page 2023-06-09 15:56:03 -05:00
Seednode 9c668ea04d Significantly increased timeouts so clear_cache doesn't error out 2023-06-03 19:49:58 -05:00
Seednode d2368884b7 Formatting cleanup for return values 2023-06-03 18:45:32 -05:00
Seednode 7780b8eaa9 Added strings.TrimPrefix to refererUri so sorting works with the new setup 2023-06-03 18:37:06 -05:00
Seednode 3d8d4c3869 Fixed hyperlinks in /html endpoint 2023-06-03 18:14:53 -05:00
Seednode 72e41ba413 Added version endpoint 2023-06-03 15:51:08 -05:00
Seednode abae8ba4c1 Replaced net/http with julienschmidt/httprouter and removed (broken) video support, changed stats/debug endpoints 2023-06-03 13:29:49 -05:00
Seednode 29afaa3025 Changed wording of file count 2023-06-02 21:04:06 -05:00
Seednode 99ad647614 Added file count to HTML debug endpoint 2023-06-02 21:00:44 -05:00
Seednode 4679208eae Replace fmt.Println() + os.Exit(1) with log.Fatal() in error handler, error out if no useful paths are passed in 2023-05-31 13:01:24 -05:00
Seednode af9b79878f Switched back from go-chi to net/http, explicitly declared mux and http.Server 2023-05-31 12:43:07 -05:00
Seednode 8fc7084098 Recompressed favicons to save space, and replaced multiple favicon handler functions with a single catchall 2023-05-30 19:13:02 -05:00
Seednode 229aaa7da2 Added embedded favicons, and replaced default mux with go-chi 2023-05-30 18:47:26 -05:00
Seednode c31518d932 Added first served/last served/most served stats to /_/stats 2023-05-12 09:05:14 -05:00
Seednode 7184542cb6 Updated transitive dependencies 2023-05-11 23:22:31 -05:00
Seednode f6ac4b6e2b Added ?sort=asc when opening link via HTML debug page 2023-05-08 20:21:39 -05:00
Seednode 3e1fb6be6a Added video support 2023-05-08 20:05:10 -05:00
Seednode 2da8e79adb Updated transitive dependencies 2023-05-08 15:40:52 -05:00
Seednode 5f78094498 Simplified handler function structure 2023-05-08 13:12:51 -05:00
Seednode 4be011755b Added -b|--bind to bind to specific address 2023-05-08 11:45:57 -05:00
Seednode 5beb1fc858 --debug now requires --cache, exits with error if not provided 2023-05-08 11:16:19 -05:00
Seednode 5fdfaee80d Split /_/debug endpoint into /_/html and /_/json, formatted accordingly 2023-05-08 09:10:13 -05:00
Seednode 8dae3865c0 Renamed /_/index to /_/debug, and adjusted readme accordingly 2023-04-28 13:31:07 -05:00
Seednode 84af467feb Debug index output is now sorted 2023-04-28 13:26:47 -05:00
Seednode 9cd9c286c2 Added -d|--debug flag and /_/index endpoint 2023-04-28 13:19:07 -05:00
Seednode c85cd55598 Fixed redirect URIs with relative input paths (e.g. ../../test) and --cache enabled 2023-04-11 07:19:06 -05:00
Seednode 15e2cc52cc Added check for empty input paths 2023-04-11 04:44:18 -05:00
Seednode 290395d0eb Updated transitive dependencies 2023-04-10 15:53:01 -05:00
Seednode 63d040839b Updated transitive dependencies 2023-02-26 18:57:52 -06:00
Seednode 966df032a6 Added retry to new file selection, with 10s timeout 2023-02-18 14:08:11 -06:00
Seednode e2356c180f Readded checks in prepareDirectory to avoid redirect issue with sort=asc 2023-02-18 13:38:18 -06:00
Seednode d05550a991 Preallocate slices when possible, remove unnecessary check when sortOrder is provided 2023-02-18 13:00:08 -06:00
Seednode 537633a030 Added persistent stats file 2023-02-08 07:50:40 -06:00
Seednode 9087cf6b4d Replaced log.Fatal() with fmt.Println() and return for non-critical functions 2023-02-07 07:39:04 -06:00
Seednode 6a532e5511 Stats page should actually be sorted now 2023-02-06 12:23:59 -06:00
Seednode ae1a1bbc5e Added zstd compression for cache file 2023-02-05 14:34:22 -06:00
Seednode d2794c721f Removed commented-out old rand source initialization 2023-02-04 23:47:09 -06:00
Seednode 69c4ccfc97 Added support for persistent index file 2023-02-04 23:44:31 -06:00
Seednode 2f92089191 Replaced Run with RunE in rootcmd, to cascade errors back to main Execute() 2023-01-27 13:20:07 -06:00
Seednode 335f6bffde Combined root variable declarations into a block, changed increment/decrement functions to unexported 2023-01-27 13:17:13 -06:00
Seednode 635df29fbc All methods that might mutate state changed to unexported, and all fields set to unexported by default 2023-01-27 10:06:10 -06:00
Seednode 2a6c6b48d4 Reverted changes that entirely broke debug, keeping change to printf strings 2023-01-24 19:06:27 -06:00
Seednode 93fa3640ef Reverted changes that entirely broke debug, keeping change to printf strings 2023-01-24 19:06:15 -06:00
Seednode 3cb2e81ec7 Rearranged functions into alphabetical order 2023-01-24 12:03:26 -06:00
Seednode da5bdfe765 Replaced %v with more specific format string in printf calls 2023-01-24 10:13:09 -06:00
Seednode fa5ae95cb3 Renamed cache handler 2023-01-23 17:41:18 -06:00
Seednode 359ded19f2 Set all functions that modify state to unexported 2023-01-23 17:30:33 -06:00
Seednode 04d253c1e6 Log accesses to /_/stats and reduce verbosity of GenerateCache() 2023-01-21 16:37:32 -06:00
Seednode 66f6069d96 Directly call getFileList() when generating cache, instead of pickFile() 2023-01-21 16:20:35 -06:00
Seednode 3bf3c5b5ed Moved struct and method declarations to the appropriate source files 2023-01-21 16:08:59 -06:00
Seednode 7c40d62496 Sped up indexing when caching is enabled but filters are applied, added RWMutex to Index struct 2023-01-21 10:27:35 -06:00
Seednode 340b637baf Added Get() and Set() functions for file index 2023-01-21 09:35:23 -06:00
Seednode fcdb81a9b7 Fixed double-scanning with cache enabled 2023-01-20 22:42:44 -06:00
Seednode 6c888ba20a Added filesize and timestamps to debug JSON output 2023-01-20 18:14:07 -06:00
Seednode 0f4c4845b2 JSON output for stats is now pretty-printed and sorted alphabetically 2023-01-19 20:31:02 -06:00
Seednode 71bedaf9e8 Changed json keys to lower-case 2023-01-19 12:40:33 -06:00
Seednode ed748a9b8c Corrected usage message 2023-01-19 12:12:40 -06:00
Seednode 1a4496b788 Added stats endpoint 2023-01-19 12:07:15 -06:00
Seednode 979a9e4d4c Added 200 Ok response when clearing cache 2023-01-18 19:14:39 -06:00
Seednode 42734cda62 Added /clear_cache endpoint to regenerate cache on demand 2023-01-18 12:11:23 -06:00
Seednode b96ee8ac99 Removed mutually exclusive flag from cache and filter, now cache is bypassed if filters are supplied 2023-01-18 11:50:29 -06:00
Seednode 0906bd6769 Updated copyright year 2023-01-18 11:19:29 -06:00
Seednode 19fa332ced Cached mode now generates cache on first run, not first HTTP request, to improve initial response time 2023-01-18 11:18:01 -06:00
Seednode d343be7253 Added support for time.Duration refresh intervals, instead of just integer seconds 2023-01-18 09:58:14 -06:00
Seednode 8ddbe8b2c6 Replaced <= 0 with < 1 for readability's sake 2022-12-20 18:24:07 -06:00
Seednode cf79bc1d3d Moved determining real IP address to its own function 2022-12-20 18:17:33 -06:00
Seednode af9def38ba Accidentally referred to response headers, not request headers, when determining IP address 2022-12-20 17:54:27 -06:00
Seednode 3d560ef770 Added initial attempt at reporting proper IPs in logs 2022-12-20 17:48:05 -06:00
Seednode cfbffb6dab Fixed incorrect IsEmpty() check that would return true if exactly one of HasIncludes() or HasExcludes() returned true 2022-12-20 17:12:37 -06:00
Seednode f9d7be008d Combined declare/initialize steps for structs 2022-11-11 09:44:47 -06:00
Seednode d3c063017d Removed extraneous check in getRefreshInterval(), inverted value check in getSortOrder(), replaced string concatenation with strings.Builder in generateFilePath() 2022-11-11 09:19:53 -06:00
Seednode 0b34784b12 Images are now centered, both vertically and horizontally 2022-11-10 23:24:14 -06:00
Seednode eff8394453 Changed variable name from PascalCase to camelCase 2022-11-10 15:34:07 -06:00
Seednode 5f28361f47 Fixed issue where invalid include/exclude values were being accepted 2022-11-10 13:57:38 -06:00
Seednode ea4b1be5c3 Added basic input verification for sortOrder/refreshInterval 2022-11-10 10:09:39 -06:00
Seednode 28af94cba3 Refresh now happens X seconds after page finishes completely loading, not X seconds after the initial request is sent 2022-11-10 09:38:40 -06:00
Seednode 4b596743f7 Replaced error if/else checks with switch/case, to keep things consistent 2022-11-10 00:29:06 -06:00
Seednode 283b4fccec Unified error handling, fixed missing file checks, and added logging for requested (but not available) files 2022-11-10 00:26:21 -06:00
Seednode 0a251e8f5a Always append refresh query string, replaced string concatenation with strings.Builder in generateQueryParams() 2022-11-10 00:04:47 -06:00
Seednode 3e98201cdd Removed extraneous </img> tag and added doctype tag 2022-11-09 23:53:02 -06:00
Seednode f12b800a71 Replaced const string template with strings.Builder, to be hopefully somewhat more readable while still being moderately efficient 2022-11-09 23:33:13 -06:00
Seednode 43a515c896 Replaced image dimension string variable with Dimensions struct, replaced handrolled HTML generation with gohtml library, added height and width to img tags 2022-11-09 23:17:19 -06:00
Seednode ac67d710c8 Moved javascript after img tag 2022-11-09 21:25:04 -06:00
Seednode a9b2af3e18 Fixed improper handling of potentially empty string for strconv.Atoi() 2022-11-08 19:30:08 -06:00
Seednode ea2e17d265 Added automatic reload functionality via query parameters, and rewrote generateQueryParams() to hopefully be more readable 2022-11-08 19:24:49 -06:00
Seednode c213911969 Only generate filter struct once, further simplify switch/case om serveHtmlHandler() into a simple if/else 2022-11-05 11:17:31 -05:00
Seednode b6f7d9c104 Reworked functions to be more concise (e.g. now getNewFile and getNextFile work with or without sortOrder) 2022-11-05 11:00:42 -05:00
Seednode 70a1eaf91d Reverted previous change because the count was actually working fine, I just forgot my test instance was pointing at multiple directories 2022-11-02 09:17:07 -05:00
Seednode ea1d8d52c6 Maybe fixed incorrect total scanned file count displayed when -v is passed 2022-11-02 09:10:55 -05:00
Seednode c13eac975f Fixed length of extensions array, and added bmp to the support formats in the readme 2022-10-31 15:18:47 -05:00
Seednode 3450ea89e0 Fixed for loop requesting out-of-range index in pickFile() 2022-10-29 10:41:03 -05:00
Seednode f6924ba7b5 Added support for .bmp images 2022-10-29 10:32:01 -05:00
Seednode 297c561fab pickFile now iterates through entire file list, instead of stopping after an arbitrary number 2022-10-28 23:07:25 -05:00
Seednode 2274c51e84 Set --cache and --filter as mutually exclusive 2022-10-28 22:59:59 -05:00
Seednode 3d6e7b0493 Added limit on file checking retries 2022-10-28 21:08:08 -05:00
Seednode ad6d7e2cd3 Empty space on image pages is now clickable, and returns a new random image 2022-10-28 19:52:53 -05:00
Seednode 97e3b47b19 Only seed rng once, at initialization, and speed up picking random file by using rand.Intn instead of shuffling the slice 2022-10-28 19:49:49 -05:00
Seednode 920bdb2615 Slight formatting change to HTML output, for consistency's sake 2022-10-28 19:18:34 -05:00
Seednode 5c7bb60dcb Entire 404 page is now clickable, and attempts to open a new random file 2022-10-28 19:09:05 -05:00
Seednode 0434353942 Display image size in tab titles, to match behavior of images served directly 2022-10-28 18:32:03 -05:00
Seednode 8c763db461 Removed two debug print statements I accidentally left in 2022-10-28 17:26:26 -05:00
Seednode f21c01e085 Added flag to cache directory scan at startup 2022-10-28 17:19:04 -05:00
Seednode 44972fde78 Reordered variable initialization to match parameter orders 2022-10-25 09:40:27 -05:00
Seednode 3801421567 Display size of file served when verbose flag is passed 2022-10-25 00:11:55 -05:00
Seednode 0434d87b3e Added symlink handling 2022-10-25 00:06:57 -05:00
Seednode c52ace1fdb Print version on launch 2022-10-23 17:39:49 -05:00
Seednode 8d50f5a088 Second attempt at fixing Linux builds 2022-10-23 16:47:23 -05:00
Seednode f85749b030 Hopefully fixed Linux functionality 2022-10-23 16:29:58 -05:00
Seednode 8dbecba77e Testing initial Windows support 2022-10-23 16:16:40 -05:00
Seednode aa2413eafc Compile regex at start, instead of each page load 2022-10-23 13:45:49 -05:00
Seednode 76109342ed "Replaced switch with sequential if statements" 2022-10-23 13:08:08 -05:00
Seednode ae82762745 Merged -c|--count flag into -v|--verbose, reformatted verbose output 2022-10-20 17:55:25 -05:00
Seednode e39950de68 Switched redirect status code back from 307 to 303, and defined it as a const. 2022-10-20 17:12:29 -05:00
Seednode 8e4c9c5e32 -c|--c now also displays time spent scanning for files 2022-10-20 14:50:42 -05:00
Seednode 1cbc84d789 Attempting to add concurrency, may god have mercy on my soul 2022-10-20 14:22:01 -05:00
Seednode 9cc372d7c4 Added -c|--count flag to display number of files and directories matched and skipped 2022-10-20 11:17:40 -05:00
Seednode 31d16f65b8 Fixed issue where having empty include but non-empty exclude caused 404 2022-10-20 10:38:32 -05:00
Seednode c8a2e56e92 Skipped parsing query params if the corresponding flag isn't enabled 2022-10-19 20:39:57 -05:00
Seednode 6508f2d170 Added flags to enable/disable filtering and sorting 2022-10-19 20:37:12 -05:00
Seednode 7819cf3090 Added handling for errors so it doesn't just silently exit if the port is in use 2022-10-19 20:07:20 -05:00