├── .github └── workflows │ └── release.yml ├── .gitignore ├── .goreleaser.yaml ├── Dockerfile ├── LICENSE.txt ├── Makefile ├── README.md ├── announce.go ├── announce_test.go ├── docs ├── favicon.ico ├── index.html ├── new_torrent_gtk.png ├── new_torrent_mac.png ├── robots.txt └── water.css ├── go.mod ├── go.sum ├── main.go ├── middleware.go ├── scrape.go ├── storage.go └── storage_test.go /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | on: 4 | push: 5 | tags: 6 | - '[0-9]*' # triggers for version tag pushed 7 | 8 | jobs: 9 | build-and-push: 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | - name: Checkout 14 | uses: actions/checkout@v4 15 | with: 16 | fetch-depth: 0 17 | 18 | - name: Set up Go 19 | uses: actions/setup-go@v5 20 | 21 | - name: Run GoReleaser 22 | uses: goreleaser/goreleaser-action@v6 23 | with: 24 | args: release --clean 25 | env: 26 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 27 | 28 | - name: Log in to Docker Hub 29 | uses: docker/login-action@v3 30 | with: 31 | username: meehow 32 | password: ${{ secrets.DOCKERHUB_TOKEN }} 33 | 34 | - name: Build and push 35 | uses: docker/build-push-action@v6 36 | with: 37 | push: true 38 | tags: meehow/privtracker:latest 39 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | privtracker 2 | config.json 3 | dist 4 | *.fiber.gz 5 | 6 | dist/ 7 | -------------------------------------------------------------------------------- /.goreleaser.yaml: -------------------------------------------------------------------------------- 1 | # This is an example .goreleaser.yml file with some sensible defaults. 2 | # Make sure to check the documentation at https://goreleaser.com 3 | 4 | # The lines below are called `modelines`. See `:help modeline` 5 | # Feel free to remove those if you don't want/need to use them. 6 | # yaml-language-server: $schema=https://goreleaser.com/static/schema.json 7 | # vim: set ts=2 sw=2 tw=0 fo=cnqoj 8 | 9 | version: 2 10 | 11 | before: 12 | hooks: 13 | # You may remove this if you don't use go modules. 14 | - go mod tidy 15 | # you may remove this if you don't need go generate 16 | - go generate ./... 17 | 18 | builds: 19 | - env: 20 | - CGO_ENABLED=0 21 | goos: 22 | - linux 23 | - windows 24 | - darwin 25 | ignore: 26 | - goos: windows 27 | goarch: arm64 28 | flags: -trimpath 29 | ldflags: -s -w -buildid= 30 | 31 | archives: 32 | - formats: tar.gz 33 | # this name template makes the OS and Arch compatible with the results of `uname`. 34 | name_template: >- 35 | {{ .ProjectName }}_ 36 | {{- title .Os }}_ 37 | {{- if eq .Arch "amd64" }}x86_64 38 | {{- else if eq .Arch "386" }}i386 39 | {{- else }}{{ .Arch }}{{ end }} 40 | {{- if .Arm }}v{{ .Arm }}{{ end }} 41 | # use zip for windows archives 42 | format_overrides: 43 | - goos: windows 44 | formats: zip 45 | files: 46 | - README.md 47 | - LICENSE.txt 48 | - docs/** 49 | 50 | changelog: 51 | sort: asc 52 | filters: 53 | exclude: 54 | - "^docs:" 55 | - "_test:" 56 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # build app 2 | FROM golang:1-alpine AS builder 3 | 4 | WORKDIR /src 5 | COPY go.mod go.sum ./ 6 | RUN go mod download 7 | 8 | COPY *.go ./ 9 | RUN CGO_ENABLED=0 go build -ldflags="-s -w -buildid=" -trimpath 10 | 11 | # build runner 12 | FROM scratch 13 | 14 | COPY docs /docs 15 | COPY --from=builder /src/privtracker / 16 | 17 | EXPOSE 1337 18 | 19 | ENTRYPOINT ["/privtracker"] 20 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU Affero General Public License is a free, copyleft license for 11 | software and other kinds of works, specifically designed to ensure 12 | cooperation with the community in the case of network server software. 13 | 14 | The licenses for most software and other practical works are designed 15 | to take away your freedom to share and change the works. By contrast, 16 | our General Public Licenses are intended to guarantee your freedom to 17 | share and change all versions of a program--to make sure it remains free 18 | software for all its users. 19 | 20 | When we speak of free software, we are referring to freedom, not 21 | price. Our General Public Licenses are designed to make sure that you 22 | have the freedom to distribute copies of free software (and charge for 23 | them if you wish), that you receive source code or can get it if you 24 | want it, that you can change the software or use pieces of it in new 25 | free programs, and that you know you can do these things. 26 | 27 | Developers that use our General Public Licenses protect your rights 28 | with two steps: (1) assert copyright on the software, and (2) offer 29 | you this License which gives you legal permission to copy, distribute 30 | and/or modify the software. 31 | 32 | A secondary benefit of defending all users' freedom is that 33 | improvements made in alternate versions of the program, if they 34 | receive widespread use, become available for other developers to 35 | incorporate. Many developers of free software are heartened and 36 | encouraged by the resulting cooperation. However, in the case of 37 | software used on network servers, this result may fail to come about. 38 | The GNU General Public License permits making a modified version and 39 | letting the public access it on a server without ever releasing its 40 | source code to the public. 41 | 42 | The GNU Affero General Public License is designed specifically to 43 | ensure that, in such cases, the modified source code becomes available 44 | to the community. It requires the operator of a network server to 45 | provide the source code of the modified version running there to the 46 | users of that server. Therefore, public use of a modified version, on 47 | a publicly accessible server, gives the public access to the source 48 | code of the modified version. 49 | 50 | An older license, called the Affero General Public License and 51 | published by Affero, was designed to accomplish similar goals. This is 52 | a different license, not a version of the Affero GPL, but Affero has 53 | released a new version of the Affero GPL which permits relicensing under 54 | this license. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | TERMS AND CONDITIONS 60 | 61 | 0. Definitions. 62 | 63 | "This License" refers to version 3 of the GNU Affero General Public License. 64 | 65 | "Copyright" also means copyright-like laws that apply to other kinds of 66 | works, such as semiconductor masks. 67 | 68 | "The Program" refers to any copyrightable work licensed under this 69 | License. Each licensee is addressed as "you". "Licensees" and 70 | "recipients" may be individuals or organizations. 71 | 72 | To "modify" a work means to copy from or adapt all or part of the work 73 | in a fashion requiring copyright permission, other than the making of an 74 | exact copy. The resulting work is called a "modified version" of the 75 | earlier work or a work "based on" the earlier work. 76 | 77 | A "covered work" means either the unmodified Program or a work based 78 | on the Program. 79 | 80 | To "propagate" a work means to do anything with it that, without 81 | permission, would make you directly or secondarily liable for 82 | infringement under applicable copyright law, except executing it on a 83 | computer or modifying a private copy. Propagation includes copying, 84 | distribution (with or without modification), making available to the 85 | public, and in some countries other activities as well. 86 | 87 | To "convey" a work means any kind of propagation that enables other 88 | parties to make or receive copies. Mere interaction with a user through 89 | a computer network, with no transfer of a copy, is not conveying. 90 | 91 | An interactive user interface displays "Appropriate Legal Notices" 92 | to the extent that it includes a convenient and prominently visible 93 | feature that (1) displays an appropriate copyright notice, and (2) 94 | tells the user that there is no warranty for the work (except to the 95 | extent that warranties are provided), that licensees may convey the 96 | work under this License, and how to view a copy of this License. If 97 | the interface presents a list of user commands or options, such as a 98 | menu, a prominent item in the list meets this criterion. 99 | 100 | 1. Source Code. 101 | 102 | The "source code" for a work means the preferred form of the work 103 | for making modifications to it. "Object code" means any non-source 104 | form of a work. 105 | 106 | A "Standard Interface" means an interface that either is an official 107 | standard defined by a recognized standards body, or, in the case of 108 | interfaces specified for a particular programming language, one that 109 | is widely used among developers working in that language. 110 | 111 | The "System Libraries" of an executable work include anything, other 112 | than the work as a whole, that (a) is included in the normal form of 113 | packaging a Major Component, but which is not part of that Major 114 | Component, and (b) serves only to enable use of the work with that 115 | Major Component, or to implement a Standard Interface for which an 116 | implementation is available to the public in source code form. A 117 | "Major Component", in this context, means a major essential component 118 | (kernel, window system, and so on) of the specific operating system 119 | (if any) on which the executable work runs, or a compiler used to 120 | produce the work, or an object code interpreter used to run it. 121 | 122 | The "Corresponding Source" for a work in object code form means all 123 | the source code needed to generate, install, and (for an executable 124 | work) run the object code and to modify the work, including scripts to 125 | control those activities. However, it does not include the work's 126 | System Libraries, or general-purpose tools or generally available free 127 | programs which are used unmodified in performing those activities but 128 | which are not part of the work. For example, Corresponding Source 129 | includes interface definition files associated with source files for 130 | the work, and the source code for shared libraries and dynamically 131 | linked subprograms that the work is specifically designed to require, 132 | such as by intimate data communication or control flow between those 133 | subprograms and other parts of the work. 134 | 135 | The Corresponding Source need not include anything that users 136 | can regenerate automatically from other parts of the Corresponding 137 | Source. 138 | 139 | The Corresponding Source for a work in source code form is that 140 | same work. 141 | 142 | 2. Basic Permissions. 143 | 144 | All rights granted under this License are granted for the term of 145 | copyright on the Program, and are irrevocable provided the stated 146 | conditions are met. This License explicitly affirms your unlimited 147 | permission to run the unmodified Program. The output from running a 148 | covered work is covered by this License only if the output, given its 149 | content, constitutes a covered work. This License acknowledges your 150 | rights of fair use or other equivalent, as provided by copyright law. 151 | 152 | You may make, run and propagate covered works that you do not 153 | convey, without conditions so long as your license otherwise remains 154 | in force. You may convey covered works to others for the sole purpose 155 | of having them make modifications exclusively for you, or provide you 156 | with facilities for running those works, provided that you comply with 157 | the terms of this License in conveying all material for which you do 158 | not control copyright. Those thus making or running the covered works 159 | for you must do so exclusively on your behalf, under your direction 160 | and control, on terms that prohibit them from making any copies of 161 | your copyrighted material outside their relationship with you. 162 | 163 | Conveying under any other circumstances is permitted solely under 164 | the conditions stated below. Sublicensing is not allowed; section 10 165 | makes it unnecessary. 166 | 167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 168 | 169 | No covered work shall be deemed part of an effective technological 170 | measure under any applicable law fulfilling obligations under article 171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 172 | similar laws prohibiting or restricting circumvention of such 173 | measures. 174 | 175 | When you convey a covered work, you waive any legal power to forbid 176 | circumvention of technological measures to the extent such circumvention 177 | is effected by exercising rights under this License with respect to 178 | the covered work, and you disclaim any intention to limit operation or 179 | modification of the work as a means of enforcing, against the work's 180 | users, your or third parties' legal rights to forbid circumvention of 181 | technological measures. 182 | 183 | 4. Conveying Verbatim Copies. 184 | 185 | You may convey verbatim copies of the Program's source code as you 186 | receive it, in any medium, provided that you conspicuously and 187 | appropriately publish on each copy an appropriate copyright notice; 188 | keep intact all notices stating that this License and any 189 | non-permissive terms added in accord with section 7 apply to the code; 190 | keep intact all notices of the absence of any warranty; and give all 191 | recipients a copy of this License along with the Program. 192 | 193 | You may charge any price or no price for each copy that you convey, 194 | and you may offer support or warranty protection for a fee. 195 | 196 | 5. Conveying Modified Source Versions. 197 | 198 | You may convey a work based on the Program, or the modifications to 199 | produce it from the Program, in the form of source code under the 200 | terms of section 4, provided that you also meet all of these conditions: 201 | 202 | a) The work must carry prominent notices stating that you modified 203 | it, and giving a relevant date. 204 | 205 | b) The work must carry prominent notices stating that it is 206 | released under this License and any conditions added under section 207 | 7. This requirement modifies the requirement in section 4 to 208 | "keep intact all notices". 209 | 210 | c) You must license the entire work, as a whole, under this 211 | License to anyone who comes into possession of a copy. This 212 | License will therefore apply, along with any applicable section 7 213 | additional terms, to the whole of the work, and all its parts, 214 | regardless of how they are packaged. This License gives no 215 | permission to license the work in any other way, but it does not 216 | invalidate such permission if you have separately received it. 217 | 218 | d) If the work has interactive user interfaces, each must display 219 | Appropriate Legal Notices; however, if the Program has interactive 220 | interfaces that do not display Appropriate Legal Notices, your 221 | work need not make them do so. 222 | 223 | A compilation of a covered work with other separate and independent 224 | works, which are not by their nature extensions of the covered work, 225 | and which are not combined with it such as to form a larger program, 226 | in or on a volume of a storage or distribution medium, is called an 227 | "aggregate" if the compilation and its resulting copyright are not 228 | used to limit the access or legal rights of the compilation's users 229 | beyond what the individual works permit. Inclusion of a covered work 230 | in an aggregate does not cause this License to apply to the other 231 | parts of the aggregate. 232 | 233 | 6. Conveying Non-Source Forms. 234 | 235 | You may convey a covered work in object code form under the terms 236 | of sections 4 and 5, provided that you also convey the 237 | machine-readable Corresponding Source under the terms of this License, 238 | in one of these ways: 239 | 240 | a) Convey the object code in, or embodied in, a physical product 241 | (including a physical distribution medium), accompanied by the 242 | Corresponding Source fixed on a durable physical medium 243 | customarily used for software interchange. 244 | 245 | b) Convey the object code in, or embodied in, a physical product 246 | (including a physical distribution medium), accompanied by a 247 | written offer, valid for at least three years and valid for as 248 | long as you offer spare parts or customer support for that product 249 | model, to give anyone who possesses the object code either (1) a 250 | copy of the Corresponding Source for all the software in the 251 | product that is covered by this License, on a durable physical 252 | medium customarily used for software interchange, for a price no 253 | more than your reasonable cost of physically performing this 254 | conveying of source, or (2) access to copy the 255 | Corresponding Source from a network server at no charge. 256 | 257 | c) Convey individual copies of the object code with a copy of the 258 | written offer to provide the Corresponding Source. This 259 | alternative is allowed only occasionally and noncommercially, and 260 | only if you received the object code with such an offer, in accord 261 | with subsection 6b. 262 | 263 | d) Convey the object code by offering access from a designated 264 | place (gratis or for a charge), and offer equivalent access to the 265 | Corresponding Source in the same way through the same place at no 266 | further charge. You need not require recipients to copy the 267 | Corresponding Source along with the object code. If the place to 268 | copy the object code is a network server, the Corresponding Source 269 | may be on a different server (operated by you or a third party) 270 | that supports equivalent copying facilities, provided you maintain 271 | clear directions next to the object code saying where to find the 272 | Corresponding Source. Regardless of what server hosts the 273 | Corresponding Source, you remain obligated to ensure that it is 274 | available for as long as needed to satisfy these requirements. 275 | 276 | e) Convey the object code using peer-to-peer transmission, provided 277 | you inform other peers where the object code and Corresponding 278 | Source of the work are being offered to the general public at no 279 | charge under subsection 6d. 280 | 281 | A separable portion of the object code, whose source code is excluded 282 | from the Corresponding Source as a System Library, need not be 283 | included in conveying the object code work. 284 | 285 | A "User Product" is either (1) a "consumer product", which means any 286 | tangible personal property which is normally used for personal, family, 287 | or household purposes, or (2) anything designed or sold for incorporation 288 | into a dwelling. In determining whether a product is a consumer product, 289 | doubtful cases shall be resolved in favor of coverage. For a particular 290 | product received by a particular user, "normally used" refers to a 291 | typical or common use of that class of product, regardless of the status 292 | of the particular user or of the way in which the particular user 293 | actually uses, or expects or is expected to use, the product. A product 294 | is a consumer product regardless of whether the product has substantial 295 | commercial, industrial or non-consumer uses, unless such uses represent 296 | the only significant mode of use of the product. 297 | 298 | "Installation Information" for a User Product means any methods, 299 | procedures, authorization keys, or other information required to install 300 | and execute modified versions of a covered work in that User Product from 301 | a modified version of its Corresponding Source. The information must 302 | suffice to ensure that the continued functioning of the modified object 303 | code is in no case prevented or interfered with solely because 304 | modification has been made. 305 | 306 | If you convey an object code work under this section in, or with, or 307 | specifically for use in, a User Product, and the conveying occurs as 308 | part of a transaction in which the right of possession and use of the 309 | User Product is transferred to the recipient in perpetuity or for a 310 | fixed term (regardless of how the transaction is characterized), the 311 | Corresponding Source conveyed under this section must be accompanied 312 | by the Installation Information. But this requirement does not apply 313 | if neither you nor any third party retains the ability to install 314 | modified object code on the User Product (for example, the work has 315 | been installed in ROM). 316 | 317 | The requirement to provide Installation Information does not include a 318 | requirement to continue to provide support service, warranty, or updates 319 | for a work that has been modified or installed by the recipient, or for 320 | the User Product in which it has been modified or installed. Access to a 321 | network may be denied when the modification itself materially and 322 | adversely affects the operation of the network or violates the rules and 323 | protocols for communication across the network. 324 | 325 | Corresponding Source conveyed, and Installation Information provided, 326 | in accord with this section must be in a format that is publicly 327 | documented (and with an implementation available to the public in 328 | source code form), and must require no special password or key for 329 | unpacking, reading or copying. 330 | 331 | 7. Additional Terms. 332 | 333 | "Additional permissions" are terms that supplement the terms of this 334 | License by making exceptions from one or more of its conditions. 335 | Additional permissions that are applicable to the entire Program shall 336 | be treated as though they were included in this License, to the extent 337 | that they are valid under applicable law. If additional permissions 338 | apply only to part of the Program, that part may be used separately 339 | under those permissions, but the entire Program remains governed by 340 | this License without regard to the additional permissions. 341 | 342 | When you convey a copy of a covered work, you may at your option 343 | remove any additional permissions from that copy, or from any part of 344 | it. (Additional permissions may be written to require their own 345 | removal in certain cases when you modify the work.) You may place 346 | additional permissions on material, added by you to a covered work, 347 | for which you have or can give appropriate copyright permission. 348 | 349 | Notwithstanding any other provision of this License, for material you 350 | add to a covered work, you may (if authorized by the copyright holders of 351 | that material) supplement the terms of this License with terms: 352 | 353 | a) Disclaiming warranty or limiting liability differently from the 354 | terms of sections 15 and 16 of this License; or 355 | 356 | b) Requiring preservation of specified reasonable legal notices or 357 | author attributions in that material or in the Appropriate Legal 358 | Notices displayed by works containing it; or 359 | 360 | c) Prohibiting misrepresentation of the origin of that material, or 361 | requiring that modified versions of such material be marked in 362 | reasonable ways as different from the original version; or 363 | 364 | d) Limiting the use for publicity purposes of names of licensors or 365 | authors of the material; or 366 | 367 | e) Declining to grant rights under trademark law for use of some 368 | trade names, trademarks, or service marks; or 369 | 370 | f) Requiring indemnification of licensors and authors of that 371 | material by anyone who conveys the material (or modified versions of 372 | it) with contractual assumptions of liability to the recipient, for 373 | any liability that these contractual assumptions directly impose on 374 | those licensors and authors. 375 | 376 | All other non-permissive additional terms are considered "further 377 | restrictions" within the meaning of section 10. If the Program as you 378 | received it, or any part of it, contains a notice stating that it is 379 | governed by this License along with a term that is a further 380 | restriction, you may remove that term. If a license document contains 381 | a further restriction but permits relicensing or conveying under this 382 | License, you may add to a covered work material governed by the terms 383 | of that license document, provided that the further restriction does 384 | not survive such relicensing or conveying. 385 | 386 | If you add terms to a covered work in accord with this section, you 387 | must place, in the relevant source files, a statement of the 388 | additional terms that apply to those files, or a notice indicating 389 | where to find the applicable terms. 390 | 391 | Additional terms, permissive or non-permissive, may be stated in the 392 | form of a separately written license, or stated as exceptions; 393 | the above requirements apply either way. 394 | 395 | 8. Termination. 396 | 397 | You may not propagate or modify a covered work except as expressly 398 | provided under this License. Any attempt otherwise to propagate or 399 | modify it is void, and will automatically terminate your rights under 400 | this License (including any patent licenses granted under the third 401 | paragraph of section 11). 402 | 403 | However, if you cease all violation of this License, then your 404 | license from a particular copyright holder is reinstated (a) 405 | provisionally, unless and until the copyright holder explicitly and 406 | finally terminates your license, and (b) permanently, if the copyright 407 | holder fails to notify you of the violation by some reasonable means 408 | prior to 60 days after the cessation. 409 | 410 | Moreover, your license from a particular copyright holder is 411 | reinstated permanently if the copyright holder notifies you of the 412 | violation by some reasonable means, this is the first time you have 413 | received notice of violation of this License (for any work) from that 414 | copyright holder, and you cure the violation prior to 30 days after 415 | your receipt of the notice. 416 | 417 | Termination of your rights under this section does not terminate the 418 | licenses of parties who have received copies or rights from you under 419 | this License. If your rights have been terminated and not permanently 420 | reinstated, you do not qualify to receive new licenses for the same 421 | material under section 10. 422 | 423 | 9. Acceptance Not Required for Having Copies. 424 | 425 | You are not required to accept this License in order to receive or 426 | run a copy of the Program. Ancillary propagation of a covered work 427 | occurring solely as a consequence of using peer-to-peer transmission 428 | to receive a copy likewise does not require acceptance. However, 429 | nothing other than this License grants you permission to propagate or 430 | modify any covered work. These actions infringe copyright if you do 431 | not accept this License. Therefore, by modifying or propagating a 432 | covered work, you indicate your acceptance of this License to do so. 433 | 434 | 10. Automatic Licensing of Downstream Recipients. 435 | 436 | Each time you convey a covered work, the recipient automatically 437 | receives a license from the original licensors, to run, modify and 438 | propagate that work, subject to this License. You are not responsible 439 | for enforcing compliance by third parties with this License. 440 | 441 | An "entity transaction" is a transaction transferring control of an 442 | organization, or substantially all assets of one, or subdividing an 443 | organization, or merging organizations. If propagation of a covered 444 | work results from an entity transaction, each party to that 445 | transaction who receives a copy of the work also receives whatever 446 | licenses to the work the party's predecessor in interest had or could 447 | give under the previous paragraph, plus a right to possession of the 448 | Corresponding Source of the work from the predecessor in interest, if 449 | the predecessor has it or can get it with reasonable efforts. 450 | 451 | You may not impose any further restrictions on the exercise of the 452 | rights granted or affirmed under this License. For example, you may 453 | not impose a license fee, royalty, or other charge for exercise of 454 | rights granted under this License, and you may not initiate litigation 455 | (including a cross-claim or counterclaim in a lawsuit) alleging that 456 | any patent claim is infringed by making, using, selling, offering for 457 | sale, or importing the Program or any portion of it. 458 | 459 | 11. Patents. 460 | 461 | A "contributor" is a copyright holder who authorizes use under this 462 | License of the Program or a work on which the Program is based. The 463 | work thus licensed is called the contributor's "contributor version". 464 | 465 | A contributor's "essential patent claims" are all patent claims 466 | owned or controlled by the contributor, whether already acquired or 467 | hereafter acquired, that would be infringed by some manner, permitted 468 | by this License, of making, using, or selling its contributor version, 469 | but do not include claims that would be infringed only as a 470 | consequence of further modification of the contributor version. For 471 | purposes of this definition, "control" includes the right to grant 472 | patent sublicenses in a manner consistent with the requirements of 473 | this License. 474 | 475 | Each contributor grants you a non-exclusive, worldwide, royalty-free 476 | patent license under the contributor's essential patent claims, to 477 | make, use, sell, offer for sale, import and otherwise run, modify and 478 | propagate the contents of its contributor version. 479 | 480 | In the following three paragraphs, a "patent license" is any express 481 | agreement or commitment, however denominated, not to enforce a patent 482 | (such as an express permission to practice a patent or covenant not to 483 | sue for patent infringement). To "grant" such a patent license to a 484 | party means to make such an agreement or commitment not to enforce a 485 | patent against the party. 486 | 487 | If you convey a covered work, knowingly relying on a patent license, 488 | and the Corresponding Source of the work is not available for anyone 489 | to copy, free of charge and under the terms of this License, through a 490 | publicly available network server or other readily accessible means, 491 | then you must either (1) cause the Corresponding Source to be so 492 | available, or (2) arrange to deprive yourself of the benefit of the 493 | patent license for this particular work, or (3) arrange, in a manner 494 | consistent with the requirements of this License, to extend the patent 495 | license to downstream recipients. "Knowingly relying" means you have 496 | actual knowledge that, but for the patent license, your conveying the 497 | covered work in a country, or your recipient's use of the covered work 498 | in a country, would infringe one or more identifiable patents in that 499 | country that you have reason to believe are valid. 500 | 501 | If, pursuant to or in connection with a single transaction or 502 | arrangement, you convey, or propagate by procuring conveyance of, a 503 | covered work, and grant a patent license to some of the parties 504 | receiving the covered work authorizing them to use, propagate, modify 505 | or convey a specific copy of the covered work, then the patent license 506 | you grant is automatically extended to all recipients of the covered 507 | work and works based on it. 508 | 509 | A patent license is "discriminatory" if it does not include within 510 | the scope of its coverage, prohibits the exercise of, or is 511 | conditioned on the non-exercise of one or more of the rights that are 512 | specifically granted under this License. You may not convey a covered 513 | work if you are a party to an arrangement with a third party that is 514 | in the business of distributing software, under which you make payment 515 | to the third party based on the extent of your activity of conveying 516 | the work, and under which the third party grants, to any of the 517 | parties who would receive the covered work from you, a discriminatory 518 | patent license (a) in connection with copies of the covered work 519 | conveyed by you (or copies made from those copies), or (b) primarily 520 | for and in connection with specific products or compilations that 521 | contain the covered work, unless you entered into that arrangement, 522 | or that patent license was granted, prior to 28 March 2007. 523 | 524 | Nothing in this License shall be construed as excluding or limiting 525 | any implied license or other defenses to infringement that may 526 | otherwise be available to you under applicable patent law. 527 | 528 | 12. No Surrender of Others' Freedom. 529 | 530 | If conditions are imposed on you (whether by court order, agreement or 531 | otherwise) that contradict the conditions of this License, they do not 532 | excuse you from the conditions of this License. If you cannot convey a 533 | covered work so as to satisfy simultaneously your obligations under this 534 | License and any other pertinent obligations, then as a consequence you may 535 | not convey it at all. For example, if you agree to terms that obligate you 536 | to collect a royalty for further conveying from those to whom you convey 537 | the Program, the only way you could satisfy both those terms and this 538 | License would be to refrain entirely from conveying the Program. 539 | 540 | 13. Remote Network Interaction; Use with the GNU General Public License. 541 | 542 | Notwithstanding any other provision of this License, if you modify the 543 | Program, your modified version must prominently offer all users 544 | interacting with it remotely through a computer network (if your version 545 | supports such interaction) an opportunity to receive the Corresponding 546 | Source of your version by providing access to the Corresponding Source 547 | from a network server at no charge, through some standard or customary 548 | means of facilitating copying of software. This Corresponding Source 549 | shall include the Corresponding Source for any work covered by version 3 550 | of the GNU General Public License that is incorporated pursuant to the 551 | following paragraph. 552 | 553 | Notwithstanding any other provision of this License, you have 554 | permission to link or combine any covered work with a work licensed 555 | under version 3 of the GNU General Public License into a single 556 | combined work, and to convey the resulting work. The terms of this 557 | License will continue to apply to the part which is the covered work, 558 | but the work with which it is combined will remain governed by version 559 | 3 of the GNU General Public License. 560 | 561 | 14. Revised Versions of this License. 562 | 563 | The Free Software Foundation may publish revised and/or new versions of 564 | the GNU Affero General Public License from time to time. Such new versions 565 | will be similar in spirit to the present version, but may differ in detail to 566 | address new problems or concerns. 567 | 568 | Each version is given a distinguishing version number. If the 569 | Program specifies that a certain numbered version of the GNU Affero General 570 | Public License "or any later version" applies to it, you have the 571 | option of following the terms and conditions either of that numbered 572 | version or of any later version published by the Free Software 573 | Foundation. If the Program does not specify a version number of the 574 | GNU Affero General Public License, you may choose any version ever published 575 | by the Free Software Foundation. 576 | 577 | If the Program specifies that a proxy can decide which future 578 | versions of the GNU Affero General Public License can be used, that proxy's 579 | public statement of acceptance of a version permanently authorizes you 580 | to choose that version for the Program. 581 | 582 | Later license versions may give you additional or different 583 | permissions. However, no additional obligations are imposed on any 584 | author or copyright holder as a result of your choosing to follow a 585 | later version. 586 | 587 | 15. Disclaimer of Warranty. 588 | 589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 597 | 598 | 16. Limitation of Liability. 599 | 600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 608 | SUCH DAMAGES. 609 | 610 | 17. Interpretation of Sections 15 and 16. 611 | 612 | If the disclaimer of warranty and limitation of liability provided 613 | above cannot be given local legal effect according to their terms, 614 | reviewing courts shall apply local law that most closely approximates 615 | an absolute waiver of all civil liability in connection with the 616 | Program, unless a warranty or assumption of liability accompanies a 617 | copy of the Program in return for a fee. 618 | 619 | END OF TERMS AND CONDITIONS 620 | 621 | How to Apply These Terms to Your New Programs 622 | 623 | If you develop a new program, and you want it to be of the greatest 624 | possible use to the public, the best way to achieve this is to make it 625 | free software which everyone can redistribute and change under these terms. 626 | 627 | To do so, attach the following notices to the program. It is safest 628 | to attach them to the start of each source file to most effectively 629 | state the exclusion of warranty; and each file should have at least 630 | the "copyright" line and a pointer to where the full notice is found. 631 | 632 | 633 | Copyright (C) 634 | 635 | This program is free software: you can redistribute it and/or modify 636 | it under the terms of the GNU Affero General Public License as published 637 | by the Free Software Foundation, either version 3 of the License, or 638 | (at your option) any later version. 639 | 640 | This program is distributed in the hope that it will be useful, 641 | but WITHOUT ANY WARRANTY; without even the implied warranty of 642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 643 | GNU Affero General Public License for more details. 644 | 645 | You should have received a copy of the GNU Affero General Public License 646 | along with this program. If not, see . 647 | 648 | Also add information on how to contact you by electronic and paper mail. 649 | 650 | If your software can interact with users remotely through a computer 651 | network, you should also make sure that it provides a way for users to 652 | get its source. For example, if your program is a web application, its 653 | interface could display a "Source" link that leads users to an archive 654 | of the code. There are many ways you could offer source, and different 655 | solutions will be better for different programs; see section 13 for the 656 | specific requirements. 657 | 658 | You should also get your employer (if you work as a programmer) or school, 659 | if any, to sign a "copyright disclaimer" for the program, if necessary. 660 | For more information on this, and how to apply and follow the GNU AGPL, see 661 | . 662 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | build: 2 | CGO_ENABLED=0 go build -ldflags="-s -w -buildid=" -trimpath 3 | 4 | deploy: build 5 | rsync -avzL --exclude '*.gz' docs privtracker privtracker:web/ 6 | 7 | test: 8 | go test -bench . -benchmem 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # [Private BitTorrent tracker for everyone](https://privtracker.com/) 2 | 3 | PrivTracker allows you to share torrent files only with your friends and nobody else. 4 | Unlike public trackers, it shares peers only within a group using the same announce URL. 5 | It really works like a private tracker, but can be generated with one click of a button. 6 | 7 | ## The Problem PrivTracker Solves 8 | 9 | Sharing large files has always been difficult without compromising privacy or simplicity. 10 | Centralized services require full uploads before sharing, often with account registration and fees for large files. 11 | Hosting a file server demands technical knowledge, like opening firewall ports, and requires your computer to stay online. 12 | PrivTracker solves this by enabling private torrent sharing within a trusted group. 13 | Using UPnP, most torrent clients can automatically handle port opening, and only one person in the group needs an open port for everyone to download. 14 | Unlike public trackers, PrivTracker shares peers' IPs only within the group and keeps files off public networks like DHT, ensuring privacy and efficient sharing. 15 | 16 | ### Build 17 | ```bash 18 | git clone https://github.com/meehow/privtracker.git 19 | cd privtracker 20 | make build 21 | ``` 22 | 23 | You can also download pre-built binaries for your system from the [Releases page](https://github.com/meehow/privtracker/releases). 24 | 25 | ### Run PrivTracker without TLS 26 | 27 | By default, PrivTracker will use port 1337. 28 | 29 | ```bash 30 | ./privtracker 31 | ``` 32 | 33 | ### Run PrivTracker with automatic TLS / HTTPS 34 | 35 | If you change the port to 443, PrivTracker will enable automatic TLS handling using [Let's Encrypt](https://letsencrypt.org/) to acquire a certificate. 36 | Port 443 must be accessible from the internet, and you must have a domain name pointing to your server. 37 | 38 | ```bash 39 | sudo setcap cap_net_bind_service=+ep privtracker # allow binding to ports below 1024 40 | PORT=443 ./privtracker 41 | ``` 42 | 43 | ### Example Systemd service 44 | 45 | Below is an example of `/etc/systemd/system/privtracker.service`, which can be used to manage your PrivTracker service. 46 | 47 | Ensure the directory paths are correct before using this configuration. 48 | 49 | ```ini 50 | [Unit] 51 | Description=privtracker 52 | After=network.target 53 | Requires=network.target 54 | 55 | [Service] 56 | Type=simple 57 | User=privtracker 58 | RestartSec=1s 59 | Restart=on-failure 60 | Environment=PORT=443 61 | AmbientCapabilities=CAP_NET_BIND_SERVICE 62 | WorkingDirectory=/home/privtracker/web 63 | ExecStart=/home/privtracker/web/privtracker 64 | 65 | [Install] 66 | WantedBy=multi-user.target 67 | ``` 68 | 69 | ### Example Docker Compose 70 | 71 | ```yaml 72 | services: 73 | privtracker: 74 | image: meehow/privtracker 75 | restart: unless-stopped 76 | user: 1000:1000 77 | environment: 78 | - PORT=1337 79 | # volume is only needed if we listed on port 443 80 | volumes: 81 | - autocert:/.cache/golang-autocert 82 | ports: 83 | - 1337:1337 84 | 85 | volumes: 86 | autocert: 87 | ``` 88 | -------------------------------------------------------------------------------- /announce.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "crypto/sha1" 5 | "fmt" 6 | "net" 7 | "net/http" 8 | "strconv" 9 | "strings" 10 | "time" 11 | 12 | "github.com/jackpal/bencode-go" 13 | ) 14 | 15 | type AnnounceResponse struct { 16 | Interval int `bencode:"interval"` 17 | Complete int `bencode:"complete"` 18 | Incomplete int `bencode:"incomplete"` 19 | Peers []byte `bencode:"peers"` 20 | PeersIPv6 []byte `bencode:"peers6,omitempty"` 21 | ExternalIP []byte `bencode:"external ip,omitempty"` 22 | } 23 | 24 | func announce(w http.ResponseWriter, r *http.Request) { 25 | query := r.URL.Query() 26 | port, err := strconv.ParseUint(query.Get("port"), 10, 16) 27 | if err != nil { 28 | http.Error(w, "port missing", 400) 29 | return 30 | } 31 | ip := getRemoteIP(r) 32 | if ip == nil { 33 | http.Error(w, "can't parse IP", 400) 34 | return 35 | } 36 | numwant, err := strconv.Atoi(query.Get("numwant")) 37 | if err != nil || numwant < 1 { 38 | numwant = 30 39 | } 40 | swarmHash := sha1.Sum([]byte(r.PathValue("room") + query.Get("info_hash"))) 41 | peer := NewPeer(ip, uint16(port)) 42 | isSeeding := query.Get("left") == "0" 43 | switch query.Get("event") { 44 | case "stopped": 45 | DeletePeer(swarmHash, peer) 46 | case "completed": 47 | GraduateLeecher(swarmHash, peer) 48 | default: 49 | PutPeer(swarmHash, peer, isSeeding) 50 | } 51 | peersIPv4, peersIPv6, numSeeders, numLeechers := GetPeers(swarmHash, peer, isSeeding, numwant) 52 | interval := 480 // must be smaller than cleanup interval 53 | switch { 54 | case numSeeders+numLeechers < 10: 55 | // try to synchronize peer requests. Maybe it will help µTP with UDP port punching... not sure 56 | interval = 240 - int(time.Now().Unix()+int64(swarmHash[0]))%240 57 | if interval < 60 { 58 | interval += 240 59 | } 60 | case numSeeders+numLeechers > 30: 61 | interval = 900 62 | } 63 | resp := AnnounceResponse{ 64 | Interval: interval, 65 | Complete: numSeeders, 66 | Incomplete: numLeechers, 67 | Peers: peersIPv4, 68 | PeersIPv6: peersIPv6, 69 | ExternalIP: ip.To4(), 70 | } 71 | w.Header().Add("X-PrivTracker", fmt.Sprintf("s:%d l:%d", numSeeders, numLeechers)) 72 | if err := bencode.Marshal(w, resp); err != nil { 73 | http.Error(w, err.Error(), 400) 74 | } 75 | } 76 | 77 | func getRemoteIP(r *http.Request) net.IP { 78 | addr := r.RemoteAddr 79 | if colonIndex := strings.LastIndex(addr, ":"); colonIndex != -1 { 80 | addr = addr[:colonIndex] 81 | } 82 | addr = strings.Trim(addr, "[]") 83 | ip := net.ParseIP(addr) 84 | if ip.IsPrivate() { 85 | ips := strings.Split(r.Header.Get("X-Forwarded-For"), ",") 86 | for _, maybeIP := range ips { 87 | ipForwarded := net.ParseIP(strings.TrimSpace(maybeIP)) 88 | if !ipForwarded.IsPrivate() { 89 | ip = ipForwarded 90 | break 91 | } 92 | } 93 | if len(ips) > 0 { 94 | } 95 | } 96 | return ip 97 | } 98 | -------------------------------------------------------------------------------- /announce_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "net/http" 5 | "net/http/httptest" 6 | "testing" 7 | ) 8 | 9 | func BenchmarkAnnounce(b *testing.B) { 10 | server := httptest.NewServer(router()) 11 | client := server.Client() 12 | for i := 0; i < b.N; i++ { 13 | resp, err := client.Get(server.URL + "/test/announce?port=1234") 14 | if err != nil { 15 | b.Fatal(err) 16 | } 17 | if resp.StatusCode != http.StatusOK { 18 | b.Fatalf("unexpected status code: %d", resp.StatusCode) 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /docs/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meehow/privtracker/bba1b07b2043ca0cffd0f021f84ad351ab65756d/docs/favicon.ico -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | PrivTracker - Private BitTorrent tracker for everyone 10 | 35 | 66 | 67 | 68 | 69 | 72 |
73 |

