webvac 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: dfcafb3a4e79eca2dc1d0a6cda1e206155f58e67
4
+ data.tar.gz: 271a2dbf6128dd3bb51c377078eb9a657ef9c03f
5
+ SHA512:
6
+ metadata.gz: 51d7a91a2eef75dcb638cb4ec54247791298be650d6232e10abc86f587b49b856ca45cdba2029b416ddf7157ea4fe8e043b67898a31cee5983e86cffab414395
7
+ data.tar.gz: b851f01e6bf625553fffbaae38f5ba9cc72051acb4150b1f41a8728cf52ee8a12b10d73c7a66fe60dc48aa136181e044e23b1fc114dd1d6e6eeb577cae1ded68
data/README ADDED
@@ -0,0 +1,120 @@
1
+ This is a somewhat specialized chunk of code!
2
+
3
+ THIS IS ALSO BETA SOFTWARE. CAVEAT EMPTOR.
4
+
5
+ Using a lookup table in Redis and venti as the backing storage, webvac
6
+ serves static content. It comes with utilities "webvac-sweep" and
7
+ "webvac-unsweep" that push things into venti and remove them from the
8
+ filesystem and place the things back into the filesystem, respectively.
9
+ The 'webvac' program itself starts up a webserver. Give these programs
10
+ '-h' or '--help' to see helpful(?) information, and see below for
11
+ configuration.
12
+
13
+ Currently I am only using it to serve uploads for UGC in Pleroma. I
14
+ have been using venti to do incremental backups of the data, and since
15
+ the uploads are WORM ("write once, read many") data, I thought it'd be
16
+ cool to serve the data directly out of venti.
17
+
18
+ I expect to use this more often and thus expect it to become a bit more
19
+ general as a result.
20
+
21
+ = Quick Start
22
+
23
+ [Check that your venti and Redis servers are operational.]
24
+
25
+ $ sudo ed /etc/webvac.json
26
+ a
27
+ '{"server_path_prepend":"/where/uploads/get/put/in/the/filesystem"}'
28
+ .
29
+ wq
30
+ $ sudo $EDITOR /etc/nginx/whatever
31
+ [edit your nginx configuration to proxy requests for files to localhost:8891
32
+ if the file doesn't exist]
33
+ $ webvac-server -D
34
+ $ find /where/uploads/get/put/in/the/filesystem -type f -print0 |
35
+ xargs -0 -n30 -P8 webvac-sweep -v --
36
+ [At this point, you should be able to rm the files in server_path_prepend to
37
+ start serving them out of venti. Big ones are slow for now.
38
+
39
+ = Mise en place
40
+
41
+ You will need a venti server and a Redis server. It'll work fine with
42
+ either Plan 9 venti or P9P venti. You will also need the 'vac' and
43
+ 'unvac' utilities that come with P9P.
44
+
45
+ You will need to either have all the stuff in the default places, or
46
+ you'll need to configure a handful of things. Otherwise, you will need
47
+ to configure probably one thing.
48
+
49
+ = Overhead
50
+
51
+ For about 100GB of files, venti takes 86GB of disk (no surprise, since
52
+ it's mostly JPGs and MP4s, so it's already compressed; the savings are
53
+ probably from dedup), and Redis takes about 60MB of RAM for this. All
54
+ of the files were put into venti as part of the backup solution, but the
55
+ originals weren't removed if they were bigger than 1MB (see doc/TODO).
56
+ The workers take some RAM to run. CPU overhead is negligible.
57
+
58
+ = Configuration
59
+
60
+ The nginx config I used to test is in doc/examples.
61
+
62
+ You will need to create a JSON file that specifies the configuration.
63
+ The first readable file from the following list is used:
64
+
65
+ · The filename given in the $WEBVAC_CONFIG environment variable.
66
+ · ./config/webvac.json
67
+ · $HOME/.webvac.json
68
+ · /etc/webvac.json
69
+
70
+ Here is an annotated list of configuration options, all of which start
71
+ with their default values. You will almost certainly need to change
72
+ server_path_prepend.
73
+
74
+ {
75
+ // A Redis connection string, one that Redic will take:
76
+ "redis_url": "redis://localhost:6379/0",
77
+
78
+ // These two options are used to turn the request path into a filesystem path.
79
+ // Watch this space, I might turn server_path_strip into an array.
80
+
81
+ // The beginning of the path that the entire server sits under; that is,
82
+ // what should be stripped from the front of the path. For Pleroma, users'
83
+ // uploads are all under /media, so this works if you're serving uploads from
84
+ // https://$domain/media/$file . You should probably not change this one for
85
+ // now, as Rake routes depend on it.
86
+ "server_path_strip": "/media",
87
+ // The beginning of the path in the *filesystem* that corresponds to where the
88
+ // files are kept. It is *incredibly* unlikely that you are using the same
89
+ // path I am.
90
+ "server_path_prepend": "/media/block/fse",
91
+
92
+ // This is where the venti server is. (This might be an array at some point.)
93
+ // This address is in dial(2) syntax, by the way, so $host:$port should be
94
+ // written tcp!$host!$port.
95
+ "venti_server": "localhost",
96
+
97
+ // Where the vac and unvac binaries are kept:
98
+ "plan9bin": "/opt/plan9/bin",
99
+
100
+ // This is to make UGC work safely out of the box. Hopefully no browser is
101
+ // dumb enough to run stuff inside <script> tags in something we're serving
102
+ // as text/plain:
103
+ "mime_substitutions": {
104
+ "text/html": "text/plain"
105
+ }
106
+ }
107
+
108
+ = TODO
109
+
110
+ See doc/TODO
111
+
112
+ = See also:
113
+
114
+ "Venti: a new approach to archival storage": http://doc.cat-v.org/plan_9/4th_edition/papers/venti/
115
+
116
+ "Pleroma": https://pleroma.social/
117
+
118
+ = I feel dirty
119
+
120
+ You can throw BTC at 1BZz3ndJUoWhEvm1BfW3FzceAjFqKTwqWV . Proceeds will go to funding the instance hosting thing.
@@ -0,0 +1,33 @@
1
+ require 'rubygems/package_task'
2
+ require 'rdoc/task'
3
+
4
+ $: << "#{File.dirname(__FILE__)}/lib"
5
+
6
+ spec = eval File.read(Dir['*.gemspec'][0])
7
+
8
+ Rake::RDocTask.new(:doc) { |t|
9
+ t.main = 'README'
10
+ t.rdoc_files.include 'lib/**/*.rb', 'doc/*', 'bin/*', 'ext/**/*.c',
11
+ 'ext/**/*.rb'
12
+ t.options << '-S' << '-N'
13
+ t.rdoc_dir = 'doc/rdoc'
14
+ }
15
+
16
+ Gem::PackageTask.new(spec) { |pkg|
17
+ pkg.need_tar_bz2 = true
18
+ }
19
+ desc "Cleans out the packaged files."
20
+ task(:clean) {
21
+ FileUtils.rm_rf 'pkg'
22
+ }
23
+
24
+ desc "Builds and installs the gem for #{spec.name}"
25
+ task(:install => :package) {
26
+ g = "pkg/#{spec.name}-#{spec.version}.gem"
27
+ system "sudo gem install -l #{g}"
28
+ }
29
+
30
+ desc "Runs IRB, automatically require()ing #{spec.name}."
31
+ task(:irb) {
32
+ exec "irb -Ilib -r#{spec.name}"
33
+ }
@@ -0,0 +1,88 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ %w(
4
+ webvac
5
+ ).each &method(:require)
6
+
7
+ def die! msg
8
+ $stderr.puts msg
9
+ exit 1
10
+ end
11
+
12
+ def usage! o = $stderr, c = 1
13
+ o.puts <<-EOS.gsub(/^\t\t/, '')
14
+ #{$0} [-h|-help|--help] [-d] [--] $files
15
+ -d delets this (if the sweep is successful)
16
+ -v Be verbose
17
+ -h This usage message
18
+ EOS
19
+ exit c
20
+ end
21
+
22
+ include WebVac
23
+ c = Config.load
24
+ v = Vac.new c
25
+ t = Table.new c
26
+
27
+ args = ARGV.dup
28
+ deletthis = false
29
+ verbose = false
30
+
31
+ def die! msg
32
+ $stderr.puts msg
33
+ exit 1
34
+ end
35
+
36
+ def usage! o = $stderr, c = 1
37
+ o.puts <<-EOS.gsub(/^\t\t/, '')
38
+ #{$0} [-h|-help|--help] [-l $host:$port] [-D] [--] $files
39
+ -h
40
+ This help.
41
+
42
+ The following options are passed through to rainbows:
43
+ -l $host:$port
44
+ Address to listen on. Defaults to localhost:8891
45
+ -D
46
+ Daemonize the process.
47
+ -E $env
48
+ Rack env to use. (Defaults to "production".)
49
+ EOS
50
+ exit c
51
+ end
52
+
53
+ TopDir = File.dirname(__dir__)
54
+ rainbow_args = {
55
+ "-c" => "#{TopDir}/conf/rainbows.rb",
56
+ "-l" => "localhost:8891",
57
+ "-E" => "production",
58
+ }
59
+ rainbow_flags = []
60
+
61
+
62
+ until args.empty?
63
+ case args[0]
64
+ when '-h', '-help', '--help'
65
+ usage! $stdout, 0
66
+ when '-l', '-E'
67
+ rainbow_args[args[0]] = args[1]
68
+ usage! if args[1].nil?
69
+ args.shift
70
+ when '-D'
71
+ rainbow_flags << args[0]
72
+ when '--'
73
+ args.shift
74
+ break
75
+ when /^-/
76
+ usage!
77
+ else
78
+ break
79
+ end
80
+ args.shift
81
+ end
82
+
83
+ exec(*[
84
+ 'rainbows',
85
+ *rainbow_flags,
86
+ *rainbow_args.to_a.flatten,
87
+ "#{TopDir}/config.ru"
88
+ ])
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ %w(
4
+ webvac
5
+ ).each &method(:require)
6
+
7
+ Encoding.default_external = Encoding::BINARY
8
+
9
+ def die! msg
10
+ $stderr.puts msg
11
+ exit 1
12
+ end
13
+
14
+ def usage! o = $stderr, c = 1
15
+ o.puts <<-EOS.gsub(/^\t\t/, '')
16
+ #{$0} [-h|-help|--help] [-d] [-v] [--] $files
17
+ -d delets this (if the sweep is successful)
18
+ -v Be verbose
19
+ -h This usage message
20
+ EOS
21
+ exit c
22
+ end
23
+
24
+ include WebVac
25
+ c = Config.load
26
+ v = Vac.new c
27
+ t = Table.new c
28
+
29
+ args = ARGV.dup
30
+ deletthis = false
31
+ verbose = false
32
+
33
+ until args.empty?
34
+ case args[0]
35
+ when '-h', '-help', '--help'
36
+ usage! $stdout, 0
37
+ when '-d'
38
+ deletthis = true
39
+ when '-v'
40
+ verbose = true
41
+ when '--'
42
+ args.shift
43
+ break
44
+ when /^-/
45
+ usage!
46
+ else
47
+ break
48
+ end
49
+ args.shift
50
+ end
51
+
52
+ args.each { |a|
53
+ die!("noexist #{a}") unless File.exist?(a)
54
+ sc = v.save!(a)
55
+ puts "#{a} -> #{sc}" if verbose
56
+ die!("wat #{a}") unless sc
57
+ t.rec_score! a, sc
58
+ t.meta_save! a, sc
59
+ File.unlink(a) if deletthis
60
+ }
@@ -0,0 +1,7 @@
1
+ worker_processes 2
2
+ pid "/tmp/dsd.pid"
3
+ preload_app false
4
+ Rainbows! {
5
+ use :ThreadPool
6
+ worker_connections 100
7
+ }
@@ -0,0 +1,87 @@
1
+ %w(
2
+ watts
3
+ webvac
4
+ ).each &method(:require)
5
+
6
+ Encoding.default_external = Encoding::BINARY
7
+
8
+ module WebVac
9
+ class R < Watts::Resource
10
+ # This is a stupid feature.
11
+ # Fortunes lifted shamelessly from http://quotes.cat-v.org/programming/
12
+ Fortunes = <<-EOFORTUNES.gsub(/\t+/, '').split(/\n+/)
13
+ There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies and the other way is to make it so complicated that there are no obvious deficiencies.
14
+ When in doubt, use brute force.
15
+ Deleted code is debugged code.
16
+ Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
17
+ The most effective debugging tool is still careful thought, coupled with judiciously placed print statements.
18
+ Controlling complexity is the essence of computer programming.
19
+ UNIX was not designed to stop its users from doing stupid things, as that would also stop them from doing clever things.
20
+ Beware of those who say that their software does not suck, for they are either fools or liars.
21
+ Unix is simple. It just takes a genius to understand its simplicity.
22
+ If you want to go somewhere, goto is the best way to get there.
23
+ I object to doing things that computers can do.
24
+ A good way to have good ideas is by being unoriginal.
25
+ a program is like a poem: you cannot write a poem without writing it.
26
+ EOFORTUNES
27
+
28
+ def headers t, path, score, contents
29
+ name = (request.params['name'] || File.basename(path)).
30
+ gsub('"', "'")
31
+ {
32
+ 'Content-Disposition' => "filename=\"#{name}\"",
33
+ 'Fortune' => Fortunes.sample,
34
+ }.merge!(t.metadata(score) || {}).tap { |h|
35
+ if contents
36
+ h['Content-Type'] ||= t.guess_mime(contents) rescue nil
37
+ h['Content-Length'] ||= contents.bytesize.to_s
38
+ end
39
+ }
40
+ end
41
+ end
42
+
43
+ class Root < R
44
+ get {
45
+ "++++++++++++[>+++++++++<-]>.+++.---."
46
+ }
47
+ end
48
+
49
+ class Serv < R
50
+ # We can cheat a little with closures because there's just one "real"
51
+ # endpoint. No need to memoize.
52
+
53
+ config = Config.load
54
+ vac = Vac.new config
55
+ tab = Table.new config
56
+
57
+ head { |*|
58
+ p = config.path_fixup(CGI.unescape(env['REQUEST_PATH']))
59
+ s = tab.path2score p
60
+ return [404, {}, ["404 Not found\nNo such path: #{p}\n"]] unless s
61
+ [200, headers(tab, p, s, nil), []]
62
+ }
63
+ get { |*|
64
+ p = config.path_fixup(CGI.unescape(env['REQUEST_PATH']))
65
+ s = tab.path2score p
66
+ return [404, {}, ["404 Not found\nNo such path: #{p}\n"]] unless s
67
+ ct = Time.parse(env['HTTP_IF_MODIFIED_SINCE']) rescue nil
68
+ if ct && ct.to_i > 0
69
+ hs = headers(tab, p, s, nil)
70
+ mt = Time.parse(hs['Last-Modified']) rescue nil
71
+ return [304, hs, []] if mt && mt > ct
72
+ end
73
+ contents = vac.load! s
74
+ hs = headers(tab, p, s, contents)
75
+ [200, headers(tab, p, s, contents), [contents]]
76
+ }
77
+ end
78
+
79
+ class App < Watts::App
80
+ resource('/', Root) {
81
+ resource(:filename, Serv)
82
+ resource(['media', :l1], Serv) { resource(:l2, Serv) }
83
+ }
84
+ end
85
+ end
86
+
87
+ run WebVac::App.new
@@ -0,0 +1,668 @@
1
+ Copyright (c) 2020 Pete (pete at debu.gs)
2
+
3
+ The text below is the AGPLv3, pulled directly from the GNU site at time
4
+ of writing ( https://www.gnu.org/licenses/agpl-3.0.txt ). I'm gonna
5
+ just do AGPL for now but might change it in the future. I don't know.
6
+ For now, this is the license:
7
+
8
+ GNU AFFERO GENERAL PUBLIC LICENSE
9
+ Version 3, 19 November 2007
10
+
11
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
12
+ Everyone is permitted to copy and distribute verbatim copies
13
+ of this license document, but changing it is not allowed.
14
+
15
+ Preamble
16
+
17
+ The GNU Affero General Public License is a free, copyleft license for
18
+ software and other kinds of works, specifically designed to ensure
19
+ cooperation with the community in the case of network server software.
20
+
21
+ The licenses for most software and other practical works are designed
22
+ to take away your freedom to share and change the works. By contrast,
23
+ our General Public Licenses are intended to guarantee your freedom to
24
+ share and change all versions of a program--to make sure it remains free
25
+ software for all its users.
26
+
27
+ When we speak of free software, we are referring to freedom, not
28
+ price. Our General Public Licenses are designed to make sure that you
29
+ have the freedom to distribute copies of free software (and charge for
30
+ them if you wish), that you receive source code or can get it if you
31
+ want it, that you can change the software or use pieces of it in new
32
+ free programs, and that you know you can do these things.
33
+
34
+ Developers that use our General Public Licenses protect your rights
35
+ with two steps: (1) assert copyright on the software, and (2) offer
36
+ you this License which gives you legal permission to copy, distribute
37
+ and/or modify the software.
38
+
39
+ A secondary benefit of defending all users' freedom is that
40
+ improvements made in alternate versions of the program, if they
41
+ receive widespread use, become available for other developers to
42
+ incorporate. Many developers of free software are heartened and
43
+ encouraged by the resulting cooperation. However, in the case of
44
+ software used on network servers, this result may fail to come about.
45
+ The GNU General Public License permits making a modified version and
46
+ letting the public access it on a server without ever releasing its
47
+ source code to the public.
48
+
49
+ The GNU Affero General Public License is designed specifically to
50
+ ensure that, in such cases, the modified source code becomes available
51
+ to the community. It requires the operator of a network server to
52
+ provide the source code of the modified version running there to the
53
+ users of that server. Therefore, public use of a modified version, on
54
+ a publicly accessible server, gives the public access to the source
55
+ code of the modified version.
56
+
57
+ An older license, called the Affero General Public License and
58
+ published by Affero, was designed to accomplish similar goals. This is
59
+ a different license, not a version of the Affero GPL, but Affero has
60
+ released a new version of the Affero GPL which permits relicensing under
61
+ this license.
62
+
63
+ The precise terms and conditions for copying, distribution and
64
+ modification follow.
65
+
66
+ TERMS AND CONDITIONS
67
+
68
+ 0. Definitions.
69
+
70
+ "This License" refers to version 3 of the GNU Affero General Public License.
71
+
72
+ "Copyright" also means copyright-like laws that apply to other kinds of
73
+ works, such as semiconductor masks.
74
+
75
+ "The Program" refers to any copyrightable work licensed under this
76
+ License. Each licensee is addressed as "you". "Licensees" and
77
+ "recipients" may be individuals or organizations.
78
+
79
+ To "modify" a work means to copy from or adapt all or part of the work
80
+ in a fashion requiring copyright permission, other than the making of an
81
+ exact copy. The resulting work is called a "modified version" of the
82
+ earlier work or a work "based on" the earlier work.
83
+
84
+ A "covered work" means either the unmodified Program or a work based
85
+ on the Program.
86
+
87
+ To "propagate" a work means to do anything with it that, without
88
+ permission, would make you directly or secondarily liable for
89
+ infringement under applicable copyright law, except executing it on a
90
+ computer or modifying a private copy. Propagation includes copying,
91
+ distribution (with or without modification), making available to the
92
+ public, and in some countries other activities as well.
93
+
94
+ To "convey" a work means any kind of propagation that enables other
95
+ parties to make or receive copies. Mere interaction with a user through
96
+ a computer network, with no transfer of a copy, is not conveying.
97
+
98
+ An interactive user interface displays "Appropriate Legal Notices"
99
+ to the extent that it includes a convenient and prominently visible
100
+ feature that (1) displays an appropriate copyright notice, and (2)
101
+ tells the user that there is no warranty for the work (except to the
102
+ extent that warranties are provided), that licensees may convey the
103
+ work under this License, and how to view a copy of this License. If
104
+ the interface presents a list of user commands or options, such as a
105
+ menu, a prominent item in the list meets this criterion.
106
+
107
+ 1. Source Code.
108
+
109
+ The "source code" for a work means the preferred form of the work
110
+ for making modifications to it. "Object code" means any non-source
111
+ form of a work.
112
+
113
+ A "Standard Interface" means an interface that either is an official
114
+ standard defined by a recognized standards body, or, in the case of
115
+ interfaces specified for a particular programming language, one that
116
+ is widely used among developers working in that language.
117
+
118
+ The "System Libraries" of an executable work include anything, other
119
+ than the work as a whole, that (a) is included in the normal form of
120
+ packaging a Major Component, but which is not part of that Major
121
+ Component, and (b) serves only to enable use of the work with that
122
+ Major Component, or to implement a Standard Interface for which an
123
+ implementation is available to the public in source code form. A
124
+ "Major Component", in this context, means a major essential component
125
+ (kernel, window system, and so on) of the specific operating system
126
+ (if any) on which the executable work runs, or a compiler used to
127
+ produce the work, or an object code interpreter used to run it.
128
+
129
+ The "Corresponding Source" for a work in object code form means all
130
+ the source code needed to generate, install, and (for an executable
131
+ work) run the object code and to modify the work, including scripts to
132
+ control those activities. However, it does not include the work's
133
+ System Libraries, or general-purpose tools or generally available free
134
+ programs which are used unmodified in performing those activities but
135
+ which are not part of the work. For example, Corresponding Source
136
+ includes interface definition files associated with source files for
137
+ the work, and the source code for shared libraries and dynamically
138
+ linked subprograms that the work is specifically designed to require,
139
+ such as by intimate data communication or control flow between those
140
+ subprograms and other parts of the work.
141
+
142
+ The Corresponding Source need not include anything that users
143
+ can regenerate automatically from other parts of the Corresponding
144
+ Source.
145
+
146
+ The Corresponding Source for a work in source code form is that
147
+ same work.
148
+
149
+ 2. Basic Permissions.
150
+
151
+ All rights granted under this License are granted for the term of
152
+ copyright on the Program, and are irrevocable provided the stated
153
+ conditions are met. This License explicitly affirms your unlimited
154
+ permission to run the unmodified Program. The output from running a
155
+ covered work is covered by this License only if the output, given its
156
+ content, constitutes a covered work. This License acknowledges your
157
+ rights of fair use or other equivalent, as provided by copyright law.
158
+
159
+ You may make, run and propagate covered works that you do not
160
+ convey, without conditions so long as your license otherwise remains
161
+ in force. You may convey covered works to others for the sole purpose
162
+ of having them make modifications exclusively for you, or provide you
163
+ with facilities for running those works, provided that you comply with
164
+ the terms of this License in conveying all material for which you do
165
+ not control copyright. Those thus making or running the covered works
166
+ for you must do so exclusively on your behalf, under your direction
167
+ and control, on terms that prohibit them from making any copies of
168
+ your copyrighted material outside their relationship with you.
169
+
170
+ Conveying under any other circumstances is permitted solely under
171
+ the conditions stated below. Sublicensing is not allowed; section 10
172
+ makes it unnecessary.
173
+
174
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
175
+
176
+ No covered work shall be deemed part of an effective technological
177
+ measure under any applicable law fulfilling obligations under article
178
+ 11 of the WIPO copyright treaty adopted on 20 December 1996, or
179
+ similar laws prohibiting or restricting circumvention of such
180
+ measures.
181
+
182
+ When you convey a covered work, you waive any legal power to forbid
183
+ circumvention of technological measures to the extent such circumvention
184
+ is effected by exercising rights under this License with respect to
185
+ the covered work, and you disclaim any intention to limit operation or
186
+ modification of the work as a means of enforcing, against the work's
187
+ users, your or third parties' legal rights to forbid circumvention of
188
+ technological measures.
189
+
190
+ 4. Conveying Verbatim Copies.
191
+
192
+ You may convey verbatim copies of the Program's source code as you
193
+ receive it, in any medium, provided that you conspicuously and
194
+ appropriately publish on each copy an appropriate copyright notice;
195
+ keep intact all notices stating that this License and any
196
+ non-permissive terms added in accord with section 7 apply to the code;
197
+ keep intact all notices of the absence of any warranty; and give all
198
+ recipients a copy of this License along with the Program.
199
+
200
+ You may charge any price or no price for each copy that you convey,
201
+ and you may offer support or warranty protection for a fee.
202
+
203
+ 5. Conveying Modified Source Versions.
204
+
205
+ You may convey a work based on the Program, or the modifications to
206
+ produce it from the Program, in the form of source code under the
207
+ terms of section 4, provided that you also meet all of these conditions:
208
+
209
+ a) The work must carry prominent notices stating that you modified
210
+ it, and giving a relevant date.
211
+
212
+ b) The work must carry prominent notices stating that it is
213
+ released under this License and any conditions added under section
214
+ 7. This requirement modifies the requirement in section 4 to
215
+ "keep intact all notices".
216
+
217
+ c) You must license the entire work, as a whole, under this
218
+ License to anyone who comes into possession of a copy. This
219
+ License will therefore apply, along with any applicable section 7
220
+ additional terms, to the whole of the work, and all its parts,
221
+ regardless of how they are packaged. This License gives no
222
+ permission to license the work in any other way, but it does not
223
+ invalidate such permission if you have separately received it.
224
+
225
+ d) If the work has interactive user interfaces, each must display
226
+ Appropriate Legal Notices; however, if the Program has interactive
227
+ interfaces that do not display Appropriate Legal Notices, your
228
+ work need not make them do so.
229
+
230
+ A compilation of a covered work with other separate and independent
231
+ works, which are not by their nature extensions of the covered work,
232
+ and which are not combined with it such as to form a larger program,
233
+ in or on a volume of a storage or distribution medium, is called an
234
+ "aggregate" if the compilation and its resulting copyright are not
235
+ used to limit the access or legal rights of the compilation's users
236
+ beyond what the individual works permit. Inclusion of a covered work
237
+ in an aggregate does not cause this License to apply to the other
238
+ parts of the aggregate.
239
+
240
+ 6. Conveying Non-Source Forms.
241
+
242
+ You may convey a covered work in object code form under the terms
243
+ of sections 4 and 5, provided that you also convey the
244
+ machine-readable Corresponding Source under the terms of this License,
245
+ in one of these ways:
246
+
247
+ a) Convey the object code in, or embodied in, a physical product
248
+ (including a physical distribution medium), accompanied by the
249
+ Corresponding Source fixed on a durable physical medium
250
+ customarily used for software interchange.
251
+
252
+ b) Convey the object code in, or embodied in, a physical product
253
+ (including a physical distribution medium), accompanied by a
254
+ written offer, valid for at least three years and valid for as
255
+ long as you offer spare parts or customer support for that product
256
+ model, to give anyone who possesses the object code either (1) a
257
+ copy of the Corresponding Source for all the software in the
258
+ product that is covered by this License, on a durable physical
259
+ medium customarily used for software interchange, for a price no
260
+ more than your reasonable cost of physically performing this
261
+ conveying of source, or (2) access to copy the
262
+ Corresponding Source from a network server at no charge.
263
+
264
+ c) Convey individual copies of the object code with a copy of the
265
+ written offer to provide the Corresponding Source. This
266
+ alternative is allowed only occasionally and noncommercially, and
267
+ only if you received the object code with such an offer, in accord
268
+ with subsection 6b.
269
+
270
+ d) Convey the object code by offering access from a designated
271
+ place (gratis or for a charge), and offer equivalent access to the
272
+ Corresponding Source in the same way through the same place at no
273
+ further charge. You need not require recipients to copy the
274
+ Corresponding Source along with the object code. If the place to
275
+ copy the object code is a network server, the Corresponding Source
276
+ may be on a different server (operated by you or a third party)
277
+ that supports equivalent copying facilities, provided you maintain
278
+ clear directions next to the object code saying where to find the
279
+ Corresponding Source. Regardless of what server hosts the
280
+ Corresponding Source, you remain obligated to ensure that it is
281
+ available for as long as needed to satisfy these requirements.
282
+
283
+ e) Convey the object code using peer-to-peer transmission, provided
284
+ you inform other peers where the object code and Corresponding
285
+ Source of the work are being offered to the general public at no
286
+ charge under subsection 6d.
287
+
288
+ A separable portion of the object code, whose source code is excluded
289
+ from the Corresponding Source as a System Library, need not be
290
+ included in conveying the object code work.
291
+
292
+ A "User Product" is either (1) a "consumer product", which means any
293
+ tangible personal property which is normally used for personal, family,
294
+ or household purposes, or (2) anything designed or sold for incorporation
295
+ into a dwelling. In determining whether a product is a consumer product,
296
+ doubtful cases shall be resolved in favor of coverage. For a particular
297
+ product received by a particular user, "normally used" refers to a
298
+ typical or common use of that class of product, regardless of the status
299
+ of the particular user or of the way in which the particular user
300
+ actually uses, or expects or is expected to use, the product. A product
301
+ is a consumer product regardless of whether the product has substantial
302
+ commercial, industrial or non-consumer uses, unless such uses represent
303
+ the only significant mode of use of the product.
304
+
305
+ "Installation Information" for a User Product means any methods,
306
+ procedures, authorization keys, or other information required to install
307
+ and execute modified versions of a covered work in that User Product from
308
+ a modified version of its Corresponding Source. The information must
309
+ suffice to ensure that the continued functioning of the modified object
310
+ code is in no case prevented or interfered with solely because
311
+ modification has been made.
312
+
313
+ If you convey an object code work under this section in, or with, or
314
+ specifically for use in, a User Product, and the conveying occurs as
315
+ part of a transaction in which the right of possession and use of the
316
+ User Product is transferred to the recipient in perpetuity or for a
317
+ fixed term (regardless of how the transaction is characterized), the
318
+ Corresponding Source conveyed under this section must be accompanied
319
+ by the Installation Information. But this requirement does not apply
320
+ if neither you nor any third party retains the ability to install
321
+ modified object code on the User Product (for example, the work has
322
+ been installed in ROM).
323
+
324
+ The requirement to provide Installation Information does not include a
325
+ requirement to continue to provide support service, warranty, or updates
326
+ for a work that has been modified or installed by the recipient, or for
327
+ the User Product in which it has been modified or installed. Access to a
328
+ network may be denied when the modification itself materially and
329
+ adversely affects the operation of the network or violates the rules and
330
+ protocols for communication across the network.
331
+
332
+ Corresponding Source conveyed, and Installation Information provided,
333
+ in accord with this section must be in a format that is publicly
334
+ documented (and with an implementation available to the public in
335
+ source code form), and must require no special password or key for
336
+ unpacking, reading or copying.
337
+
338
+ 7. Additional Terms.
339
+
340
+ "Additional permissions" are terms that supplement the terms of this
341
+ License by making exceptions from one or more of its conditions.
342
+ Additional permissions that are applicable to the entire Program shall
343
+ be treated as though they were included in this License, to the extent
344
+ that they are valid under applicable law. If additional permissions
345
+ apply only to part of the Program, that part may be used separately
346
+ under those permissions, but the entire Program remains governed by
347
+ this License without regard to the additional permissions.
348
+
349
+ When you convey a copy of a covered work, you may at your option
350
+ remove any additional permissions from that copy, or from any part of
351
+ it. (Additional permissions may be written to require their own
352
+ removal in certain cases when you modify the work.) You may place
353
+ additional permissions on material, added by you to a covered work,
354
+ for which you have or can give appropriate copyright permission.
355
+
356
+ Notwithstanding any other provision of this License, for material you
357
+ add to a covered work, you may (if authorized by the copyright holders of
358
+ that material) supplement the terms of this License with terms:
359
+
360
+ a) Disclaiming warranty or limiting liability differently from the
361
+ terms of sections 15 and 16 of this License; or
362
+
363
+ b) Requiring preservation of specified reasonable legal notices or
364
+ author attributions in that material or in the Appropriate Legal
365
+ Notices displayed by works containing it; or
366
+
367
+ c) Prohibiting misrepresentation of the origin of that material, or
368
+ requiring that modified versions of such material be marked in
369
+ reasonable ways as different from the original version; or
370
+
371
+ d) Limiting the use for publicity purposes of names of licensors or
372
+ authors of the material; or
373
+
374
+ e) Declining to grant rights under trademark law for use of some
375
+ trade names, trademarks, or service marks; or
376
+
377
+ f) Requiring indemnification of licensors and authors of that
378
+ material by anyone who conveys the material (or modified versions of
379
+ it) with contractual assumptions of liability to the recipient, for
380
+ any liability that these contractual assumptions directly impose on
381
+ those licensors and authors.
382
+
383
+ All other non-permissive additional terms are considered "further
384
+ restrictions" within the meaning of section 10. If the Program as you
385
+ received it, or any part of it, contains a notice stating that it is
386
+ governed by this License along with a term that is a further
387
+ restriction, you may remove that term. If a license document contains
388
+ a further restriction but permits relicensing or conveying under this
389
+ License, you may add to a covered work material governed by the terms
390
+ of that license document, provided that the further restriction does
391
+ not survive such relicensing or conveying.
392
+
393
+ If you add terms to a covered work in accord with this section, you
394
+ must place, in the relevant source files, a statement of the
395
+ additional terms that apply to those files, or a notice indicating
396
+ where to find the applicable terms.
397
+
398
+ Additional terms, permissive or non-permissive, may be stated in the
399
+ form of a separately written license, or stated as exceptions;
400
+ the above requirements apply either way.
401
+
402
+ 8. Termination.
403
+
404
+ You may not propagate or modify a covered work except as expressly
405
+ provided under this License. Any attempt otherwise to propagate or
406
+ modify it is void, and will automatically terminate your rights under
407
+ this License (including any patent licenses granted under the third
408
+ paragraph of section 11).
409
+
410
+ However, if you cease all violation of this License, then your
411
+ license from a particular copyright holder is reinstated (a)
412
+ provisionally, unless and until the copyright holder explicitly and
413
+ finally terminates your license, and (b) permanently, if the copyright
414
+ holder fails to notify you of the violation by some reasonable means
415
+ prior to 60 days after the cessation.
416
+
417
+ Moreover, your license from a particular copyright holder is
418
+ reinstated permanently if the copyright holder notifies you of the
419
+ violation by some reasonable means, this is the first time you have
420
+ received notice of violation of this License (for any work) from that
421
+ copyright holder, and you cure the violation prior to 30 days after
422
+ your receipt of the notice.
423
+
424
+ Termination of your rights under this section does not terminate the
425
+ licenses of parties who have received copies or rights from you under
426
+ this License. If your rights have been terminated and not permanently
427
+ reinstated, you do not qualify to receive new licenses for the same
428
+ material under section 10.
429
+
430
+ 9. Acceptance Not Required for Having Copies.
431
+
432
+ You are not required to accept this License in order to receive or
433
+ run a copy of the Program. Ancillary propagation of a covered work
434
+ occurring solely as a consequence of using peer-to-peer transmission
435
+ to receive a copy likewise does not require acceptance. However,
436
+ nothing other than this License grants you permission to propagate or
437
+ modify any covered work. These actions infringe copyright if you do
438
+ not accept this License. Therefore, by modifying or propagating a
439
+ covered work, you indicate your acceptance of this License to do so.
440
+
441
+ 10. Automatic Licensing of Downstream Recipients.
442
+
443
+ Each time you convey a covered work, the recipient automatically
444
+ receives a license from the original licensors, to run, modify and
445
+ propagate that work, subject to this License. You are not responsible
446
+ for enforcing compliance by third parties with this License.
447
+
448
+ An "entity transaction" is a transaction transferring control of an
449
+ organization, or substantially all assets of one, or subdividing an
450
+ organization, or merging organizations. If propagation of a covered
451
+ work results from an entity transaction, each party to that
452
+ transaction who receives a copy of the work also receives whatever
453
+ licenses to the work the party's predecessor in interest had or could
454
+ give under the previous paragraph, plus a right to possession of the
455
+ Corresponding Source of the work from the predecessor in interest, if
456
+ the predecessor has it or can get it with reasonable efforts.
457
+
458
+ You may not impose any further restrictions on the exercise of the
459
+ rights granted or affirmed under this License. For example, you may
460
+ not impose a license fee, royalty, or other charge for exercise of
461
+ rights granted under this License, and you may not initiate litigation
462
+ (including a cross-claim or counterclaim in a lawsuit) alleging that
463
+ any patent claim is infringed by making, using, selling, offering for
464
+ sale, or importing the Program or any portion of it.
465
+
466
+ 11. Patents.
467
+
468
+ A "contributor" is a copyright holder who authorizes use under this
469
+ License of the Program or a work on which the Program is based. The
470
+ work thus licensed is called the contributor's "contributor version".
471
+
472
+ A contributor's "essential patent claims" are all patent claims
473
+ owned or controlled by the contributor, whether already acquired or
474
+ hereafter acquired, that would be infringed by some manner, permitted
475
+ by this License, of making, using, or selling its contributor version,
476
+ but do not include claims that would be infringed only as a
477
+ consequence of further modification of the contributor version. For
478
+ purposes of this definition, "control" includes the right to grant
479
+ patent sublicenses in a manner consistent with the requirements of
480
+ this License.
481
+
482
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
483
+ patent license under the contributor's essential patent claims, to
484
+ make, use, sell, offer for sale, import and otherwise run, modify and
485
+ propagate the contents of its contributor version.
486
+
487
+ In the following three paragraphs, a "patent license" is any express
488
+ agreement or commitment, however denominated, not to enforce a patent
489
+ (such as an express permission to practice a patent or covenant not to
490
+ sue for patent infringement). To "grant" such a patent license to a
491
+ party means to make such an agreement or commitment not to enforce a
492
+ patent against the party.
493
+
494
+ If you convey a covered work, knowingly relying on a patent license,
495
+ and the Corresponding Source of the work is not available for anyone
496
+ to copy, free of charge and under the terms of this License, through a
497
+ publicly available network server or other readily accessible means,
498
+ then you must either (1) cause the Corresponding Source to be so
499
+ available, or (2) arrange to deprive yourself of the benefit of the
500
+ patent license for this particular work, or (3) arrange, in a manner
501
+ consistent with the requirements of this License, to extend the patent
502
+ license to downstream recipients. "Knowingly relying" means you have
503
+ actual knowledge that, but for the patent license, your conveying the
504
+ covered work in a country, or your recipient's use of the covered work
505
+ in a country, would infringe one or more identifiable patents in that
506
+ country that you have reason to believe are valid.
507
+
508
+ If, pursuant to or in connection with a single transaction or
509
+ arrangement, you convey, or propagate by procuring conveyance of, a
510
+ covered work, and grant a patent license to some of the parties
511
+ receiving the covered work authorizing them to use, propagate, modify
512
+ or convey a specific copy of the covered work, then the patent license
513
+ you grant is automatically extended to all recipients of the covered
514
+ work and works based on it.
515
+
516
+ A patent license is "discriminatory" if it does not include within
517
+ the scope of its coverage, prohibits the exercise of, or is
518
+ conditioned on the non-exercise of one or more of the rights that are
519
+ specifically granted under this License. You may not convey a covered
520
+ work if you are a party to an arrangement with a third party that is
521
+ in the business of distributing software, under which you make payment
522
+ to the third party based on the extent of your activity of conveying
523
+ the work, and under which the third party grants, to any of the
524
+ parties who would receive the covered work from you, a discriminatory
525
+ patent license (a) in connection with copies of the covered work
526
+ conveyed by you (or copies made from those copies), or (b) primarily
527
+ for and in connection with specific products or compilations that
528
+ contain the covered work, unless you entered into that arrangement,
529
+ or that patent license was granted, prior to 28 March 2007.
530
+
531
+ Nothing in this License shall be construed as excluding or limiting
532
+ any implied license or other defenses to infringement that may
533
+ otherwise be available to you under applicable patent law.
534
+
535
+ 12. No Surrender of Others' Freedom.
536
+
537
+ If conditions are imposed on you (whether by court order, agreement or
538
+ otherwise) that contradict the conditions of this License, they do not
539
+ excuse you from the conditions of this License. If you cannot convey a
540
+ covered work so as to satisfy simultaneously your obligations under this
541
+ License and any other pertinent obligations, then as a consequence you may
542
+ not convey it at all. For example, if you agree to terms that obligate you
543
+ to collect a royalty for further conveying from those to whom you convey
544
+ the Program, the only way you could satisfy both those terms and this
545
+ License would be to refrain entirely from conveying the Program.
546
+
547
+ 13. Remote Network Interaction; Use with the GNU General Public License.
548
+
549
+ Notwithstanding any other provision of this License, if you modify the
550
+ Program, your modified version must prominently offer all users
551
+ interacting with it remotely through a computer network (if your version
552
+ supports such interaction) an opportunity to receive the Corresponding
553
+ Source of your version by providing access to the Corresponding Source
554
+ from a network server at no charge, through some standard or customary
555
+ means of facilitating copying of software. This Corresponding Source
556
+ shall include the Corresponding Source for any work covered by version 3
557
+ of the GNU General Public License that is incorporated pursuant to the
558
+ following paragraph.
559
+
560
+ Notwithstanding any other provision of this License, you have
561
+ permission to link or combine any covered work with a work licensed
562
+ under version 3 of the GNU General Public License into a single
563
+ combined work, and to convey the resulting work. The terms of this
564
+ License will continue to apply to the part which is the covered work,
565
+ but the work with which it is combined will remain governed by version
566
+ 3 of the GNU General Public License.
567
+
568
+ 14. Revised Versions of this License.
569
+
570
+ The Free Software Foundation may publish revised and/or new versions of
571
+ the GNU Affero General Public License from time to time. Such new versions
572
+ will be similar in spirit to the present version, but may differ in detail to
573
+ address new problems or concerns.
574
+
575
+ Each version is given a distinguishing version number. If the
576
+ Program specifies that a certain numbered version of the GNU Affero General
577
+ Public License "or any later version" applies to it, you have the
578
+ option of following the terms and conditions either of that numbered
579
+ version or of any later version published by the Free Software
580
+ Foundation. If the Program does not specify a version number of the
581
+ GNU Affero General Public License, you may choose any version ever published
582
+ by the Free Software Foundation.
583
+
584
+ If the Program specifies that a proxy can decide which future
585
+ versions of the GNU Affero General Public License can be used, that proxy's
586
+ public statement of acceptance of a version permanently authorizes you
587
+ to choose that version for the Program.
588
+
589
+ Later license versions may give you additional or different
590
+ permissions. However, no additional obligations are imposed on any
591
+ author or copyright holder as a result of your choosing to follow a
592
+ later version.
593
+
594
+ 15. Disclaimer of Warranty.
595
+
596
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
597
+ APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
598
+ HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
599
+ OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
600
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
601
+ PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
602
+ IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
603
+ ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
604
+
605
+ 16. Limitation of Liability.
606
+
607
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
608
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
609
+ THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
610
+ GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
611
+ USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
612
+ DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
613
+ PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
614
+ EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
615
+ SUCH DAMAGES.
616
+
617
+ 17. Interpretation of Sections 15 and 16.
618
+
619
+ If the disclaimer of warranty and limitation of liability provided
620
+ above cannot be given local legal effect according to their terms,
621
+ reviewing courts shall apply local law that most closely approximates
622
+ an absolute waiver of all civil liability in connection with the
623
+ Program, unless a warranty or assumption of liability accompanies a
624
+ copy of the Program in return for a fee.
625
+
626
+ END OF TERMS AND CONDITIONS
627
+
628
+ How to Apply These Terms to Your New Programs
629
+
630
+ If you develop a new program, and you want it to be of the greatest
631
+ possible use to the public, the best way to achieve this is to make it
632
+ free software which everyone can redistribute and change under these terms.
633
+
634
+ To do so, attach the following notices to the program. It is safest
635
+ to attach them to the start of each source file to most effectively
636
+ state the exclusion of warranty; and each file should have at least
637
+ the "copyright" line and a pointer to where the full notice is found.
638
+
639
+ <one line to give the program's name and a brief idea of what it does.>
640
+ Copyright (C) <year> <name of author>
641
+
642
+ This program is free software: you can redistribute it and/or modify
643
+ it under the terms of the GNU Affero General Public License as published by
644
+ the Free Software Foundation, either version 3 of the License, or
645
+ (at your option) any later version.
646
+
647
+ This program is distributed in the hope that it will be useful,
648
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
649
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
650
+ GNU Affero General Public License for more details.
651
+
652
+ You should have received a copy of the GNU Affero General Public License
653
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
654
+
655
+ Also add information on how to contact you by electronic and paper mail.
656
+
657
+ If your software can interact with users remotely through a computer
658
+ network, you should also make sure that it provides a way for users to
659
+ get its source. For example, if your program is a web application, its
660
+ interface could display a "Source" link that leads users to an archive
661
+ of the code. There are many ways you could offer source, and different
662
+ solutions will be better for different programs; see section 13 for the
663
+ specific requirements.
664
+
665
+ You should also get your employer (if you work as a programmer) or school,
666
+ if any, to sign a "copyright disclaimer" for the program, if necessary.
667
+ For more information on this, and how to apply and follow the GNU AGPL, see
668
+ <https://www.gnu.org/licenses/>.