├── .github
├── Dockerfile
├── goreleaser.yml
└── workflows
│ └── ci.yml
├── .gitignore
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── engine
├── config.go
├── engine.go
└── torrent.go
├── go.mod
├── go.sum
├── main.go
├── server
├── server.go
├── server_api.go
├── server_files.go
├── server_search.go
└── server_stats.go
└── static
├── files
├── cloud-favicon.png
├── css
│ ├── Lato
│ │ ├── Lato-1.woff
│ │ ├── Lato-2.woff
│ │ ├── Lato-3.woff
│ │ ├── Lato-4.woff
│ │ └── Lato.css
│ ├── app.css
│ ├── sections
│ │ ├── downloads.css
│ │ ├── omni.css
│ │ └── torrents.css
│ ├── semantic.min.css
│ └── themes
│ │ └── default
│ │ └── assets
│ │ ├── fonts
│ │ ├── icons.eot
│ │ ├── icons.otf
│ │ ├── icons.svg
│ │ ├── icons.ttf
│ │ ├── icons.woff
│ │ └── icons.woff2
│ │ └── images
│ │ └── flags.png
├── index.html
├── js
│ ├── config-controller.js
│ ├── downloads-controller.js
│ ├── omni-controller.js
│ ├── run.js
│ ├── semantic-checkbox.js
│ ├── torrents-controller.js
│ ├── utils.js
│ └── vendor
│ │ ├── angular.min.js
│ │ ├── moment.min.js
│ │ └── query-string.js
└── template
│ ├── config.html
│ ├── download-tree.html
│ ├── downloads.html
│ ├── omni.html
│ └── torrents.html
└── static.go
/.github/Dockerfile:
--------------------------------------------------------------------------------
1 | # build stage
2 | FROM golang:alpine AS build
3 | RUN apk update && apk add git
4 | ADD . /src
5 | WORKDIR /src
6 | ENV CGO_ENABLED 0
7 | RUN go build \
8 | -trimpath \
9 | -ldflags "-s -w -X main.version=$(git describe --abbrev=0 --tags)" \
10 | -o /tmp/bin
11 | # run stage
12 | FROM scratch
13 | COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
14 | WORKDIR /app
15 | COPY --from=build /tmp/bin /app/bin
16 | ENTRYPOINT ["/app/bin"]
--------------------------------------------------------------------------------
/.github/goreleaser.yml:
--------------------------------------------------------------------------------
1 | # test this file with
2 | # goreleaser build --snapshot --config .github/goreleaser.yml
3 | version: 2
4 | builds:
5 | - env:
6 | - CGO_ENABLED=0
7 | flags:
8 | - -trimpath
9 | ldflags:
10 | - -s -w -X main.version={{.Version}}
11 | goos:
12 | - linux
13 | - darwin
14 | - windows
15 | - openbsd
16 | goarch:
17 | - '386'
18 | - amd64
19 | - arm
20 | - arm64
21 | goarm:
22 | - '6'
23 | - '7'
24 | nfpms:
25 | - maintainer: "https://github.com/{{ .Env.GITHUB_USER }}"
26 | formats:
27 | - deb
28 | - rpm
29 | - apk
30 | archives:
31 | - format: gz
32 | files:
33 | - none*
34 | changelog:
35 | sort: asc
36 | filters:
37 | exclude:
38 | - "^docs:"
39 | - "^test:"
40 |
--------------------------------------------------------------------------------
/.github/workflows/ci.yml:
--------------------------------------------------------------------------------
1 | name: CI
2 | on:
3 | pull_request: {}
4 | push: {}
5 | permissions: write-all
6 | jobs:
7 | # ================
8 | # BUILD AND TEST JOB
9 | # ================
10 | test:
11 | name: Build & Test
12 | strategy:
13 | matrix:
14 | # optionally test/build across multiple platforms/Go-versions
15 | go-version: ["1.23"]
16 | platform: [ubuntu-latest]
17 | runs-on: ${{ matrix.platform }}
18 | steps:
19 | - name: Checkout
20 | uses: actions/checkout@v3
21 | with:
22 | fetch-depth: 0
23 | - name: Set up Go
24 | uses: actions/setup-go@v3
25 | with:
26 | go-version: ${{ matrix.go-version }}
27 | check-latest: true
28 | - name: Build
29 | run: go build -v -o /dev/null .
30 | - name: Test
31 | run: go test -v ./...
32 | # ================
33 | # RELEASE BINARIES (on push "v*" tag)
34 | # ================
35 | release_binaries:
36 | name: Release Binaries
37 | needs: test
38 | if: startsWith(github.ref, 'refs/tags/v')
39 | runs-on: ubuntu-latest
40 | steps:
41 | - name: Check out code
42 | uses: actions/checkout@v3
43 | - name: goreleaser
44 | uses: goreleaser/goreleaser-action@v6
45 | with:
46 | distribution: goreleaser # or 'goreleaser-pro'
47 | version: "~> v2" # or 'latest', 'nightly', semver
48 | args: release --config .github/goreleaser.yml
49 | env:
50 | GITHUB_USER: ${{ github.repository_owner }}
51 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52 | # ================
53 | # RELEASE DOCKER IMAGES (on push "v*" tag)
54 | # ================
55 | release_docker:
56 | name: Release Docker Images
57 | needs: test
58 | if: startsWith(github.ref, 'refs/tags/v')
59 | runs-on: ubuntu-latest
60 | steps:
61 | - name: Check out code
62 | uses: actions/checkout@v3
63 | - name: Set up QEMU
64 | uses: docker/setup-qemu-action@v2
65 | - name: Set up Docker Buildx
66 | uses: docker/setup-buildx-action@v2
67 | - name: Login to GitHub Container Registry
68 | uses: docker/login-action@v2
69 | with:
70 | registry: ghcr.io
71 | username: ${{ github.actor }}
72 | password: ${{ secrets.GITHUB_TOKEN }}
73 | - name: Docker meta
74 | id: meta
75 | uses: docker/metadata-action@v4
76 | with:
77 | images: ghcr.io/${{ github.repository }}
78 | tags: |
79 | type=semver,pattern={{version}}
80 | type=semver,pattern={{major}}.{{minor}}
81 | type=semver,pattern={{major}}
82 | - name: Build and push
83 | uses: docker/build-push-action@v3
84 | with:
85 | file: .github/Dockerfile
86 | platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/386,linux/arm/v7,linux/arm/v6
87 | push: true
88 | tags: ${{ steps.meta.outputs.tags }}
89 | labels: ${{ steps.meta.outputs.labels }}
90 | cache-from: type=gha
91 | cache-to: type=gha,mode=max
92 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | downloads
2 | cloud-torrent.json
3 | tmp/
4 | dev.sh
5 | dist/
6 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | ### Contributing guide
2 |
3 | Quick start:
4 |
5 | * Download Go
6 | * Fork this repo
7 | * Edit static files
8 | * Edit backend Go files
9 | * `go run main.go`
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
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 |
663 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | **Cloud torrent** is a a self-hosted remote torrent client, written in Go (golang). You start torrents remotely, which are downloaded as sets of files on the local disk of the server, which are then retrievable or streamable via HTTP.
4 |
5 | ### Features
6 |
7 | * Single binary
8 | * Cross platform
9 | * Embedded torrent search
10 | * Real-time updates
11 | * Mobile-friendly
12 | * Fast [content server](http://golang.org/pkg/net/http/#ServeContent)
13 |
14 | See [Future Features here](#future-features)
15 |
16 | ### Install
17 |
18 | **Binaries**
19 |
20 | [](https://github.com/jpillora/cloud-torrent/releases) [](https://github.com/jpillora/cloud-torrent/releases)
21 |
22 | See [the latest release](https://github.com/jpillora/cloud-torrent/releases/latest) or download and install it now with
23 |
24 | ```
25 | curl https://i.jpillora.com/cloud-torrent! | bash
26 | ```
27 |
28 | *Tip*: [Auto-run `cloud-torrent` on boot](https://github.com/jpillora/cloud-torrent/wiki/Auto-Run-on-Reboot)
29 |
30 | **Docker**
31 |
32 | [][dockerhub]
33 |
34 | [dockerhub]: https://hub.docker.com/r/jpillora/cloud-torrent/
35 |
36 | ``` sh
37 | $ docker run -d -p 3000:3000 -v /path/to/my/downloads:/downloads jpillora/cloud-torrent
38 | ```
39 |
40 | **Source**
41 |
42 | *[Go](https://golang.org/dl/) is required to install from source*
43 |
44 | ``` sh
45 | $ go get -v github.com/jpillora/cloud-torrent
46 | ```
47 |
48 | **VPS**
49 |
50 | [Digital Ocean](https://m.do.co/c/011fa87fde07)
51 |
52 | 1. [Sign up with free $10 credit](https://m.do.co/c/011fa87fde07)
53 | 2. "Create Droplet"
54 | 3. "One-Click Apps"
55 | 4. "Docker X.X.X on X.X"
56 | 5. Choose server size ("$5/month" is enough)
57 | 6. Choose server location
58 | 7. **OPTIONAL** Add your SSH key
59 | 8. "Create"
60 | 9. You will be emailed the server details (`IP Address: ..., Username: root, Password: ...`)
61 | 10. SSH into the server using these details (Windows: [Putty](https://the.earth.li/~sgtatham/putty/latest/x86/putty.exe), Mac: Terminal)
62 | 11. Follow the prompts to set a new password
63 | 12. Run `cloud-torrent` with:
64 |
65 | docker run --name ct -d -p 63000:63000 \
66 | --restart always \
67 | -v /root/downloads:/downloads \
68 | jpillora/cloud-torrent --port 63000
69 |
70 | 13. Visit `http://:63000/`
71 | 14. **OPTIONAL** In addition to `--port` you can specify the options below
72 |
73 | [Vultr](http://www.vultr.com/?ref=6947403-3B)
74 |
75 | * [Sign up with free $10 credit here](http://www.vultr.com/?ref=6947403-3B)
76 | * Follow the DO tutorial above, very similar steps ("Applications" instead of "One-Click Apps")
77 | * Offers different server locations
78 |
79 | [AWS](https://aws.amazon.com)
80 |
81 | **Heroku** (Heroku is no longer supported)
82 |
83 | ### Usage
84 |
85 | ```
86 | $ cloud-torrent --help
87 |
88 | Usage: cloud-torrent [options]
89 |
90 | Options:
91 | --title, -t Title of this instance (default Cloud Torrent, env TITLE)
92 | --port, -p Listening port (default 3000, env PORT)
93 | --host, -h Listening interface (default all)
94 | --auth, -a Optional basic auth in form 'user:password' (env AUTH)
95 | --config-path, -c Configuration file path (default cloud-torrent.json)
96 | --key-path, -k TLS Key file path
97 | --cert-path, -r TLS Certicate file path
98 | --log, -l Enable request logging
99 | --open, -o Open now with your default browser
100 | --help
101 | --version, -v
102 |
103 | Version:
104 | 0.X.Y
105 |
106 | Read more:
107 | https://github.com/jpillora/cloud-torrent
108 |
109 | ```
110 |
111 | ### Future features
112 |
113 | The next set of [core features can be tracked here](https://github.com/jpillora/cloud-torrent/issues?q=is%3Aopen+is%3Aissue+label%3Acore-feature). This feature set requires large structural changes and therefore requires a complete rewrite for best results. This rewrite is in progress in the `0.9` branch though it will take quite some time.
114 |
115 | In summary, the core features will be:
116 |
117 | * **Remote backends**
118 |
119 | It's looking like `0.9` will be more of a general purpose cloud transfer engine. It will be capable of transfering files from and source file-system to any destination file-system. A torrent can be viewed a folder with files, just like your local disk, and Dropbox. As long as it has a concept of files and folders, it could potentially be a cloud-torrent file-system backend. Track this issue https://github.com/jpillora/cloud-torrent/issues/24 for the list of proposed backends.
120 |
121 | * **File Transforms**
122 |
123 | During a file tranfer, one could apply different transforms against the byte stream for various effect. For example, supported transforms might include: video transcoding (using ffmpeg), encryption and decryption, [media sorting](https://github.com/jpillora/cloud-torrent/issues/4) (file renaming), and writing multiple files as a single zip file.
124 |
125 | * **Automatic updates** Binary will upgrade itself, adding new features as they get released.
126 |
127 | * **RSS** Automatically add torrents, with smart episode filter.
128 |
129 | Once completed, cloud-torrent will no longer be a simple torrent client and most likely project be renamed.
130 |
131 | #### Donate
132 |
133 | If you'd like to buy me a coffee or more, you can donate via [PayPal](https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=dev%40jpillora%2ecom&lc=AU&item_name=Open%20Source%20Donation&button_subtype=services¤cy_code=USD&bn=PP%2dBuyNowBF%3abtn_buynowCC_LG%2egif%3aNonHosted) or BitCoin `1AxEWoz121JSC3rV8e9MkaN9GAc5Jxvs4`.
134 |
135 | ### Notes
136 |
137 | This project is the rewrite of the original [Node version](https://github.com/jpillora/node-torrent-cloud).
138 |
139 | 
140 |
141 | Credits to @anacrolix for https://github.com/anacrolix/torrent
142 |
143 | Copyright (c) 2017 Jaime Pillora
--------------------------------------------------------------------------------
/engine/config.go:
--------------------------------------------------------------------------------
1 | package engine
2 |
3 | type Config struct {
4 | AutoStart bool
5 | DisableEncryption bool
6 | DownloadDirectory string
7 | EnableUpload bool
8 | EnableSeeding bool
9 | IncomingPort int
10 | }
11 |
--------------------------------------------------------------------------------
/engine/engine.go:
--------------------------------------------------------------------------------
1 | package engine
2 |
3 | import (
4 | "encoding/hex"
5 | "fmt"
6 | "os"
7 | "path/filepath"
8 | "sync"
9 | "time"
10 |
11 | "github.com/anacrolix/torrent"
12 | "github.com/anacrolix/torrent/metainfo"
13 | )
14 |
15 | // the Engine Cloud Torrent engine, backed by anacrolix/torrent
16 | type Engine struct {
17 | mut sync.Mutex
18 | cacheDir string
19 | client *torrent.Client
20 | config Config
21 | ts map[string]*Torrent
22 | }
23 |
24 | func New() *Engine {
25 | return &Engine{ts: map[string]*Torrent{}}
26 | }
27 |
28 | func (e *Engine) Config() Config {
29 | return e.config
30 | }
31 |
32 | func (e *Engine) Configure(c Config) error {
33 | //recieve config
34 | if e.client != nil {
35 | e.client.Close()
36 | time.Sleep(1 * time.Second)
37 | }
38 | if c.IncomingPort <= 0 {
39 | return fmt.Errorf("Invalid incoming port (%d)", c.IncomingPort)
40 | }
41 |
42 | config := torrent.NewDefaultClientConfig()
43 | config.DataDir = c.DownloadDirectory
44 | config.NoUpload = !c.EnableUpload
45 | config.Seed = c.EnableSeeding
46 | config.ListenPort = c.IncomingPort
47 | client, err := torrent.NewClient(config)
48 | if err != nil {
49 | return err
50 | }
51 | e.mut.Lock()
52 | e.config = c
53 | e.client = client
54 | e.mut.Unlock()
55 | //reset
56 | e.GetTorrents()
57 | return nil
58 | }
59 |
60 | func (e *Engine) NewMagnet(magnetURI string) error {
61 | tt, err := e.client.AddMagnet(magnetURI)
62 | if err != nil {
63 | return err
64 | }
65 | return e.newTorrent(tt)
66 | }
67 |
68 | func (e *Engine) NewTorrent(spec *torrent.TorrentSpec) error {
69 | tt, _, err := e.client.AddTorrentSpec(spec)
70 | if err != nil {
71 | return err
72 | }
73 | return e.newTorrent(tt)
74 | }
75 |
76 | func (e *Engine) newTorrent(tt *torrent.Torrent) error {
77 | t := e.upsertTorrent(tt)
78 | go func() {
79 | <-t.t.GotInfo()
80 | e.StartTorrent(t.InfoHash)
81 | }()
82 | return nil
83 | }
84 |
85 | // GetTorrents moves torrents out of the anacrolix/torrent
86 | // and into the local cache
87 | func (e *Engine) GetTorrents() map[string]*Torrent {
88 | e.mut.Lock()
89 | defer e.mut.Unlock()
90 |
91 | if e.client == nil {
92 | return nil
93 | }
94 | for _, tt := range e.client.Torrents() {
95 | e.upsertTorrent(tt)
96 | }
97 | return e.ts
98 | }
99 |
100 | func (e *Engine) upsertTorrent(tt *torrent.Torrent) *Torrent {
101 | ih := tt.InfoHash().HexString()
102 | torrent, ok := e.ts[ih]
103 | if !ok {
104 | torrent = &Torrent{InfoHash: ih}
105 | e.ts[ih] = torrent
106 | }
107 | //update torrent fields using underlying torrent
108 | torrent.Update(tt)
109 | return torrent
110 | }
111 |
112 | func (e *Engine) getTorrent(infohash string) (*Torrent, error) {
113 | ih, err := str2ih(infohash)
114 | if err != nil {
115 | return nil, err
116 | }
117 | t, ok := e.ts[ih.HexString()]
118 | if !ok {
119 | return t, fmt.Errorf("Missing torrent %x", ih)
120 | }
121 | return t, nil
122 | }
123 |
124 | func (e *Engine) getOpenTorrent(infohash string) (*Torrent, error) {
125 | t, err := e.getTorrent(infohash)
126 | if err != nil {
127 | return nil, err
128 | }
129 | return t, nil
130 | }
131 |
132 | func (e *Engine) StartTorrent(infohash string) error {
133 | t, err := e.getOpenTorrent(infohash)
134 | if err != nil {
135 | return err
136 | }
137 | if t.Started {
138 | return fmt.Errorf("Already started")
139 | }
140 | t.Started = true
141 | for _, f := range t.Files {
142 | if f != nil {
143 | f.Started = true
144 | }
145 | }
146 | if t.t.Info() != nil {
147 | t.t.DownloadAll()
148 | }
149 | return nil
150 | }
151 |
152 | func (e *Engine) StopTorrent(infohash string) error {
153 | t, err := e.getTorrent(infohash)
154 | if err != nil {
155 | return err
156 | }
157 | if !t.Started {
158 | return fmt.Errorf("Already stopped")
159 | }
160 | //there is no stop - kill underlying torrent
161 | t.t.Drop()
162 | t.Started = false
163 | for _, f := range t.Files {
164 | if f != nil {
165 | f.Started = false
166 | }
167 | }
168 | return nil
169 | }
170 |
171 | func (e *Engine) DeleteTorrent(infohash string) error {
172 | t, err := e.getTorrent(infohash)
173 | if err != nil {
174 | return err
175 | }
176 | os.Remove(filepath.Join(e.cacheDir, infohash+".torrent"))
177 | delete(e.ts, t.InfoHash)
178 | ih, _ := str2ih(infohash)
179 | if tt, ok := e.client.Torrent(ih); ok {
180 | tt.Drop()
181 | }
182 | return nil
183 | }
184 |
185 | func (e *Engine) StartFile(infohash, filepath string) error {
186 | t, err := e.getOpenTorrent(infohash)
187 | if err != nil {
188 | return err
189 | }
190 | var f *File
191 | for _, file := range t.Files {
192 | if file.Path == filepath {
193 | f = file
194 | break
195 | }
196 | }
197 | if f == nil {
198 | return fmt.Errorf("Missing file %s", filepath)
199 | }
200 | if f.Started {
201 | return fmt.Errorf("Already started")
202 | }
203 | t.Started = true
204 | f.Started = true
205 | return nil
206 | }
207 |
208 | func (e *Engine) StopFile(infohash, filepath string) error {
209 | return fmt.Errorf("Unsupported")
210 | }
211 |
212 | func str2ih(str string) (metainfo.Hash, error) {
213 | var ih metainfo.Hash
214 | e, err := hex.Decode(ih[:], []byte(str))
215 | if err != nil {
216 | return ih, fmt.Errorf("Invalid hex string")
217 | }
218 | if e != 20 {
219 | return ih, fmt.Errorf("Invalid length")
220 | }
221 | return ih, nil
222 | }
223 |
--------------------------------------------------------------------------------
/engine/torrent.go:
--------------------------------------------------------------------------------
1 | package engine
2 |
3 | import (
4 | "time"
5 |
6 | "github.com/anacrolix/torrent"
7 | )
8 |
9 | type Torrent struct {
10 | //anacrolix/torrent
11 | InfoHash string
12 | Name string
13 | Loaded bool
14 | Downloaded int64
15 | Size int64
16 | Files []*File
17 | //cloud torrent
18 | Started bool
19 | Dropped bool
20 | Percent float32
21 | DownloadRate float32
22 | t *torrent.Torrent
23 | updatedAt time.Time
24 | }
25 |
26 | type File struct {
27 | //anacrolix/torrent
28 | Path string
29 | Size int64
30 | Chunks int
31 | Completed int
32 | //cloud torrent
33 | Started bool
34 | Percent float32
35 | f *torrent.File
36 | }
37 |
38 | func (torrent *Torrent) Update(t *torrent.Torrent) {
39 | torrent.Name = t.Name()
40 | torrent.Loaded = t.Info() != nil
41 | if torrent.Loaded {
42 | torrent.updateLoaded(t)
43 | }
44 | torrent.t = t
45 | }
46 |
47 | func (torrent *Torrent) updateLoaded(t *torrent.Torrent) {
48 |
49 | torrent.Size = t.Length()
50 | totalChunks := 0
51 | totalCompleted := 0
52 |
53 | tfiles := t.Files()
54 | if len(tfiles) > 0 && torrent.Files == nil {
55 | torrent.Files = make([]*File, len(tfiles))
56 | }
57 | //merge in files
58 | for i, f := range tfiles {
59 | path := f.Path()
60 | file := torrent.Files[i]
61 | if file == nil {
62 | file = &File{Path: path}
63 | torrent.Files[i] = file
64 | }
65 | chunks := f.State()
66 |
67 | file.Size = f.Length()
68 | file.Chunks = len(chunks)
69 | completed := 0
70 | for _, p := range chunks {
71 | if p.Complete {
72 | completed++
73 | }
74 | }
75 | file.Completed = completed
76 | file.Percent = percent(int64(file.Completed), int64(file.Chunks))
77 | file.f = f
78 |
79 | totalChunks += file.Chunks
80 | totalCompleted += file.Completed
81 | }
82 |
83 | //cacluate rate
84 | now := time.Now()
85 | bytes := t.BytesCompleted()
86 | torrent.Percent = percent(bytes, torrent.Size)
87 | if !torrent.updatedAt.IsZero() {
88 | dt := float32(now.Sub(torrent.updatedAt))
89 | db := float32(bytes - torrent.Downloaded)
90 | rate := db * (float32(time.Second) / dt)
91 | if rate >= 0 {
92 | torrent.DownloadRate = rate
93 | }
94 | }
95 | torrent.Downloaded = bytes
96 | torrent.updatedAt = now
97 | }
98 |
99 | func percent(n, total int64) float32 {
100 | if total == 0 {
101 | return float32(0)
102 | }
103 | return float32(int(float64(10000)*(float64(n)/float64(total)))) / 100
104 | }
105 |
--------------------------------------------------------------------------------
/go.mod:
--------------------------------------------------------------------------------
1 | module github.com/jpillora/cloud-torrent
2 |
3 | go 1.23.0
4 |
5 | toolchain go1.23.1
6 |
7 | require (
8 | github.com/NYTimes/gziphandler v1.1.1
9 | github.com/anacrolix/torrent v1.58.0
10 | github.com/jpillora/archive v0.0.0-20160301031048-e0b3681851f1
11 | github.com/jpillora/backoff v1.0.0
12 | github.com/jpillora/cookieauth v1.1.1
13 | github.com/jpillora/opts v1.2.3
14 | github.com/jpillora/requestlog v1.0.0
15 | github.com/jpillora/scraper v0.3.0
16 | github.com/jpillora/velox v0.4.1
17 | github.com/shirou/gopsutil/v3 v3.24.5
18 | github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
19 | )
20 |
21 | require (
22 | github.com/PuerkitoBio/goquery v1.10.0 // indirect
23 | github.com/RoaringBitmap/roaring v1.9.4 // indirect
24 | github.com/ajwerner/btree v0.0.0-20211221152037-f427b3e689c0 // indirect
25 | github.com/alecthomas/atomic v0.1.0-alpha2 // indirect
26 | github.com/anacrolix/chansync v0.6.0 // indirect
27 | github.com/anacrolix/dht/v2 v2.22.0 // indirect
28 | github.com/anacrolix/envpprof v1.4.0 // indirect
29 | github.com/anacrolix/generics v0.0.3-0.20240902042256-7fb2702ef0ca // indirect
30 | github.com/anacrolix/go-libutp v1.3.1 // indirect
31 | github.com/anacrolix/log v0.16.0 // indirect
32 | github.com/anacrolix/missinggo v1.3.0 // indirect
33 | github.com/anacrolix/missinggo/perf v1.0.0 // indirect
34 | github.com/anacrolix/missinggo/v2 v2.8.0 // indirect
35 | github.com/anacrolix/mmsg v1.1.1 // indirect
36 | github.com/anacrolix/multiless v0.4.0 // indirect
37 | github.com/anacrolix/stm v0.5.0 // indirect
38 | github.com/anacrolix/sync v0.5.3 // indirect
39 | github.com/anacrolix/upnp v0.1.4 // indirect
40 | github.com/anacrolix/utp v0.2.0 // indirect
41 | github.com/andrew-d/go-termutil v0.0.0-20150726205930-009166a695a2 // indirect
42 | github.com/andybalholm/cascadia v1.3.2 // indirect
43 | github.com/bahlo/generic-list-go v0.2.0 // indirect
44 | github.com/benbjohnson/immutable v0.4.3 // indirect
45 | github.com/bits-and-blooms/bitset v1.17.0 // indirect
46 | github.com/bradfitz/iter v0.0.0-20191230175014-e8f45d346db8 // indirect
47 | github.com/cespare/xxhash v1.1.0 // indirect
48 | github.com/davecgh/go-spew v1.1.1 // indirect
49 | github.com/dustin/go-humanize v1.0.1 // indirect
50 | github.com/edsrzf/mmap-go v1.2.0 // indirect
51 | github.com/elithrar/simple-scrypt v1.3.0 // indirect
52 | github.com/floatdrop/lru v1.3.0 // indirect
53 | github.com/go-llsqlite/adapter v0.1.0 // indirect
54 | github.com/go-llsqlite/crawshaw v0.5.5 // indirect
55 | github.com/go-logr/logr v1.4.2 // indirect
56 | github.com/go-logr/stdr v1.2.2 // indirect
57 | github.com/go-ole/go-ole v1.3.0 // indirect
58 | github.com/google/btree v1.1.3 // indirect
59 | github.com/google/uuid v1.6.0 // indirect
60 | github.com/gorilla/websocket v1.5.3 // indirect
61 | github.com/hashicorp/errwrap v1.1.0 // indirect
62 | github.com/hashicorp/go-multierror v1.1.1 // indirect
63 | github.com/huandu/xstrings v1.5.0 // indirect
64 | github.com/jpillora/ansi v1.0.3 // indirect
65 | github.com/jpillora/eventsource v1.1.0 // indirect
66 | github.com/jpillora/sizestr v1.0.0 // indirect
67 | github.com/klauspost/cpuid/v2 v2.2.9 // indirect
68 | github.com/lufia/plan9stats v0.0.0-20240909124753-873cd0166683 // indirect
69 | github.com/mattn/go-isatty v0.0.20 // indirect
70 | github.com/minio/sha256-simd v1.0.1 // indirect
71 | github.com/mr-tron/base58 v1.2.0 // indirect
72 | github.com/mschoch/smat v0.2.0 // indirect
73 | github.com/multiformats/go-multihash v0.2.3 // indirect
74 | github.com/multiformats/go-varint v0.0.7 // indirect
75 | github.com/ncruces/go-strftime v0.1.9 // indirect
76 | github.com/pion/datachannel v1.5.9 // indirect
77 | github.com/pion/dtls/v3 v3.0.4 // indirect
78 | github.com/pion/ice/v4 v4.0.3 // indirect
79 | github.com/pion/interceptor v0.1.37 // indirect
80 | github.com/pion/logging v0.2.2 // indirect
81 | github.com/pion/mdns/v2 v2.0.7 // indirect
82 | github.com/pion/randutil v0.1.0 // indirect
83 | github.com/pion/rtcp v1.2.14 // indirect
84 | github.com/pion/rtp v1.8.9 // indirect
85 | github.com/pion/sctp v1.8.34 // indirect
86 | github.com/pion/sdp/v3 v3.0.9 // indirect
87 | github.com/pion/srtp/v3 v3.0.4 // indirect
88 | github.com/pion/stun/v3 v3.0.0 // indirect
89 | github.com/pion/transport/v3 v3.0.7 // indirect
90 | github.com/pion/turn/v4 v4.0.0 // indirect
91 | github.com/pion/webrtc/v4 v4.0.5 // indirect
92 | github.com/pkg/errors v0.9.1 // indirect
93 | github.com/posener/complete v1.2.3 // indirect
94 | github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect
95 | github.com/protolambda/ctxlock v0.1.0 // indirect
96 | github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
97 | github.com/rs/dnscache v0.0.0-20230804202142-fc85eb664529 // indirect
98 | github.com/shoenig/go-m1cpu v0.1.6 // indirect
99 | github.com/spaolacci/murmur3 v1.1.0 // indirect
100 | github.com/tidwall/btree v1.7.0 // indirect
101 | github.com/tklauser/go-sysconf v0.3.14 // indirect
102 | github.com/tklauser/numcpus v0.9.0 // indirect
103 | github.com/tomasen/realip v0.0.0-20180522021738-f0c99a92ddce // indirect
104 | github.com/wlynxg/anet v0.0.5 // indirect
105 | github.com/yusufpapurcu/wmi v1.2.4 // indirect
106 | go.etcd.io/bbolt v1.3.11 // indirect
107 | go.opentelemetry.io/otel v1.32.0 // indirect
108 | go.opentelemetry.io/otel/metric v1.32.0 // indirect
109 | go.opentelemetry.io/otel/trace v1.32.0 // indirect
110 | golang.org/x/crypto v0.29.0 // indirect
111 | golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f // indirect
112 | golang.org/x/net v0.31.0 // indirect
113 | golang.org/x/sync v0.9.0 // indirect
114 | golang.org/x/sys v0.27.0 // indirect
115 | golang.org/x/time v0.8.0 // indirect
116 | gomodules.xyz/jsonpatch/v3 v3.0.1 // indirect
117 | gomodules.xyz/orderedmap v0.1.0 // indirect
118 | lukechampine.com/blake3 v1.3.0 // indirect
119 | modernc.org/libc v1.61.3 // indirect
120 | modernc.org/mathutil v1.6.0 // indirect
121 | modernc.org/memory v1.8.0 // indirect
122 | modernc.org/sqlite v1.34.1 // indirect
123 | zombiezen.com/go/sqlite v1.4.0 // indirect
124 | )
125 |
--------------------------------------------------------------------------------
/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "log"
5 |
6 | "github.com/jpillora/cloud-torrent/server"
7 | "github.com/jpillora/opts"
8 | )
9 |
10 | var version = "0.0.0-src" //set with ldflags
11 |
12 | func main() {
13 | s := server.Server{
14 | Title: "Cloud Torrent",
15 | Port: 3000,
16 | ConfigPath: "cloud-torrent.json",
17 | }
18 |
19 | o := opts.New(&s)
20 | o.Version(version)
21 | o.PkgRepo()
22 | o.SetLineWidth(96)
23 | o.Parse()
24 |
25 | if err := s.Run(version); err != nil {
26 | log.Fatal(err)
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/server/server.go:
--------------------------------------------------------------------------------
1 | package server
2 |
3 | import (
4 | "compress/gzip"
5 | "crypto/tls"
6 | "encoding/json"
7 | "fmt"
8 | "io/ioutil"
9 | "log"
10 | "net/http"
11 | "os"
12 | "path/filepath"
13 | "runtime"
14 | "strings"
15 | "sync"
16 | "time"
17 |
18 | "github.com/NYTimes/gziphandler"
19 | "github.com/jpillora/cloud-torrent/engine"
20 | "github.com/jpillora/cloud-torrent/static"
21 | "github.com/jpillora/cookieauth"
22 | "github.com/jpillora/requestlog"
23 | "github.com/jpillora/scraper/scraper"
24 | "github.com/jpillora/velox"
25 | "github.com/skratchdot/open-golang/open"
26 | )
27 |
28 | //Server is the "State" portion of the diagram
29 | type Server struct {
30 | //config
31 | Title string `help:"Title of this instance" env:"TITLE"`
32 | Port int `help:"Listening port" env:"PORT"`
33 | Host string `help:"Listening interface (default all)"`
34 | Auth string `help:"Optional basic auth in form 'user:password'" env:"AUTH"`
35 | ConfigPath string `help:"Configuration file path"`
36 | KeyPath string `help:"TLS Key file path"`
37 | CertPath string `help:"TLS Certicate file path" short:"r"`
38 | Log bool `help:"Enable request logging"`
39 | Open bool `help:"Open now with your default browser"`
40 | //http handlers
41 | files, static http.Handler
42 | scraper *scraper.Handler
43 | scraperh http.Handler
44 | //torrent engine
45 | engine *engine.Engine
46 | state struct {
47 | velox.State
48 | sync.Mutex
49 | Config engine.Config
50 | SearchProviders scraper.Config
51 | Downloads *fsNode
52 | Torrents map[string]*engine.Torrent
53 | Users map[string]string
54 | Stats struct {
55 | Title string
56 | Version string
57 | Runtime string
58 | Uptime time.Time
59 | System stats
60 | }
61 | }
62 | }
63 |
64 | // Run the server
65 | func (s *Server) Run(version string) error {
66 | isTLS := s.CertPath != "" || s.KeyPath != "" //poor man's XOR
67 | if isTLS && (s.CertPath == "" || s.KeyPath == "") {
68 | return fmt.Errorf("You must provide both key and cert paths")
69 | }
70 | s.state.Stats.Title = s.Title
71 | s.state.Stats.Version = version
72 | s.state.Stats.Runtime = strings.TrimPrefix(runtime.Version(), "go")
73 | s.state.Stats.Uptime = time.Now()
74 | s.state.Stats.System.pusher = velox.Pusher(&s.state)
75 | //init maps
76 | s.state.Users = map[string]string{}
77 | //will use a the local embed/ dir if it exists, otherwise will use the hardcoded embedded binaries
78 | s.files = http.HandlerFunc(s.serveFiles)
79 | s.static = ctstatic.FileSystemHandler()
80 | s.scraper = &scraper.Handler{
81 | Log: false, Debug: false,
82 | Headers: map[string]string{
83 | //we're a trusty browser :)
84 | "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36",
85 | },
86 | }
87 | if err := s.scraper.LoadConfig(defaultSearchConfig); err != nil {
88 | log.Fatal(err)
89 | }
90 | //scraper
91 | s.state.SearchProviders = s.scraper.Config //share scraper config
92 | go s.fetchSearchConfigLoop()
93 | s.scraperh = http.StripPrefix("/search", s.scraper)
94 | //torrent engine
95 | s.engine = engine.New()
96 | //configure engine
97 | c := engine.Config{
98 | DownloadDirectory: "./downloads",
99 | EnableUpload: true,
100 | AutoStart: true,
101 | }
102 | if _, err := os.Stat(s.ConfigPath); err == nil {
103 | if b, err := ioutil.ReadFile(s.ConfigPath); err != nil {
104 | return fmt.Errorf("Read configuration error: %s", err)
105 | } else if len(b) == 0 {
106 | //ignore empty file
107 | } else if err := json.Unmarshal(b, &c); err != nil {
108 | return fmt.Errorf("Malformed configuration: %s", err)
109 | }
110 | }
111 | if c.IncomingPort <= 0 || c.IncomingPort >= 65535 {
112 | c.IncomingPort = 50007
113 | }
114 | if err := s.reconfigure(c); err != nil {
115 | return fmt.Errorf("initial configure failed: %s", err)
116 | }
117 | //poll torrents and files
118 | go func() {
119 | for {
120 | s.state.Lock()
121 | s.state.Torrents = s.engine.GetTorrents()
122 | s.state.Downloads = s.listFiles()
123 | s.state.Unlock()
124 | s.state.Push()
125 | time.Sleep(1 * time.Second)
126 | }
127 | }()
128 | //start collecting stats
129 | go func() {
130 | for {
131 | c := s.engine.Config()
132 | s.state.Stats.System.loadStats(c.DownloadDirectory)
133 | time.Sleep(5 * time.Second)
134 | }
135 | }()
136 |
137 | host := s.Host
138 | if host == "" {
139 | host = "0.0.0.0"
140 | }
141 | addr := fmt.Sprintf("%s:%d", host, s.Port)
142 | proto := "http"
143 | if isTLS {
144 | proto += "s"
145 | }
146 | if s.Open {
147 | openhost := host
148 | if openhost == "0.0.0.0" {
149 | openhost = "localhost"
150 | }
151 | go func() {
152 | time.Sleep(1 * time.Second)
153 | open.Run(fmt.Sprintf("%s://%s:%d", proto, openhost, s.Port))
154 | }()
155 | }
156 | //define handler chain, from last to first
157 | h := http.Handler(http.HandlerFunc(s.handle))
158 | //gzip
159 | compression := gzip.DefaultCompression
160 | minSize := 0 //IMPORTANT
161 | gzipWrap, _ := gziphandler.NewGzipLevelAndMinSize(compression, minSize)
162 | h = gzipWrap(h)
163 | //auth
164 | if s.Auth != "" {
165 | user := s.Auth
166 | pass := ""
167 | if s := strings.SplitN(s.Auth, ":", 2); len(s) == 2 {
168 | user = s[0]
169 | pass = s[1]
170 | }
171 | h = cookieauth.New().SetUserPass(user, pass).Wrap(h)
172 | log.Printf("Enabled HTTP authentication")
173 | }
174 | if s.Log {
175 | h = requestlog.Wrap(h)
176 | }
177 | log.Printf("Listening at %s://%s", proto, addr)
178 | //serve!
179 | server := http.Server{
180 | //disable http2 due to velox bug
181 | TLSNextProto: map[string]func(*http.Server, *tls.Conn, http.Handler){},
182 | //address
183 | Addr: addr,
184 | //handler stack
185 | Handler: h,
186 | }
187 | if isTLS {
188 | return server.ListenAndServeTLS(s.CertPath, s.KeyPath)
189 | }
190 | return server.ListenAndServe()
191 | }
192 |
193 | func (s *Server) reconfigure(c engine.Config) error {
194 | dldir, err := filepath.Abs(c.DownloadDirectory)
195 | if err != nil {
196 | return fmt.Errorf("Invalid path")
197 | }
198 | c.DownloadDirectory = dldir
199 | if err := s.engine.Configure(c); err != nil {
200 | return err
201 | }
202 | b, _ := json.MarshalIndent(&c, "", " ")
203 | ioutil.WriteFile(s.ConfigPath, b, 0755)
204 | s.state.Config = c
205 | s.state.Push()
206 | return nil
207 | }
208 |
209 | func (s *Server) handle(w http.ResponseWriter, r *http.Request) {
210 | //handle realtime client library
211 | if r.URL.Path == "/js/velox.js" {
212 | velox.JS.ServeHTTP(w, r)
213 | return
214 | }
215 | //handle realtime client connections
216 | if r.URL.Path == "/sync" {
217 | conn, err := velox.Sync(&s.state, w, r)
218 | if err != nil {
219 | log.Printf("sync failed: %s", err)
220 | return
221 | }
222 | s.state.Users[conn.ID()] = r.RemoteAddr
223 | s.state.Push()
224 | conn.Wait()
225 | delete(s.state.Users, conn.ID())
226 | s.state.Push()
227 | return
228 | }
229 | //search
230 | if strings.HasPrefix(r.URL.Path, "/search") {
231 | s.scraperh.ServeHTTP(w, r)
232 | return
233 | }
234 | //api call
235 | if strings.HasPrefix(r.URL.Path, "/api/") {
236 | //only pass request in, expect error out
237 | if err := s.api(r); err == nil {
238 | w.WriteHeader(http.StatusOK)
239 | w.Write([]byte("OK"))
240 | } else {
241 | w.WriteHeader(http.StatusBadRequest)
242 | w.Write([]byte(err.Error()))
243 | }
244 | return
245 | }
246 | //no match, assume static file
247 | s.files.ServeHTTP(w, r)
248 | }
249 |
--------------------------------------------------------------------------------
/server/server_api.go:
--------------------------------------------------------------------------------
1 | package server
2 |
3 | import (
4 | "bytes"
5 | "encoding/json"
6 | "fmt"
7 | "io/ioutil"
8 | "net/http"
9 | "strings"
10 |
11 | "github.com/anacrolix/torrent"
12 | "github.com/anacrolix/torrent/metainfo"
13 |
14 | "github.com/jpillora/cloud-torrent/engine"
15 | )
16 |
17 | func (s *Server) api(r *http.Request) error {
18 | defer r.Body.Close()
19 | if r.Method != "POST" {
20 | return fmt.Errorf("Invalid request method (expecting POST)")
21 | }
22 |
23 | action := strings.TrimPrefix(r.URL.Path, "/api/")
24 |
25 | data, err := ioutil.ReadAll(r.Body)
26 | if err != nil {
27 | return fmt.Errorf("Failed to download request body")
28 | }
29 |
30 | //convert url into torrent bytes
31 | if action == "url" {
32 | url := string(data)
33 | remote, err := http.Get(url)
34 | if err != nil {
35 | return fmt.Errorf("Invalid remote torrent URL: %s (%s)", err, url)
36 | }
37 | //TODO enforce max body size (32k?)
38 | data, err = ioutil.ReadAll(remote.Body)
39 | if err != nil {
40 | return fmt.Errorf("Failed to download remote torrent: %s", err)
41 | }
42 | action = "torrentfile"
43 | }
44 |
45 | //convert torrent bytes into magnet
46 | if action == "torrentfile" {
47 | reader := bytes.NewBuffer(data)
48 | info, err := metainfo.Load(reader)
49 | if err != nil {
50 | return err
51 | }
52 | spec := torrent.TorrentSpecFromMetaInfo(info)
53 | if err := s.engine.NewTorrent(spec); err != nil {
54 | return fmt.Errorf("Torrent error: %s", err)
55 | }
56 | return nil
57 | }
58 |
59 | //update after action completes
60 | defer s.state.Push()
61 |
62 | //interface with engine
63 | switch action {
64 | case "configure":
65 | c := engine.Config{}
66 | if err := json.Unmarshal(data, &c); err != nil {
67 | return err
68 | }
69 | if err := s.reconfigure(c); err != nil {
70 | return err
71 | }
72 | case "magnet":
73 | uri := string(data)
74 | if err := s.engine.NewMagnet(uri); err != nil {
75 | return fmt.Errorf("Magnet error: %s", err)
76 | }
77 | case "torrent":
78 | cmd := strings.SplitN(string(data), ":", 2)
79 | if len(cmd) != 2 {
80 | return fmt.Errorf("Invalid request")
81 | }
82 | state := cmd[0]
83 | infohash := cmd[1]
84 | if state == "start" {
85 | if err := s.engine.StartTorrent(infohash); err != nil {
86 | return err
87 | }
88 | } else if state == "stop" {
89 | if err := s.engine.StopTorrent(infohash); err != nil {
90 | return err
91 | }
92 | } else if state == "delete" {
93 | if err := s.engine.DeleteTorrent(infohash); err != nil {
94 | return err
95 | }
96 | } else {
97 | return fmt.Errorf("Invalid state: %s", state)
98 | }
99 | case "file":
100 | cmd := strings.SplitN(string(data), ":", 3)
101 | if len(cmd) != 3 {
102 | return fmt.Errorf("Invalid request")
103 | }
104 | state := cmd[0]
105 | infohash := cmd[1]
106 | filepath := cmd[2]
107 | if state == "start" {
108 | if err := s.engine.StartFile(infohash, filepath); err != nil {
109 | return err
110 | }
111 | } else if state == "stop" {
112 | if err := s.engine.StopFile(infohash, filepath); err != nil {
113 | return err
114 | }
115 | } else {
116 | return fmt.Errorf("Invalid state: %s", state)
117 | }
118 | default:
119 | return fmt.Errorf("Invalid action: %s", action)
120 | }
121 | return nil
122 | }
123 |
--------------------------------------------------------------------------------
/server/server_files.go:
--------------------------------------------------------------------------------
1 | package server
2 |
3 | import (
4 | "errors"
5 | "fmt"
6 | "io/ioutil"
7 | "log"
8 | "net/http"
9 | "os"
10 | "path/filepath"
11 | "strings"
12 | "time"
13 |
14 | "github.com/jpillora/archive"
15 | )
16 |
17 | const fileNumberLimit = 1000
18 |
19 | type fsNode struct {
20 | Name string
21 | Size int64
22 | Modified time.Time
23 | Children []*fsNode
24 | }
25 |
26 | func (s *Server) listFiles() *fsNode {
27 | rootDir := s.state.Config.DownloadDirectory
28 | root := &fsNode{}
29 | if info, err := os.Stat(rootDir); err == nil {
30 | if err := list(rootDir, info, root, new(int)); err != nil {
31 | log.Printf("File listing failed: %s", err)
32 | }
33 | }
34 | return root
35 | }
36 |
37 | func (s *Server) serveFiles(w http.ResponseWriter, r *http.Request) {
38 | if strings.HasPrefix(r.URL.Path, "/download/") {
39 | url := strings.TrimPrefix(r.URL.Path, "/download/")
40 | //dldir is absolute
41 | dldir := s.state.Config.DownloadDirectory
42 | file := filepath.Join(dldir, url)
43 | //only allow fetches/deletes inside the dl dir
44 | if !strings.HasPrefix(file, dldir) || dldir == file {
45 | http.Error(w, "Nice try\n"+dldir+"\n"+file, http.StatusBadRequest)
46 | return
47 | }
48 | info, err := os.Stat(file)
49 | if err != nil {
50 | http.Error(w, "File stat error: "+err.Error(), http.StatusBadRequest)
51 | return
52 | }
53 | switch r.Method {
54 | case "GET":
55 | if info.IsDir() {
56 | w.Header().Set("Content-Type", "application/zip")
57 | w.WriteHeader(200)
58 | //write .zip archive directly into response
59 | a := archive.NewZipWriter(w)
60 | a.AddDir(file)
61 | a.Close()
62 | } else {
63 | f, err := os.Open(file)
64 | if err != nil {
65 | http.Error(w, "File open error: "+err.Error(), http.StatusBadRequest)
66 | return
67 | }
68 | http.ServeContent(w, r, info.Name(), info.ModTime(), f)
69 | f.Close()
70 | }
71 | case "DELETE":
72 | if err := os.RemoveAll(file); err != nil {
73 | http.Error(w, "Delete failed: "+err.Error(), http.StatusInternalServerError)
74 | }
75 | default:
76 | http.Error(w, "Not allowed", http.StatusMethodNotAllowed)
77 | }
78 | return
79 | }
80 | s.static.ServeHTTP(w, r)
81 | }
82 |
83 | //custom directory walk
84 |
85 | func list(path string, info os.FileInfo, node *fsNode, n *int) error {
86 | if (!info.IsDir() && !info.Mode().IsRegular()) || strings.HasPrefix(info.Name(), ".") {
87 | return errors.New("Non-regular file")
88 | }
89 | (*n)++
90 | if (*n) > fileNumberLimit {
91 | return errors.New("Over file limit") //limit number of files walked
92 | }
93 | node.Name = info.Name()
94 | node.Size = info.Size()
95 | node.Modified = info.ModTime()
96 | if !info.IsDir() {
97 | return nil
98 | }
99 | children, err := ioutil.ReadDir(path)
100 | if err != nil {
101 | return fmt.Errorf("Failed to list files")
102 | }
103 | node.Size = 0
104 | for _, i := range children {
105 | c := &fsNode{}
106 | p := filepath.Join(path, i.Name())
107 | if err := list(p, i, c, n); err != nil {
108 | continue
109 | }
110 | node.Size += c.Size
111 | node.Children = append(node.Children, c)
112 | }
113 | return nil
114 | }
115 |
--------------------------------------------------------------------------------
/server/server_search.go:
--------------------------------------------------------------------------------
1 | package server
2 |
3 | import (
4 | "bytes"
5 | "encoding/json"
6 | "io/ioutil"
7 | "log"
8 | "net/http"
9 | "time"
10 |
11 | "github.com/jpillora/backoff"
12 | )
13 |
14 | const searchConfigURL = "https://gist.githubusercontent.com/jpillora/4d945b46b3025843b066adf3d685be6b/raw/scraper-config.json"
15 |
16 | func (s *Server) fetchSearchConfigLoop() {
17 | b := backoff.Backoff{Max: 30 * time.Minute}
18 | for {
19 | if err := s.fetchSearchConfig(); err != nil {
20 | //ignore error
21 | time.Sleep(b.Duration())
22 | } else {
23 | //no errror - check again in half hour
24 | time.Sleep(30 * time.Minute)
25 | b.Reset()
26 | }
27 | }
28 | }
29 |
30 | var fetches = 0
31 | var currentConfig, _ = normalize(defaultSearchConfig)
32 |
33 | func (s *Server) fetchSearchConfig() error {
34 | resp, err := http.Get(searchConfigURL)
35 | if err != nil {
36 | return err
37 | }
38 | defer resp.Body.Close()
39 | newConfig, err := ioutil.ReadAll(resp.Body)
40 | if err != nil {
41 | return err
42 | }
43 | newConfig, err = normalize(newConfig)
44 | if err != nil {
45 | return err
46 | }
47 | fetches++
48 | if bytes.Equal(currentConfig, newConfig) {
49 | return nil //skip
50 | }
51 | if err := s.scraper.LoadConfig(newConfig); err != nil {
52 | return err
53 | }
54 | s.state.SearchProviders = s.scraper.Config
55 | s.state.Push()
56 | currentConfig = newConfig
57 | log.Printf("Loaded new search providers")
58 | return nil
59 | }
60 |
61 | func normalize(input []byte) ([]byte, error) {
62 | output := bytes.Buffer{}
63 | if err := json.Indent(&output, input, "", " "); err != nil {
64 | return nil, err
65 | }
66 | return output.Bytes(), nil
67 | }
68 |
69 | //see github.com/jpillora/scraper for config specification
70 | //cloud-torrent uses "-item" handlers
71 | var defaultSearchConfig = []byte(`{
72 | "zq": {
73 | "name": "Zooqle",
74 | "url": "https://zooqle.com/search?q={{query}}&pg={{page:1}}&s=ns&v=t&sd=d",
75 | "list": "#body_container .panel-body > table tbody tr",
76 | "result": {
77 | "name": "td:nth-child(2) a",
78 | "url": ["td:nth-child(2) a", "@href"],
79 | "magnet": ["a[title=Magnet\\ link]", "@href"],
80 | "seeds": "td:nth-child(6) .progress-bar:nth-child(1)",
81 | "peers": "td:nth-child(6) .progress-bar:nth-child(2)"
82 | }
83 | },
84 | "rbg": {
85 | "name": "RARBG",
86 | "url": "https://rarbg.to/torrents.php?search={{query}}&order=seeders&by=DESC&page={{page:1}}",
87 | "list": "table.lista2t tr.lista2",
88 | "result": {
89 | "name":["td:nth-child(2) > a[title]"],
90 | "torrent":["td:nth-child(2) > a[title]","@href","s~/torrent/~~","s~^~https://rarbg.to/download.php?f=file.torrent&id=~"],
91 | "size": "td:nth-child(4)",
92 | "seeds": "td:nth-child(5)",
93 | "peers": "td:nth-child(6)"
94 | }
95 | },
96 | "eztv": {
97 | "name": "EZTV",
98 | "url": "https://eztv.ag/search/{{query}}",
99 | "list": "table tr.forum_header_border",
100 | "result": {
101 | "name": "td:nth-child(2) a",
102 | "url": ["td:nth-child(2) a", "@href"],
103 | "magnet": ["td:nth-child(3) a:nth-child(1)", "@href"],
104 | "size": "td:nth-child(4)",
105 | "seeds": "td:nth-child(6)"
106 | }
107 | },
108 | "1337x": {
109 | "name": "1337X",
110 | "url": "http://1337x.to/sort-search/{{query}}/seeders/desc/{{page:1}}/",
111 | "list": ".box-info-detail table.table tr",
112 | "result": {
113 | "name":[".coll-1 a:nth-child(2)"],
114 | "url":[".coll-1 a:nth-child(2)", "@href"],
115 | "seeds": ".coll-2",
116 | "peers": ".coll-3",
117 | "size": [".coll-4", "/([\\d\\.]+ [KMGT]?B)/"]
118 | }
119 | },
120 | "1337x/item": {
121 | "name": "1337X (Item)",
122 | "url": "http://1337x.to{{item}}",
123 | "result": {
124 | "magnet": [".download-links-dontblock a.btn","@href"]
125 | }
126 | },
127 | "abb": {
128 | "name": "The Audiobook Bay",
129 | "url": "http://audiobookbay.me/page/{{page:1}}?s={{query}}",
130 | "list": "#content > div",
131 | "result": {
132 | "name":["div.postTitle > h2 > a","@title"],
133 | "url":["div.postTitle > h2 > a","@href"],
134 | "seeds": "div.postContent > p:nth-child(3) > span:nth-child(1)",
135 | "peers": "div.postContent > p:nth-child(3) > span:nth-child(3)"
136 | }
137 | },
138 | "abb/item": {
139 | "name": "The Audiobook Bay (Item)",
140 | "url": "http://audiobookbay.me{{item}}",
141 | "result": {
142 | "infohash": "/td>([a-f0-9]+)",
143 | "tracker": "table tr td:nth-child(2)"
144 | }
145 | },
146 | "tpb": {
147 | "name": "The Pirate Bay",
148 | "url": "https://thepiratebay.org/search/{{query}}/{{page:0}}/7//",
149 | "list": "#searchResult > tbody > tr",
150 | "result": {
151 | "name":"a.detLink",
152 | "path":["a.detLink","@href"],
153 | "magnet": ["a[title=Download\\ this\\ torrent\\ using\\ magnet]","@href"],
154 | "size": "/Size (\\d+(\\.\\d+).[KMG]iB)/",
155 | "seeds": "td:nth-child(3)",
156 | "peers": "td:nth-child(4)"
157 | }
158 | }
159 | }`)
160 |
--------------------------------------------------------------------------------
/server/server_stats.go:
--------------------------------------------------------------------------------
1 | package server
2 |
3 | import (
4 | "runtime"
5 |
6 | velox "github.com/jpillora/velox/go"
7 | "github.com/shirou/gopsutil/v3/cpu"
8 | "github.com/shirou/gopsutil/v3/disk"
9 | "github.com/shirou/gopsutil/v3/mem"
10 | )
11 |
12 | type stats struct {
13 | Set bool `json:"set"`
14 | CPU float64 `json:"cpu"`
15 | DiskUsed int64 `json:"diskUsed"`
16 | DiskTotal int64 `json:"diskTotal"`
17 | MemoryUsed int64 `json:"memoryUsed"`
18 | MemoryTotal int64 `json:"memoryTotal"`
19 | GoMemory int64 `json:"goMemory"`
20 | GoRoutines int `json:"goRoutines"`
21 | //internal
22 | pusher velox.Pusher
23 | }
24 |
25 | func (s *stats) loadStats(diskDir string) {
26 | //count cpu cycles between last count
27 | if percents, err := cpu.Percent(0, false); err == nil && len(percents) == 1 {
28 | s.CPU = percents[0]
29 | }
30 | //count disk usage
31 | if stat, err := disk.Usage(diskDir); err == nil {
32 | s.DiskUsed = int64(stat.Used)
33 | s.DiskTotal = int64(stat.Total)
34 | }
35 | //count memory usage
36 | if stat, err := mem.VirtualMemory(); err == nil {
37 | s.MemoryUsed = int64(stat.Used)
38 | s.MemoryTotal = int64(stat.Total)
39 | }
40 | //count total bytes allocated by the go runtime
41 | memStats := runtime.MemStats{}
42 | runtime.ReadMemStats(&memStats)
43 | s.GoMemory = int64(memStats.Alloc)
44 | //count current number of goroutines
45 | s.GoRoutines = runtime.NumGoroutine()
46 | //done
47 | s.Set = true
48 | s.pusher.Push()
49 | }
50 |
--------------------------------------------------------------------------------
/static/files/cloud-favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jpillora/cloud-torrent/c931df6a18a7ae1d0ff962de8348dc79ed4a1807/static/files/cloud-favicon.png
--------------------------------------------------------------------------------
/static/files/css/Lato/Lato-1.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jpillora/cloud-torrent/c931df6a18a7ae1d0ff962de8348dc79ed4a1807/static/files/css/Lato/Lato-1.woff
--------------------------------------------------------------------------------
/static/files/css/Lato/Lato-2.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jpillora/cloud-torrent/c931df6a18a7ae1d0ff962de8348dc79ed4a1807/static/files/css/Lato/Lato-2.woff
--------------------------------------------------------------------------------
/static/files/css/Lato/Lato-3.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jpillora/cloud-torrent/c931df6a18a7ae1d0ff962de8348dc79ed4a1807/static/files/css/Lato/Lato-3.woff
--------------------------------------------------------------------------------
/static/files/css/Lato/Lato-4.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jpillora/cloud-torrent/c931df6a18a7ae1d0ff962de8348dc79ed4a1807/static/files/css/Lato/Lato-4.woff
--------------------------------------------------------------------------------
/static/files/css/Lato/Lato.css:
--------------------------------------------------------------------------------
1 | @font-face {
2 | font-family: 'Lato';
3 | font-style: normal;
4 | font-weight: 400;
5 | src: local('Lato Regular'), local('Lato-Regular'), url(./Lato-1.woff) format('woff');
6 | }
7 | @font-face {
8 | font-family: 'Lato';
9 | font-style: normal;
10 | font-weight: 700;
11 | src: local('Lato Bold'), local('Lato-Bold'), url(./Lato-2.woff) format('woff');
12 | }
13 | @font-face {
14 | font-family: 'Lato';
15 | font-style: italic;
16 | font-weight: 400;
17 | src: local('Lato Italic'), local('Lato-Italic'), url(./Lato-3.woff) format('woff');
18 | }
19 | @font-face {
20 | font-family: 'Lato';
21 | font-style: italic;
22 | font-weight: 700;
23 | src: local('Lato Bold Italic'), local('Lato-BoldItalic'), url(./Lato-4.woff) format('woff');
24 | }
25 |
--------------------------------------------------------------------------------
/static/files/css/app.css:
--------------------------------------------------------------------------------
1 | @import url("./sections/omni.css");
2 | @import url("./sections/torrents.css");
3 | @import url("./sections/downloads.css");
4 |
5 | /* global styles */
6 |
7 | html,
8 | body {
9 | width: 100%;
10 | margin: 0;
11 | padding: 0;
12 | }
13 |
14 | .cage {
15 | padding-top: 25px;
16 | padding-bottom: 40px;
17 | max-width: 700px;
18 | margin: 0 auto;
19 | }
20 |
21 | @media (max-width: 740px) {
22 | .cage {
23 | margin: 0 10px;
24 | padding-top: 10px;
25 | }
26 | }
27 |
28 | @media (max-width: 480px) {
29 | body .title a {
30 | font-size: 1.65rem;
31 | }
32 | }
33 |
34 | html body .muted {
35 | color: gray;
36 | }
37 |
38 | footer {
39 | text-align: right;
40 | color: grey;
41 | font-style: italic;
42 | font-size: 0.8em;
43 | opacity: 0.25;
44 | transition: opacity 0.3s ease-in-out;
45 | }
46 |
47 | footer:hover {
48 | opacity: 1;
49 | }
50 |
51 | footer:hover .extra {
52 | display: inline;
53 | }
54 |
55 | footer .extra {
56 | display: none;
57 | }
58 |
59 | .ellipsis {
60 | display: inline-block;
61 | overflow: hidden;
62 | white-space: nowrap;
63 | text-overflow: ellipsis;
64 | }
65 |
66 | [ng-click] {
67 | cursor: pointer;
68 | }
69 |
70 | .disabled {
71 | cursor: default !important;
72 | }
73 |
74 | .icon[ng-click] {
75 | font-size: 1.2em;
76 | }
77 |
78 | .app .connect-warning {
79 | padding-top: 50px;
80 | position: fixed;
81 | z-index: 10000;
82 | left: 0;
83 | top: 0;
84 | width: 100%;
85 | height: 100%;
86 | background-color: rgba(0, 0, 0, 1);
87 | opacity: 0.95;
88 | }
89 |
90 | /*
91 | ================
92 | app styles
93 | */
94 |
95 | .title {
96 | position: relative;
97 | }
98 |
99 | .title a {
100 | font-size: 2.35rem;
101 | }
102 |
103 | .title .status {
104 | position: absolute;
105 | top: 2px;
106 | right: 10px;
107 | }
108 |
109 | .app .config form.edit {
110 | margin-bottom: 1rem;
111 | }
112 |
113 | .app .config form.edit input {
114 | font-family: monospace;
115 | }
116 |
117 | .app .config form.edit .buttons {
118 | text-align: center;
119 | }
120 |
121 | .section-header {
122 | margin-top: 20px;
123 | position: relative;
124 | }
125 |
126 | .section-header .right {
127 | position: absolute;
128 | right: 0px;
129 | top: 1px;
130 | margin: 9px;
131 | font-size: 0.75rem;
132 | color: grey;
133 | }
134 |
135 | table.tcld .name {
136 | text-align: right !important;
137 | word-break: break-all;
138 | }
139 |
140 | .uploads .upload .size {
141 | width: 100px;
142 | }
143 |
144 | [onfileclick] {
145 | cursor: pointer;
146 | }
147 |
148 | [ondropfile] {
149 | position: relative;
150 | }
151 |
152 | [ondropfile] .file-drop-cover {
153 | position: absolute;
154 | top: 0;
155 | left: 0;
156 | height: 100%;
157 | width: 102%;
158 | margin-top: 1%;
159 | margin-left: -1%;
160 | pointer-events: none;
161 | background: rgba(173, 216, 230, 0.5);
162 | opacity: 0;
163 | transition: opacity ease 0.3s;
164 | z-index: 5;
165 | overflow: hidden;
166 | }
167 |
168 | [ondropfile] .file-drop-cover.shown {
169 | opacity: 1;
170 | }
171 |
172 | [ondropfile] .file-drop-cover .dots {
173 | height: 100%;
174 | border: 1px dotted #333;
175 | border-radius: 3px;
176 | }
177 |
178 | [ondropfile] .file-drop-cover .dots .msg {
179 | position: absolute;
180 | text-align: center;
181 | font-size: 2em;
182 | left: 0;
183 | top: 30px;
184 | width: 100%;
185 | }
186 |
--------------------------------------------------------------------------------
/static/files/css/sections/downloads.css:
--------------------------------------------------------------------------------
1 | .nodownloads, .nouploads {
2 | text-align: center;
3 | }
4 |
5 | .downloads .ui.list .content {
6 | width: 100%;
7 | }
8 |
9 | .downloads .ui.list .content .header a {
10 | word-break: break-all;
11 | }
12 |
13 | .downloads .ui.list .item .controls {
14 | opacity: 0;
15 | transition: opacity .3s ease-in-out;
16 | }
17 |
18 | @media (max-width: 480px) {
19 | .downloads .ui.list .item .controls {
20 | opacity: 0.5;
21 | }
22 | }
23 |
24 | .downloads .ui.list .item:hover > .content > .header > .controls {
25 | opacity: 1;
26 | }
27 |
28 | .downloads .preview video, .downloads .preview img, .downloads .preview audio {
29 | margin-top: 5px;
30 | max-width: 90%;
31 | }
--------------------------------------------------------------------------------
/static/files/css/sections/omni.css:
--------------------------------------------------------------------------------
1 | .omni {
2 | margin-top: 5px;
3 | }
4 |
5 | .omni .buttons {
6 | margin-top: 5px;
7 | text-align: center;
8 | }
9 |
10 | .omni .results {
11 | max-height: 200px;
12 | overflow-y: auto;
13 | border: 1px solid rgba(0, 0, 0, 0.15);
14 | margin-top: 5px;
15 | border-radius: 4px;
16 | }
17 |
18 | .omni .results .name {
19 | /*font-size: .75em;*/
20 | text-align: right;
21 | }
22 |
23 | .omni .results .users {
24 | width: 75px;
25 | text-align: center;
26 | }
27 | .omni .results .seeds {
28 | color: #5bbd72;
29 | }
30 |
31 | .omni .results .peers {
32 | color: rgb(176, 127, 20);
33 | }
34 |
35 | .omni .results .loadmore {
36 | text-align: right;
37 | }
38 |
39 | .omni .search select {
40 | padding: 0 10px;
41 | margin-top: 0px;
42 | border-radius: 4px;
43 | background: #d58686;
44 | color: #888;
45 | border: none;
46 | outline: none;
47 | height: 31px;
48 | display: inline-block;
49 | -webkit-appearance: none;
50 | -moz-appearance: none;
51 | appearance: none;
52 | cursor: pointer;
53 | }
54 | .omni .form {
55 | margin-top: 5px;
56 | }
57 |
58 | .icon-wrapper {
59 | z-index: 6;
60 | position: absolute;
61 | right: 0;
62 | padding: 10px;
63 | cursor: pointer;
64 | }
65 |
--------------------------------------------------------------------------------
/static/files/css/sections/torrents.css:
--------------------------------------------------------------------------------
1 | section.torrents {
2 | margin-bottom: 20px;
3 | }
4 |
5 | .torrent {
6 | opacity: 0.95;
7 | min-height: 10px;
8 | }
9 |
10 | .torrent.open {
11 | opacity: 1
12 | }
13 |
14 | .torrent .info .name,
15 | .torrent .info .hash {
16 | text-overflow: ellipsis;
17 | overflow: hidden;
18 | white-space: nowrap;
19 | }
20 |
21 | .torrent .info .name {
22 | font-size: 1.2rem;
23 | }
24 |
25 | .torrent .info .hash {
26 | font-size: 0.75rem;
27 | }
28 |
29 | .torrent .info .progress {
30 | margin: 0;
31 | }
32 | .torrent .info .progress .bar {
33 | height: 10px;
34 | }
35 |
36 | .torrent .status {
37 | padding: 5px;
38 | display: inline-block;
39 | }
40 |
41 | .torrent .status .muted {
42 | color: lightgray;
43 | }
44 |
45 | .torrent .controls.column {
46 | /*padding-top: 5px;*/
47 | text-align: right;
48 | }
49 |
50 | .torrent .stopped.row .column {
51 | padding: 0 100px;
52 | text-align: center;
53 | font-size: 0.75rem;
54 | }
55 |
56 |
57 |
58 | .torrent .download.file .name span {
59 | position: relative;
60 | z-index: 1;
61 | }
62 |
63 | .torrent .download.file .name .percent {
64 | display: inline-block;
65 | width: 60px;
66 | }
67 |
68 |
69 | .torrent .download.file .name,
70 | .torrent .download.file .percent {
71 | position: relative;
72 | overflow: hidden;
73 | }
74 |
75 | .torrent .downloads .progress {
76 | position: absolute;
77 | top: 0;
78 | left: 0;
79 | width: 100%;
80 | opacity: 0.55;
81 | z-index: 0;
82 | padding: 4px;
83 | margin: 0;
84 | height: 100%;
85 | background: none;
86 | }
87 | .torrent .download.file .progress .bar {
88 | height: 100%;
89 | }
90 |
91 | .torrent .downloads thead tr th.size {
92 | width: 110px;
93 | }
94 | .torrent .downloads tfoot tr th {
95 | font-weight: bold;
96 | font-size: 0.85rem;
97 | }
98 |
--------------------------------------------------------------------------------
/static/files/css/themes/default/assets/fonts/icons.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jpillora/cloud-torrent/c931df6a18a7ae1d0ff962de8348dc79ed4a1807/static/files/css/themes/default/assets/fonts/icons.eot
--------------------------------------------------------------------------------
/static/files/css/themes/default/assets/fonts/icons.otf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jpillora/cloud-torrent/c931df6a18a7ae1d0ff962de8348dc79ed4a1807/static/files/css/themes/default/assets/fonts/icons.otf
--------------------------------------------------------------------------------
/static/files/css/themes/default/assets/fonts/icons.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jpillora/cloud-torrent/c931df6a18a7ae1d0ff962de8348dc79ed4a1807/static/files/css/themes/default/assets/fonts/icons.ttf
--------------------------------------------------------------------------------
/static/files/css/themes/default/assets/fonts/icons.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jpillora/cloud-torrent/c931df6a18a7ae1d0ff962de8348dc79ed4a1807/static/files/css/themes/default/assets/fonts/icons.woff
--------------------------------------------------------------------------------
/static/files/css/themes/default/assets/fonts/icons.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jpillora/cloud-torrent/c931df6a18a7ae1d0ff962de8348dc79ed4a1807/static/files/css/themes/default/assets/fonts/icons.woff2
--------------------------------------------------------------------------------
/static/files/css/themes/default/assets/images/flags.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jpillora/cloud-torrent/c931df6a18a7ae1d0ff962de8348dc79ed4a1807/static/files/css/themes/default/assets/images/flags.png
--------------------------------------------------------------------------------
/static/files/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Cloud Torrent
5 |
6 |
7 |
8 |
9 |
10 |
15 |
16 |
17 |
18 |