PrivTracker

74 |

Private BitTorrent tracker for everyone

75 |

76 | PrivTracker allows you to share torrent files only with your friends and nobody else. 77 | Unlike public trackers, it shares peers only within a group using the same announce URL. 78 | It really works like a private tracker, but can be generated with one click of a button. 79 |

80 | 81 | 82 | 83 | 89 | 90 |

How to create private torrent?

91 |

Using transmission on Linux:

92 |
    93 |
  • File New…
  • 94 |
  • Select file to share
  • 95 |
  • In Trackers field enter {{origin}}/{{room}}/announce
  • 96 |
  • Select Private torrent
  • 97 |
  • Click New
  • 98 |
  • Click Add in next window
  • 99 |
  • Click Open to start seeding
  • 100 |
  • Done. Now you can send torrent file to your friends…
  • 101 |
102 |
103 | New Torrent screenshot 104 |
{{origin}}/{{room}}/announce
105 |
106 |

Using transmission on Mac:

107 |
    108 |
  • File Create Torrent File…
  • 109 |
  • Select file to share
  • 110 |
  • Click + under Trackers field and enter {{origin}}/{{room}}/announce
  • 112 |
  • Select Private 113 |
  • Select Open when created
  • 114 |
  • Click Create
  • 115 |
  • Click Add to start seeding
  • 116 |
  • Done. Now you can send torrent file to your friends…
  • 117 |
