Project

General

Profile

« Previous | Next » 

Revision b1444d9c

Added by jahoti about 2 years ago

Incorporate test suite from jahoti branch

View differences:

copyright
72 72
   2021 jahoti <jahoti@tilde.team>
73 73
License: GPL-2+
74 74

  
75
Files: test/*
76
Copyright: 2021 jahoti <jahoti@tilde.team>
77
   2021 jahoti <jahoti@tilde.team>
78
License: AGPL-3+ or Alicense-1.0
79

  
80
Files: test/proxy_core.py
81
Copyright: 2015, inaz2
82
   2021 jahoti <jahoti@tilde.team>
83
License: BSD-3
84
 Redistribution and use in source and binary forms, with or without
85
 modification, are permitted provided that the following conditions are met:
86
 .
87
 * Redistributions of source code must retain the above copyright notice, this
88
   list of conditions and the following disclaimer.
89
 .
90
 * Redistributions in binary form must reproduce the above copyright notice,
91
   this list of conditions and the following disclaimer in the documentation
92
   and/or other materials provided with the distribution.
93
 .
94
 * Neither the name of proxy2 nor the names of its
95
   contributors may be used to endorse or promote products derived from
96
   this software without specific prior written permission.
97
 .
98
 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
99
 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
100
 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
101
 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
102
 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
103
 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
104
 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
105
 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
106
 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
107
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
108

  
109
Files: test/server.py
110
Copyright: 2021 jahoti <jahoti@tilde.team>
111
License: AGPL-3+
112

  
75 113
Files: licenses/*
76 114
Copyright: 2001, 2002, 2011-2013 Creative Commons
77 115
License: CC-BY-4.0
......
84 122
License: CC0
85 123
 See `licenses/cc0.txt'
86 124

  
87
Files: licenses/gpl-2.txt licenses/gpl-3.0.txt
125
Files: licenses/gpl-2.txt licenses/gpl-3.0.txt licenses/agpl-3.0.txt
88 126
Copyright: 2007 Free Software Foundation, Inc. <https://fsf.org/>
89 127
License: no-changing
90 128
 Everyone is permitted to copy and distribute verbatim copies of
......
150 188

  
151 189
License: CC-BY-4.0
152 190
 See `licenses/cc-by-4.0.txt'
191

  
192
License: AGPL-3+
193
 This program is free software; you can redistribute it and/or modify
194
 it under the terms of the GNU Affero General Public License as
195
 published by the Free Software Foundation; either version 3 of
196
 the License, or (at your option) any later version.
197
 .
198
 This program is distributed in the hope that it will be useful,
199
 but WITHOUT ANY WARRANTY; without even the implied warranty of
200
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
201
 GNU Affero General Public License for more details.
202
 .
203
 You should have received a copy of the
204
 GNU Affero General Public License along with this program; if not,
205
 you can get it from  `https://www.gnu.org/licenses/agpl-3.0.html'.
licenses/agpl-3.0.txt
1
GNU AFFERO GENERAL PUBLIC LICENSE
2

  
3
Version 3, 19 November 2007
4

  
5
Copyright © 2007 Free Software Foundation, Inc. <http://fsf.org/>
6
Everyone is permitted to copy and distribute verbatim copies of this
7
license document, but changing it is not allowed.
8

  
9
Preamble
10

  
11
The GNU Affero General Public License is a free, copyleft license for
12
software and other kinds of works, specifically designed to ensure
13
cooperation with the community in the case of network server software.
14

  
15
The licenses for most software and other practical works are designed to
16
take away your freedom to share and change the works. By contrast, our
17
General Public Licenses are intended to guarantee your freedom to share and
18
change all versions of a program--to make sure it remains free software for
19
all its users.
20

  
21
When we speak of free software, we are referring to freedom, not price. Our
22
General Public Licenses are designed to make sure that you have the freedom
23
to distribute copies of free software (and charge for them if you wish),
24
that you receive source code or can get it if you want it, that you can
25
change the software or use pieces of it in new free programs, and that you
26
know you can do these things.
27

  
28
Developers that use our General Public Licenses protect your rights with
29
two steps: (1) assert copyright on the software, and (2) offer you this
30
License which gives you legal permission to copy, distribute and/or modify
31
the software.
32

  
33
A secondary benefit of defending all users' freedom is that improvements
34
made in alternate versions of the program, if they receive widespread use,
35
become available for other developers to incorporate. Many developers of
36
free software are heartened and encouraged by the resulting cooperation.
37
However, in the case of software used on network servers, this result may
38
fail to come about. The GNU General Public License permits making a
39
modified version and letting the public access it on a server without ever
40
releasing its source code to the public.
41

  
42
The GNU Affero General Public License is designed specifically to ensure
43
that, in such cases, the modified source code becomes available to the
44
community. It requires the operator of a network server to provide the
45
source code of the modified version running there to the users of that
46
server. Therefore, public use of a modified version, on a publicly
47
accessible server, gives the public access to the source code of the
48
modified version.
49

  
50
An older license, called the Affero General Public License and published by
51
Affero, was designed to accomplish similar goals. This is a different
52
license, not a version of the Affero GPL, but Affero has released a new
53
version of the Affero GPL which permits relicensing under this license.
54

  
55
The precise terms and conditions for copying, distribution and modification
56
follow.
57

  
58
TERMS AND CONDITIONS
59

  
60
0. Definitions.
61

  
62
"This License" refers to version 3 of the GNU Affero General Public
63
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 License.
69
Each licensee is addressed as "you". "Licensees" and "recipients" may be
70
individuals or organizations.
71

  
72
To "modify" a work means to copy from or adapt all or part of the work in a
73
fashion requiring copyright permission, other than the making of an exact
74
copy. The resulting work is called a "modified version" of the earlier work
75
or a work "based on" the earlier work.
76

  
77
A "covered work" means either the unmodified Program or a work based on the
78
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 infringement
82
under applicable copyright law, except executing it on a computer or
83
modifying a private copy. Propagation includes copying, distribution (with
84
or without modification), making available to the public, and in some
85
countries other activities as well.
86

  
87
To "convey" a work means any kind of propagation that enables other parties
88
to make or receive copies. Mere interaction with a user through a computer
89
network, with no transfer of a copy, is not conveying.
90

  
91
An interactive user interface displays "Appropriate Legal Notices" to the
92
extent that it includes a convenient and prominently visible feature that
93
(1) displays an appropriate copyright notice, and (2) tells the user that
94
there is no warranty for the work (except to the extent that warranties are
95
provided), that licensees may convey the work under this License, and how
96
to view a copy of this License. If the interface presents a list of user
97
commands or options, such as a menu, a prominent item in the list meets
98
this criterion.
99

  
100
1. Source Code.
101

  
102
The "source code" for a work means the preferred form of the work for
103
making modifications to it. "Object code" means any non-source form of a
104
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 is
109
widely used among developers working in that language.
110

  
111
The "System Libraries" of an executable work include anything, other than
112
the work as a whole, that (a) is included in the normal form of packaging a
113
Major Component, but which is not part of that Major Component, and (b)
114
serves only to enable use of the work with that Major Component, or to
115
implement a Standard Interface for which an implementation is available to
116
the public in source code form. A "Major Component", in this context, means
117
a major essential component (kernel, window system, and so on) of the
118
specific operating system (if any) on which the executable work runs, or a
119
compiler used to produce the work, or an object code interpreter used to
120
run it.
121

  
122
The "Corresponding Source" for a work in object code form means all the
123
source code needed to generate, install, and (for an executable work) run
124
the object code and to modify the work, including scripts to control those
125
activities. However, it does not include the work's System Libraries, or
126
general-purpose tools or generally available free programs which are used
127
unmodified in performing those activities but which are not part of the
128
work. For example, Corresponding Source includes interface definition files
129
associated with source files for the work, and the source code for shared
130
libraries and dynamically linked subprograms that the work is specifically
131
designed to require, such as by intimate data communication or control flow
132
between those subprograms and other parts of the work.
133

  
134
The Corresponding Source need not include anything that users can
135
regenerate automatically from other parts of the Corresponding Source.
136

  
137
The Corresponding Source for a work in source code form is that same work.
138

  
139
2. Basic Permissions.
140

  
141
All rights granted under this License are granted for the term of copyright
142
on the Program, and are irrevocable provided the stated conditions are met.
143
This License explicitly affirms your unlimited permission to run the
144
unmodified Program. The output from running a covered work is covered by
145
this License only if the output, given its content, constitutes a covered
146
work. This License acknowledges your rights of fair use or other
147
equivalent, as provided by copyright law.
148

  
149
You may make, run and propagate covered works that you do not convey,
150
without conditions so long as your license otherwise remains in force. You
151
may convey covered works to others for the sole purpose of having them make
152
modifications exclusively for you, or provide you with facilities for
153
running those works, provided that you comply with the terms of this
154
License in conveying all material for which you do not control copyright.
155
Those thus making or running the covered works for you must do so
156
exclusively on your behalf, under your direction and control, on terms that
157
prohibit them from making any copies of your copyrighted material outside
158
their relationship with you.
159

  
160
Conveying under any other circumstances is permitted solely under the
161
conditions stated below. Sublicensing is not allowed; section 10 makes it
162
unnecessary.
163

  
164
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
165

  
166
No covered work shall be deemed part of an effective technological measure
167
under any applicable law fulfilling obligations under article 11 of the
168
WIPO copyright treaty adopted on 20 December 1996, or similar laws
169
prohibiting or restricting circumvention of such measures.
170

  
171
When you convey a covered work, you waive any legal power to forbid
172
circumvention of technological measures to the extent such circumvention is
173
effected by exercising rights under this License with respect to the
174
covered work, and you disclaim any intention to limit operation or
175
modification of the work as a means of enforcing, against the work's users,
176
your or third parties' legal rights to forbid circumvention of
177
technological measures.
178

  
179
4. Conveying Verbatim Copies.
180

  
181
You may convey verbatim copies of the Program's source code as you receive
182
it, in any medium, provided that you conspicuously and appropriately
183
publish on each copy an appropriate copyright notice; keep intact all
184
notices stating that this License and any non-permissive terms added in
185
accord with section 7 apply to the code; keep intact all notices of the
186
absence of any warranty; and give all recipients a copy of this License
187
along with the Program.
188

  
189
You may charge any price or no price for each copy that you convey, and you
190
may offer support or warranty protection for a fee.
191

  
192
5. Conveying Modified Source Versions.
193

  
194
You may convey a work based on the Program, or the modifications to produce
195
it from the Program, in the form of source code under the terms of section
196
4, provided that you also meet all of these conditions:
197

  
198
  • a) The work must carry prominent notices stating that you modified it,
199
    and giving a relevant date.
200
  • b) The work must carry prominent notices stating that it is released
201
    under this License and any conditions added under section 7. This
202
    requirement modifies the requirement in section 4 to "keep intact all
203
    notices".
204
  • c) You must license the entire work, as a whole, under this License to
205
    anyone who comes into possession of a copy. This License will therefore
206
    apply, along with any applicable section 7 additional terms, to the
207
    whole of the work, and all its parts, regardless of how they are
208
    packaged. This License gives no permission to license the work in any
209
    other way, but it does not invalidate such permission if you have
210
    separately received it.
211
  • d) If the work has interactive user interfaces, each must display
212
    Appropriate Legal Notices; however, if the Program has interactive
213
    interfaces that do not display Appropriate Legal Notices, your work
214
    need not make them do so.
215

  
216
A compilation of a covered work with other separate and independent works,
217
which are not by their nature extensions of the covered work, and which are
218
not combined with it such as to form a larger program, in or on a volume of
219
a storage or distribution medium, is called an "aggregate" if the
220
compilation and its resulting copyright are not used to limit the access or
221
legal rights of the compilation's users beyond what the individual works
222
permit. Inclusion of a covered work in an aggregate does not cause this
223
License to apply to the other parts of the aggregate.
224

  
225
6. Conveying Non-Source Forms.
226

  
227
You may convey a covered work in object code form under the terms of
228
sections 4 and 5, provided that you also convey the machine-readable
229
Corresponding Source under the terms of this License, in one of these ways:
230

  
231
  • a) Convey the object code in, or embodied in, a physical product
232
    (including a physical distribution medium), accompanied by the
233
    Corresponding Source fixed on a durable physical medium customarily
234
    used for software interchange.
235
  • b) Convey the object code in, or embodied in, a physical product
236
    (including a physical distribution medium), accompanied by a written
237
    offer, valid for at least three years and valid for as long as you
238
    offer spare parts or customer support for that product model, to give
239
    anyone who possesses the object code either (1) a copy of the
240
    Corresponding Source for all the software in the product that is
241
    covered by this License, on a durable physical medium customarily used
242
    for software interchange, for a price no more than your reasonable cost
243
    of physically performing this conveying of source, or (2) access to
244
    copy the Corresponding Source from a network server at no charge.
245
  • c) Convey individual copies of the object code with a copy of the
246
    written offer to provide the Corresponding Source. This alternative is
247
    allowed only occasionally and noncommercially, and only if you received
248
    the object code with such an offer, in accord with subsection 6b.
249
  • d) Convey the object code by offering access from a designated place
250
    (gratis or for a charge), and offer equivalent access to the
251
    Corresponding Source in the same way through the same place at no
252
    further charge. You need not require recipients to copy the
253
    Corresponding Source along with the object code. If the place to copy
254
    the object code is a network server, the Corresponding Source may be on
255
    a different server (operated by you or a third party) that supports
256
    equivalent copying facilities, provided you maintain clear directions
257
    next to the object code saying where to find the Corresponding Source.
258
    Regardless of what server hosts the Corresponding Source, you remain
259
    obligated to ensure that it is available for as long as needed to
260
    satisfy these requirements.
261
  • e) Convey the object code using peer-to-peer transmission, provided you
262
    inform other peers where the object code and Corresponding Source of
263
    the work are being offered to the general public at no charge under
264
    subsection 6d.
265

  
266
A separable portion of the object code, whose source code is excluded from
267
the Corresponding Source as a System Library, need not be included in
268
conveying the object code work.
269

  
270
A "User Product" is either (1) a "consumer product", which means any
271
tangible personal property which is normally used for personal, family, or
272
household purposes, or (2) anything designed or sold for incorporation into
273
a dwelling. In determining whether a product is a consumer product,
274
doubtful cases shall be resolved in favor of coverage. For a particular
275
product received by a particular user, "normally used" refers to a typical
276
or common use of that class of product, regardless of the status of the
277
particular user or of the way in which the particular user actually uses,
278
or expects or is expected to use, the product. A product is a consumer
279
product regardless of whether the product has substantial commercial,
280
industrial or non-consumer uses, unless such uses represent the only
281
significant mode of use of the product.
282

  
283
"Installation Information" for a User Product means any methods,
284
procedures, authorization keys, or other information required to install
285
and execute modified versions of a covered work in that User Product from a
286
modified version of its Corresponding Source. The information must suffice
287
to ensure that the continued functioning of the modified object code is in
288
no case prevented or interfered with solely because modification has been
289
made.
290

  
291
If you convey an object code work under this section in, or with, or
292
specifically for use in, a User Product, and the conveying occurs as part
293
of a transaction in which the right of possession and use of the User
294
Product is transferred to the recipient in perpetuity or for a fixed term
295
(regardless of how the transaction is characterized), the Corresponding
296
Source conveyed under this section must be accompanied by the Installation
297
Information. But this requirement does not apply if neither you nor any
298
third party retains the ability to install modified object code on the User
299
Product (for example, the work has been installed in ROM).
300

  
301
The requirement to provide Installation Information does not include a
302
requirement to continue to provide support service, warranty, or updates
303
for a work that has been modified or installed by the recipient, or for the
304
User Product in which it has been modified or installed. Access to a
305
network may be denied when the modification itself materially and adversely
306
affects the operation of the network or violates the rules and protocols
307
for communication across the network.
308

  
309
Corresponding Source conveyed, and Installation Information provided, in
310
accord with this section must be in a format that is publicly documented
311
(and with an implementation available to the public in source code form),
312
and must require no special password or key for unpacking, reading or
313
copying.
314

  
315
7. Additional Terms.
316

  
317
"Additional permissions" are terms that supplement the terms of this
318
License by making exceptions from one or more of its conditions. Additional
319
permissions that are applicable to the entire Program shall be treated as
320
though they were included in this License, to the extent that they are
321
valid under applicable law. If additional permissions apply only to part of
322
the Program, that part may be used separately under those permissions, but
323
the entire Program remains governed by this License without regard to the
324
additional permissions.
325

  
326
When you convey a copy of a covered work, you may at your option remove any
327
additional permissions from that copy, or from any part of it. (Additional
328
permissions may be written to require their own removal in certain cases
329
when you modify the work.) You may place additional permissions on
330
material, added by you to a covered work, for which you have or can give
331
appropriate copyright permission.
332

  
333
Notwithstanding any other provision of this License, for material you add
334
to a covered work, you may (if authorized by the copyright holders of that
335
material) supplement the terms of this License with terms:
336

  
337
  • a) Disclaiming warranty or limiting liability differently from the
338
    terms of sections 15 and 16 of this License; or
339
  • b) Requiring preservation of specified reasonable legal notices or
340
    author attributions in that material or in the Appropriate Legal
341
    Notices displayed by works containing it; or
342
  • c) Prohibiting misrepresentation of the origin of that material, or
343
    requiring that modified versions of such material be marked in
344
    reasonable ways as different from the original version; or
345
  • d) Limiting the use for publicity purposes of names of licensors or
346
    authors of the material; or
347
  • e) Declining to grant rights under trademark law for use of some trade
348
    names, trademarks, or service marks; or
349
  • f) Requiring indemnification of licensors and authors of that material
350
    by anyone who conveys the material (or modified versions of it) with
351
    contractual assumptions of liability to the recipient, for any
352
    liability that these contractual assumptions directly impose on those
353
    licensors and authors.
354

  
355
All other non-permissive additional terms are considered "further
356
restrictions" within the meaning of section 10. If the Program as you
357
received it, or any part of it, contains a notice stating that it is
358
governed by this License along with a term that is a further restriction,
359
you may remove that term. If a license document contains a further
360
restriction but permits relicensing or conveying under this License, you
361
may add to a covered work material governed by the terms of that license
362
document, provided that the further restriction does not survive such
363
relicensing or conveying.
364

  
365
If you add terms to a covered work in accord with this section, you must
366
place, in the relevant source files, a statement of the additional terms
367
that apply to those files, or a notice indicating where to find the
368
applicable terms.
369

  
370
Additional terms, permissive or non-permissive, may be stated in the form
371
of a separately written license, or stated as exceptions; the above
372
requirements apply either way.
373

  
374
8. Termination.
375

  
376
You may not propagate or modify a covered work except as expressly provided
377
under this License. Any attempt otherwise to propagate or modify it is
378
void, and will automatically terminate your rights under this License
379
(including any patent licenses granted under the third paragraph of section
380
11).
381

  
382
However, if you cease all violation of this License, then your license from
383
a particular copyright holder is reinstated (a) provisionally, unless and
384
until the copyright holder explicitly and finally terminates your license,
385
and (b) permanently, if the copyright holder fails to notify you of the
386
violation by some reasonable means prior to 60 days after the cessation.
387

  
388
Moreover, your license from a particular copyright holder is reinstated
389
permanently if the copyright holder notifies you of the violation by some
390
reasonable means, this is the first time you have received notice of
391
violation of this License (for any work) from that copyright holder, and
392
you cure the violation prior to 30 days after your receipt of the notice.
393

  
394
Termination of your rights under this section does not terminate the
395
licenses of parties who have received copies or rights from you under this
396
License. If your rights have been terminated and not permanently
397
reinstated, you do not qualify to receive new licenses for the same
398
material under section 10.
399

  
400
9. Acceptance Not Required for Having Copies.
401

  
402
You are not required to accept this License in order to receive or run a
403
copy of the Program. Ancillary propagation of a covered work occurring
404
solely as a consequence of using peer-to-peer transmission to receive a
405
copy likewise does not require acceptance. However, nothing other than this
406
License grants you permission to propagate or modify any covered work.
407
These actions infringe copyright if you do not accept this License.
408
Therefore, by modifying or propagating a covered work, you indicate your
409
acceptance of this License to do so.
410

  
411
10. Automatic Licensing of Downstream Recipients.
412

  
413
Each time you convey a covered work, the recipient automatically receives a
414
license from the original licensors, to run, modify and propagate that
415
work, subject to this License. You are not responsible for enforcing
416
compliance by third parties with this License.
417

  
418
An "entity transaction" is a transaction transferring control of an
419
organization, or substantially all assets of one, or subdividing an
420
organization, or merging organizations. If propagation of a covered work
421
results from an entity transaction, each party to that transaction who
422
receives a copy of the work also receives whatever licenses to the work the
423
party's predecessor in interest had or could give under the previous
424
paragraph, plus a right to possession of the Corresponding Source of the
425
work from the predecessor in interest, if the predecessor has it or can get
426
it with reasonable efforts.
427

  
428
You may not impose any further restrictions on the exercise of the rights
429
granted or affirmed under this License. For example, you may not impose a
430
license fee, royalty, or other charge for exercise of rights granted under
431
this License, and you may not initiate litigation (including a cross-claim
432
or counterclaim in a lawsuit) alleging that any patent claim is infringed
433
by making, using, selling, offering for sale, or importing the Program or
434
any portion of it.
435

  
436
11. Patents.
437

  
438
A "contributor" is a copyright holder who authorizes use under this License
439
of the Program or a work on which the Program is based. The work thus
440
licensed is called the contributor's "contributor version".
441

  
442
A contributor's "essential patent claims" are all patent claims owned or
443
controlled by the contributor, whether already acquired or hereafter
444
acquired, that would be infringed by some manner, permitted by this
445
License, of making, using, or selling its contributor version, but do not
446
include claims that would be infringed only as a consequence of further
447
modification of the contributor version. For purposes of this definition,
448
"control" includes the right to grant patent sublicenses in a manner
449
consistent with the requirements of this License.
450

  
451
Each contributor grants you a non-exclusive, worldwide, royalty-free patent
452
license under the contributor's essential patent claims, to make, use,
453
sell, offer for sale, import and otherwise run, modify and propagate the
454
contents of its contributor version.
455

  
456
In the following three paragraphs, a "patent license" is any express
457
agreement or commitment, however denominated, not to enforce a patent (such
458
as an express permission to practice a patent or covenant not to sue for
459
patent infringement). To "grant" such a patent license to a party means to
460
make such an agreement or commitment not to enforce a patent against the
461
party.
462

  
463
If you convey a covered work, knowingly relying on a patent license, and
464
the Corresponding Source of the work is not available for anyone to copy,
465
free of charge and under the terms of this License, through a publicly
466
available network server or other readily accessible means, then you must
467
either (1) cause the Corresponding Source to be so available, or (2)
468
arrange to deprive yourself of the benefit of the patent license for this
469
particular work, or (3) arrange, in a manner consistent with the
470
requirements of this License, to extend the patent license to downstream
471
recipients. "Knowingly relying" means you have actual knowledge that, but
472
for the patent license, your conveying the covered work in a country, or
473
your recipient's use of the covered work in a country, would infringe one
474
or more identifiable patents in that country that you have reason to
475
believe are valid.
476

  
477
If, pursuant to or in connection with a single transaction or arrangement,
478
you convey, or propagate by procuring conveyance of, a covered work, and
479
grant a patent license to some of the parties receiving the covered work
480
authorizing them to use, propagate, modify or convey a specific copy of the
481
covered work, then the patent license you grant is automatically extended
482
to all recipients of the covered work and works based on it.
483

  
484
A patent license is "discriminatory" if it does not include within the
485
scope of its coverage, prohibits the exercise of, or is conditioned on the
486
non-exercise of one or more of the rights that are specifically granted
487
under this License. You may not convey a covered work if you are a party to
488
an arrangement with a third party that is in the business of distributing
489
software, under which you make payment to the third party based on the
490
extent of your activity of conveying the work, and under which the third
491
party grants, to any of the parties who would receive the covered work from
492
you, a discriminatory patent license (a) in connection with copies of the
493
covered work conveyed by you (or copies made from those copies), or (b)
494
primarily for and in connection with specific products or compilations that
495
contain the covered work, unless you entered into that arrangement, or that
496
patent license was granted, prior to 28 March 2007.
497

  
498
Nothing in this License shall be construed as excluding or limiting any
499
implied license or other defenses to infringement that may otherwise be
500
available to you under applicable patent law.
501

  
502
12. No Surrender of Others' Freedom.
503

  
504
If conditions are imposed on you (whether by court order, agreement or
505
otherwise) that contradict the conditions of this License, they do not
506
excuse you from the conditions of this License. If you cannot convey a
507
covered work so as to satisfy simultaneously your obligations under this
508
License and any other pertinent obligations, then as a consequence you may
509
not convey it at all. For example, if you agree to terms that obligate you
510
to collect a royalty for further conveying from those to whom you convey
511
the Program, the only way you could satisfy both those terms and this
512
License would be to refrain entirely from conveying the Program.
513

  
514
13. Remote Network Interaction; Use with the GNU General Public License.
515

  
516
Notwithstanding any other provision of this License, if you modify the
517
Program, your modified version must prominently offer all users interacting
518
with it remotely through a computer network (if your version supports such
519
interaction) an opportunity to receive the Corresponding Source of your
520
version by providing access to the Corresponding Source from a network
521
server at no charge, through some standard or customary means of
522
facilitating copying of software. This Corresponding Source shall include
523
the Corresponding Source for any work covered by version 3 of the GNU
524
General Public License that is incorporated pursuant to the following
525
paragraph.
526

  
527
Notwithstanding any other provision of this License, you have permission to
528
link or combine any covered work with a work licensed under version 3 of
529
the GNU General Public License into a single combined work, and to convey
530
the resulting work. The terms of this License will continue to apply to the
531
part which is the covered work, but the work with which it is combined will
532
remain governed by version 3 of the GNU General Public License.
533

  
534
14. Revised Versions of this License.
535

  
536
The Free Software Foundation may publish revised and/or new versions of the
537
GNU Affero General Public License from time to time. Such new versions will
538
be similar in spirit to the present version, but may differ in detail to
539
address new problems or concerns.
540

  
541
Each version is given a distinguishing version number. If the Program
542
specifies that a certain numbered version of the GNU Affero General Public
543
License "or any later version" applies to it, you have the option of
544
following the terms and conditions either of that numbered version or of
545
any later version published by the Free Software Foundation. If the Program
546
does not specify a version number of the GNU Affero General Public License,
547
you may choose any version ever published by the Free Software Foundation.
548

  
549
If the Program specifies that a proxy can decide which future versions of
550
the GNU Affero General Public License can be used, that proxy's public
551
statement of acceptance of a version permanently authorizes you to choose
552
that version for the Program.
553

  
554
Later license versions may give you additional or different permissions.
555
However, no additional obligations are imposed on any author or copyright
556
holder as a result of your choosing to follow a later version.
557

  
558
15. Disclaimer of Warranty.
559

  
560
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE
561
LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
562
OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND,
563
EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
564
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
565
ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.
566
SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY
567
SERVICING, REPAIR OR CORRECTION.
568

  
569
16. Limitation of Liability.
570

  
571
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL
572
ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE
573
PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
574
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
575
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
576
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
577
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
578
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
579
SUCH DAMAGES.
580

  
581
17. Interpretation of Sections 15 and 16.
582

  
583
If the disclaimer of warranty and limitation of liability provided above
584
cannot be given local legal effect according to their terms, reviewing
585
courts shall apply local law that most closely approximates an absolute
586
waiver of all civil liability in connection with the Program, unless a
587
warranty or assumption of liability accompanies a copy of the Program in
588
return for a fee.
589

  
590
END OF TERMS AND CONDITIONS
591

  
592
How to Apply These Terms to Your New Programs
593

  
594
If you develop a new program, and you want it to be of the greatest
595
possible use to the public, the best way to achieve this is to make it free
596
software which everyone can redistribute and change under these terms.
597

  
598
To do so, attach the following notices to the program. It is safest to
599
attach them to the start of each source file to most effectively state the
600
exclusion of warranty; and each file should have at least the "copyright"
601
line and a pointer to where the full notice is found.
602

  
603
    <one line to give the program's name and a brief idea of what it does.>
604
    Copyright (C) <year>  <name of author>
605

  
606
    This program is free software: you can redistribute it and/or modify
607
    it under the terms of the GNU Affero General Public License as
608
    published by the Free Software Foundation, either version 3 of the
609
    License, or (at your option) any later version.
610

  
611
    This program is distributed in the hope that it will be useful,
612
    but WITHOUT ANY WARRANTY; without even the implied warranty of
613
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
614
    GNU Affero General Public License for more details.
615

  
616
    You should have received a copy of the GNU Affero General Public License
617
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
618

  
619
Also add information on how to contact you by electronic and paper mail.
620

  
621
If your software can interact with users remotely through a computer
622
network, you should also make sure that it provides a way for users to get
623
its source. For example, if your program is a web application, its
624
interface could display a "Source" link that leads users to an archive of
625
the code. There are many ways you could offer source, and different
626
solutions will be better for different programs; see section 13 for the
627
specific requirements.
628

  
629
You should also get your employer (if you work as a programmer) or school,
630
if any, to sign a "copyright disclaimer" for the program, if necessary. For
631
more information on this, and how to apply and follow the GNU AGPL, see <
632
http://www.gnu.org/licenses/>.
633

  
test/data/pages/gotmyowndomain.html
1
<html>
2
	<head>
3
		<meta name=charset value="latin1">
4
		<title>
5
			Schrodinger's Document
6
		</title>
7
	</head>
8
	<body>
9
		A nice, simple page for testing.
10
		<script>
11
			document.write('<p><b>Or so you thought...</b></p>');
12
		</script>
13
	</body>
14
</html>
test/data/pages/gotmyowndomain_https.html
1
<html>
2
	<head>
3
		<meta name=charset value="latin1">
4
		<title>
5
			Schrodinger's Document
6
		</title>
7
	</head>
8
	<body>
9
		A nice, simple page for testing (using HTTPS).
10
		<script>
11
			document.write('<p><b>Or so you thought...</b></p>');
12
		</script>
13
	</body>
14
</html>
test/gorilla.py
1
#!/usr/bin/env python3
2
#
3
# Copyright (C) 2021 jahoti <jahoti@tilde.team>
4
# Licensing information is collated in the `copyright` file
5

  
6
"""
7
A partial re-implementation of Hydrilla in Python, for testing purposes.
8

  
9
This will eventually be replaced with a build of the actual thing.
10
"""
11

  
12
import json, os, sys
13

  
14
def load_db(path):
15
	DB = {'script': {}, 'bag': {}, 'page': {}}
16
	if path[-1] != os.sep:
17
		path += os.sep
18
	
19
	DB['path'] = path
20
	for file in os.listdir(path):
21
		subdir = path + file
22
		
23
		if (os.st.S_IFMT(os.stat(subdir).st_mode) & os.st.S_IFDIR) == 0:
24
			continue
25
		
26
		with open(subdir + os.sep + 'index.json') as f:
27
			data = json.load(f)
28
		
29
		type_, data['file'] = data['type'], file
30
		name_key = 'pattern' if type_ == 'page' else 'name'
31
		
32
		DB[type_][data[name_key]] = data
33
		del data['type'], data[name_key]
34
		if type_ == 'script':
35
			with open(path + file + os.sep + data['location']) as f:
36
				data['text'] = f.read()
37
	
38
	return DB
39

  
40

  
41
def mkhachette(patterns):
42
	patterns = set(patterns)
43
	if '*' in patterns:
44
		patterns.remove('*')
45
		patterns.update(DB['page'].keys())
46
	
47
	scripts, bags, pages, new_bags = {}, {}, {}, []
48
	for pattern in patterns:
49
		pages[pattern] = data = DB['page'][pattern]
50
		type_, name = data['payload']
51
		if type_ == 'script':
52
			scripts[name] = DB['script'][name]
53
		else:
54
			new_bags.append(name)
55
	
56
	while new_bags:
57
		name = new_bags.pop(0)
58
		if name in bags:
59
			continue
60
		
61
		bags[name] = data = DB['bag'][name]['components']
62
		for type_, name in data:
63
			if type_ == 'script':
64
				scripts[name] = DB['script'][name]
65
			else:
66
				new_bags.append(name)
67
	
68
	items, path = [], DB['path']
69
	for script, data in scripts.items():
70
		item = {'hash': data['sha256']}
71
		with open(path + data['file'] + os.sep + data['location']) as f:
72
			item['text'] = f.read()
73
		
74
		items.append({'s' + script: item})
75
	
76
	for bag, data in bags.items():
77
		items.append({'b' + bag: [[type_[0], name] for type_, name in data]})
78
	
79
	for page, data in pages.items():
80
		type_, name = data['payload']
81
		items.append({'p' + page: {'components': [type_[0], name]}})
82
	
83
	return items
84

  
85

  
86
if __name__ == '__main__':
87
	if len(sys.argv) < 3 or not os.path.isdir(sys.argv[1]):
88
		sys.stderr.write('Usage: %s [hydrilla content path] (page pattern (page pattern (...)))' % sys.argv[0])
89
		sys.exit(1)
90
	
91
	DB = load_db(sys.argv[1])
92
	print(json.dumps(mkhachette(sys.argv[2:])))
test/init.sh
1
#!/bin/sh
2
#
3
# Copyright (C) 2021 jahoti <jahoti@tilde.team>
4
# Licensing information is collated in the `copyright` file
5

  
6
# Initialize the root certificate for the tests proxy server
7
# Make sure this is run in the directory where they will be put!
8

  
9
gen_keys () {
10
    while [ -n "$1" ]; do
11
	openssl genrsa -out "${1}".key 4096
12
    done
13
}
14

  
15
if [ -n "$1" ]; then
16
    cd "$1"
17
fi
18
gen_keys ca cert
19
openssl req -new -x509 -days ${2:-183} -key ca.key -out ca.crt -subj "/CN=Hachette Test"
test/misc_constants.py
1
# Copyright (C) 2021 jahoti <jahoti@tilde.team>
2
# Licensing information is collated in the `copyright` file
3

  
4
"""
5
Miscellaneous data that were found useful
6
"""
7

  
8
mime_types = {
9
	"7z": "application/x-7z-compressed",	"oga": "audio/ogg",
10
	"abw": "application/x-abiword",		"ogv": "video/ogg",
11
	"arc": "application/x-freearc",		"ogx": "application/ogg",
12
	"bin": "application/octet-stream",	"opus": "audio/opus",
13
	"bz": "application/x-bzip",		"otf": "font/otf",
14
	"bz2": "application/x-bzip2",		"pdf": "application/pdf",
15
	"css": "text/css",			"png": "image/png",
16
	"csv": "text/csv",			"sh": "application/x-sh",
17
	"gif": "image/gif",			"svg": "image/svg+xml",
18
	"gz": "application/gzip",		"tar": "application/x-tar",
19
	"htm": "text/html",			"ts": "video/mp2t",
20
	"html": "text/html",			"ttf": "font/ttf",
21
	"ico": "image/vnd.microsoft.icon",	"txt": "text/plain",
22
	"js": "text/javascript",		"wav": "audio/wav",
23
	"jpeg": "image/jpeg",			"weba": "audio/webm",
24
	"jpg": "image/jpeg",			"webm": "video/webm",
25
	"json": "application/json",		"woff": "font/woff",	
26
	"mjs": "text/javascript",		"woff2": "font/woff2",
27
	"mp3": "audio/mpeg",			"xhtml": "application/xhtml+xml",
28
	"mp4": "video/mp4",			"zip": "application/zip",
29
	"mpeg": "video/mpeg",
30
	"odp": "application/vnd.oasis.opendocument.presentation",
31
	"ods": "application/vnd.oasis.opendocument.spreadsheet",
32
	"odt": "application/vnd.oasis.opendocument.text",
33
	"xml": "application/xml" # text/xml if readable from casual users
34
}
test/proxy_core.py
1
# Copyright (c) 2015, inaz2
2
# Copyright (C) 2021 jahoti <jahoti@tilde.team>
3
# Licensing information is collated in the `copyright` file
4

  
5
"""
6
The core for a "virtual network" proxy
7

  
8
Be sure to set certdir to your intended certificates directory before running.
9
"""
10

  
11
import os, socket, ssl, subprocess, sys, threading, time
12
from http.server import HTTPServer, BaseHTTPRequestHandler
13
from socketserver import ThreadingMixIn
14

  
15
gen_cert_req, lock = 'openssl req -new -key %scert.key -subj /CN=%s', threading.Lock()
16
sign_cert_req = 'openssl x509 -req -days 3650 -CA %sca.crt -CAkey %sca.key -set_serial %d -out %s'
17

  
18
def popen(command, *args, **kwargs):
19
    return subprocess.Popen((command % args).split(' '), **kwargs)
20

  
21
class ProxyRequestHandler(BaseHTTPRequestHandler):
22
	"""Handles a network request made to the proxy"""
23
	def log_error(self, format, *args):
24
		# suppress "Request timed out: timeout('timed out',)"
25
		if isinstance(args[0], socket.timeout):
26
			return
27

  
28
		self.log_message(format, *args)
29

  
30
	def do_CONNECT(self):
31
		hostname = self.path.split(':')[0]
32
		certpath = '%s%s.crt' % (certdir, hostname if hostname != 'ca' else 'CA')
33

  
34
		with lock:
35
			if not os.path.isfile(certpath):
36
				p1 = popen(gen_cert_req, certdir, hostname, stdout=subprocess.PIPE).stdout
37
				popen(sign_cert_req, certdir, certdir, time.time() * 1000, certpath, stdin=p1, stderr=subprocess.PIPE).communicate()
38

  
39
		self.send_response(200)
40
		self.end_headers()
41

  
42
		self.connection = ssl.wrap_socket(self.connection, keyfile=certdir+'cert.key', certfile=certpath, server_side=True)
43
		self.rfile = self.connection.makefile('rb', self.rbufsize)
44
		self.wfile = self.connection.makefile('wb', self.wbufsize)
45

  
46
		self.close_connection = int(self.headers.get('Proxy-Connection', '').lower() == 'close')
47

  
48
	def proxy(self):
49
		content_length = int(self.headers.get('Content-Length', 0))
50
		req_body = self.rfile.read(content_length) if content_length else None
51

  
52
		if self.path[0] == '/':
53
			if isinstance(self.connection, ssl.SSLSocket):
54
				self.path = 'https://%s%s' % (self.headers['Host'], self.path)
55
			else:
56
				self.path = 'http://%s%s' % (self.headers['Host'], self.path)
57

  
58
		self.handle_request(req_body)
59

  
60
	do_OPTIONS = do_DELETE = do_PUT = do_HEAD = do_POST = do_GET = proxy
61

  
62
	def handle_request(self, req_body):
63
		pass
64

  
65

  
66
class ThreadingHTTPServer(ThreadingMixIn, HTTPServer):
67
	"""The actual proxy server"""
68
	address_family, daemon_threads = socket.AF_INET6, True
69

  
70
	def handle_error(self, request, client_address):
71
		# suppress socket/ssl related errors
72
		cls, e = sys.exc_info()[:2]
73
		if not (cls is socket.error or cls is ssl.SSLError):
74
			return HTTPServer.handle_error(self, request, client_address)
test/server.py
1
#!/usr/bin/env python3
2
#
3
# Copyright (C) 2021 jahoti <jahoti@tilde.team>
4
# Licensing information is collated in the `copyright` file
5

  
6
"""
7
A modular "virtual network" proxy,
8
wrapping the classes in proxy_core.py
9
"""
10

  
11
import proxy_core
12
from urllib.parse import parse_qs
13
from misc_constants import *
14
from world_wide_library import catalog as internet
15

  
16
class RequestHijacker(proxy_core.ProxyRequestHandler):
17
	def handle_request(self, req_body):
18
		path_components = self.path.split('?', maxsplit=1)
19
		path = path_components[0]
20
		try:
21
			# Response format: (status_code, headers (dict. of strings),
22
			#       body as bytes or filename containing body as string)
23
			if path in internet:
24
				info = internet[path]
25
				if type(info) == tuple:
26
					status_code, headers, body_file = info
27
					if type(body_file) == str:
28
						if 'Content-Type' not in headers and '.' in body_file:
29
							ext = body_file.rsplit('.', maxsplit=1)[-1]
30
							if ext in mime_types:
31
								headers['Content-Type'] = mime_types[ext]
32
							
33
						with open(body_file, mode='rb') as f:
34
							body_file = f.read()
35
						
36
				else:
37
					# A function to evaluate to get the response
38
					get_params, post_params = {}, {}
39
					if len(path_components) == 2:
40
						get_params = parse_qs(path_components[1])
41
					
42
					# Parse POST parameters; currently only supports
43
					# application/x-www-form-urlencoded
44
					if req_body:
45
						post_params = parse_qs(req_body.encode())
46

  
47
					status_code, headers, body_file = info(self.command, get_params, post_params)
48
					if type(body_file) == str:
49
						body_file = body_file.encode()
50
			
51
				if type(status_code) != int or status_code <= 0:
52
					raise Exception('Invalid status code %r' % status_code)
53
				
54
				for header, header_value in headers.items():
55
					if type(header) != str:
56
						raise Exception('Invalid header key %r' % header)
57
					
58
					elif type(header_value) != str:
59
						raise Exception('Invalid header value %r' % header_value)
60
			else:
61
				status_code, headers = 404, {'Content-Type': 'text/plain'}
62
				body_file = b'Handler for this URL not found.'
63
		
64
		except Exception as e:
65
			status_code, headers, body_file = 500, {'Content-Type': 'text/plain'}, b'Internal Error:\n' + repr(e).encode()
66
		
67
		headers['Content-Length'] = str(len(body_file))
68
		self.send_response(status_code)
69
		for header, header_value in headers.items():
70
			self.send_header(header, header_value)
71
		
72
		self.end_headers()
73
		self.wfile.write(body_file)
74
		
75

  
76

  
77
def do_an_internet(certdir, port):
78
	"""Start up the proxy/server"""
79
	proxy_core.certdir = certdir
80
	httpd = proxy_core.ThreadingHTTPServer(('', port), RequestHijacker)
81
	httpd.serve_forever()
82

  
83
if __name__ == '__main__':
84
	import sys
85
	def fail(msg, error_code):
86
		print('Error:', msg)
87
		print('Usage:', sys.argv[0], '[certificates directory] (port)')
88
		sys.exit(error_code)
89
	
90
	if len(sys.argv) < 2:
91
		fail('missing required argument "certificates directory".', 1)
92
	
93
	certdir = sys.argv[1]
94
	if not proxy_core.os.path.isdir(certdir):
95
		fail('selected certificate directory does not exist.', 2)
96
	
97
	port = sys.argv[2] if len(sys.argv) > 2 else '1337'
98
	if not port.isnumeric():
99
		fail('port must be an integer.', 3)
100
	
101
	do_an_internet(certdir, int(port))
test/world_wide_library.py
1
# Copyright (C) 2021 jahoti <jahoti@tilde.team>
2
# Licensing information is collated in the `copyright` file
3

  
4
"""
5
Our helpful little stand-in for the Internet
6
"""
7

  
8
catalog = {
9
	'http://gotmyowndoma.in': (302, {'location': 'http://gotmyowndoma.in/index.html'}, b''),
10
	'http://gotmyowndoma.in/': (302, {'location': 'http://gotmyowndoma.in/index.html'}, b''),
11
	'http://gotmyowndoma.in/index.html': (200, {}, 'data/pages/gotmyowndomain.html'),
12
	'https://gotmyowndoma.in': (302, {'location': 'https://gotmyowndoma.in/index.html'}, b''),
13
	'https://gotmyowndoma.in/': (302, {'location': 'https://gotmyowndoma.in/index.html'}, b''),
14
	'https://gotmyowndoma.in/index.html': (200, {}, 'data/pages/gotmyowndomain_https.html')
15
}

Also available in: Unified diff