118 |
119 | New Torrent screenshot 120 |
{{origin}}/{{room}}/announce
121 |
122 | 123 |

The Problem PrivTracker solves

124 |

125 | Sharing large files has always been difficult without compromising privacy or simplicity. 126 | Centralized services require full uploads before sharing, often with account registration and fees for 127 | large files. 128 | Hosting a file server demands technical knowledge, like opening firewall ports, and requires your 129 | computer to stay online. 130 | PrivTracker solves this by enabling private torrent sharing within a trusted group. 131 | Using UPnP, most torrent clients can automatically handle port opening, and only one person in the group 132 | needs an open port for everyone to download. 133 | Unlike public trackers, PrivTracker shares peers' IPs only within the group and keeps files off public 134 | networks like DHT, ensuring privacy and efficient sharing. 135 |

136 |
137 | 138 | 139 | -------------------------------------------------------------------------------- /docs/new_torrent_gtk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meehow/privtracker/bba1b07b2043ca0cffd0f021f84ad351ab65756d/docs/new_torrent_gtk.png -------------------------------------------------------------------------------- /docs/new_torrent_mac.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/meehow/privtracker/bba1b07b2043ca0cffd0f021f84ad351ab65756d/docs/new_torrent_mac.png -------------------------------------------------------------------------------- /docs/robots.txt: -------------------------------------------------------------------------------- 1 | User-Agent: * 2 | Disallow: /*/announce$ 3 | Disallow: /*/scrape$ -------------------------------------------------------------------------------- /docs/water.css: -------------------------------------------------------------------------------- 1 | /** 2 | * Automatic version: 3 | * Uses light theme by default but switches to dark theme 4 | * if a system-wide theme preference is set on the user's device. 5 | */ 6 | 7 | :root { 8 | --background-body: #fff; 9 | --background: #efefef; 10 | --background-alt: #f7f7f7; 11 | --selection: #9e9e9e; 12 | --text-main: #363636; 13 | --text-bright: #000; 14 | --text-muted: #70777f; 15 | --links: #0076d1; 16 | --focus: #0096bfab; 17 | --border: #dbdbdb; 18 | --code: #000; 19 | --animation-duration: 0.1s; 20 | --button-base: #d0cfcf; 21 | --button-hover: #9b9b9b; 22 | --scrollbar-thumb: rgb(170, 170, 170); 23 | --scrollbar-thumb-hover: var(--button-hover); 24 | --form-placeholder: #949494; 25 | --form-text: #1d1d1d; 26 | --variable: #39a33c; 27 | --highlight: #ff0; 28 | --select-arrow: url("data:image/svg+xml;charset=utf-8,%3C?xml version='1.0' encoding='utf-8'?%3E %3Csvg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' height='62.5' width='116.9' fill='%23161f27'%3E %3Cpath d='M115.3,1.6 C113.7,0 111.1,0 109.5,1.6 L58.5,52.7 L7.4,1.6 C5.8,0 3.2,0 1.6,1.6 C0,3.2 0,5.8 1.6,7.4 L55.5,61.3 C56.3,62.1 57.3,62.5 58.4,62.5 C59.4,62.5 60.5,62.1 61.3,61.3 L115.2,7.4 C116.9,5.8 116.9,3.2 115.3,1.6Z'/%3E %3C/svg%3E"); 29 | } 30 | 31 | @media (prefers-color-scheme: dark) { 32 | :root { 33 | --background-body: #202b38; 34 | --background: #161f27; 35 | --background-alt: #1a242f; 36 | --selection: #1c76c5; 37 | --text-main: #dbdbdb; 38 | --text-bright: #fff; 39 | --text-muted: #a9b1ba; 40 | --links: #41adff; 41 | --focus: #0096bfab; 42 | --border: #526980; 43 | --code: #ffbe85; 44 | --animation-duration: 0.1s; 45 | --button-base: #0c151c; 46 | --button-hover: #040a0f; 47 | --scrollbar-thumb: var(--button-hover); 48 | --scrollbar-thumb-hover: rgb(0, 0, 0); 49 | --form-placeholder: #a9a9a9; 50 | --form-text: #fff; 51 | --variable: #d941e2; 52 | --highlight: #efdb43; 53 | --select-arrow: url("data:image/svg+xml;charset=utf-8,%3C?xml version='1.0' encoding='utf-8'?%3E %3Csvg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' height='62.5' width='116.9' fill='%23efefef'%3E %3Cpath d='M115.3,1.6 C113.7,0 111.1,0 109.5,1.6 L58.5,52.7 L7.4,1.6 C5.8,0 3.2,0 1.6,1.6 C0,3.2 0,5.8 1.6,7.4 L55.5,61.3 C56.3,62.1 57.3,62.5 58.4,62.5 C59.4,62.5 60.5,62.1 61.3,61.3 L115.2,7.4 C116.9,5.8 116.9,3.2 115.3,1.6Z'/%3E %3C/svg%3E"); 54 | } 55 | } 56 | 57 | html { 58 | scrollbar-color: rgb(170, 170, 170) #fff; 59 | scrollbar-color: var(--scrollbar-thumb) var(--background-body); 60 | scrollbar-width: thin; 61 | } 62 | 63 | @media (prefers-color-scheme: dark) { 64 | 65 | html { 66 | scrollbar-color: #040a0f #202b38; 67 | scrollbar-color: var(--scrollbar-thumb) var(--background-body); 68 | } 69 | } 70 | 71 | @media (prefers-color-scheme: dark) { 72 | 73 | html { 74 | scrollbar-color: #040a0f #202b38; 75 | scrollbar-color: var(--scrollbar-thumb) var(--background-body); 76 | } 77 | } 78 | 79 | @media (prefers-color-scheme: dark) { 80 | 81 | html { 82 | scrollbar-color: #040a0f #202b38; 83 | scrollbar-color: var(--scrollbar-thumb) var(--background-body); 84 | } 85 | } 86 | 87 | @media (prefers-color-scheme: dark) { 88 | 89 | html { 90 | scrollbar-color: #040a0f #202b38; 91 | scrollbar-color: var(--scrollbar-thumb) var(--background-body); 92 | } 93 | } 94 | 95 | @media (prefers-color-scheme: dark) { 96 | 97 | html { 98 | scrollbar-color: #040a0f #202b38; 99 | scrollbar-color: var(--scrollbar-thumb) var(--background-body); 100 | } 101 | } 102 | 103 | @media (prefers-color-scheme: dark) { 104 | 105 | html { 106 | scrollbar-color: #040a0f #202b38; 107 | scrollbar-color: var(--scrollbar-thumb) var(--background-body); 108 | } 109 | } 110 | 111 | body { 112 | font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 'Segoe UI Emoji', 'Apple Color Emoji', 'Noto Color Emoji', sans-serif; 113 | line-height: 1.4; 114 | max-width: 800px; 115 | margin: 20px auto; 116 | padding: 0 10px; 117 | word-wrap: break-word; 118 | color: #363636; 119 | color: var(--text-main); 120 | background: #fff; 121 | background: var(--background-body); 122 | text-rendering: optimizeLegibility; 123 | } 124 | 125 | @media (prefers-color-scheme: dark) { 126 | 127 | body { 128 | background: #202b38; 129 | background: var(--background-body); 130 | } 131 | } 132 | 133 | @media (prefers-color-scheme: dark) { 134 | 135 | body { 136 | color: #dbdbdb; 137 | color: var(--text-main); 138 | } 139 | } 140 | 141 | button { 142 | transition: 143 | background-color 0.1s linear, 144 | border-color 0.1s linear, 145 | color 0.1s linear, 146 | box-shadow 0.1s linear, 147 | transform 0.1s ease; 148 | transition: 149 | background-color var(--animation-duration) linear, 150 | border-color var(--animation-duration) linear, 151 | color var(--animation-duration) linear, 152 | box-shadow var(--animation-duration) linear, 153 | transform var(--animation-duration) ease; 154 | } 155 | 156 | @media (prefers-color-scheme: dark) { 157 | 158 | button { 159 | transition: 160 | background-color 0.1s linear, 161 | border-color 0.1s linear, 162 | color 0.1s linear, 163 | box-shadow 0.1s linear, 164 | transform 0.1s ease; 165 | transition: 166 | background-color var(--animation-duration) linear, 167 | border-color var(--animation-duration) linear, 168 | color var(--animation-duration) linear, 169 | box-shadow var(--animation-duration) linear, 170 | transform var(--animation-duration) ease; 171 | } 172 | } 173 | 174 | input { 175 | transition: 176 | background-color 0.1s linear, 177 | border-color 0.1s linear, 178 | color 0.1s linear, 179 | box-shadow 0.1s linear, 180 | transform 0.1s ease; 181 | transition: 182 | background-color var(--animation-duration) linear, 183 | border-color var(--animation-duration) linear, 184 | color var(--animation-duration) linear, 185 | box-shadow var(--animation-duration) linear, 186 | transform var(--animation-duration) ease; 187 | } 188 | 189 | @media (prefers-color-scheme: dark) { 190 | 191 | input { 192 | transition: 193 | background-color 0.1s linear, 194 | border-color 0.1s linear, 195 | color 0.1s linear, 196 | box-shadow 0.1s linear, 197 | transform 0.1s ease; 198 | transition: 199 | background-color var(--animation-duration) linear, 200 | border-color var(--animation-duration) linear, 201 | color var(--animation-duration) linear, 202 | box-shadow var(--animation-duration) linear, 203 | transform var(--animation-duration) ease; 204 | } 205 | } 206 | 207 | textarea { 208 | transition: 209 | background-color 0.1s linear, 210 | border-color 0.1s linear, 211 | color 0.1s linear, 212 | box-shadow 0.1s linear, 213 | transform 0.1s ease; 214 | transition: 215 | background-color var(--animation-duration) linear, 216 | border-color var(--animation-duration) linear, 217 | color var(--animation-duration) linear, 218 | box-shadow var(--animation-duration) linear, 219 | transform var(--animation-duration) ease; 220 | } 221 | 222 | @media (prefers-color-scheme: dark) { 223 | 224 | textarea { 225 | transition: 226 | background-color 0.1s linear, 227 | border-color 0.1s linear, 228 | color 0.1s linear, 229 | box-shadow 0.1s linear, 230 | transform 0.1s ease; 231 | transition: 232 | background-color var(--animation-duration) linear, 233 | border-color var(--animation-duration) linear, 234 | color var(--animation-duration) linear, 235 | box-shadow var(--animation-duration) linear, 236 | transform var(--animation-duration) ease; 237 | } 238 | } 239 | 240 | h1 { 241 | font-size: 2.2em; 242 | margin-top: 0; 243 | } 244 | 245 | h1, 246 | h2, 247 | h3, 248 | h4, 249 | h5, 250 | h6 { 251 | margin-bottom: 12px; 252 | margin-top: 24px; 253 | } 254 | 255 | h1 { 256 | color: #000; 257 | color: var(--text-bright); 258 | } 259 | 260 | @media (prefers-color-scheme: dark) { 261 | 262 | h1 { 263 | color: #fff; 264 | color: var(--text-bright); 265 | } 266 | } 267 | 268 | h2 { 269 | color: #000; 270 | color: var(--text-bright); 271 | } 272 | 273 | @media (prefers-color-scheme: dark) { 274 | 275 | h2 { 276 | color: #fff; 277 | color: var(--text-bright); 278 | } 279 | } 280 | 281 | h3 { 282 | color: #000; 283 | color: var(--text-bright); 284 | } 285 | 286 | @media (prefers-color-scheme: dark) { 287 | 288 | h3 { 289 | color: #fff; 290 | color: var(--text-bright); 291 | } 292 | } 293 | 294 | h4 { 295 | color: #000; 296 | color: var(--text-bright); 297 | } 298 | 299 | @media (prefers-color-scheme: dark) { 300 | 301 | h4 { 302 | color: #fff; 303 | color: var(--text-bright); 304 | } 305 | } 306 | 307 | h5 { 308 | color: #000; 309 | color: var(--text-bright); 310 | } 311 | 312 | @media (prefers-color-scheme: dark) { 313 | 314 | h5 { 315 | color: #fff; 316 | color: var(--text-bright); 317 | } 318 | } 319 | 320 | h6 { 321 | color: #000; 322 | color: var(--text-bright); 323 | } 324 | 325 | @media (prefers-color-scheme: dark) { 326 | 327 | h6 { 328 | color: #fff; 329 | color: var(--text-bright); 330 | } 331 | } 332 | 333 | strong { 334 | color: #000; 335 | color: var(--text-bright); 336 | } 337 | 338 | @media (prefers-color-scheme: dark) { 339 | 340 | strong { 341 | color: #fff; 342 | color: var(--text-bright); 343 | } 344 | } 345 | 346 | h1, 347 | h2, 348 | h3, 349 | h4, 350 | h5, 351 | h6, 352 | b, 353 | strong, 354 | th { 355 | font-weight: 600; 356 | } 357 | 358 | q::before { 359 | content: none; 360 | } 361 | 362 | q::after { 363 | content: none; 364 | } 365 | 366 | blockquote { 367 | border-left: 4px solid #0096bfab; 368 | border-left: 4px solid var(--focus); 369 | margin: 1.5em 0; 370 | padding: 0.5em 1em; 371 | font-style: italic; 372 | } 373 | 374 | @media (prefers-color-scheme: dark) { 375 | 376 | blockquote { 377 | border-left: 4px solid #0096bfab; 378 | border-left: 4px solid var(--focus); 379 | } 380 | } 381 | 382 | q { 383 | border-left: 4px solid #0096bfab; 384 | border-left: 4px solid var(--focus); 385 | margin: 1.5em 0; 386 | padding: 0.5em 1em; 387 | font-style: italic; 388 | } 389 | 390 | @media (prefers-color-scheme: dark) { 391 | 392 | q { 393 | border-left: 4px solid #0096bfab; 394 | border-left: 4px solid var(--focus); 395 | } 396 | } 397 | 398 | blockquote > footer { 399 | font-style: normal; 400 | border: 0; 401 | } 402 | 403 | blockquote cite { 404 | font-style: normal; 405 | } 406 | 407 | address { 408 | font-style: normal; 409 | } 410 | 411 | a[href^='mailto\:']::before { 412 | content: '📧 '; 413 | } 414 | 415 | a[href^='tel\:']::before { 416 | content: '📞 '; 417 | } 418 | 419 | a[href^='sms\:']::before { 420 | content: '💬 '; 421 | } 422 | 423 | mark { 424 | background-color: #ff0; 425 | background-color: var(--highlight); 426 | border-radius: 2px; 427 | padding: 0 2px 0 2px; 428 | color: #000; 429 | } 430 | 431 | @media (prefers-color-scheme: dark) { 432 | 433 | mark { 434 | background-color: #efdb43; 435 | background-color: var(--highlight); 436 | } 437 | } 438 | 439 | a > code, 440 | a > strong { 441 | color: inherit; 442 | } 443 | 444 | button, 445 | select, 446 | input[type='submit'], 447 | input[type='reset'], 448 | input[type='button'], 449 | input[type='checkbox'], 450 | input[type='range'], 451 | input[type='radio'] { 452 | cursor: pointer; 453 | } 454 | 455 | input, 456 | select { 457 | display: block; 458 | } 459 | 460 | [type='checkbox'], 461 | [type='radio'] { 462 | display: initial; 463 | } 464 | 465 | input { 466 | color: #1d1d1d; 467 | color: var(--form-text); 468 | background-color: #efefef; 469 | background-color: var(--background); 470 | font-family: inherit; 471 | font-size: inherit; 472 | margin-right: 6px; 473 | margin-bottom: 6px; 474 | padding: 10px; 475 | border: none; 476 | border-radius: 6px; 477 | outline: none; 478 | } 479 | 480 | @media (prefers-color-scheme: dark) { 481 | 482 | input { 483 | background-color: #161f27; 484 | background-color: var(--background); 485 | } 486 | } 487 | 488 | @media (prefers-color-scheme: dark) { 489 | 490 | input { 491 | color: #fff; 492 | color: var(--form-text); 493 | } 494 | } 495 | 496 | button { 497 | color: #1d1d1d; 498 | color: var(--form-text); 499 | background-color: #efefef; 500 | background-color: var(--background); 501 | font-family: inherit; 502 | font-size: inherit; 503 | margin-right: 6px; 504 | margin-bottom: 6px; 505 | padding: 10px; 506 | border: none; 507 | border-radius: 6px; 508 | outline: none; 509 | } 510 | 511 | @media (prefers-color-scheme: dark) { 512 | 513 | button { 514 | background-color: #161f27; 515 | background-color: var(--background); 516 | } 517 | } 518 | 519 | @media (prefers-color-scheme: dark) { 520 | 521 | button { 522 | color: #fff; 523 | color: var(--form-text); 524 | } 525 | } 526 | 527 | textarea { 528 | color: #1d1d1d; 529 | color: var(--form-text); 530 | background-color: #efefef; 531 | background-color: var(--background); 532 | font-family: inherit; 533 | font-size: inherit; 534 | margin-right: 6px; 535 | margin-bottom: 6px; 536 | padding: 10px; 537 | border: none; 538 | border-radius: 6px; 539 | outline: none; 540 | } 541 | 542 | @media (prefers-color-scheme: dark) { 543 | 544 | textarea { 545 | background-color: #161f27; 546 | background-color: var(--background); 547 | } 548 | } 549 | 550 | @media (prefers-color-scheme: dark) { 551 | 552 | textarea { 553 | color: #fff; 554 | color: var(--form-text); 555 | } 556 | } 557 | 558 | select { 559 | color: #1d1d1d; 560 | color: var(--form-text); 561 | background-color: #efefef; 562 | background-color: var(--background); 563 | font-family: inherit; 564 | font-size: inherit; 565 | margin-right: 6px; 566 | margin-bottom: 6px; 567 | padding: 10px; 568 | border: none; 569 | border-radius: 6px; 570 | outline: none; 571 | } 572 | 573 | @media (prefers-color-scheme: dark) { 574 | 575 | select { 576 | background-color: #161f27; 577 | background-color: var(--background); 578 | } 579 | } 580 | 581 | @media (prefers-color-scheme: dark) { 582 | 583 | select { 584 | color: #fff; 585 | color: var(--form-text); 586 | } 587 | } 588 | 589 | button { 590 | background-color: #d0cfcf; 591 | background-color: var(--button-base); 592 | padding-right: 30px; 593 | padding-left: 30px; 594 | } 595 | 596 | @media (prefers-color-scheme: dark) { 597 | 598 | button { 599 | background-color: #0c151c; 600 | background-color: var(--button-base); 601 | } 602 | } 603 | 604 | input[type='submit'] { 605 | background-color: #d0cfcf; 606 | background-color: var(--button-base); 607 | padding-right: 30px; 608 | padding-left: 30px; 609 | } 610 | 611 | @media (prefers-color-scheme: dark) { 612 | 613 | input[type='submit'] { 614 | background-color: #0c151c; 615 | background-color: var(--button-base); 616 | } 617 | } 618 | 619 | input[type='reset'] { 620 | background-color: #d0cfcf; 621 | background-color: var(--button-base); 622 | padding-right: 30px; 623 | padding-left: 30px; 624 | } 625 | 626 | @media (prefers-color-scheme: dark) { 627 | 628 | input[type='reset'] { 629 | background-color: #0c151c; 630 | background-color: var(--button-base); 631 | } 632 | } 633 | 634 | input[type='button'] { 635 | background-color: #d0cfcf; 636 | background-color: var(--button-base); 637 | padding-right: 30px; 638 | padding-left: 30px; 639 | } 640 | 641 | @media (prefers-color-scheme: dark) { 642 | 643 | input[type='button'] { 644 | background-color: #0c151c; 645 | background-color: var(--button-base); 646 | } 647 | } 648 | 649 | button:hover { 650 | background: #9b9b9b; 651 | background: var(--button-hover); 652 | } 653 | 654 | @media (prefers-color-scheme: dark) { 655 | 656 | button:hover { 657 | background: #040a0f; 658 | background: var(--button-hover); 659 | } 660 | } 661 | 662 | input[type='submit']:hover { 663 | background: #9b9b9b; 664 | background: var(--button-hover); 665 | } 666 | 667 | @media (prefers-color-scheme: dark) { 668 | 669 | input[type='submit']:hover { 670 | background: #040a0f; 671 | background: var(--button-hover); 672 | } 673 | } 674 | 675 | input[type='reset']:hover { 676 | background: #9b9b9b; 677 | background: var(--button-hover); 678 | } 679 | 680 | @media (prefers-color-scheme: dark) { 681 | 682 | input[type='reset']:hover { 683 | background: #040a0f; 684 | background: var(--button-hover); 685 | } 686 | } 687 | 688 | input[type='button']:hover { 689 | background: #9b9b9b; 690 | background: var(--button-hover); 691 | } 692 | 693 | @media (prefers-color-scheme: dark) { 694 | 695 | input[type='button']:hover { 696 | background: #040a0f; 697 | background: var(--button-hover); 698 | } 699 | } 700 | 701 | input[type='color'] { 702 | min-height: 2rem; 703 | padding: 8px; 704 | cursor: pointer; 705 | } 706 | 707 | input[type='checkbox'], 708 | input[type='radio'] { 709 | height: 1em; 710 | width: 1em; 711 | } 712 | 713 | input[type='radio'] { 714 | border-radius: 100%; 715 | } 716 | 717 | input { 718 | vertical-align: top; 719 | } 720 | 721 | label { 722 | vertical-align: middle; 723 | margin-bottom: 4px; 724 | display: inline-block; 725 | } 726 | 727 | input:not([type='checkbox']):not([type='radio']), 728 | input[type='range'], 729 | select, 730 | button, 731 | textarea { 732 | -webkit-appearance: none; 733 | } 734 | 735 | textarea { 736 | display: block; 737 | margin-right: 0; 738 | box-sizing: border-box; 739 | resize: vertical; 740 | } 741 | 742 | textarea:not([cols]) { 743 | width: 100%; 744 | } 745 | 746 | textarea:not([rows]) { 747 | min-height: 40px; 748 | height: 140px; 749 | } 750 | 751 | select { 752 | background: #efefef url("data:image/svg+xml;charset=utf-8,%3C?xml version='1.0' encoding='utf-8'?%3E %3Csvg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' height='62.5' width='116.9' fill='%23161f27'%3E %3Cpath d='M115.3,1.6 C113.7,0 111.1,0 109.5,1.6 L58.5,52.7 L7.4,1.6 C5.8,0 3.2,0 1.6,1.6 C0,3.2 0,5.8 1.6,7.4 L55.5,61.3 C56.3,62.1 57.3,62.5 58.4,62.5 C59.4,62.5 60.5,62.1 61.3,61.3 L115.2,7.4 C116.9,5.8 116.9,3.2 115.3,1.6Z'/%3E %3C/svg%3E") calc(100% - 12px) 50% / 12px no-repeat; 753 | background: var(--background) var(--select-arrow) calc(100% - 12px) 50% / 12px no-repeat; 754 | padding-right: 35px; 755 | } 756 | 757 | @media (prefers-color-scheme: dark) { 758 | 759 | select { 760 | background: #161f27 url("data:image/svg+xml;charset=utf-8,%3C?xml version='1.0' encoding='utf-8'?%3E %3Csvg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' height='62.5' width='116.9' fill='%23efefef'%3E %3Cpath d='M115.3,1.6 C113.7,0 111.1,0 109.5,1.6 L58.5,52.7 L7.4,1.6 C5.8,0 3.2,0 1.6,1.6 C0,3.2 0,5.8 1.6,7.4 L55.5,61.3 C56.3,62.1 57.3,62.5 58.4,62.5 C59.4,62.5 60.5,62.1 61.3,61.3 L115.2,7.4 C116.9,5.8 116.9,3.2 115.3,1.6Z'/%3E %3C/svg%3E") calc(100% - 12px) 50% / 12px no-repeat; 761 | background: var(--background) var(--select-arrow) calc(100% - 12px) 50% / 12px no-repeat; 762 | } 763 | } 764 | 765 | @media (prefers-color-scheme: dark) { 766 | 767 | select { 768 | background: #161f27 url("data:image/svg+xml;charset=utf-8,%3C?xml version='1.0' encoding='utf-8'?%3E %3Csvg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' height='62.5' width='116.9' fill='%23efefef'%3E %3Cpath d='M115.3,1.6 C113.7,0 111.1,0 109.5,1.6 L58.5,52.7 L7.4,1.6 C5.8,0 3.2,0 1.6,1.6 C0,3.2 0,5.8 1.6,7.4 L55.5,61.3 C56.3,62.1 57.3,62.5 58.4,62.5 C59.4,62.5 60.5,62.1 61.3,61.3 L115.2,7.4 C116.9,5.8 116.9,3.2 115.3,1.6Z'/%3E %3C/svg%3E") calc(100% - 12px) 50% / 12px no-repeat; 769 | background: var(--background) var(--select-arrow) calc(100% - 12px) 50% / 12px no-repeat; 770 | } 771 | } 772 | 773 | @media (prefers-color-scheme: dark) { 774 | 775 | select { 776 | background: #161f27 url("data:image/svg+xml;charset=utf-8,%3C?xml version='1.0' encoding='utf-8'?%3E %3Csvg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' height='62.5' width='116.9' fill='%23efefef'%3E %3Cpath d='M115.3,1.6 C113.7,0 111.1,0 109.5,1.6 L58.5,52.7 L7.4,1.6 C5.8,0 3.2,0 1.6,1.6 C0,3.2 0,5.8 1.6,7.4 L55.5,61.3 C56.3,62.1 57.3,62.5 58.4,62.5 C59.4,62.5 60.5,62.1 61.3,61.3 L115.2,7.4 C116.9,5.8 116.9,3.2 115.3,1.6Z'/%3E %3C/svg%3E") calc(100% - 12px) 50% / 12px no-repeat; 777 | background: var(--background) var(--select-arrow) calc(100% - 12px) 50% / 12px no-repeat; 778 | } 779 | } 780 | 781 | @media (prefers-color-scheme: dark) { 782 | 783 | select { 784 | background: #161f27 url("data:image/svg+xml;charset=utf-8,%3C?xml version='1.0' encoding='utf-8'?%3E %3Csvg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' height='62.5' width='116.9' fill='%23efefef'%3E %3Cpath d='M115.3,1.6 C113.7,0 111.1,0 109.5,1.6 L58.5,52.7 L7.4,1.6 C5.8,0 3.2,0 1.6,1.6 C0,3.2 0,5.8 1.6,7.4 L55.5,61.3 C56.3,62.1 57.3,62.5 58.4,62.5 C59.4,62.5 60.5,62.1 61.3,61.3 L115.2,7.4 C116.9,5.8 116.9,3.2 115.3,1.6Z'/%3E %3C/svg%3E") calc(100% - 12px) 50% / 12px no-repeat; 785 | background: var(--background) var(--select-arrow) calc(100% - 12px) 50% / 12px no-repeat; 786 | } 787 | } 788 | 789 | select::-ms-expand { 790 | display: none; 791 | } 792 | 793 | select[multiple] { 794 | padding-right: 10px; 795 | background-image: none; 796 | overflow-y: auto; 797 | } 798 | 799 | input:focus { 800 | box-shadow: 0 0 0 2px #0096bfab; 801 | box-shadow: 0 0 0 2px var(--focus); 802 | } 803 | 804 | @media (prefers-color-scheme: dark) { 805 | 806 | input:focus { 807 | box-shadow: 0 0 0 2px #0096bfab; 808 | box-shadow: 0 0 0 2px var(--focus); 809 | } 810 | } 811 | 812 | select:focus { 813 | box-shadow: 0 0 0 2px #0096bfab; 814 | box-shadow: 0 0 0 2px var(--focus); 815 | } 816 | 817 | @media (prefers-color-scheme: dark) { 818 | 819 | select:focus { 820 | box-shadow: 0 0 0 2px #0096bfab; 821 | box-shadow: 0 0 0 2px var(--focus); 822 | } 823 | } 824 | 825 | button:focus { 826 | box-shadow: 0 0 0 2px #0096bfab; 827 | box-shadow: 0 0 0 2px var(--focus); 828 | } 829 | 830 | @media (prefers-color-scheme: dark) { 831 | 832 | button:focus { 833 | box-shadow: 0 0 0 2px #0096bfab; 834 | box-shadow: 0 0 0 2px var(--focus); 835 | } 836 | } 837 | 838 | textarea:focus { 839 | box-shadow: 0 0 0 2px #0096bfab; 840 | box-shadow: 0 0 0 2px var(--focus); 841 | } 842 | 843 | @media (prefers-color-scheme: dark) { 844 | 845 | textarea:focus { 846 | box-shadow: 0 0 0 2px #0096bfab; 847 | box-shadow: 0 0 0 2px var(--focus); 848 | } 849 | } 850 | 851 | input[type='checkbox']:active, 852 | input[type='radio']:active, 853 | input[type='submit']:active, 854 | input[type='reset']:active, 855 | input[type='button']:active, 856 | input[type='range']:active, 857 | button:active { 858 | transform: translateY(2px); 859 | } 860 | 861 | input:disabled, 862 | select:disabled, 863 | button:disabled, 864 | textarea:disabled { 865 | cursor: not-allowed; 866 | opacity: 0.5; 867 | } 868 | 869 | ::-moz-placeholder { 870 | color: #949494; 871 | color: var(--form-placeholder); 872 | } 873 | 874 | :-ms-input-placeholder { 875 | color: #949494; 876 | color: var(--form-placeholder); 877 | } 878 | 879 | ::-ms-input-placeholder { 880 | color: #949494; 881 | color: var(--form-placeholder); 882 | } 883 | 884 | ::placeholder { 885 | color: #949494; 886 | color: var(--form-placeholder); 887 | } 888 | 889 | @media (prefers-color-scheme: dark) { 890 | 891 | ::-moz-placeholder { 892 | color: #a9a9a9; 893 | color: var(--form-placeholder); 894 | } 895 | 896 | :-ms-input-placeholder { 897 | color: #a9a9a9; 898 | color: var(--form-placeholder); 899 | } 900 | 901 | ::-ms-input-placeholder { 902 | color: #a9a9a9; 903 | color: var(--form-placeholder); 904 | } 905 | 906 | ::placeholder { 907 | color: #a9a9a9; 908 | color: var(--form-placeholder); 909 | } 910 | } 911 | 912 | fieldset { 913 | border: 1px #0096bfab solid; 914 | border: 1px var(--focus) solid; 915 | border-radius: 6px; 916 | margin: 0; 917 | margin-bottom: 12px; 918 | padding: 10px; 919 | } 920 | 921 | @media (prefers-color-scheme: dark) { 922 | 923 | fieldset { 924 | border: 1px #0096bfab solid; 925 | border: 1px var(--focus) solid; 926 | } 927 | } 928 | 929 | legend { 930 | font-size: 0.9em; 931 | font-weight: 600; 932 | } 933 | 934 | input[type='range'] { 935 | margin: 10px 0; 936 | padding: 10px 0; 937 | background: transparent; 938 | } 939 | 940 | input[type='range']:focus { 941 | outline: none; 942 | } 943 | 944 | input[type='range']::-webkit-slider-runnable-track { 945 | width: 100%; 946 | height: 9.5px; 947 | -webkit-transition: 0.2s; 948 | transition: 0.2s; 949 | background: #efefef; 950 | background: var(--background); 951 | border-radius: 3px; 952 | } 953 | 954 | @media (prefers-color-scheme: dark) { 955 | 956 | input[type='range']::-webkit-slider-runnable-track { 957 | background: #161f27; 958 | background: var(--background); 959 | } 960 | } 961 | 962 | input[type='range']::-webkit-slider-thumb { 963 | box-shadow: 0 1px 1px #000, 0 0 1px #0d0d0d; 964 | height: 20px; 965 | width: 20px; 966 | border-radius: 50%; 967 | background: #dbdbdb; 968 | background: var(--border); 969 | -webkit-appearance: none; 970 | margin-top: -7px; 971 | } 972 | 973 | @media (prefers-color-scheme: dark) { 974 | 975 | input[type='range']::-webkit-slider-thumb { 976 | background: #526980; 977 | background: var(--border); 978 | } 979 | } 980 | 981 | input[type='range']:focus::-webkit-slider-runnable-track { 982 | background: #efefef; 983 | background: var(--background); 984 | } 985 | 986 | @media (prefers-color-scheme: dark) { 987 | 988 | input[type='range']:focus::-webkit-slider-runnable-track { 989 | background: #161f27; 990 | background: var(--background); 991 | } 992 | } 993 | 994 | input[type='range']::-moz-range-track { 995 | width: 100%; 996 | height: 9.5px; 997 | -moz-transition: 0.2s; 998 | transition: 0.2s; 999 | background: #efefef; 1000 | background: var(--background); 1001 | border-radius: 3px; 1002 | } 1003 | 1004 | @media (prefers-color-scheme: dark) { 1005 | 1006 | input[type='range']::-moz-range-track { 1007 | background: #161f27; 1008 | background: var(--background); 1009 | } 1010 | } 1011 | 1012 | input[type='range']::-moz-range-thumb { 1013 | box-shadow: 1px 1px 1px #000, 0 0 1px #0d0d0d; 1014 | height: 20px; 1015 | width: 20px; 1016 | border-radius: 50%; 1017 | background: #dbdbdb; 1018 | background: var(--border); 1019 | } 1020 | 1021 | @media (prefers-color-scheme: dark) { 1022 | 1023 | input[type='range']::-moz-range-thumb { 1024 | background: #526980; 1025 | background: var(--border); 1026 | } 1027 | } 1028 | 1029 | input[type='range']::-ms-track { 1030 | width: 100%; 1031 | height: 9.5px; 1032 | background: transparent; 1033 | border-color: transparent; 1034 | border-width: 16px 0; 1035 | color: transparent; 1036 | } 1037 | 1038 | input[type='range']::-ms-fill-lower { 1039 | background: #efefef; 1040 | background: var(--background); 1041 | border: 0.2px solid #010101; 1042 | border-radius: 3px; 1043 | box-shadow: 1px 1px 1px #000, 0 0 1px #0d0d0d; 1044 | } 1045 | 1046 | @media (prefers-color-scheme: dark) { 1047 | 1048 | input[type='range']::-ms-fill-lower { 1049 | background: #161f27; 1050 | background: var(--background); 1051 | } 1052 | } 1053 | 1054 | input[type='range']::-ms-fill-upper { 1055 | background: #efefef; 1056 | background: var(--background); 1057 | border: 0.2px solid #010101; 1058 | border-radius: 3px; 1059 | box-shadow: 1px 1px 1px #000, 0 0 1px #0d0d0d; 1060 | } 1061 | 1062 | @media (prefers-color-scheme: dark) { 1063 | 1064 | input[type='range']::-ms-fill-upper { 1065 | background: #161f27; 1066 | background: var(--background); 1067 | } 1068 | } 1069 | 1070 | input[type='range']::-ms-thumb { 1071 | box-shadow: 1px 1px 1px #000, 0 0 1px #0d0d0d; 1072 | border: 1px solid #000; 1073 | height: 20px; 1074 | width: 20px; 1075 | border-radius: 50%; 1076 | background: #dbdbdb; 1077 | background: var(--border); 1078 | } 1079 | 1080 | @media (prefers-color-scheme: dark) { 1081 | 1082 | input[type='range']::-ms-thumb { 1083 | background: #526980; 1084 | background: var(--border); 1085 | } 1086 | } 1087 | 1088 | input[type='range']:focus::-ms-fill-lower { 1089 | background: #efefef; 1090 | background: var(--background); 1091 | } 1092 | 1093 | @media (prefers-color-scheme: dark) { 1094 | 1095 | input[type='range']:focus::-ms-fill-lower { 1096 | background: #161f27; 1097 | background: var(--background); 1098 | } 1099 | } 1100 | 1101 | input[type='range']:focus::-ms-fill-upper { 1102 | background: #efefef; 1103 | background: var(--background); 1104 | } 1105 | 1106 | @media (prefers-color-scheme: dark) { 1107 | 1108 | input[type='range']:focus::-ms-fill-upper { 1109 | background: #161f27; 1110 | background: var(--background); 1111 | } 1112 | } 1113 | 1114 | a { 1115 | text-decoration: none; 1116 | color: #0076d1; 1117 | color: var(--links); 1118 | } 1119 | 1120 | @media (prefers-color-scheme: dark) { 1121 | 1122 | a { 1123 | color: #41adff; 1124 | color: var(--links); 1125 | } 1126 | } 1127 | 1128 | a:hover { 1129 | text-decoration: underline; 1130 | } 1131 | 1132 | code { 1133 | background: #efefef; 1134 | background: var(--background); 1135 | color: #000; 1136 | color: var(--code); 1137 | padding: 2.5px 5px; 1138 | border-radius: 6px; 1139 | font-size: 1em; 1140 | } 1141 | 1142 | @media (prefers-color-scheme: dark) { 1143 | 1144 | code { 1145 | color: #ffbe85; 1146 | color: var(--code); 1147 | } 1148 | } 1149 | 1150 | @media (prefers-color-scheme: dark) { 1151 | 1152 | code { 1153 | background: #161f27; 1154 | background: var(--background); 1155 | } 1156 | } 1157 | 1158 | samp { 1159 | background: #efefef; 1160 | background: var(--background); 1161 | color: #000; 1162 | color: var(--code); 1163 | padding: 2.5px 5px; 1164 | border-radius: 6px; 1165 | font-size: 1em; 1166 | } 1167 | 1168 | @media (prefers-color-scheme: dark) { 1169 | 1170 | samp { 1171 | color: #ffbe85; 1172 | color: var(--code); 1173 | } 1174 | } 1175 | 1176 | @media (prefers-color-scheme: dark) { 1177 | 1178 | samp { 1179 | background: #161f27; 1180 | background: var(--background); 1181 | } 1182 | } 1183 | 1184 | time { 1185 | background: #efefef; 1186 | background: var(--background); 1187 | color: #000; 1188 | color: var(--code); 1189 | padding: 2.5px 5px; 1190 | border-radius: 6px; 1191 | font-size: 1em; 1192 | } 1193 | 1194 | @media (prefers-color-scheme: dark) { 1195 | 1196 | time { 1197 | color: #ffbe85; 1198 | color: var(--code); 1199 | } 1200 | } 1201 | 1202 | @media (prefers-color-scheme: dark) { 1203 | 1204 | time { 1205 | background: #161f27; 1206 | background: var(--background); 1207 | } 1208 | } 1209 | 1210 | pre > code { 1211 | padding: 10px; 1212 | display: block; 1213 | overflow-x: auto; 1214 | } 1215 | 1216 | var { 1217 | color: #39a33c; 1218 | color: var(--variable); 1219 | font-style: normal; 1220 | font-family: monospace; 1221 | } 1222 | 1223 | @media (prefers-color-scheme: dark) { 1224 | 1225 | var { 1226 | color: #d941e2; 1227 | color: var(--variable); 1228 | } 1229 | } 1230 | 1231 | kbd { 1232 | background: #efefef; 1233 | background: var(--background); 1234 | border: 1px solid #dbdbdb; 1235 | border: 1px solid var(--border); 1236 | border-radius: 2px; 1237 | color: #363636; 1238 | color: var(--text-main); 1239 | padding: 2px 4px 2px 4px; 1240 | } 1241 | 1242 | @media (prefers-color-scheme: dark) { 1243 | 1244 | kbd { 1245 | color: #dbdbdb; 1246 | color: var(--text-main); 1247 | } 1248 | } 1249 | 1250 | @media (prefers-color-scheme: dark) { 1251 | 1252 | kbd { 1253 | border: 1px solid #526980; 1254 | border: 1px solid var(--border); 1255 | } 1256 | } 1257 | 1258 | @media (prefers-color-scheme: dark) { 1259 | 1260 | kbd { 1261 | background: #161f27; 1262 | background: var(--background); 1263 | } 1264 | } 1265 | 1266 | img, 1267 | video { 1268 | max-width: 100%; 1269 | height: auto; 1270 | } 1271 | 1272 | hr { 1273 | border: none; 1274 | border-top: 1px solid #dbdbdb; 1275 | border-top: 1px solid var(--border); 1276 | } 1277 | 1278 | @media (prefers-color-scheme: dark) { 1279 | 1280 | hr { 1281 | border-top: 1px solid #526980; 1282 | border-top: 1px solid var(--border); 1283 | } 1284 | } 1285 | 1286 | table { 1287 | border-collapse: collapse; 1288 | margin-bottom: 10px; 1289 | width: 100%; 1290 | table-layout: fixed; 1291 | } 1292 | 1293 | table caption { 1294 | text-align: left; 1295 | } 1296 | 1297 | td, 1298 | th { 1299 | padding: 6px; 1300 | text-align: left; 1301 | vertical-align: top; 1302 | word-wrap: break-word; 1303 | } 1304 | 1305 | thead { 1306 | border-bottom: 1px solid #dbdbdb; 1307 | border-bottom: 1px solid var(--border); 1308 | } 1309 | 1310 | @media (prefers-color-scheme: dark) { 1311 | 1312 | thead { 1313 | border-bottom: 1px solid #526980; 1314 | border-bottom: 1px solid var(--border); 1315 | } 1316 | } 1317 | 1318 | tfoot { 1319 | border-top: 1px solid #dbdbdb; 1320 | border-top: 1px solid var(--border); 1321 | } 1322 | 1323 | @media (prefers-color-scheme: dark) { 1324 | 1325 | tfoot { 1326 | border-top: 1px solid #526980; 1327 | border-top: 1px solid var(--border); 1328 | } 1329 | } 1330 | 1331 | tbody tr:nth-child(even) { 1332 | background-color: #efefef; 1333 | background-color: var(--background); 1334 | } 1335 | 1336 | @media (prefers-color-scheme: dark) { 1337 | 1338 | tbody tr:nth-child(even) { 1339 | background-color: #161f27; 1340 | background-color: var(--background); 1341 | } 1342 | } 1343 | 1344 | tbody tr:nth-child(even) button { 1345 | background-color: #f7f7f7; 1346 | background-color: var(--background-alt); 1347 | } 1348 | 1349 | @media (prefers-color-scheme: dark) { 1350 | 1351 | tbody tr:nth-child(even) button { 1352 | background-color: #1a242f; 1353 | background-color: var(--background-alt); 1354 | } 1355 | } 1356 | 1357 | tbody tr:nth-child(even) button:hover { 1358 | background-color: #fff; 1359 | background-color: var(--background-body); 1360 | } 1361 | 1362 | @media (prefers-color-scheme: dark) { 1363 | 1364 | tbody tr:nth-child(even) button:hover { 1365 | background-color: #202b38; 1366 | background-color: var(--background-body); 1367 | } 1368 | } 1369 | 1370 | ::-webkit-scrollbar { 1371 | height: 10px; 1372 | width: 10px; 1373 | } 1374 | 1375 | ::-webkit-scrollbar-track { 1376 | background: #efefef; 1377 | background: var(--background); 1378 | border-radius: 6px; 1379 | } 1380 | 1381 | @media (prefers-color-scheme: dark) { 1382 | 1383 | ::-webkit-scrollbar-track { 1384 | background: #161f27; 1385 | background: var(--background); 1386 | } 1387 | } 1388 | 1389 | ::-webkit-scrollbar-thumb { 1390 | background: rgb(170, 170, 170); 1391 | background: var(--scrollbar-thumb); 1392 | border-radius: 6px; 1393 | } 1394 | 1395 | @media (prefers-color-scheme: dark) { 1396 | 1397 | ::-webkit-scrollbar-thumb { 1398 | background: #040a0f; 1399 | background: var(--scrollbar-thumb); 1400 | } 1401 | } 1402 | 1403 | @media (prefers-color-scheme: dark) { 1404 | 1405 | ::-webkit-scrollbar-thumb { 1406 | background: #040a0f; 1407 | background: var(--scrollbar-thumb); 1408 | } 1409 | } 1410 | 1411 | ::-webkit-scrollbar-thumb:hover { 1412 | background: #9b9b9b; 1413 | background: var(--scrollbar-thumb-hover); 1414 | } 1415 | 1416 | @media (prefers-color-scheme: dark) { 1417 | 1418 | ::-webkit-scrollbar-thumb:hover { 1419 | background: rgb(0, 0, 0); 1420 | background: var(--scrollbar-thumb-hover); 1421 | } 1422 | } 1423 | 1424 | @media (prefers-color-scheme: dark) { 1425 | 1426 | ::-webkit-scrollbar-thumb:hover { 1427 | background: rgb(0, 0, 0); 1428 | background: var(--scrollbar-thumb-hover); 1429 | } 1430 | } 1431 | 1432 | ::-moz-selection { 1433 | background-color: #9e9e9e; 1434 | background-color: var(--selection); 1435 | color: #000; 1436 | color: var(--text-bright); 1437 | } 1438 | 1439 | ::selection { 1440 | background-color: #9e9e9e; 1441 | background-color: var(--selection); 1442 | color: #000; 1443 | color: var(--text-bright); 1444 | } 1445 | 1446 | @media (prefers-color-scheme: dark) { 1447 | 1448 | ::-moz-selection { 1449 | color: #fff; 1450 | color: var(--text-bright); 1451 | } 1452 | 1453 | ::selection { 1454 | color: #fff; 1455 | color: var(--text-bright); 1456 | } 1457 | } 1458 | 1459 | @media (prefers-color-scheme: dark) { 1460 | 1461 | ::-moz-selection { 1462 | background-color: #1c76c5; 1463 | background-color: var(--selection); 1464 | } 1465 | 1466 | ::selection { 1467 | background-color: #1c76c5; 1468 | background-color: var(--selection); 1469 | } 1470 | } 1471 | 1472 | details { 1473 | display: flex; 1474 | flex-direction: column; 1475 | align-items: flex-start; 1476 | background-color: #f7f7f7; 1477 | background-color: var(--background-alt); 1478 | padding: 10px 10px 0; 1479 | margin: 1em 0; 1480 | border-radius: 6px; 1481 | overflow: hidden; 1482 | } 1483 | 1484 | @media (prefers-color-scheme: dark) { 1485 | 1486 | details { 1487 | background-color: #1a242f; 1488 | background-color: var(--background-alt); 1489 | } 1490 | } 1491 | 1492 | details[open] { 1493 | padding: 10px; 1494 | } 1495 | 1496 | details > :last-child { 1497 | margin-bottom: 0; 1498 | } 1499 | 1500 | details[open] summary { 1501 | margin-bottom: 10px; 1502 | } 1503 | 1504 | summary { 1505 | display: list-item; 1506 | background-color: #efefef; 1507 | background-color: var(--background); 1508 | padding: 10px; 1509 | margin: -10px -10px 0; 1510 | cursor: pointer; 1511 | outline: none; 1512 | } 1513 | 1514 | @media (prefers-color-scheme: dark) { 1515 | 1516 | summary { 1517 | background-color: #161f27; 1518 | background-color: var(--background); 1519 | } 1520 | } 1521 | 1522 | summary:hover, 1523 | summary:focus { 1524 | text-decoration: underline; 1525 | } 1526 | 1527 | details > :not(summary) { 1528 | margin-top: 0; 1529 | } 1530 | 1531 | summary::-webkit-details-marker { 1532 | color: #363636; 1533 | color: var(--text-main); 1534 | } 1535 | 1536 | @media (prefers-color-scheme: dark) { 1537 | 1538 | summary::-webkit-details-marker { 1539 | color: #dbdbdb; 1540 | color: var(--text-main); 1541 | } 1542 | } 1543 | 1544 | dialog { 1545 | background-color: #f7f7f7; 1546 | background-color: var(--background-alt); 1547 | color: #363636; 1548 | color: var(--text-main); 1549 | border: none; 1550 | border-radius: 6px; 1551 | border-color: #dbdbdb; 1552 | border-color: var(--border); 1553 | padding: 10px 30px; 1554 | } 1555 | 1556 | @media (prefers-color-scheme: dark) { 1557 | 1558 | dialog { 1559 | border-color: #526980; 1560 | border-color: var(--border); 1561 | } 1562 | } 1563 | 1564 | @media (prefers-color-scheme: dark) { 1565 | 1566 | dialog { 1567 | color: #dbdbdb; 1568 | color: var(--text-main); 1569 | } 1570 | } 1571 | 1572 | @media (prefers-color-scheme: dark) { 1573 | 1574 | dialog { 1575 | background-color: #1a242f; 1576 | background-color: var(--background-alt); 1577 | } 1578 | } 1579 | 1580 | dialog > header:first-child { 1581 | background-color: #efefef; 1582 | background-color: var(--background); 1583 | border-radius: 6px 6px 0 0; 1584 | margin: -10px -30px 10px; 1585 | padding: 10px; 1586 | text-align: center; 1587 | } 1588 | 1589 | @media (prefers-color-scheme: dark) { 1590 | 1591 | dialog > header:first-child { 1592 | background-color: #161f27; 1593 | background-color: var(--background); 1594 | } 1595 | } 1596 | 1597 | dialog::-webkit-backdrop { 1598 | background: #0000009c; 1599 | -webkit-backdrop-filter: blur(4px); 1600 | backdrop-filter: blur(4px); 1601 | } 1602 | 1603 | dialog::backdrop { 1604 | background: #0000009c; 1605 | -webkit-backdrop-filter: blur(4px); 1606 | backdrop-filter: blur(4px); 1607 | } 1608 | 1609 | footer { 1610 | border-top: 1px solid #dbdbdb; 1611 | border-top: 1px solid var(--border); 1612 | padding-top: 10px; 1613 | color: #70777f; 1614 | color: var(--text-muted); 1615 | } 1616 | 1617 | @media (prefers-color-scheme: dark) { 1618 | 1619 | footer { 1620 | color: #a9b1ba; 1621 | color: var(--text-muted); 1622 | } 1623 | } 1624 | 1625 | @media (prefers-color-scheme: dark) { 1626 | 1627 | footer { 1628 | border-top: 1px solid #526980; 1629 | border-top: 1px solid var(--border); 1630 | } 1631 | } 1632 | 1633 | body > footer { 1634 | margin-top: 40px; 1635 | } 1636 | 1637 | @media print { 1638 | body, 1639 | pre, 1640 | code, 1641 | summary, 1642 | details, 1643 | button, 1644 | input, 1645 | textarea { 1646 | background-color: #fff; 1647 | } 1648 | 1649 | button, 1650 | input, 1651 | textarea { 1652 | border: 1px solid #000; 1653 | } 1654 | 1655 | body, 1656 | h1, 1657 | h2, 1658 | h3, 1659 | h4, 1660 | h5, 1661 | h6, 1662 | pre, 1663 | code, 1664 | button, 1665 | input, 1666 | textarea, 1667 | footer, 1668 | summary, 1669 | strong { 1670 | color: #000; 1671 | } 1672 | 1673 | summary::marker { 1674 | color: #000; 1675 | } 1676 | 1677 | summary::-webkit-details-marker { 1678 | color: #000; 1679 | } 1680 | 1681 | tbody tr:nth-child(even) { 1682 | background-color: #f2f2f2; 1683 | } 1684 | 1685 | a { 1686 | color: #00f; 1687 | text-decoration: underline; 1688 | } 1689 | } 1690 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/meehow/privtracker 2 | 3 | go 1.24.0 4 | 5 | require ( 6 | github.com/jackpal/bencode-go v1.0.2 7 | golang.org/x/crypto v0.37.0 8 | golang.org/x/net v0.39.0 9 | 10 | ) 11 | 12 | require golang.org/x/text v0.24.0 // indirect 13 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | github.com/jackpal/bencode-go v1.0.2 h1:LcCNfZ344u0LpBPOZNjpCLps/wUOuN4r87Fy9+5yU8g= 2 | github.com/jackpal/bencode-go v1.0.2/go.mod h1:6jI9mUjO3GQbZti3JizEfxTzRfWOM8oBBcwbwlTfceI= 3 | golang.org/x/crypto v0.37.0 h1:kJNSjF/Xp7kU0iB2Z+9viTPMW4EqqsrywMXLJOOsXSE= 4 | golang.org/x/crypto v0.37.0/go.mod h1:vg+k43peMZ0pUMhYmVAWysMK35e6ioLh3wB8ZCAfbVc= 5 | golang.org/x/net v0.39.0 h1:ZCu7HMWDxpXpaiKdhzIfaltL9Lp31x/3fCP11bc6/fY= 6 | golang.org/x/net v0.39.0/go.mod h1:X7NRbYVEA+ewNkCNyJ513WmMdQ3BineSwVtN2zD/d+E= 7 | golang.org/x/text v0.24.0 h1:dd5Bzh4yt5KYA8f9CJHCP4FB4D51c2c6JvN37xJJkJ0= 8 | golang.org/x/text v0.24.0/go.mod h1:L8rBsPeo2pSS+xqN0d5u2ikmjtmoJbDBT1b7nHvFCdU= 9 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "crypto/tls" 5 | "fmt" 6 | "log" 7 | "net" 8 | "net/http" 9 | "os" 10 | "path/filepath" 11 | 12 | "golang.org/x/crypto/acme/autocert" 13 | "golang.org/x/net/publicsuffix" 14 | ) 15 | 16 | func main() { 17 | port := os.Getenv("PORT") 18 | if port == "" { 19 | port = "1337" 20 | } 21 | handler := router(recoveryMiddleware, headersMiddleware, logRequestMiddleware) 22 | if port == "443" { 23 | go redirect80() 24 | fmt.Println("PrivTracker listening on https://0.0.0.0/ (please use your FQDN to access this server)") 25 | log.Fatal(http.Serve(autocertListener(), handler)) 26 | } else { 27 | fmt.Printf("PrivTracker listening on http://0.0.0.0:%s/\n", port) 28 | log.Fatal(http.ListenAndServe(":"+port, handler)) 29 | } 30 | } 31 | 32 | func router(middlewares ...Middleware) http.Handler { 33 | mux := http.NewServeMux() 34 | mux.Handle("/", http.FileServer(http.Dir("docs"))) 35 | mux.HandleFunc("GET /{room}/announce", announce) 36 | mux.HandleFunc("GET /{room}/scrape", scrape) 37 | return chainMiddleware(mux, middlewares...) 38 | } 39 | 40 | func autocertListener() net.Listener { 41 | homeDir, err := os.UserHomeDir() 42 | if err != nil { 43 | log.Fatal(err) 44 | } 45 | cacheDir := filepath.Join(homeDir, ".cache", "golang-autocert") 46 | m := &autocert.Manager{ 47 | Prompt: autocert.AcceptTOS, 48 | Cache: autocert.DirCache(cacheDir), 49 | } 50 | cfg := &tls.Config{ 51 | GetCertificate: m.GetCertificate, 52 | NextProtos: []string{"h2", "http/1.1", "acme-tls/1"}, 53 | } 54 | listener, err := tls.Listen("tcp", ":443", cfg) 55 | if err != nil { 56 | log.Fatal(err) 57 | } 58 | return listener 59 | } 60 | 61 | func redirect(w http.ResponseWriter, r *http.Request) { 62 | url := fmt.Sprintf("https://%s/", r.Host) 63 | if _, icann := publicsuffix.PublicSuffix(r.Host); !icann { 64 | // fallback in case we can't get FQDN 65 | url = "https://privtracker.com/" 66 | } 67 | http.Redirect(w, r, url, http.StatusMovedPermanently) 68 | } 69 | 70 | func redirect80() { 71 | handler := chainMiddleware(http.HandlerFunc(redirect), logRequestMiddleware) 72 | err := http.ListenAndServe(":80", handler) 73 | if err != nil { 74 | fmt.Println(err) 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /middleware.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | "runtime/debug" 7 | "time" 8 | ) 9 | 10 | type Middleware func(http.Handler) http.Handler 11 | 12 | type ResponseWriterWrapper struct { 13 | http.ResponseWriter 14 | StatusCode int 15 | BytesSent int 16 | } 17 | 18 | func (rw *ResponseWriterWrapper) WriteHeader(code int) { 19 | rw.StatusCode = code 20 | rw.ResponseWriter.WriteHeader(code) 21 | } 22 | 23 | func (rw *ResponseWriterWrapper) Write(data []byte) (int, error) { 24 | bytesWritten, err := rw.ResponseWriter.Write(data) 25 | rw.BytesSent += bytesWritten 26 | return bytesWritten, err 27 | } 28 | 29 | func logRequestMiddleware(next http.Handler) http.Handler { 30 | return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 31 | wrapper := &ResponseWriterWrapper{ResponseWriter: w, StatusCode: http.StatusOK} 32 | timer := time.Now() 33 | next.ServeHTTP(wrapper, r) 34 | fmt.Printf("%d - %5dµs %21s %4s %42s %6d %11s - %s - %s\n", 35 | wrapper.StatusCode, time.Since(timer).Microseconds(), r.RemoteAddr, 36 | r.Method, r.URL.Path, wrapper.BytesSent, 37 | wrapper.Header().Get("X-PrivTracker"), r.Referer(), r.UserAgent()) 38 | }) 39 | } 40 | 41 | func headersMiddleware(next http.Handler) http.Handler { 42 | return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 43 | if r.TLS != nil { 44 | w.Header().Set("Strict-Transport-Security", "max-age=31536000") // hsts 45 | } 46 | w.Header().Set("Server", "PrivTracker") 47 | next.ServeHTTP(w, r) 48 | }) 49 | } 50 | 51 | func recoveryMiddleware(next http.Handler) http.Handler { 52 | return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 53 | defer func() { 54 | if err := recover(); err != nil { 55 | fmt.Printf("Recovered from panic: %v\n%s\n", err, debug.Stack()) 56 | http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError) 57 | } 58 | }() 59 | next.ServeHTTP(w, r) 60 | }) 61 | } 62 | 63 | func chainMiddleware(handler http.Handler, middlewares ...Middleware) http.Handler { 64 | // Apply middlewares in reverse order (outermost to innermost) 65 | for i := len(middlewares) - 1; i >= 0; i-- { 66 | handler = middlewares[i](handler) 67 | } 68 | return handler 69 | } 70 | -------------------------------------------------------------------------------- /scrape.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "crypto/sha1" 5 | "fmt" 6 | "net/http" 7 | 8 | "github.com/jackpal/bencode-go" 9 | ) 10 | 11 | type ScrapeResponse struct { 12 | Files map[string]Stat `bencode:"files"` 13 | } 14 | 15 | type Stat struct { 16 | Complete int `bencode:"complete"` 17 | Incomplete int `bencode:"incomplete"` 18 | // Downloaded uint `bencode:"downloaded"` 19 | } 20 | 21 | func scrape(w http.ResponseWriter, r *http.Request) { 22 | query := r.URL.Query() 23 | infoHash := query.Get("info_hash") 24 | swarmHash := sha1.Sum([]byte(r.PathValue("room") + infoHash)) 25 | 26 | numSeeders, numLeechers := GetStats(swarmHash) 27 | resp := ScrapeResponse{ 28 | Files: map[string]Stat{ 29 | infoHash: { 30 | Complete: numSeeders, 31 | Incomplete: numLeechers, 32 | }, 33 | }, 34 | } 35 | w.Header().Add("X-PrivTracker", fmt.Sprintf("s:%d l:%d", numSeeders, numLeechers)) 36 | if err := bencode.Marshal(w, resp); err != nil { 37 | http.Error(w, err.Error(), 400) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /storage.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "bytes" 5 | "crypto/sha1" 6 | "encoding/binary" 7 | "fmt" 8 | "net" 9 | "sync" 10 | "time" 11 | ) 12 | 13 | type Hash [sha1.Size]byte // we use sha1 and we are not affraid of hash collisions 14 | type Peer [18]byte // 16 bytes for IP and 2 bytes for port number 15 | 16 | var v4InV6Prefix = []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff} 17 | var shards [256]*shard 18 | 19 | type shard struct { 20 | swarms map[Hash]*Swarm 21 | sync.RWMutex 22 | } 23 | 24 | type Swarm struct { 25 | seeders map[Peer]int64 26 | leechers map[Peer]int64 27 | } 28 | 29 | func init() { 30 | for i := range shards { 31 | shards[i] = &shard{ 32 | swarms: make(map[Hash]*Swarm), 33 | } 34 | } 35 | go Cleanup(time.Minute * 16) // needs to be bigget than biggest interval in announce.go 36 | } 37 | 38 | func NewSwarm() *Swarm { 39 | return &Swarm{ 40 | seeders: make(map[Peer]int64), 41 | leechers: make(map[Peer]int64), 42 | } 43 | } 44 | 45 | func NewPeer(ip net.IP, port uint16) (peer Peer) { 46 | copy(peer[:16], ip) 47 | binary.BigEndian.PutUint16(peer[16:18], port) 48 | return 49 | } 50 | 51 | func (peer Peer) String() string { 52 | ip := net.IP(peer[:16]) 53 | port := binary.BigEndian.Uint16(peer[16:18]) 54 | return fmt.Sprintf("%s:%d", ip, port) 55 | } 56 | 57 | func shardIndex(hash Hash) uint8 { 58 | // return int(binary.BigEndian.Uint16(hash[:2])) % len(shards) 59 | return hash[0] // works only with 256 shards 60 | } 61 | 62 | func PutPeer(h Hash, peer Peer, seeding bool) { 63 | shard := shards[shardIndex(h)] 64 | shard.Lock() 65 | defer shard.Unlock() 66 | if _, ok := shard.swarms[h]; !ok { 67 | shard.swarms[h] = NewSwarm() 68 | } 69 | if seeding { 70 | shard.swarms[h].seeders[peer] = time.Now().Unix() 71 | } else { 72 | shard.swarms[h].leechers[peer] = time.Now().Unix() 73 | } 74 | } 75 | 76 | func DeletePeer(h Hash, peer Peer) { 77 | shard := shards[shardIndex(h)] 78 | shard.Lock() 79 | defer shard.Unlock() 80 | if _, ok := shard.swarms[h]; !ok { 81 | return 82 | } 83 | delete(shard.swarms[h].seeders, peer) 84 | delete(shard.swarms[h].leechers, peer) 85 | } 86 | 87 | func GraduateLeecher(h Hash, peer Peer) { 88 | shard := shards[shardIndex(h)] 89 | shard.Lock() 90 | defer shard.Unlock() 91 | if _, ok := shard.swarms[h]; !ok { 92 | shard.swarms[h] = NewSwarm() 93 | } 94 | shard.swarms[h].seeders[peer] = time.Now().Unix() 95 | delete(shard.swarms[h].leechers, peer) 96 | } 97 | 98 | func GetPeers(h Hash, client Peer, seeding bool, numWant int) (peersIPv4, peersIPv6 []byte, numSeeders, numLeechers int) { 99 | shard := shards[shardIndex(h)] 100 | shard.RLock() 101 | defer shard.RUnlock() 102 | if _, ok := shard.swarms[h]; !ok { 103 | return 104 | } 105 | 106 | numSeeders = len(shard.swarms[h].seeders) 107 | numLeechers = len(shard.swarms[h].leechers) 108 | 109 | // seeders don't need other seeders 110 | if !seeding { 111 | for peer := range shard.swarms[h].seeders { 112 | if numWant == 0 { 113 | break 114 | } 115 | if peer == client { 116 | continue 117 | } 118 | if bytes.HasPrefix(peer[:], v4InV6Prefix) { 119 | peersIPv4 = append(peersIPv4, peer[len(v4InV6Prefix):]...) 120 | } else { 121 | peersIPv6 = append(peersIPv6, peer[:]...) 122 | } 123 | numWant-- 124 | } 125 | } 126 | for peer := range shard.swarms[h].leechers { 127 | if numWant == 0 { 128 | break 129 | } 130 | if peer == client { 131 | continue 132 | } 133 | if bytes.HasPrefix(peer[:], v4InV6Prefix) { 134 | peersIPv4 = append(peersIPv4, peer[len(v4InV6Prefix):]...) 135 | } else { 136 | peersIPv6 = append(peersIPv6, peer[:]...) 137 | } 138 | numWant-- 139 | } 140 | return 141 | } 142 | 143 | func GetStats(h Hash) (numSeeders, numLeechers int) { 144 | shard := shards[shardIndex(h)] 145 | shard.RLock() 146 | defer shard.RUnlock() 147 | if _, ok := shard.swarms[h]; !ok { 148 | return 149 | } 150 | numSeeders = len(shard.swarms[h].seeders) 151 | numLeechers = len(shard.swarms[h].leechers) 152 | return 153 | } 154 | 155 | func Cleanup(duration time.Duration) { 156 | ticker := time.NewTicker(duration) 157 | for range ticker.C { 158 | expiration := time.Now().Unix() - int64(duration.Seconds()) 159 | for _, shard := range shards { 160 | shard.Lock() 161 | for h, swarm := range shard.swarms { 162 | for peer, lastSeen := range swarm.seeders { 163 | if lastSeen < expiration { 164 | delete(swarm.seeders, peer) 165 | } 166 | } 167 | for peer, lastSeen := range swarm.leechers { 168 | if lastSeen < expiration { 169 | delete(swarm.leechers, peer) 170 | } 171 | } 172 | if len(swarm.leechers) == 0 && len(swarm.seeders) == 0 { 173 | delete(shard.swarms, h) 174 | } 175 | } 176 | shard.Unlock() 177 | } 178 | } 179 | } 180 | -------------------------------------------------------------------------------- /storage_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "crypto/rand" 5 | mrand "math/rand" 6 | "net" 7 | "testing" 8 | ) 9 | 10 | func BenchmarkPutPeerGetPeers(b *testing.B) { 11 | var swarmHash Hash 12 | for i := 0; i < b.N; i++ { 13 | for j := 0; j < 100; j++ { 14 | rand.Read(swarmHash[:]) 15 | for k := 0; k < 10; k++ { 16 | peer := NewPeer(net.ParseIP("127.0.0.1"), uint16(mrand.Uint32())) 17 | 18 | PutPeer(swarmHash, peer, true) 19 | GetPeers(swarmHash, peer, true, 99) 20 | 21 | GraduateLeecher(swarmHash, peer) 22 | GetPeers(swarmHash, peer, true, 99) 23 | 24 | DeletePeer(swarmHash, peer) 25 | GetPeers(swarmHash, peer, true, 99) 26 | } 27 | } 28 | } 29 | } 30 | --------------------------------------------------------------------------------