commit b9ec01945dfa6bc79dee8e3ffa7ba7b0f37709af Author: Davide De Rosa Date: Thu Oct 11 09:13:19 2018 +0200 Initial commit diff --git a/.env b/.env new file mode 100644 index 00000000..cf81d50b --- /dev/null +++ b/.env @@ -0,0 +1,11 @@ +LC_ALL="en_US.UTF-8" +LANG="en_US.UTF-8" + +STAGE_BUILD_PATH="build/$TARGET" +STAGE_ARTIFACTS_PATH="dist/$TARGET" +STAGE_ARCHIVE_NAME="Passepartout" +BUILD_CHANGELOG_PATH="ci/BUILD" + +GYM_SCHEME="Passepartout-iOS" +MATCH_READONLY="true" +IPA_OUTPUT_PATH="$STAGE_ARTIFACTS_PATH/$STAGE_ARCHIVE_NAME.ipa" diff --git a/.env.beta-archive b/.env.beta-archive new file mode 100644 index 00000000..64a23f6a --- /dev/null +++ b/.env.beta-archive @@ -0,0 +1,2 @@ +MATCH_TYPE="appstore" +GYM_EXPORT_METHOD="app-store" diff --git a/.env.beta-deploy b/.env.beta-deploy new file mode 100644 index 00000000..c62dfe0e --- /dev/null +++ b/.env.beta-deploy @@ -0,0 +1,3 @@ +PILOT_IPA=$IPA_OUTPUT_PATH +PILOT_DISTRIBUTE_EXTERNAL="true" +DEMO_ACCOUNT_REQUIRED="true" diff --git a/.env.dev-archive b/.env.dev-archive new file mode 100644 index 00000000..cc2fad4a --- /dev/null +++ b/.env.dev-archive @@ -0,0 +1,2 @@ +MATCH_TYPE="adhoc" +GYM_EXPORT_METHOD="ad-hoc" diff --git a/.env.dev-deploy b/.env.dev-deploy new file mode 100644 index 00000000..38055479 --- /dev/null +++ b/.env.dev-deploy @@ -0,0 +1,6 @@ +FL_HOCKEY_IPA=$IPA_OUTPUT_PATH +FL_HOCKEY_COMMIT_SHA=$(git rev-parse HEAD) +#FL_HOCKEY_COMMIT_SHA=$CI_COMMIT_SHA +#FL_HOCKEY_BUILD_SERVER_URL="$CI_PROJECT_URL/-/jobs/$CI_JOB_ID" +#FL_HOCKEY_REPOSITORY_URL=$CI_PROJECT_URL +FL_HOCKEY_STRATEGY="replace" diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..cb6b16a8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,18 @@ +.DS_Store +*.swp +*.pbxuser +**/*.xcworkspace/xcuserdata +**/*.xcodeproj/project.xcworkspace +**/*.xcodeproj/xcuserdata +Pods +fastlane/**/*.html +fastlane/README.md +fastlane/report.xml +fastlane/test_output +fastlane/metadata/review_information +fastlane/metadata/trade_representative_contact_information +build +dist +.env.secret* +Preview.html +Gemfile.lock diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..247b659a --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,10 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## 1.0 beta 975 (2018-10-11) + +First public beta release. diff --git a/CLA.rst b/CLA.rst new file mode 100644 index 00000000..6ad8d991 --- /dev/null +++ b/CLA.rst @@ -0,0 +1,9 @@ +By making a contribution to this project, I certify that: + +(a) The contribution was created in whole or in part by me and I have the right to submit it under the MIT license; or + +(b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the MIT license; or + +(c) The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it. + +(d) I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it) is maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..1896e471 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,8 @@ +## Contributing + +- Use imperative commit messages. + - GOOD: "Add new feature" + - BAD: "Added new feature" +- Rebase your branch to `master` and possibly squash unrelevant commits. +- Make sure to pass the unit tests, as long as CI doesn't automate them yet. +- Submit the PR. diff --git a/Gemfile b/Gemfile new file mode 100644 index 00000000..e1075020 --- /dev/null +++ b/Gemfile @@ -0,0 +1,5 @@ +source "https://rubygems.org" + +gem "fastlane" +gem "cocoapods", ">= 1.6.0.beta" +gem "dotenv" diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..f288702d --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/Passepartout-iOS-Tunnel/Info.plist b/Passepartout-iOS-Tunnel/Info.plist new file mode 100644 index 00000000..9162b3c4 --- /dev/null +++ b/Passepartout-iOS-Tunnel/Info.plist @@ -0,0 +1,31 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleDisplayName + Passepartout-iOS-Tunnel + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + XPC! + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + NSExtension + + NSExtensionPointIdentifier + com.apple.networkextension.packet-tunnel + NSExtensionPrincipalClass + $(PRODUCT_MODULE_NAME).PacketTunnelProvider + + + diff --git a/Passepartout-iOS-Tunnel/PacketTunnelProvider.swift b/Passepartout-iOS-Tunnel/PacketTunnelProvider.swift new file mode 100644 index 00000000..a4fb783c --- /dev/null +++ b/Passepartout-iOS-Tunnel/PacketTunnelProvider.swift @@ -0,0 +1,37 @@ +// +// PacketTunnelProvider.swift +// Passepartout-iOS-Tunnel +// +// Created by Davide De Rosa on 6/6/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import TunnelKit + +class PacketTunnelProvider: TunnelKitProvider { + override func startTunnel(options: [String : NSObject]?, completionHandler: @escaping (Error?) -> Void) { + if let version = GroupConstants.App.version { + appVersion = "\(GroupConstants.App.name) \(version)" + } + dnsTimeout = GroupConstants.VPN.dnsTimeout + logSeparator = GroupConstants.VPN.sessionMarker + super.startTunnel(options: options, completionHandler: completionHandler) + } +} diff --git a/Passepartout-iOS-Tunnel/Tunnel.entitlements b/Passepartout-iOS-Tunnel/Tunnel.entitlements new file mode 100644 index 00000000..ad9e428b --- /dev/null +++ b/Passepartout-iOS-Tunnel/Tunnel.entitlements @@ -0,0 +1,14 @@ + + + + + com.apple.developer.networking.networkextension + + packet-tunnel-provider + + com.apple.security.application-groups + + group.com.algoritmico.Passepartout + + + diff --git a/Passepartout-iOS/AppDelegate.swift b/Passepartout-iOS/AppDelegate.swift new file mode 100644 index 00000000..7872f6c5 --- /dev/null +++ b/Passepartout-iOS/AppDelegate.swift @@ -0,0 +1,142 @@ +// +// AppDelegate.swift +// Passepartout-iOS +// +// Created by Davide De Rosa on 6/6/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import UIKit +import SwiftyBeaver + +private let log = SwiftyBeaver.self + +@UIApplicationMain +class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDelegate { + + var window: UIWindow? + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { + AppConstants.Log.configure() + + InfrastructureFactory.shared.loadCache() + + // Override point for customization after application launch. + let splitViewController = window!.rootViewController as! UISplitViewController +// splitViewController.preferredPrimaryColumnWidthFraction = 0.4 +// splitViewController.minimumPrimaryColumnWidth = 360.0 + splitViewController.maximumPrimaryColumnWidth = .infinity + splitViewController.delegate = self + if UI_USER_INTERFACE_IDIOM() == .pad { + splitViewController.preferredDisplayMode = .allVisible +// } else { +// splitViewController.preferredDisplayMode = .primaryOverlay + } + + Theme.current.applyAppearance() + + return true + } + + func applicationWillResignActive(_ application: UIApplication) { + // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. + TransientStore.shared.serialize() // synchronize + } + + func applicationDidEnterBackground(_ application: UIApplication) { + // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. + } + + func applicationWillEnterForeground(_ application: UIApplication) { + // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. + } + + func applicationDidBecomeActive(_ application: UIApplication) { + // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. + } + + func applicationWillTerminate(_ application: UIApplication) { + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. + } + + // MARK: UISplitViewControllerDelegate + + func splitViewController(_ splitViewController: UISplitViewController, collapseSecondary secondaryViewController: UIViewController, onto primaryViewController: UIViewController) -> Bool { + return !TransientStore.shared.service.hasActiveProfile() + } + + // MARK: URLs + + func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool { + guard let root = window?.rootViewController else { + fatalError("No window.rootViewController?") + } + + do { + + // already presented: update URL + if let nav = root.presentedViewController as? UINavigationController, let wizard = nav.topViewController as? WizardHostViewController { + try wizard.setConfigurationURL(url) + return true + } + + // present now + let nav = StoryboardScene.Organizer.wizardHostIdentifier.instantiate() + guard let wizard = nav.topViewController as? WizardHostViewController else { + fatalError("Expected WizardHostViewController from storyboard") + } + try wizard.setConfigurationURL(url) + + // best effort to delegate to main vc + let split = root as? UISplitViewController + let master = split?.viewControllers.first as? UINavigationController + master?.viewControllers.forEach { + if let organizerVC = $0 as? OrganizerViewController { + wizard.delegate = organizerVC + } + } + nav.modalPresentationStyle = .formSheet + root.present(nav, animated: true, completion: nil) + } catch { + let alert = Macros.alert(L10n.Organizer.Sections.Hosts.header, L10n.Wizards.Host.Alerts.parsing) + alert.addCancelAction(L10n.Global.ok) + root.present(alert, animated: true, completion: nil) + } + return true + } +} + +extension UISplitViewController { + var serviceViewController: ServiceViewController? { + for vc in viewControllers { + guard let nav = vc as? UINavigationController else { + continue + } + if let found = nav.viewControllers.first(where: { + $0 as? ServiceViewController != nil + }) as? ServiceViewController { + return found + } + } + return nil + } +} diff --git a/Passepartout-iOS/Assets.xcassets/AppIcon.appiconset/AppIcon-1024.png b/Passepartout-iOS/Assets.xcassets/AppIcon.appiconset/AppIcon-1024.png new file mode 100644 index 00000000..3593cc76 Binary files /dev/null and b/Passepartout-iOS/Assets.xcassets/AppIcon.appiconset/AppIcon-1024.png differ diff --git a/Passepartout-iOS/Assets.xcassets/AppIcon.appiconset/AppIcon-120.png b/Passepartout-iOS/Assets.xcassets/AppIcon.appiconset/AppIcon-120.png new file mode 100644 index 00000000..5bb38396 Binary files /dev/null and b/Passepartout-iOS/Assets.xcassets/AppIcon.appiconset/AppIcon-120.png differ diff --git a/Passepartout-iOS/Assets.xcassets/AppIcon.appiconset/AppIcon-152.png b/Passepartout-iOS/Assets.xcassets/AppIcon.appiconset/AppIcon-152.png new file mode 100644 index 00000000..217a39d8 Binary files /dev/null and b/Passepartout-iOS/Assets.xcassets/AppIcon.appiconset/AppIcon-152.png differ diff --git a/Passepartout-iOS/Assets.xcassets/AppIcon.appiconset/AppIcon-167.png b/Passepartout-iOS/Assets.xcassets/AppIcon.appiconset/AppIcon-167.png new file mode 100644 index 00000000..15099973 Binary files /dev/null and b/Passepartout-iOS/Assets.xcassets/AppIcon.appiconset/AppIcon-167.png differ diff --git a/Passepartout-iOS/Assets.xcassets/AppIcon.appiconset/AppIcon-180.png b/Passepartout-iOS/Assets.xcassets/AppIcon.appiconset/AppIcon-180.png new file mode 100644 index 00000000..1e7f8038 Binary files /dev/null and b/Passepartout-iOS/Assets.xcassets/AppIcon.appiconset/AppIcon-180.png differ diff --git a/Passepartout-iOS/Assets.xcassets/AppIcon.appiconset/AppIcon-76.png b/Passepartout-iOS/Assets.xcassets/AppIcon.appiconset/AppIcon-76.png new file mode 100644 index 00000000..04d8afe3 Binary files /dev/null and b/Passepartout-iOS/Assets.xcassets/AppIcon.appiconset/AppIcon-76.png differ diff --git a/Passepartout-iOS/Assets.xcassets/AppIcon.appiconset/Contents.json b/Passepartout-iOS/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000..7bdf4b02 --- /dev/null +++ b/Passepartout-iOS/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,104 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "3x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "AppIcon-120.png", + "scale" : "2x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "AppIcon-180.png", + "scale" : "3x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "2x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "AppIcon-76.png", + "scale" : "1x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "AppIcon-152.png", + "scale" : "2x" + }, + { + "size" : "83.5x83.5", + "idiom" : "ipad", + "filename" : "AppIcon-167.png", + "scale" : "2x" + }, + { + "size" : "1024x1024", + "idiom" : "ios-marketing", + "filename" : "AppIcon-1024.png", + "scale" : "1x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Passepartout-iOS/Assets.xcassets/Contents.json b/Passepartout-iOS/Assets.xcassets/Contents.json new file mode 100644 index 00000000..da4a164c --- /dev/null +++ b/Passepartout-iOS/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Passepartout-iOS/Assets.xcassets/logo.imageset/Contents.json b/Passepartout-iOS/Assets.xcassets/logo.imageset/Contents.json new file mode 100644 index 00000000..b54d173d --- /dev/null +++ b/Passepartout-iOS/Assets.xcassets/logo.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "logo@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "logo@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Passepartout-iOS/Assets.xcassets/logo.imageset/logo@2x.png b/Passepartout-iOS/Assets.xcassets/logo.imageset/logo@2x.png new file mode 100644 index 00000000..c18bae2f Binary files /dev/null and b/Passepartout-iOS/Assets.xcassets/logo.imageset/logo@2x.png differ diff --git a/Passepartout-iOS/Assets.xcassets/logo.imageset/logo@3x.png b/Passepartout-iOS/Assets.xcassets/logo.imageset/logo@3x.png new file mode 100644 index 00000000..4e1d504a Binary files /dev/null and b/Passepartout-iOS/Assets.xcassets/logo.imageset/logo@3x.png differ diff --git a/Passepartout-iOS/Cells/Cells.swift b/Passepartout-iOS/Cells/Cells.swift new file mode 100644 index 00000000..179311b1 --- /dev/null +++ b/Passepartout-iOS/Cells/Cells.swift @@ -0,0 +1,58 @@ +// +// Cells.swift +// Passepartout-iOS +// +// Created by Davide De Rosa on 6/25/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import UIKit + +struct Cells { +} + +extension UITableView { + func dequeue(_ type: T.Type, identifier: String, for indexPath: IndexPath) -> T { + guard let cell = dequeueReusableCell(withIdentifier: identifier, for: indexPath) as? T else { + fatalError("Not a \(T.description())") + } + return cell + } +} + +protocol CellProvider { + associatedtype T: UITableViewCell + + static var identifier: String { get } + + func register(with tableView: UITableView) + + func dequeue(from tableView: UITableView, for indexPath: IndexPath) -> T +} + +extension CellProvider { + static var identifier: String { + return String(describing: T.self) + } + + func register(with tableView: UITableView) { + tableView.register(T.self, forCellReuseIdentifier: Self.identifier) + } +} diff --git a/Passepartout-iOS/Cells/DestructiveTableViewCell.swift b/Passepartout-iOS/Cells/DestructiveTableViewCell.swift new file mode 100644 index 00000000..b9513d8d --- /dev/null +++ b/Passepartout-iOS/Cells/DestructiveTableViewCell.swift @@ -0,0 +1,75 @@ +// +// DestructiveTableViewCell.swift +// Passepartout-iOS +// +// Created by Davide De Rosa on 6/22/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import UIKit + +extension Cells { + static let destructive = DestructiveTableViewCell.Provider() +} + +class DestructiveTableViewCell: UITableViewCell { + @IBOutlet private lazy var labelCaption: UILabel? = { + let label = UILabel() + label.textAlignment = .center + contentView.addSubview(label) + return label + }() + + var caption: String? { + get { + return labelCaption?.text + } + set { + labelCaption?.text = newValue + } + } + + var captionColor: UIColor? { + get { + return labelCaption?.textColor + } + set { + labelCaption?.textColor = newValue + } + } + + override func layoutSubviews() { + super.layoutSubviews() + + labelCaption?.frame = contentView.bounds + } +} + +extension DestructiveTableViewCell { + class Provider: CellProvider { + typealias T = DestructiveTableViewCell + + func dequeue(from tableView: UITableView, for indexPath: IndexPath) -> DestructiveTableViewCell { + let cell = tableView.dequeue(T.self, identifier: Provider.identifier, for: indexPath) + cell.apply(Theme.current) + return cell + } + } +} diff --git a/Passepartout-iOS/Cells/FieldTableViewCell.swift b/Passepartout-iOS/Cells/FieldTableViewCell.swift new file mode 100644 index 00000000..e695488e --- /dev/null +++ b/Passepartout-iOS/Cells/FieldTableViewCell.swift @@ -0,0 +1,119 @@ +// +// FieldTableViewCell.swift +// Passepartout-iOS +// +// Created by Davide De Rosa on 6/13/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import UIKit + +extension Cells { + static let field = FieldTableViewCell.Provider() +} + +protocol FieldTableViewCellDelegate: class { + func fieldCellDidEdit(_: FieldTableViewCell) + + func fieldCellDidEnter(_: FieldTableViewCell) +} + +class FieldTableViewCell: UITableViewCell { + var caption: String? { + get { + return textLabel?.text + } + set { + textLabel?.text = newValue + } + } + + var captionColor: UIColor? { + get { + return textLabel?.textColor + } + set { + textLabel?.textColor = newValue + } + } + + var captionWidth: CGFloat = 0.0 { + didSet { + layoutSubviews() + } + } + + private(set) lazy var field = UITextField() + + weak var delegate: FieldTableViewCellDelegate? + + override func awakeFromNib() { + super.awakeFromNib() + + field.autocapitalizationType = .none + field.autocorrectionType = .no + field.textAlignment = .left + field.delegate = self + selectionStyle = .none + contentView.addSubview(field) + } + + override func layoutSubviews() { + super.layoutSubviews() + + var frame: CGRect + let label: UILabel = textLabel! + + frame = label.frame + frame.size.width = captionWidth + label.frame = frame + + let offset: CGFloat = 15.0 + field.frame = CGRect( + x: label.frame.maxX, + y: 0.0, + width: bounds.size.width - label.frame.maxX - offset, + height: bounds.size.height + ) + } +} + +extension FieldTableViewCell: UITextFieldDelegate { + func textFieldDidEndEditing(_ textField: UITextField) { + delegate?.fieldCellDidEdit(self) + } + + func textFieldShouldReturn(_ textField: UITextField) -> Bool { + delegate?.fieldCellDidEnter(self) + return true + } +} + +extension FieldTableViewCell { + class Provider: CellProvider { + typealias T = FieldTableViewCell + + func dequeue(from tableView: UITableView, for indexPath: IndexPath) -> FieldTableViewCell { + let cell = tableView.dequeue(T.self, identifier: Provider.identifier, for: indexPath) + cell.apply(Theme.current) + return cell + } + } +} diff --git a/Passepartout-iOS/Cells/SettingTableViewCell.swift b/Passepartout-iOS/Cells/SettingTableViewCell.swift new file mode 100644 index 00000000..906198c8 --- /dev/null +++ b/Passepartout-iOS/Cells/SettingTableViewCell.swift @@ -0,0 +1,89 @@ +// +// SettingTableViewCell.swift +// Passepartout-iOS +// +// Created by Davide De Rosa on 6/13/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import UIKit + +extension Cells { + static let setting = SettingTableViewCell.Provider() +} + +class SettingTableViewCell: UITableViewCell { + var isTappable: Bool = true { + didSet { + selectionStyle = isTappable ? .default : .none + } + } + + var leftText: String? { + get { + return textLabel?.text + } + set { + textLabel?.text = newValue + } + } + + var leftTextColor: UIColor? { + get { + return textLabel?.textColor + } + set { + textLabel?.textColor = newValue + } + } + + var rightText: String? { + get { + return detailTextLabel?.text + } + set { + detailTextLabel?.text = newValue + } + } + + var rightTextColor: UIColor? { + get { + return detailTextLabel?.textColor + } + set { + detailTextLabel?.textColor = newValue + } + } +} + +extension SettingTableViewCell { + class Provider: CellProvider { + typealias T = SettingTableViewCell + + func dequeue(from tableView: UITableView, for indexPath: IndexPath) -> SettingTableViewCell { + let cell = tableView.dequeue(T.self, identifier: Provider.identifier, for: indexPath) + cell.apply(Theme.current) + cell.rightText = nil + cell.isTappable = true + cell.accessoryType = .disclosureIndicator + return cell + } + } +} diff --git a/Passepartout-iOS/Cells/ToggleTableViewCell.swift b/Passepartout-iOS/Cells/ToggleTableViewCell.swift new file mode 100644 index 00000000..97c4dcd2 --- /dev/null +++ b/Passepartout-iOS/Cells/ToggleTableViewCell.swift @@ -0,0 +1,112 @@ +// +// ToggleTableViewCell.swift +// Passepartout-iOS +// +// Created by Davide De Rosa on 6/13/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import UIKit + +extension Cells { + static let toggle = ToggleTableViewCell.Provider() +} + +protocol ToggleTableViewCellDelegate: class { + func toggleCell(_: ToggleTableViewCell, didToggleToValue value: Bool) +} + +class ToggleTableViewCell: UITableViewCell { + var caption: String? { + get { + return textLabel?.text + } + set { + textLabel?.text = newValue + } + } + + var captionColor: UIColor? { + get { + return textLabel?.textColor + } + set { + textLabel?.textColor = newValue + } + } + + var toggle: UISwitch { + return accessoryView as! UISwitch + } + + var isOn: Bool { + get { + return toggle.isOn + } + set { + guard newValue != toggle.isOn else { + return + } + toggle.isOn = newValue + } + } + + func setOn(_ on: Bool, animated: Bool) { + guard on != toggle.isOn else { + return + } + toggle.setOn(on, animated: animated) + } + + weak var delegate: ToggleTableViewCellDelegate? + + override func awakeFromNib() { + super.awakeFromNib() + + let toggle = UISwitch() + toggle.addTarget(self, action: #selector(toggleMoved), for: .valueChanged) + accessoryView = toggle + selectionStyle = .none + } + + @objc private func toggleMoved() { + delegate?.toggleCell(self, didToggleToValue: toggle.isOn) + } +} + +extension ToggleTableViewCell { + class Provider: CellProvider { + typealias T = ToggleTableViewCell + + func dequeue(from tableView: UITableView, for indexPath: IndexPath) -> ToggleTableViewCell { + let cell = tableView.dequeue(T.self, identifier: Provider.identifier, for: indexPath) + cell.apply(Theme.current) + return cell + } + + func dequeue(from tableView: UITableView, for indexPath: IndexPath, tag: Int, delegate: ToggleTableViewCellDelegate) -> ToggleTableViewCell { + let cell = tableView.dequeue(T.self, identifier: Provider.identifier, for: indexPath) + cell.apply(Theme.current) + cell.tag = tag + cell.delegate = delegate + return cell + } + } +} diff --git a/Passepartout-iOS/Global/HUD.swift b/Passepartout-iOS/Global/HUD.swift new file mode 100644 index 00000000..5b6de6f8 --- /dev/null +++ b/Passepartout-iOS/Global/HUD.swift @@ -0,0 +1,64 @@ +// +// HUD.swift +// Passepartout-iOS +// +// Created by Davide De Rosa on 9/18/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// +// This file incorporates work covered by the following copyright and +// permission notice: +// +// Copyright (c) 2018-Present Private Internet Access +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +import UIKit +import MBProgressHUD + +class HUD { + private let backend: MBProgressHUD + + init() { + guard let window = UIApplication.shared.windows.first else { + fatalError("Could not locate front window?") + } + + backend = MBProgressHUD.showAdded(to: window, animated: true) + backend.backgroundView.backgroundColor = UIColor(white: 0.0, alpha: 0.6) + backend.mode = .indeterminate + backend.removeFromSuperViewOnHide = true + +// Theme.current.applyOverlay(hud.backgroundView) +// Theme.current.applyOverlay(hud.bezelView) + } + + func show() { + backend.show(animated: true) + } + + func hide() { + backend.hide(animated: true) + } +} diff --git a/Passepartout-iOS/Global/IssueReporter.swift b/Passepartout-iOS/Global/IssueReporter.swift new file mode 100644 index 00000000..03e24c23 --- /dev/null +++ b/Passepartout-iOS/Global/IssueReporter.swift @@ -0,0 +1,82 @@ +// +// IssueReporter.swift +// Passepartout-iOS +// +// Created by Davide De Rosa on 9/26/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import Foundation +import MessageUI + +class IssueReporter: NSObject { + static let shared = IssueReporter() + + private weak var viewController: UIViewController? + + override private init() { + super.init() + } + + func present(in viewController: UIViewController) { + guard MFMailComposeViewController.canSendMail() else { + let alert = Macros.alert(L10n.IssueReporter.title, L10n.IssueReporter.Alerts.EmailNotConfigured.message) + alert.addCancelAction(L10n.Global.ok) + viewController.present(alert, animated: true, completion: nil) + return + } + + self.viewController = viewController + + let alert = Macros.alert(L10n.IssueReporter.title, L10n.IssueReporter.message) + alert.addDefaultAction(L10n.IssueReporter.Buttons.withLog) { + VPN.shared.requestDebugLog(fallback: AppConstants.Log.debugSnapshot) { + self.composeEmail(withDebugLog: $0) + } + } + alert.addAction(UIAlertAction(title: L10n.IssueReporter.Buttons.withoutLog, style: .default) { (action) in + self.composeEmail(withDebugLog: nil) + }) + alert.addCancelAction(L10n.Global.cancel) + viewController.present(alert, animated: true, completion: nil) + } + + private func composeEmail(withDebugLog debugLog: String?) { + let metadata = DebugLog(raw: "--").decoratedString() + + let vc = MFMailComposeViewController() + vc.setToRecipients([AppConstants.IssueReporter.recipient]) + vc.setSubject(L10n.IssueReporter.Email.subject(GroupConstants.App.name)) + vc.setMessageBody(L10n.IssueReporter.Email.body(metadata), isHTML: false) + if let raw = debugLog { + let attachment = DebugLog(raw: raw).decoratedData() + vc.addAttachmentData(attachment, mimeType: AppConstants.IssueReporter.attachmentMIME, fileName: AppConstants.Log.debugFilename) + } + vc.mailComposeDelegate = self + vc.apply(Theme.current) + viewController?.present(vc, animated: true, completion: nil) + } +} + +extension IssueReporter: MFMailComposeViewControllerDelegate { + func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) { + viewController?.dismiss(animated: true, completion: nil) + } +} diff --git a/Passepartout-iOS/Global/Macros.swift b/Passepartout-iOS/Global/Macros.swift new file mode 100644 index 00000000..4b3cc95f --- /dev/null +++ b/Passepartout-iOS/Global/Macros.swift @@ -0,0 +1,68 @@ +// +// Macros.swift +// Passepartout-iOS +// +// Created by Davide De Rosa on 6/16/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import UIKit + +class Macros { + static func alert(_ title: String?, _ message: String?) -> UIAlertController { + return UIAlertController(title: title, message: message, preferredStyle: .alert) + } + + static func actionSheet(_ title: String?, _ message: String?) -> UIAlertController { + return UIAlertController(title: title, message: message, preferredStyle: .actionSheet) + } + + static var isDeviceNonPlus: Bool { + return (UI_USER_INTERFACE_IDIOM() == .phone) && (UIScreen.main.scale < 3.0) + } +} + +extension UIAlertController { + func addDefaultAction(_ title: String, handler: @escaping () -> Void) { + let action = UIAlertAction(title: title, style: .default) { (action) in + handler() + } + addAction(action) + preferredAction = action + } + + func addCancelAction(_ title: String, handler: (() -> Void)? = nil) { + let action = UIAlertAction(title: title, style: .cancel) { (action) in + handler?() + } + addAction(action) + if actions.count == 1 { + preferredAction = action + } + } + + func addDestructiveAction(_ title: String, handler: @escaping () -> Void) { + let action = UIAlertAction(title: title, style: .destructive) { (action) in + handler() + } + addAction(action) + preferredAction = action + } +} diff --git a/Passepartout-iOS/Global/OptionViewController.swift b/Passepartout-iOS/Global/OptionViewController.swift new file mode 100644 index 00000000..56a32f7b --- /dev/null +++ b/Passepartout-iOS/Global/OptionViewController.swift @@ -0,0 +1,75 @@ +// +// OptionViewController.swift +// Passepartout-iOS +// +// Created by Davide De Rosa on 9/5/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import UIKit + +protocol OptionViewControllerDelegate: class { + func optionController(_: OptionViewController, descriptionFor option: T) -> String + + func optionController(_: OptionViewController, didSelect option: T) +} + +class OptionViewController: UIViewController, UITableViewDataSource, UITableViewDelegate { + private lazy var tableView = UITableView(frame: .zero, style: .grouped) + + var options: [T] = [] + + var selectedOption: T? + + var descriptionBlock: ((T) -> String)? + + var selectionBlock: ((T) -> Void)? + + weak var delegate: OptionViewControllerDelegate? + + override func viewDidLoad() { + super.viewDidLoad() + + tableView.register(SettingTableViewCell.self, forCellReuseIdentifier: SettingTableViewCell.Provider.identifier) + tableView.frame = view.bounds + tableView.autoresizingMask = [.flexibleWidth, .flexibleHeight] + view.addSubview(tableView) + + tableView.dataSource = self + tableView.delegate = self + } + + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return options.count + } + + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let opt = options[indexPath.row] + let cell = Cells.setting.dequeue(from: tableView, for: indexPath) + cell.leftText = descriptionBlock?(opt) ?? delegate?.optionController(self, descriptionFor: opt) + cell.accessoryType = (opt == selectedOption) ? .checkmark : .none + return cell + } + + func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + let opt = options[indexPath.row] + selectionBlock?(opt) ?? delegate?.optionController(self, didSelect: opt) + } +} diff --git a/Passepartout-iOS/Global/SwiftGen+Storyboards.swift b/Passepartout-iOS/Global/SwiftGen+Storyboards.swift new file mode 100644 index 00000000..bd13578a --- /dev/null +++ b/Passepartout-iOS/Global/SwiftGen+Storyboards.swift @@ -0,0 +1,98 @@ +// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen + +// swiftlint:disable sorted_imports +import Foundation +import UIKit +import Passepartout_iOS + +// swiftlint:disable superfluous_disable_command +// swiftlint:disable file_length + +internal protocol StoryboardType { + static var storyboardName: String { get } +} + +internal extension StoryboardType { + static var storyboard: UIStoryboard { + let name = self.storyboardName + return UIStoryboard(name: name, bundle: Bundle(for: BundleToken.self)) + } +} + +internal struct SceneType { + internal let storyboard: StoryboardType.Type + internal let identifier: String + + internal func instantiate() -> T { + let identifier = self.identifier + guard let controller = storyboard.storyboard.instantiateViewController(withIdentifier: identifier) as? T else { + fatalError("ViewController '\(identifier)' is not of the expected class \(T.self).") + } + return controller + } +} + +internal struct InitialSceneType { + internal let storyboard: StoryboardType.Type + + internal func instantiate() -> T { + guard let controller = storyboard.storyboard.instantiateInitialViewController() as? T else { + fatalError("ViewController is not of the expected class \(T.self).") + } + return controller + } +} + +internal protocol SegueType: RawRepresentable { } + +internal extension UIViewController { + func perform(segue: S, sender: Any? = nil) where S.RawValue == String { + let identifier = segue.rawValue + performSegue(withIdentifier: identifier, sender: sender) + } +} + +// swiftlint:disable explicit_type_interface identifier_name line_length type_body_length type_name +internal enum StoryboardScene { + internal enum Main: StoryboardType { + internal static let storyboardName = "Main" + + internal static let initialScene = InitialSceneType(storyboard: Main.self) + + internal static let accountIdentifier = SceneType(storyboard: Main.self, identifier: "AccountIdentifier") + + internal static let configurationIdentifier = SceneType(storyboard: Main.self, identifier: "ConfigurationIdentifier") + + internal static let serviceIdentifier = SceneType(storyboard: Main.self, identifier: "ServiceIdentifier") + } + internal enum Organizer: StoryboardType { + internal static let storyboardName = "Organizer" + + internal static let initialScene = InitialSceneType(storyboard: Organizer.self) + + internal static let provider = SceneType(storyboard: Organizer.self, identifier: "Provider") + + internal static let wizardHostIdentifier = SceneType(storyboard: Organizer.self, identifier: "WizardHostIdentifier") + } +} + +internal enum StoryboardSegue { + internal enum Main: String, SegueType { + case accountSegueIdentifier = "AccountSegueIdentifier" + case debugLogSegueIdentifier = "DebugLogSegueIdentifier" + case endpointSegueIdentifier = "EndpointSegueIdentifier" + case hostParametersSegueIdentifier = "HostParametersSegueIdentifier" + case providerPoolSegueIdentifier = "ProviderPoolSegueIdentifier" + case providerPresetSegueIdentifier = "ProviderPresetSegueIdentifier" + } + internal enum Organizer: String, SegueType { + case aboutSegueIdentifier = "AboutSegueIdentifier" + case addProviderSegueIdentifier = "AddProviderSegueIdentifier" + case creditsSegueIdentifier = "CreditsSegueIdentifier" + case selectProfileSegueIdentifier = "SelectProfileSegueIdentifier" + case versionSegueIdentifier = "VersionSegueIdentifier" + } +} +// swiftlint:enable explicit_type_interface identifier_name line_length type_body_length type_name + +private final class BundleToken {} diff --git a/Passepartout-iOS/Global/Theme+Cells.swift b/Passepartout-iOS/Global/Theme+Cells.swift new file mode 100644 index 00000000..dd951a13 --- /dev/null +++ b/Passepartout-iOS/Global/Theme+Cells.swift @@ -0,0 +1,88 @@ +// +// Theme+Cells.swift +// Passepartout-iOS +// +// Created by Davide De Rosa on 6/25/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import UIKit + +extension DestructiveTableViewCell { + func apply(_ theme: Theme) { + accessoryType = .none + selectionStyle = .default + captionColor = theme.palette.colorDestructive + } +} + +extension FieldTableViewCell { + func apply(_ theme: Theme) { + captionColor = theme.palette.colorPrimaryText + } +} + +extension SettingTableViewCell { + func apply(_ theme: Theme) { + leftTextColor = theme.palette.colorPrimaryText + rightTextColor = theme.palette.colorSecondaryText + } +} + +extension ToggleTableViewCell { + func apply(_ theme: Theme) { + captionColor = theme.palette.colorPrimaryText + } +} + +extension SettingTableViewCell { + func applyAction(_ theme: Theme) { + leftTextColor = theme.palette.colorAction + rightTextColor = nil + accessoryType = .none + } + + func applyVPN(_ theme: Theme, with vpnStatus: VPNStatus?) { + leftTextColor = theme.palette.colorPrimaryText + guard let vpnStatus = vpnStatus else { + rightText = L10n.Vpn.disabled + rightTextColor = theme.palette.colorSecondaryText + return + } + + switch vpnStatus { + case .connecting: + rightText = L10n.Vpn.connecting + rightTextColor = theme.palette.colorIndeterminate + + case .connected: + rightText = L10n.Vpn.active + rightTextColor = theme.palette.colorOn + + case .disconnecting: + rightText = L10n.Vpn.disconnecting + rightTextColor = theme.palette.colorIndeterminate + + case .disconnected: + rightText = L10n.Vpn.inactive + rightTextColor = theme.palette.colorOff + } + } +} diff --git a/Passepartout-iOS/Global/Theme+Titles.swift b/Passepartout-iOS/Global/Theme+Titles.swift new file mode 100644 index 00000000..b0fdd044 --- /dev/null +++ b/Passepartout-iOS/Global/Theme+Titles.swift @@ -0,0 +1,36 @@ +// +// Theme+Titles.swift +// Passepartout-iOS +// +// Created by Davide De Rosa on 7/16/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import UIKit + +extension UIViewController { + func applyMasterTitle(_ theme: Theme) { + navigationItem.largeTitleDisplayMode = theme.masterTitleDisplayMode + } + + func applyDetailTitle(_ theme: Theme) { + navigationItem.largeTitleDisplayMode = theme.detailTitleDisplayMode + } +} diff --git a/Passepartout-iOS/Global/Theme.swift b/Passepartout-iOS/Global/Theme.swift new file mode 100644 index 00000000..05683c03 --- /dev/null +++ b/Passepartout-iOS/Global/Theme.swift @@ -0,0 +1,133 @@ +// +// Theme.swift +// Passepartout-iOS +// +// Created by Davide De Rosa on 6/14/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import UIKit +import MessageUI + +extension UIColor { + convenience init(rgb: UInt32, alpha: CGFloat) { + let r = CGFloat((rgb & 0xff0000) >> 16) / 255.0 + let g = CGFloat((rgb & 0xff00) >> 8) / 255.0 + let b = CGFloat(rgb & 0xff) / 255.0 + self.init(red: r, green: g, blue: b, alpha: alpha) + } +} + +struct Theme { + struct Palette { + var colorPrimaryBackground = UIColor(rgb: 0x515d71, alpha: 1.0) + + var colorAccent1 = UIColor(rgb: 0xd69c68, alpha: 1.0) + + var colorPrimaryText: UIColor = .darkText + + var colorPrimaryLightText: UIColor = .white + + var colorSecondaryText: UIColor = .gray + + var colorOn: UIColor { + return colorAccent1 + } + + var colorIndeterminate: UIColor { + return colorSecondaryText + } + + var colorOff: UIColor { + return colorSecondaryText + } + +// var colorAction = UIColor(red: 214.0 / 255.0, green: 156.0 / 255.0, blue: 104.0 / 255.0, alpha: 1.0) + var colorAction: UIColor { + return colorAccent1 + } + + var colorDestructive = UIColor(red: 0.8, green: 0.27, blue: 0.2, alpha: 1.0) + } + + static let current = Theme() + + var palette: Palette + + var masterTitleDisplayMode: UINavigationItem.LargeTitleDisplayMode + + var detailTitleDisplayMode: UINavigationItem.LargeTitleDisplayMode + + private init() { + palette = Palette() + masterTitleDisplayMode = .never + detailTitleDisplayMode = .never + } +} + +extension Theme { + func applyAppearance() { + let bar = UINavigationBar.appearance() + bar.barTintColor = palette.colorPrimaryBackground + bar.tintColor = palette.colorPrimaryLightText + bar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: palette.colorPrimaryLightText] + bar.largeTitleTextAttributes = bar.titleTextAttributes + + let toolbar = UIToolbar.appearance() + toolbar.barTintColor = palette.colorPrimaryBackground + toolbar.tintColor = palette.colorPrimaryLightText + + let toggle = UISwitch.appearance() + toggle.onTintColor = palette.colorAction.withAlphaComponent(0.7) + } +} + +extension UIView { + func applyPrimaryBackground(_ theme: Theme) { + backgroundColor = theme.palette.colorPrimaryBackground + } +} + +extension UILabel { + func apply(_ theme: Theme) { + textColor = theme.palette.colorPrimaryText + } + + func applyLight(_ theme: Theme) { + textColor = theme.palette.colorPrimaryLightText + } +} + +extension UIButton { + func apply(_ theme: Theme) { + tintColor = theme.palette.colorAction + } +} + +// XXX: status bar is broken +extension MFMailComposeViewController { + func apply(_ theme: Theme) { + let bar = navigationBar + bar.barTintColor = theme.palette.colorPrimaryBackground + bar.tintColor = theme.palette.colorPrimaryLightText + bar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: theme.palette.colorPrimaryLightText] + bar.largeTitleTextAttributes = bar.titleTextAttributes + } +} diff --git a/Passepartout-iOS/Global/UITextView+Search.swift b/Passepartout-iOS/Global/UITextView+Search.swift new file mode 100644 index 00000000..6b5d2f21 --- /dev/null +++ b/Passepartout-iOS/Global/UITextView+Search.swift @@ -0,0 +1,96 @@ +// +// UITextView+Search.swift +// Passepartout-iOS +// +// Created by Davide De Rosa on 8/1/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import UIKit + +extension UITextView { + func firstVisibleIndex() -> Int { + let endOffset = contentOffset + let end = closestPosition(to: endOffset) ?? beginningOfDocument + return offset(from: beginningOfDocument, to: end) + } + + func lastVisibleIndex() -> Int { + let startOffset = CGPoint( + x: contentOffset.x + frame.size.width, + y: contentOffset.y + frame.size.height + ) + let start = closestPosition(to: startOffset) ?? endOfDocument + return offset(from: beginningOfDocument, to: start) + } + + func findPrevious(string: String) { + let last = text.index(text.startIndex, offsetBy: firstVisibleIndex()) + let context = text.startIndex..>> found: \(nsRange)") + scrollRangeToVisible(nsRange) +// scrollRangeToTop(nsRange) + } + + func findNext(string: String) { + let first = text.index(text.startIndex, offsetBy: lastVisibleIndex()) + let context = first..>> found: \(nsRange)") + scrollRangeToVisible(nsRange) +// scrollRangeToTop(nsRange) + } + + func scrollRangeToTop(_ nsRange: NSRange) { + let start = position(from: beginningOfDocument, offset: nsRange.location) ?? beginningOfDocument + let end = position(from: start, offset: nsRange.length) ?? endOfDocument + guard let range = textRange(from: start, to: end) else { + return + } + let target = convert(firstRect(for: range), to: textInputView) + setContentOffset(target.origin, animated: true) + } + +// func scrollRangeToTop(_ range: NSRange) { +// let glyphRange = layoutManager.glyphRange(forCharacterRange: range, actualCharacterRange: nil) +// let rect = layoutManager.boundingRect(forGlyphRange: glyphRange, in: textContainer) +// let topTextInset = textContainerInset.top +// let target = CGPoint(x: 0, y: topTextInset + rect.origin.y) +// setContentOffset(target, animated: true) +// log.debug(">>> target: \(target)") +// } + + func scrollToBegin() { + scrollRangeToVisible(NSMakeRange(0, 1)) + } + + func scrollToEnd() { + scrollRangeToVisible(NSMakeRange(text.count - 1, 1)) + } +} diff --git a/Passepartout-iOS/Info.plist b/Passepartout-iOS/Info.plist new file mode 100644 index 00000000..f0b1cf26 --- /dev/null +++ b/Passepartout-iOS/Info.plist @@ -0,0 +1,72 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleDisplayName + Passepartout + CFBundleDocumentTypes + + + CFBundleTypeIconFiles + + CFBundleTypeName + OpenVPN + CFBundleTypeRole + Viewer + LSHandlerRank + Owner + LSItemContentTypes + + net.openvpn.formats.ovpn + + + + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + ITSAppUsesNonExemptEncryption + + LSRequiresIPhoneOS + + LSSupportsOpeningDocumentsInPlace + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + arm64 + + UIStatusBarStyle + UIStatusBarStyleLightContent + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UIViewControllerBasedStatusBarAppearance + + + diff --git a/Passepartout-iOS/Passepartout.entitlements b/Passepartout-iOS/Passepartout.entitlements new file mode 100644 index 00000000..df0b1c20 --- /dev/null +++ b/Passepartout-iOS/Passepartout.entitlements @@ -0,0 +1,16 @@ + + + + + com.apple.developer.networking.networkextension + + packet-tunnel-provider + + com.apple.developer.networking.wifi-info + + com.apple.security.application-groups + + group.com.algoritmico.Passepartout + + + diff --git a/Passepartout-iOS/Scenes/AccountViewController.swift b/Passepartout-iOS/Scenes/AccountViewController.swift new file mode 100644 index 00000000..f20fcbda --- /dev/null +++ b/Passepartout-iOS/Scenes/AccountViewController.swift @@ -0,0 +1,223 @@ +// +// AccountViewController.swift +// Passepartout-iOS +// +// Created by Davide De Rosa on 6/12/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import UIKit + +protocol AccountViewControllerDelegate: class { + func accountController(_: AccountViewController, didEnterCredentials credentials: Credentials) + + func accountControllerDidComplete(_: AccountViewController) +} + +class AccountViewController: UIViewController, TableModelHost { + @IBOutlet private weak var tableView: UITableView? + + private weak var cellUsername: FieldTableViewCell? + + private weak var cellPassword: FieldTableViewCell? + + private weak var cellPasswordConfirmation: FieldTableViewCell? + + var currentCredentials: Credentials? + + var usernamePlaceholder: String? + + var infrastructureName: Infrastructure.Name? { + didSet { + guard let name = infrastructureName else { + model.removeFooter(for: .only) + return + } + let V = L10n.Account.SuggestionFooter.Infrastructure.self + switch name { + case .pia: + model.setFooter(V.pia, for: .only) + } + tableView?.reloadData() + } + } + + var credentials: Credentials { + let username = cellUsername?.field.text ?? "" + let password = cellPassword?.field.text ?? "" + return Credentials(username, password).trimmed() + } + + weak var delegate: AccountViewControllerDelegate? + + // MARK: TableModelHost + + let model: TableModel = { + let model: TableModel = TableModel() + model.add(.only) + model.set([.username, .password, .passwordConfirmation], in: .only) + return model + }() + + func reloadModel() { + } + + // MARK: UIViewController + + override func awakeFromNib() { + super.awakeFromNib() + + applyDetailTitle(Theme.current) + } + + override func viewDidLoad() { + super.viewDidLoad() + + title = L10n.Service.Cells.Account.caption + cellUsername?.field.text = currentCredentials?.username + cellPassword?.field.text = currentCredentials?.password + } + + override func viewDidAppear(_ animated: Bool) { + super.viewDidAppear(animated) + + cellUsername?.field.becomeFirstResponder() + } + + // MARK: Actions + + private func commit() { + let newCredentials = credentials +// guard !credentials.isEmpty else { +// return +// } + currentCredentials = newCredentials + delegate?.accountController(self, didEnterCredentials: newCredentials) + } + + @IBAction private func done() { + guard cellPassword?.field.text == cellPasswordConfirmation?.field.text else { + let alert = Macros.alert(title, L10n.Account.Cells.PasswordConfirm.mismatch) + alert.addCancelAction(L10n.Global.ok) + present(alert, animated: true, completion: nil) + return + } + + view.endEditing(true) + delegate?.accountControllerDidComplete(self) + } + + @objc private func footerTapped() { + } +} + +// MARK: - + +extension AccountViewController: UITableViewDataSource, UITableViewDelegate, FieldTableViewCellDelegate { + enum SectionType: Int { + case only + } + + enum RowType: Int { + case username + + case password + + case passwordConfirmation + } + + private static let footerButtonTag = 1000 + + func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String? { + return model.footer(for: .only) + } + + func tableView(_ tableView: UITableView, willDisplayFooterView view: UIView, forSection section: Int) { + var optButton = view.viewWithTag(AccountViewController.footerButtonTag) as? UIButton + if optButton == nil { + let button = UIButton() + button.frame = view.bounds + view.addSubview(button) + optButton = button + } + optButton?.addTarget(self, action: #selector(footerTapped), for: .touchUpInside) + } + + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return model.count(for: section) + } + + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let cell = Cells.field.dequeue(from: tableView, for: indexPath) + switch model.row(at: indexPath) { + case .username: + cellUsername = cell + cell.caption = L10n.Account.Cells.Username.caption + cell.field.placeholder = usernamePlaceholder ?? L10n.Account.Cells.Username.placeholder + cell.field.clearButtonMode = .always + cell.field.isSecureTextEntry = false + cell.field.text = currentCredentials?.username + cell.field.keyboardType = .emailAddress + cell.field.returnKeyType = .next + + case .password: + cellPassword = cell + cell.caption = L10n.Account.Cells.Password.caption + cell.field.placeholder = L10n.Account.Cells.Password.placeholder + cell.field.clearButtonMode = .always + cell.field.isSecureTextEntry = true + cell.field.text = currentCredentials?.password + cell.field.returnKeyType = .done + + case .passwordConfirmation: + cellPasswordConfirmation = cell + cell.caption = L10n.Account.Cells.PasswordConfirm.caption + cell.field.placeholder = L10n.Account.Cells.Password.placeholder + cell.field.clearButtonMode = .always + cell.field.isSecureTextEntry = true + cell.field.text = currentCredentials?.password + cell.field.returnKeyType = .done + } + cell.captionWidth = 120.0 + cell.delegate = self + return cell + } + + func fieldCellDidEdit(_: FieldTableViewCell) { + commit() + } + + func fieldCellDidEnter(_ cell: FieldTableViewCell) { + switch cell { + case cellUsername: + cellPassword?.field.becomeFirstResponder() + + case cellPassword: + cellPasswordConfirmation?.field.becomeFirstResponder() + + case cellPasswordConfirmation: + cellPasswordConfirmation?.field.resignFirstResponder() + done() + + default: + break + } + } +} diff --git a/Passepartout-iOS/Scenes/ConfigurationModificationDelegate.swift b/Passepartout-iOS/Scenes/ConfigurationModificationDelegate.swift new file mode 100644 index 00000000..fd326f9d --- /dev/null +++ b/Passepartout-iOS/Scenes/ConfigurationModificationDelegate.swift @@ -0,0 +1,33 @@ +// +// ConfigurationModificationDelegate.swift +// Passepartout-iOS +// +// Created by Davide De Rosa on 9/6/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import Foundation +import TunnelKit + +protocol ConfigurationModificationDelegate: class { + func configuration(didUpdate newConfiguration: TunnelKitProvider.Configuration) + + func configurationShouldReinstall() +} diff --git a/Passepartout-iOS/Scenes/ConfigurationViewController.swift b/Passepartout-iOS/Scenes/ConfigurationViewController.swift new file mode 100644 index 00000000..bed347b3 --- /dev/null +++ b/Passepartout-iOS/Scenes/ConfigurationViewController.swift @@ -0,0 +1,308 @@ +// +// ConfigurationViewController.swift +// Passepartout-iOS +// +// Created by Davide De Rosa on 9/2/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import UIKit +import TunnelKit + +class ConfigurationViewController: UIViewController, TableModelHost { + @IBOutlet private weak var tableView: UITableView! + + private lazy var itemRefresh = UIBarButtonItem(barButtonSystemItem: .refresh, target: self, action: #selector(refresh)) + + var initialConfiguration: TunnelKitProvider.Configuration! + + private lazy var configuration: TunnelKitProvider.ConfigurationBuilder = initialConfiguration.builder() + + var isEditable = false + + weak var delegate: ConfigurationModificationDelegate? + + // MARK: TableModelHost + + lazy var model: TableModel = { + let model: TableModel = TableModel() + + // sections + model.add(.communication) + model.add(.tls) + model.add(.other) + + // headers + model.setHeader(L10n.Configuration.Sections.Communication.header, for: .communication) + model.setHeader(L10n.Configuration.Sections.Tls.header, for: .tls) + model.setHeader(L10n.Configuration.Sections.Other.header, for: .other) + + // footers + if isEditable { + model.setFooter(L10n.Configuration.Sections.Communication.Footer.editable, for: .communication) + } + + // rows + model.set([.cipher, .digest, .compressionFrame], in: .communication) + model.set([.client, .tlsWrapping], in: .tls) + model.set([.compressionAlgorithm, .keepAlive, .renegSeconds], in: .other) + + return model + }() + + func reloadModel() { + } + + // MARK: UIViewController + + override func awakeFromNib() { + super.awakeFromNib() + + applyDetailTitle(Theme.current) + } + + override func viewDidLoad() { + super.viewDidLoad() + + guard let _ = initialConfiguration else { + fatalError("Initial configuration not set") + } + + guard isEditable else { + tableView.allowsSelection = false + return + } + itemRefresh.isEnabled = false + navigationItem.rightBarButtonItem = itemRefresh + } + + override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(animated) + + if let ip = tableView.indexPathForSelectedRow { + tableView.deselectRow(at: ip, animated: true) + } + } + + // MARK: Actions + + @IBAction private func refresh() { + guard isEditable else { + return + } + initialConfiguration = configuration.build() + itemRefresh.isEnabled = false + + delegate?.configurationShouldReinstall() + } +} + +// MARK: - + +extension ConfigurationViewController: UITableViewDataSource, UITableViewDelegate { + enum SectionType: Int { + case communication + + case tls + + case other + } + + enum RowType: Int { + case cipher + + case digest + + case compressionFrame + + case client + + case tlsWrapping + + case compressionAlgorithm + + case keepAlive + + case renegSeconds + } + + func numberOfSections(in tableView: UITableView) -> Int { + return model.count + } + + func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? { + return model.header(for: section) + } + + func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String? { + return model.footer(for: section) + } + + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return model.count(for: section) + } + + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let row = model.row(at: indexPath) + + let cell = Cells.setting.dequeue(from: tableView, for: indexPath) + if !isEditable { + cell.accessoryType = .none + } + cell.isTappable = isEditable + switch row { + case .cipher: + cell.leftText = L10n.Configuration.Cells.Cipher.caption + cell.rightText = configuration.cipher.description + + case .digest: + cell.leftText = L10n.Configuration.Cells.Digest.caption + if !configuration.cipher.embedsDigest { + cell.rightText = configuration.digest.description + } else { + cell.rightText = L10n.Configuration.Cells.Digest.Value.embedded + cell.accessoryType = .none + cell.isTappable = false + } + + case .compressionFrame: + cell.leftText = L10n.Configuration.Cells.CompressionFrame.caption + cell.rightText = configuration.compressionFraming.cellDescription + + case .client: + cell.leftText = L10n.Configuration.Cells.Client.caption + cell.rightText = (configuration.clientCertificate != nil) ? L10n.Configuration.Cells.Client.Value.enabled : L10n.Configuration.Cells.Client.Value.disabled + cell.accessoryType = .none + cell.isTappable = false + + case .tlsWrapping: + cell.leftText = L10n.Configuration.Cells.TlsWrapping.caption + let V = L10n.Configuration.Cells.TlsWrapping.Value.self + cell.rightText = V.disabled + cell.accessoryType = .none + cell.isTappable = false + + case .compressionAlgorithm: + cell.leftText = L10n.Configuration.Cells.CompressionAlgorithm.caption + cell.rightText = L10n.Configuration.Cells.CompressionAlgorithm.Value.disabled // hardcoded because compression unsupported + cell.accessoryType = .none + cell.isTappable = false + + case .keepAlive: + cell.leftText = L10n.Configuration.Cells.KeepAlive.caption + let V = L10n.Configuration.Cells.KeepAlive.Value.self + if let keepAlive = configuration.keepAliveSeconds, keepAlive > 0 { + cell.rightText = V.seconds(keepAlive) + } else { + cell.rightText = V.never + } + cell.accessoryType = .none + cell.isTappable = false + + case .renegSeconds: + cell.leftText = L10n.Configuration.Cells.RenegotiationSeconds.caption + let V = L10n.Configuration.Cells.RenegotiationSeconds.Value.self + if let reneg = configuration.renegotiatesAfterSeconds, reneg > 0 { + cell.rightText = V.after(TimeInterval(reneg).localized) + } else { + cell.rightText = V.never + } + cell.accessoryType = .none + cell.isTappable = false + } + return cell + } + + func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + guard isEditable else { + fatalError("Table should not allow selection when isEditable is false") + } + + switch model.row(at: indexPath) { + case .cipher: + let vc = OptionViewController() + vc.options = [.aes128cbc, .aes192cbc, .aes256cbc, .aes128gcm, .aes192gcm, .aes256gcm] + vc.selectedOption = configuration.cipher + vc.descriptionBlock = { $0.description } + vc.selectionBlock = { [weak self] in + self?.configuration.cipher = $0 + self?.popAndCheckRefresh() + } + navigationController?.pushViewController(vc, animated: true) + + case .digest: + guard !configuration.cipher.embedsDigest else { + return + } + + let vc = OptionViewController() + vc.options = [.sha1, .sha224, .sha256, .sha384, .sha512] + vc.selectedOption = configuration.digest + vc.descriptionBlock = { $0.description } + vc.selectionBlock = { [weak self] in + self?.configuration.digest = $0 + self?.popAndCheckRefresh() + } + navigationController?.pushViewController(vc, animated: true) + + case .compressionFrame: + let vc = OptionViewController() + vc.options = [.disabled, .compLZO, .compress] + vc.selectedOption = configuration.compressionFraming + vc.descriptionBlock = { $0.cellDescription } + vc.selectionBlock = { [weak self] in + self?.configuration.compressionFraming = $0 + self?.popAndCheckRefresh() + } + navigationController?.pushViewController(vc, animated: true) + + default: + break + } + } + + // MARK: Helpers + + private func popAndCheckRefresh() { + itemRefresh.isEnabled = !configuration.canCommunicate(with: initialConfiguration) + tableView.reloadData() + navigationController?.popViewController(animated: true) + + delegate?.configuration(didUpdate: configuration.build()) + } +} + +// MARK: - + +private extension SessionProxy.CompressionFraming { + var cellDescription: String { + let V = L10n.Configuration.Cells.CompressionFrame.Value.self + switch self { + case .disabled: + return V.disabled + + case .compLZO: + return V.lzo + + case .compress: + return V.compress + } + } +} diff --git a/Passepartout-iOS/Scenes/DebugLogViewController.swift b/Passepartout-iOS/Scenes/DebugLogViewController.swift new file mode 100644 index 00000000..34bc5b57 --- /dev/null +++ b/Passepartout-iOS/Scenes/DebugLogViewController.swift @@ -0,0 +1,126 @@ +// +// DebugLogViewController.swift +// Passepartout-iOS +// +// Created by Davide De Rosa on 6/12/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import UIKit +import SwiftyBeaver + +private let log = SwiftyBeaver.self + +class DebugLogViewController: UIViewController { + @IBOutlet private weak var textLog: UITextView! + + private let vpn = VPN.shared + + deinit { + NotificationCenter.default.removeObserver(self) + } + + override func awakeFromNib() { + super.awakeFromNib() + + applyDetailTitle(Theme.current) + } + + override func viewDidLoad() { + super.viewDidLoad() + + title = L10n.Service.Cells.DebugLog.caption + textLog.contentInsetAdjustmentBehavior = .never + + NotificationCenter.default.addObserver(self, selector: #selector(vpnDidPrepare), name: .VPNDidPrepare, object: nil) + if vpn.isPrepared { + startRefreshingLog() + } + } + + @IBAction private func share(_ sender: Any?) { + guard let raw = textLog.text, !raw.isEmpty else { + let alert = Macros.alert(title, L10n.DebugLog.Alerts.EmptyLog.message) + alert.addCancelAction(L10n.Global.ok) + present(alert, animated: true, completion: nil) + return + } + let data = DebugLog(raw: raw).decoratedData() + + let path = NSTemporaryDirectory().appending(AppConstants.Log.debugFilename) + let url = URL(fileURLWithPath: path) + do { + try data.write(to: url) + } catch let e { + log.error("Failed saving temporary debug log file: \(e)") + return + } + let vc = UIActivityViewController(activityItems: [url], applicationActivities: nil) + vc.popoverPresentationController?.barButtonItem = sender as? UIBarButtonItem + vc.completionWithItemsHandler = { (type, completed, items, error) in + try? FileManager.default.removeItem(at: url) + } + present(vc, animated: true, completion: nil) + } + + @IBAction private func previousSession() { + textLog.findPrevious(string: GroupConstants.VPN.sessionMarker) + } + + @IBAction private func nextSession() { + textLog.findNext(string: GroupConstants.VPN.sessionMarker) + } + + private func startRefreshingLog() { + vpn.requestDebugLog(fallback: AppConstants.Log.debugSnapshot) { + self.textLog.text = $0 + + DispatchQueue.main.async { + self.textLog.scrollToEnd() + self.refreshLogInBackground() + } + } + } + + private func refreshLogInBackground() { + let updateBlock = { + DispatchQueue.main.asyncAfter(deadline: .now() + AppConstants.Log.viewerRefreshInterval) { [weak self] in + self?.refreshLogInBackground() + } + } + + // only update if screen is visible + guard let _ = viewIfLoaded?.window else { + updateBlock() + return + } + + vpn.requestDebugLog(fallback: AppConstants.Log.debugSnapshot) { + self.textLog.text = $0 + updateBlock() + } + } + + // MARK: Notifications + + @objc private func vpnDidPrepare() { + startRefreshingLog() + } +} diff --git a/Passepartout-iOS/Scenes/EndpointViewController.swift b/Passepartout-iOS/Scenes/EndpointViewController.swift new file mode 100644 index 00000000..31a2f41e --- /dev/null +++ b/Passepartout-iOS/Scenes/EndpointViewController.swift @@ -0,0 +1,307 @@ +// +// EndpointViewController.swift +// Passepartout-iOS +// +// Created by Davide De Rosa on 6/25/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import UIKit +import TunnelKit + +protocol EndpointViewControllerDelegate: class { + func endpointController(_: EndpointViewController, didUpdateWithNewAddress newAddress: String?, newProtocol: TunnelKitProvider.EndpointProtocol?) +} + +class EndpointViewController: UIViewController, TableModelHost { + @IBOutlet private weak var tableView: UITableView! + + private lazy var itemRefresh = UIBarButtonItem(barButtonSystemItem: .refresh, target: self, action: #selector(refresh)) + + private var endpointAddresses: [String] = [] + + private var endpointProtocols: [TunnelKitProvider.EndpointProtocol] = [] + + private var initialAddress: String? + + private var initialProtocol: TunnelKitProvider.EndpointProtocol? + + private var currentAddress: String? + + private var currentProtocol: TunnelKitProvider.EndpointProtocol? + + private var currentAddressIndexPath: IndexPath? + + private var currentProtocolIndexPath: IndexPath? + + var dataSource: EndpointDataSource! + + weak var delegate: EndpointViewControllerDelegate? + + weak var modificationDelegate: ConfigurationModificationDelegate? + + // MARK: TableModelHost + + lazy var model: TableModel = { + let model: TableModel = TableModel() + + model.add(.locationAddresses) + model.add(.locationProtocols) + + model.setHeader(L10n.Endpoint.Sections.LocationAddresses.header, for: .locationAddresses) + model.setHeader(L10n.Endpoint.Sections.LocationProtocols.header, for: .locationProtocols) + + if dataSource.canCustomizeEndpoint { + var addressRows: [RowType] = Array(repeating: .availableAddress, count: dataSource.addresses.count) + addressRows.insert(.anyAddress, at: 0) + model.set(addressRows, in: .locationAddresses) + + var protocolRows: [RowType] = Array(repeating: .availableProtocol, count: dataSource.protocols.count) + protocolRows.insert(.anyProtocol, at: 0) + model.set(protocolRows, in: .locationProtocols) + } else { + model.set(.availableAddress, count: dataSource.addresses.count, in: .locationAddresses) + model.set(.availableProtocol, count: dataSource.protocols.count, in: .locationProtocols) + } + + return model + }() + + func reloadModel() { + } + + // MARK: UIViewController + + override func awakeFromNib() { + super.awakeFromNib() + + applyDetailTitle(Theme.current) + } + + override func viewDidLoad() { + super.viewDidLoad() + + title = L10n.Service.Cells.Endpoint.caption + guard let _ = dataSource else { + fatalError("Data source not set") + } + endpointAddresses = dataSource.addresses + endpointProtocols = dataSource.protocols + + guard dataSource.canCustomizeEndpoint else { + tableView.allowsSelection = false + return + } + itemRefresh.isEnabled = false + navigationItem.rightBarButtonItem = itemRefresh + + initialAddress = dataSource.customAddress + initialProtocol = dataSource.customProtocol + currentAddress = initialAddress + currentProtocol = initialProtocol + + tableView.reloadData() + if let ip = selectedIndexPath { + tableView.scrollToRow(at: ip, at: .middle, animated: false) + } + } + + override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(animated) + + guard let selected = tableView.indexPathForSelectedRow else { + return + } + tableView.deselectRow(at: selected, animated: true) + } + + // MARK: Actions + + @IBAction private func refresh() { + guard dataSource.canCustomizeEndpoint else { + return + } + initialAddress = dataSource.customAddress + initialProtocol = dataSource.customProtocol + itemRefresh.isEnabled = false + + modificationDelegate?.configurationShouldReinstall() + } + + // MARK: Helpers + + private func setNeedsRefresh() { + itemRefresh.isEnabled = (currentAddress != initialAddress) || (currentProtocol != initialProtocol) + } + + private func commitChanges() { + guard dataSource.canCustomizeEndpoint else { + return + } + + delegate?.endpointController(self, didUpdateWithNewAddress: currentAddress, newProtocol: currentProtocol) + } +} + +// MARK: - + +extension EndpointViewController: UITableViewDataSource, UITableViewDelegate { + enum SectionType { + case locationAddresses + + case locationProtocols + } + + enum RowType: Int { + case anyAddress + + case availableAddress + + case anyProtocol + + case availableProtocol + } + + private var selectedIndexPath: IndexPath? { + guard let i = endpointAddresses.index(where: { $0 == currentAddress }) else { + return nil + } + return IndexPath(row: i, section: 0) + } + + func numberOfSections(in tableView: UITableView) -> Int { + return model.count + } + + func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? { + return model.header(for: section) + } + + func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String? { + return model.footer(for: section) + } + + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return model.count(for: section) + } + + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let row = model.row(at: indexPath) + switch row { + case .anyAddress: + let cell = Cells.setting.dequeue(from: tableView, for: indexPath) + cell.leftText = L10n.Endpoint.Cells.AnyAddress.caption + cell.accessoryType = .none + cell.isTappable = true + if let _ = currentAddress { + cell.accessoryType = .none + } else { + cell.accessoryType = .checkmark + currentAddressIndexPath = indexPath + } + return cell + + case .availableAddress: + let address = endpointAddresses[mappedIndex(indexPath.row)] + let cell = Cells.setting.dequeue(from: tableView, for: indexPath) + cell.leftText = address + cell.accessoryType = .none + cell.isTappable = true + if address == currentAddress { + cell.accessoryType = .checkmark + currentAddressIndexPath = indexPath + } else { + cell.accessoryType = .none + } + return cell + + case .anyProtocol: + let cell = Cells.setting.dequeue(from: tableView, for: indexPath) + cell.leftText = L10n.Endpoint.Cells.AnyProtocol.caption + cell.accessoryType = .none + cell.isTappable = true + if let _ = currentProtocol { + cell.accessoryType = .none + } else { + cell.accessoryType = .checkmark + currentProtocolIndexPath = indexPath + } + return cell + + case .availableProtocol: + let proto = endpointProtocols[mappedIndex(indexPath.row)] + let cell = Cells.setting.dequeue(from: tableView, for: indexPath) + cell.leftText = proto.description + cell.accessoryType = .none + cell.isTappable = true + if proto == currentProtocol { + cell.accessoryType = .checkmark + currentProtocolIndexPath = indexPath + } else { + cell.accessoryType = .none + } + return cell + } + } + + func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + let row = model.row(at: indexPath) + var updatedIndexPaths: [IndexPath] = [indexPath] + + switch row { + case .anyAddress: + currentAddress = nil + if let old = currentAddressIndexPath { + updatedIndexPaths.append(old) + } + + case .availableAddress: + currentAddress = endpointAddresses[mappedIndex(indexPath.row)] + if let old = currentAddressIndexPath { + updatedIndexPaths.append(old) + } + + case .anyProtocol: + currentProtocol = nil + if let old = currentProtocolIndexPath { + updatedIndexPaths.append(old) + } + + case .availableProtocol: + currentProtocol = endpointProtocols[mappedIndex(indexPath.row)] + if let old = currentProtocolIndexPath { + updatedIndexPaths.append(old) + } + } + + setNeedsRefresh() + commitChanges() + tableView.reloadRows(at: updatedIndexPaths, with: .automatic) + } + + // MARK: Helpers + + private func mappedIndex(_ i: Int) -> Int { + if dataSource.canCustomizeEndpoint { + return i - 1 + } + return i + } +} diff --git a/Passepartout-iOS/Scenes/Organizer/AboutViewController.swift b/Passepartout-iOS/Scenes/Organizer/AboutViewController.swift new file mode 100644 index 00000000..cbfa1c75 --- /dev/null +++ b/Passepartout-iOS/Scenes/Organizer/AboutViewController.swift @@ -0,0 +1,203 @@ +// +// AboutViewController.swift +// Passepartout-iOS +// +// Created by Davide De Rosa on 9/28/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import UIKit + +class AboutViewController: UITableViewController, TableModelHost { + + // MARK: TableModelHost + + let model: TableModel = { + let model: TableModel = TableModel() + model.add(.info) + model.add(.source) + model.add(.feedback) + model.setHeader(L10n.About.Sections.Info.header, for: .info) + model.setHeader(L10n.About.Sections.Source.header, for: .source) + model.setHeader(L10n.About.Sections.Feedback.header, for: .feedback) + model.set([.version, .credits, .website], in: .info) + model.set([.sourcePassepartout, .sourceTunnelKit], in: .source) + model.set([.reportIssue, .writeReview], in: .feedback) + return model + }() + + func reloadModel() { + } + + // MARK: UIViewController + + override func awakeFromNib() { + super.awakeFromNib() + + applyDetailTitle(Theme.current) + } + + override func viewDidLoad() { + super.viewDidLoad() + + title = L10n.About.title + } + + // MARK: Actions + + private func showVersion() { + perform(segue: StoryboardSegue.Organizer.versionSegueIdentifier) + } + + private func showCredits() { + perform(segue: StoryboardSegue.Organizer.creditsSegueIdentifier) + } + + private func visitWebsite() { + UIApplication.shared.open(AppConstants.URLs.website, options: [:], completionHandler: nil) + } + + private func visitRepository(_ url: URL) { + UIApplication.shared.open(url, options: [:], completionHandler: nil) + } + + private func reportIssue() { + IssueReporter.shared.present(in: self) + } + + private func writeReview() { + let url = AppConstants.URLs.review(withId: GroupConstants.App.appId) + UIApplication.shared.open(url, options: [:], completionHandler: nil) + } + + @IBAction private func dismiss() { + dismiss(animated: true, completion: nil) + } +} + +// MARK: - + +extension AboutViewController { + enum SectionType: Int { + case info + + case source + + case feedback + } + + enum RowType: Int { + case version + + case credits + + case website + + case sourcePassepartout + + case sourceTunnelKit + + case writeReview + + case reportIssue + } + + override func numberOfSections(in tableView: UITableView) -> Int { + return model.count + } + + override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? { + return model.header(for: section) + } + + override func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String? { + return model.footer(for: section) + } + + override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return model.count(for: section) + } + + override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + switch model.row(at: indexPath) { + case .version: + let cell = Cells.setting.dequeue(from: tableView, for: indexPath) + cell.leftText = L10n.About.Cells.Version.caption + cell.rightText = Utils.versionString() + return cell + + case .credits: + let cell = Cells.setting.dequeue(from: tableView, for: indexPath) + cell.leftText = L10n.Credits.title + return cell + + case .website: + let cell = Cells.setting.dequeue(from: tableView, for: indexPath) + cell.leftText = L10n.About.Cells.Website.caption + return cell + + case .sourcePassepartout: + let cell = Cells.setting.dequeue(from: tableView, for: indexPath) + cell.leftText = GroupConstants.App.name + return cell + + case .sourceTunnelKit: + let cell = Cells.setting.dequeue(from: tableView, for: indexPath) + cell.leftText = GroupConstants.App.tunnelKitName + return cell + + case .reportIssue: + let cell = Cells.setting.dequeue(from: tableView, for: indexPath) + cell.leftText = L10n.IssueReporter.title + return cell + + case .writeReview: + let cell = Cells.setting.dequeue(from: tableView, for: indexPath) + cell.leftText = L10n.About.Cells.WriteReview.caption + return cell + } + } + + override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + switch model.row(at: indexPath) { + case .version: + showVersion() + + case .credits: + showCredits() + + case .website: + visitWebsite() + + case .sourcePassepartout: + visitRepository(AppConstants.Repos.passepartout) + + case .sourceTunnelKit: + visitRepository(AppConstants.Repos.tunnelKit) + + case .reportIssue: + reportIssue() + + case .writeReview: + writeReview() + } + tableView.deselectRow(at: indexPath, animated: true) + } +} diff --git a/Passepartout-iOS/Scenes/Organizer/CreditsViewController.swift b/Passepartout-iOS/Scenes/Organizer/CreditsViewController.swift new file mode 100644 index 00000000..f62b5d0c --- /dev/null +++ b/Passepartout-iOS/Scenes/Organizer/CreditsViewController.swift @@ -0,0 +1,62 @@ +// +// CreditsViewController.swift +// Passepartout-iOS +// +// Created by Davide De Rosa on 9/26/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import UIKit + +class CreditsViewController: UIViewController { + @IBOutlet private weak var scrollView: UIScrollView? + +// @IBOutlet private weak var labelTitle: UILabel? +// +// @IBOutlet private weak var labelIntro: UILabel? +// +// @IBOutlet private weak var buttonPassepartout: UIButton? +// +// @IBOutlet private weak var buttonTunnelKit: UIButton? + + @IBOutlet private weak var labelThirdParties: UILabel? + + override func awakeFromNib() { + super.awakeFromNib() + + applyDetailTitle(Theme.current) + } + + override func viewDidLoad() { + super.viewDidLoad() + + title = L10n.Credits.title +// labelIntro?.text = L10n.Credits.Labels.intro +// buttonPassepartout?.setTitle(L10n.Credits.Buttons.passepartout, for: .normal) +// buttonTunnelKit?.setTitle(L10n.Credits.Buttons.tunnelkit, for: .normal) + + var notices = AppConstants.Notices.all + notices.insert(L10n.Credits.Labels.thirdParties, at: 0) + labelThirdParties?.text = notices.joined(separator: "\n\n") + + scrollView?.applyPrimaryBackground(Theme.current) + labelThirdParties?.applyLight(Theme.current) + } +} diff --git a/Passepartout-iOS/Scenes/Organizer/OrganizerViewController.swift b/Passepartout-iOS/Scenes/Organizer/OrganizerViewController.swift new file mode 100644 index 00000000..580a6f6b --- /dev/null +++ b/Passepartout-iOS/Scenes/Organizer/OrganizerViewController.swift @@ -0,0 +1,399 @@ +// +// OrganizerViewController.swift +// Passepartout-iOS +// +// Created by Davide De Rosa on 9/2/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import UIKit + +// XXX: convoluted due to the separation of provider/host profiles + +class OrganizerViewController: UITableViewController, TableModelHost { + private let service = TransientStore.shared.service + + private var providerProfiles: [ProviderConnectionProfile] = [] + + private var hostProfiles: [HostConnectionProfile] = [] + + private var availableProviderNames: [Infrastructure.Name]? + + // MARK: TableModelHost + + let model: TableModel = { + let model: TableModel = TableModel() + model.add(.providers) + model.add(.hosts) + model.add(.about) + model.add(.destruction) + model.setHeader(L10n.Organizer.Sections.Providers.header, for: .providers) + model.setHeader(L10n.Organizer.Sections.Hosts.header, for: .hosts) + model.setFooter(L10n.Organizer.Sections.Providers.footer, for: .providers) + model.setFooter(L10n.Organizer.Sections.Hosts.footer, for: .hosts) + model.set([.openAbout], in: .about) + model.set([.uninstall], in: .destruction) + return model + }() + + func reloadModel() { + providerProfiles.removeAll() + hostProfiles.removeAll() + + service.profileIds().forEach { + let profile = service.profile(withId: $0) + if let p = profile as? ProviderConnectionProfile { + providerProfiles.append(p) + } else if let p = profile as? HostConnectionProfile { + hostProfiles.append(p) + } else { + fatalError("Unexpected profile type \(type(of: profile))") + } + } + providerProfiles.sort { $0.name.rawValue < $1.name.rawValue } + hostProfiles.sort { $0.title < $1.title } + + var providers = [RowType](repeating: .profile, count: providerProfiles.count) + var hosts = [RowType](repeating: .profile, count: hostProfiles.count) + providers.append(.addProvider) + hosts.append(.addHost) + + model.set(providers, in: .providers) + model.set(hosts, in: .hosts) + } + + // MARK: UIViewController + + override func awakeFromNib() { + super.awakeFromNib() + + applyMasterTitle(Theme.current) + } + + override func viewDidLoad() { + super.viewDidLoad() + + title = GroupConstants.App.title + navigationItem.rightBarButtonItem = editButtonItem + Cells.destructive.register(with: tableView) + reloadModel() + + tableView.reloadData() + if let ip = selectedIndexPath { + tableView.scrollToRow(at: ip, at: .middle, animated: false) + } + + service.delegate = self + } + + override func shouldPerformSegue(withIdentifier identifier: String, sender: Any?) -> Bool { + if let cell = sender as? UITableViewCell, let indexPath = tableView.indexPath(for: cell) { + return model.row(at: indexPath) == .profile + } + + // fall back to active profile if no selection + return service.hasActiveProfile() + } + + override func prepare(for segue: UIStoryboardSegue, sender: Any?) { + let destination = (segue.destination as? UINavigationController)?.topViewController + + if let vc = destination as? ServiceViewController { + var selectedProfile: ConnectionProfile? + + // XXX: sender can be a cell or a profile + selectedProfile = sender as? ConnectionProfile + if selectedProfile == nil, let cell = sender as? UITableViewCell, let indexPath = tableView.indexPath(for: cell) { + selectedProfile = profile(at: indexPath) + } + assert(selectedProfile != nil, "No selected profile") + + vc.profile = selectedProfile + } else if let vc = destination as? Wizard { + if let providerVC = vc as? WizardProviderViewController { + providerVC.availableNames = availableProviderNames ?? [] + } + vc.delegate = self + } + } + + // MARK: Actions + + @IBAction private func about() { + perform(segue: StoryboardSegue.Organizer.aboutSegueIdentifier, sender: nil) + } + + private func addNewProvider() { + var names = Set(InfrastructureFactory.shared.allNames) + let createdNames = providerProfiles.map { $0.name } + names.formSymmetricDifference(createdNames) + + guard !names.isEmpty else { + let alert = Macros.alert( + L10n.Organizer.Sections.Providers.header, + L10n.Organizer.Alerts.ExhaustedProviders.message + ) + alert.addCancelAction(L10n.Global.ok) + present(alert, animated: true, completion: nil) + return + } + + availableProviderNames = names.sorted { $0.rawValue < $1.rawValue } + perform(segue: StoryboardSegue.Organizer.addProviderSegueIdentifier) + } + + private func addNewHost() { + let alert = Macros.alert( + L10n.Organizer.Sections.Hosts.header, + L10n.Organizer.Alerts.AddHost.message + ) + alert.addCancelAction(L10n.Global.ok) + present(alert, animated: true, completion: nil) + } + + private func removeProfile(at indexPath: IndexPath) { + let sectionObject = model.section(for: indexPath.section) + let rowProfile = profile(at: indexPath) + switch sectionObject { + case .providers: + providerProfiles.remove(at: indexPath.row) + + case .hosts: + hostProfiles.remove(at: indexPath.row) + + default: + return + } + +// var fallbackSection: SectionType? + + let total = providerProfiles.count + hostProfiles.count + + // removed all profiles + if total == 0 { + VPN.shared.disconnect(completionHandler: nil) + } + // removed active profile + else if service.isActiveProfile(rowProfile) { +// let anyProvider = providerProfiles.first +// let anyHost = hostProfiles.first +// guard let anyProfile: ConnectionProfile = firstProvider ?? firstHost else { +// fatalError("There must be one profile somewhere") +// } +// fallbackSection = (anyProvider != nil) ? .providers : .hosts +// store.service.activateProfile(only) + VPN.shared.disconnect(completionHandler: nil) + } + + tableView.beginUpdates() + model.deleteRow(in: sectionObject, at: indexPath.row) + tableView.deleteRows(at: [indexPath], with: .automatic) +// if let fallbackSection = fallbackSection { +// let section = model.index(ofSection: fallbackSection) +// tableView.reloadRows(at: [IndexPath(row: 0, section: section)], with: .none) +// } + tableView.endUpdates() + + let _ = service.removeProfile(rowProfile) + splitViewController?.serviceViewController?.hideProfileIfDeleted() + TransientStore.shared.serialize() // delete + } + + private func confirmVpnProfileDeletion() { + let alert = Macros.alert( + L10n.Organizer.Cells.Uninstall.caption, + L10n.Organizer.Alerts.DeleteVpnProfile.message + ) + alert.addDefaultAction(L10n.Global.ok) { + VPN.shared.uninstall(completionHandler: nil) + } + alert.addCancelAction(L10n.Global.cancel) + present(alert, animated: true, completion: nil) + } +} + +// MARK: - + +extension OrganizerViewController { + enum SectionType: Int { + case providers + + case hosts + + case about + + case destruction + } + + enum RowType: Int { + case profile + + case addProvider + + case addHost + + case openAbout + + case uninstall + } + + private var selectedIndexPath: IndexPath? { + guard let active = service.activeProfile?.id else { + return nil + } + if let row = providerProfiles.index(where: { $0.id == active }) { + return IndexPath(row: row, section: 0) + } + if let row = hostProfiles.index(where: { $0.id == active }) { + return IndexPath(row: row, section: 1) + } + return nil + } + + override func numberOfSections(in tableView: UITableView) -> Int { + return model.count + } + + override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? { + return model.header(for: section) + } + + override func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String? { + return model.footer(for: section) + } + + override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return model.count(for: section) + } + + override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + switch model.row(at: indexPath) { + case .profile: + let cell = Cells.setting.dequeue(from: tableView, for: indexPath) + let rowProfile = profile(at: indexPath) + cell.leftText = rowProfile.title + cell.accessoryType = service.isActiveProfile(rowProfile) ? .checkmark : .none + return cell + + case .addProvider: + let cell = Cells.setting.dequeue(from: tableView, for: indexPath) + cell.applyAction(Theme.current) + cell.leftText = L10n.Organizer.Cells.AddProvider.caption + return cell + + case .addHost: + let cell = Cells.setting.dequeue(from: tableView, for: indexPath) + cell.applyAction(Theme.current) + cell.leftText = L10n.Organizer.Cells.AddHost.caption + return cell + + case .openAbout: + let cell = Cells.setting.dequeue(from: tableView, for: indexPath) + cell.leftText = L10n.Organizer.Cells.About.caption(GroupConstants.App.name) + return cell + + case .uninstall: + let cell = Cells.destructive.dequeue(from: tableView, for: indexPath) + cell.caption = L10n.Organizer.Cells.Uninstall.caption + return cell + } + } + + override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + switch model.row(at: indexPath) { + case .profile: +// selectedProfileId = profile(at: indexPath).id + break + + case .addProvider: + addNewProvider() + + case .addHost: + addNewHost() + + case .openAbout: + about() + + case .uninstall: + confirmVpnProfileDeletion() + } + tableView.deselectRow(at: indexPath, animated: true) + } + + override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool { + guard tableView.isEditing else { + return false + } + return model.row(at: indexPath) == .profile + } + + override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) { + removeProfile(at: indexPath) + } + + // MARK: Helpers + + private func sectionProfiles(at indexPath: IndexPath) -> [ConnectionProfile] { + let sectionProfiles: [ConnectionProfile] + let sectionObject = model.section(for: indexPath.section) + switch sectionObject { + case .providers: + sectionProfiles = providerProfiles + + case .hosts: + sectionProfiles = hostProfiles + + default: + fatalError("Unexpected section: \(sectionObject)") + } + guard indexPath.row < sectionProfiles.count else { + fatalError("No profile found at \(indexPath), is it an add cell?") + } + return sectionProfiles + } + + private func profile(at indexPath: IndexPath) -> ConnectionProfile { + return sectionProfiles(at: indexPath)[indexPath.row] + } +} + +// MARK: - + +extension OrganizerViewController: ConnectionServiceDelegate { + func connectionService(didDeactivate profile: ConnectionProfile) { + tableView.reloadData() + } + + func connectionService(didActivate profile: ConnectionProfile) { + tableView.reloadData() + } +} + +extension OrganizerViewController: WizardDelegate { + func wizard(didCreate profile: ConnectionProfile, withCredentials credentials: Credentials) { + service.addOrReplaceProfile(profile, credentials: credentials) + TransientStore.shared.serialize() // add + + reloadModel() + tableView.reloadData() + + perform(segue: StoryboardSegue.Organizer.selectProfileSegueIdentifier, sender: profile) + } +} diff --git a/Passepartout-iOS/Scenes/Organizer/VersionViewController.swift b/Passepartout-iOS/Scenes/Organizer/VersionViewController.swift new file mode 100644 index 00000000..3513abfc --- /dev/null +++ b/Passepartout-iOS/Scenes/Organizer/VersionViewController.swift @@ -0,0 +1,66 @@ +// +// VersionViewController.swift +// Passepartout-iOS +// +// Created by Davide De Rosa on 9/27/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import UIKit + +class VersionViewController: UIViewController { + @IBOutlet private weak var scrollView: UIScrollView? + + @IBOutlet private weak var labelTitle: UILabel? + + @IBOutlet private weak var labelVersion: UILabel? + + @IBOutlet private weak var labelCopyright: UILabel? + + @IBOutlet private weak var labelIntro: UILabel? + + @IBOutlet private weak var buttonChangelog: UIButton? + + override func awakeFromNib() { + super.awakeFromNib() + + applyDetailTitle(Theme.current) + } + + override func viewDidLoad() { + super.viewDidLoad() + + labelTitle?.text = GroupConstants.App.name + labelVersion?.text = Utils.versionString() + labelCopyright?.text = GroupConstants.App.name + labelIntro?.text = L10n.Version.Labels.intro + buttonChangelog?.setTitle(L10n.Version.Buttons.changelog, for: .normal) + + scrollView?.applyPrimaryBackground(Theme.current) + for label in [labelTitle, labelVersion, labelCopyright, labelIntro] { + label?.applyLight(Theme.current) + } + buttonChangelog?.apply(Theme.current) + } + + @IBAction private func visitChangelog() { + UIApplication.shared.open(AppConstants.URLs.changelog, options: [:], completionHandler: nil) + } +} diff --git a/Passepartout-iOS/Scenes/Organizer/WizardHostViewController.swift b/Passepartout-iOS/Scenes/Organizer/WizardHostViewController.swift new file mode 100644 index 00000000..37788e92 --- /dev/null +++ b/Passepartout-iOS/Scenes/Organizer/WizardHostViewController.swift @@ -0,0 +1,267 @@ +// +// WizardHostViewController.swift +// Passepartout-iOS +// +// Created by Davide De Rosa on 9/4/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import UIKit +import TunnelKit +import SwiftyBeaver + +private let log = SwiftyBeaver.self + +class WizardHostViewController: UITableViewController, TableModelHost, Wizard { + private struct ParsedFile { + let filename: String + + let hostname: String + + let configuration: TunnelKitProvider.Configuration + } + + @IBOutlet private weak var itemNext: UIBarButtonItem! + + private let existingHosts: [HostConnectionProfile] = { + var hosts: [HostConnectionProfile] = [] + let service = TransientStore.shared.service + let ids = service.profileIds() + for id in ids { + guard let host = service.profile(withId: id) as? HostConnectionProfile else { + continue + } + hosts.append(host) + } + return hosts.sorted { $0.title < $1.title } + }() + + private var parsedFile: ParsedFile? { + didSet { + useSuggestedTitle() + } + } + + private var createdProfile: HostConnectionProfile? + + weak var delegate: WizardDelegate? + + // MARK: TableModelHost + + lazy var model: TableModel = { + let model: TableModel = TableModel() + model.add(.meta) + if !existingHosts.isEmpty { + model.add(.existing) + model.setHeader(L10n.Wizards.Host.Sections.Existing.header, for: .existing) + } + model.set([.titleInput], in: .meta) + model.set(.existingHost, count: existingHosts.count, in: .existing) + return model + }() + + func reloadModel() { + } + + // MARK: UIViewController + + override func viewDidLoad() { + super.viewDidLoad() + + title = L10n.Organizer.Sections.Hosts.header + itemNext.title = L10n.Global.next + } + + override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(animated) + + useSuggestedTitle() + } + + override func viewDidAppear(_ animated: Bool) { + super.viewDidAppear(animated) + + cellTitle?.field.becomeFirstResponder() + } + + // MARK: Actions + + func setConfigurationURL(_ url: URL) throws { + log.debug("Parsing configuration URL: \(url)") + + let filename = url.deletingPathExtension().lastPathComponent + let hostname: String + let configuration: TunnelKitProvider.Configuration + do { + (hostname, configuration) = try TunnelKitProvider.Configuration.parsed(from: url) + } catch let e { + log.error("Could not parse .ovpn configuration file: \(e)") + throw e + } + parsedFile = ParsedFile(filename: filename, hostname: hostname, configuration: configuration) + } + + private func useSuggestedTitle() { + guard let field = cellTitle?.field else { + return + } + if field.text?.isEmpty ?? true { + field.text = parsedFile?.filename + } + } + + @IBAction private func next() { + guard let enteredTitle = cellTitle?.field.text?.trimmingCharacters(in: .whitespaces), !enteredTitle.isEmpty else { + return + } + guard let file = parsedFile else { + return + } + + let profile = HostConnectionProfile(title: enteredTitle, hostname: file.hostname) + profile.parameters = file.configuration + + guard !TransientStore.shared.service.containsProfile(profile) else { + let alert = Macros.alert(title, L10n.Wizards.Host.Alerts.existing) + alert.addDefaultAction(L10n.Global.ok) { + self.next(withProfile: profile) + } + alert.addCancelAction(L10n.Global.cancel) + present(alert, animated: true, completion: nil) + return + } + next(withProfile: profile) + } + + private func next(withProfile profile: HostConnectionProfile) { + createdProfile = profile + + let accountVC = StoryboardScene.Main.accountIdentifier.instantiate() + accountVC.delegate = self + navigationController?.pushViewController(accountVC, animated: true) + } + + private func finish(withCredentials credentials: Credentials) { + guard let profile = createdProfile else { + fatalError("No profile created?") + } + dismiss(animated: true) { + self.delegate?.wizard(didCreate: profile, withCredentials: credentials) + } + } + + @IBAction private func close() { + dismiss(animated: true, completion: nil) + } +} + +// MARK: - + +extension WizardHostViewController { + enum SectionType: Int { + case meta + + case existing + } + + enum RowType: Int { + case titleInput + + case existingHost + } + + private var cellTitle: FieldTableViewCell? { + guard let ip = model.indexPath(row: .titleInput, section: .meta) else { + return nil + } + return tableView.cellForRow(at: ip) as? FieldTableViewCell + } + + override func numberOfSections(in tableView: UITableView) -> Int { + return model.count + } + + override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? { + return model.header(for: section) + } + + override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return model.count(for: section) + } + + override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + switch model.row(at: indexPath) { + case .titleInput: + let cell = Cells.field.dequeue(from: tableView, for: indexPath) + cell.caption = L10n.Wizards.Host.Cells.TitleInput.caption + cell.captionWidth = 100.0 + cell.field.placeholder = L10n.Wizards.Host.Cells.TitleInput.placeholder + cell.field.clearButtonMode = .always + cell.field.returnKeyType = .done + cell.delegate = self + return cell + + case .existingHost: + let profile = existingHosts[indexPath.row] + + let cell = Cells.setting.dequeue(from: tableView, for: indexPath) + cell.leftText = profile.title + cell.accessoryType = .none + cell.isTappable = true + return cell + } + } + + override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + switch model.row(at: indexPath) { + case .existingHost: + guard let titleIndexPath = model.indexPath(row: .titleInput, section: .meta) else { + fatalError("Could not found title cell?") + } + let profile = existingHosts[indexPath.row] + let cellTitle = tableView.cellForRow(at: titleIndexPath) as? FieldTableViewCell + cellTitle?.field.text = profile.title + tableView.deselectRow(at: indexPath, animated: true) + + default: + break + } + } +} + +// MARK: - + +extension WizardHostViewController: FieldTableViewCellDelegate { + func fieldCellDidEdit(_: FieldTableViewCell) { + } + + func fieldCellDidEnter(_: FieldTableViewCell) { + next() + } +} + +extension WizardHostViewController: AccountViewControllerDelegate { + func accountController(_: AccountViewController, didEnterCredentials credentials: Credentials) { + } + + func accountControllerDidComplete(_ vc: AccountViewController) { + finish(withCredentials: vc.credentials) + } +} diff --git a/Passepartout-iOS/Scenes/Organizer/WizardProviderViewController.swift b/Passepartout-iOS/Scenes/Organizer/WizardProviderViewController.swift new file mode 100644 index 00000000..05e5c4d3 --- /dev/null +++ b/Passepartout-iOS/Scenes/Organizer/WizardProviderViewController.swift @@ -0,0 +1,96 @@ +// +// WizardProviderViewController.swift +// Passepartout-iOS +// +// Created by Davide De Rosa on 9/4/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import UIKit + +class WizardProviderViewController: UITableViewController, Wizard { + var availableNames: [Infrastructure.Name] = [] + + private var createdProfile: ProviderConnectionProfile? + + weak var delegate: WizardDelegate? + + override func viewDidLoad() { + super.viewDidLoad() + + title = L10n.Organizer.Sections.Providers.header + } + + private func next(withName name: Infrastructure.Name) { + let profile = ProviderConnectionProfile(name: name) + createdProfile = profile + + let accountVC = StoryboardScene.Main.accountIdentifier.instantiate() + let infrastructure = InfrastructureFactory.shared.get(name) + accountVC.usernamePlaceholder = infrastructure.defaults.username + accountVC.infrastructureName = infrastructure.name + accountVC.delegate = self + navigationController?.pushViewController(accountVC, animated: true) + } + + private func finish(withCredentials credentials: Credentials) { + guard let profile = createdProfile else { + fatalError("No profile created?") + } + dismiss(animated: true) { + self.delegate?.wizard(didCreate: profile, withCredentials: credentials) + } + } + + @IBAction private func close() { + dismiss(animated: true, completion: nil) + } +} + +// MARK: - + +extension WizardProviderViewController { + override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return availableNames.count + } + + override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let name = availableNames[indexPath.row] + let cell = Cells.setting.dequeue(from: tableView, for: indexPath) + cell.leftText = name.rawValue + return cell + } + + override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + let name = availableNames[indexPath.row] + next(withName: name) + } +} + +// MARK: - + +extension WizardProviderViewController: AccountViewControllerDelegate { + func accountController(_: AccountViewController, didEnterCredentials credentials: Credentials) { + } + + func accountControllerDidComplete(_ vc: AccountViewController) { + finish(withCredentials: vc.credentials) + } +} diff --git a/Passepartout-iOS/Scenes/ProviderPoolViewController.swift b/Passepartout-iOS/Scenes/ProviderPoolViewController.swift new file mode 100644 index 00000000..fb3346a7 --- /dev/null +++ b/Passepartout-iOS/Scenes/ProviderPoolViewController.swift @@ -0,0 +1,90 @@ +// +// ProviderPoolViewController.swift +// Passepartout-iOS +// +// Created by Davide De Rosa on 6/12/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import UIKit + +protocol ProviderPoolViewControllerDelegate: class { + func providerPoolController(_: ProviderPoolViewController, didSelectPool pool: Pool) +} + +class ProviderPoolViewController: UIViewController { + @IBOutlet private weak var tableView: UITableView! + + var pools: [Pool] = [] + + var currentPoolId: String? + + weak var delegate: ProviderPoolViewControllerDelegate? + + // MARK: UIViewController + + override func awakeFromNib() { + super.awakeFromNib() + + applyDetailTitle(Theme.current) + } + + override func viewDidLoad() { + super.viewDidLoad() + + title = L10n.Service.Cells.Provider.Pool.caption + tableView.reloadData() + if let ip = selectedIndexPath { + tableView.scrollToRow(at: ip, at: .middle, animated: false) + } + } +} + +// MARK: - + +extension ProviderPoolViewController: UITableViewDataSource, UITableViewDelegate { + private var selectedIndexPath: IndexPath? { + guard let row = pools.index(where: { $0.id == currentPoolId }) else { + return nil + } + return IndexPath(row: row, section: 0) + } + + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return pools.count + } + + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let pool = pools[indexPath.row] + + let cell = Cells.setting.dequeue(from: tableView, for: indexPath) + cell.leftText = pool.name +// cell.rightText = pool.country + cell.accessoryType = (pool.id == currentPoolId) ? .checkmark : .none + cell.isTappable = true + return cell + } + + func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + let pool = pools[indexPath.row] + currentPoolId = pool.id + delegate?.providerPoolController(self, didSelectPool: pool) + } +} diff --git a/Passepartout-iOS/Scenes/ProviderPresetViewController.swift b/Passepartout-iOS/Scenes/ProviderPresetViewController.swift new file mode 100644 index 00000000..4f534590 --- /dev/null +++ b/Passepartout-iOS/Scenes/ProviderPresetViewController.swift @@ -0,0 +1,136 @@ +// +// ProviderPresetViewController.swift +// Passepartout-iOS +// +// Created by Davide De Rosa on 9/2/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import UIKit + +protocol ProviderPresetViewControllerDelegate: class { + func providerPresetController(_: ProviderPresetViewController, didSelectPreset preset: InfrastructurePreset) +} + +class ProviderPresetViewController: UIViewController { + @IBOutlet private weak var tableView: UITableView! + + var presets: [InfrastructurePreset] = [] + + var currentPresetId: String? + + weak var delegate: ProviderPresetViewControllerDelegate? + + // MARK: Table + + private let rows: [RowType] = [.presetDescription, .techDetails] + + // MARK: UIViewController + + override func awakeFromNib() { + super.awakeFromNib() + + applyDetailTitle(Theme.current) + } + + override func viewDidLoad() { + super.viewDidLoad() + + title = L10n.Service.Cells.Provider.Preset.caption + tableView.reloadData() + if let ip = selectedIndexPath { + tableView.scrollToRow(at: ip, at: .middle, animated: false) + } + } + + override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(animated) + + if let ip = tableView.indexPathForSelectedRow { + tableView.deselectRow(at: ip, animated: true) + } + } +} + +extension ProviderPresetViewController: UITableViewDataSource, UITableViewDelegate { + enum RowType: Int { + case presetDescription + + case techDetails + } + + private var selectedIndexPath: IndexPath? { + guard let i = presets.index(where: { $0.id == currentPresetId }) else { + return nil + } + return IndexPath(row: 0, section: i) + } + + func numberOfSections(in tableView: UITableView) -> Int { + return presets.count + } + + func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? { + let preset = presets[section] + return preset.name + } + +// func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String? { +// return L10n.Provider.Preset.Sections.Main.footer +// } + + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return rows.count + } + + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let preset = presets[indexPath.section] + + let cell = Cells.setting.dequeue(from: tableView, for: indexPath) + cell.isTappable = true + switch rows[indexPath.row] { + case .presetDescription: + cell.leftText = preset.comment + cell.accessoryType = (preset.id == currentPresetId) ? .checkmark : .none + + case .techDetails: + cell.applyAction(Theme.current) + cell.leftText = L10n.Provider.Preset.Cells.TechDetails.caption + cell.accessoryType = .none + } + return cell + } + + func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + let preset = presets[indexPath.section] + + switch rows[indexPath.row] { + case .presetDescription: + currentPresetId = preset.id + delegate?.providerPresetController(self, didSelectPreset: preset) + + case .techDetails: + let vc = StoryboardScene.Main.configurationIdentifier.instantiate() + vc.title = preset.name + vc.initialConfiguration = preset.configuration + navigationController?.pushViewController(vc, animated: true) + } + } +} diff --git a/Passepartout-iOS/Scenes/ServiceViewController.swift b/Passepartout-iOS/Scenes/ServiceViewController.swift new file mode 100644 index 00000000..825b55c9 --- /dev/null +++ b/Passepartout-iOS/Scenes/ServiceViewController.swift @@ -0,0 +1,1028 @@ +// +// ServiceViewController.swift +// Passepartout-iOS +// +// Created by Davide De Rosa on 6/6/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import UIKit +import NetworkExtension +import CoreTelephony +import TunnelKit + +class ServiceViewController: UIViewController, TableModelHost { + @IBOutlet private weak var tableView: UITableView! + + @IBOutlet private weak var viewWelcome: UIView! + + @IBOutlet private weak var labelWelcome: UILabel! + + var profile: ConnectionProfile? { + didSet { + title = profile?.title + reloadModel() + updateViewsIfNeeded() + } + } + + private let service = TransientStore.shared.service + + private lazy var vpn = GracefulVPN(service: service) + + private var lastInfrastructureUpdate: Date? + + // MARK: Table + + var model: TableModel = TableModel() + + private let trustedNetworks = TrustedNetworksModel() + + // MARK: UIViewController + + deinit { + NotificationCenter.default.removeObserver(self) + } + + override func awakeFromNib() { + super.awakeFromNib() + + applyDetailTitle(Theme.current) + } + + override func viewDidLoad() { + super.viewDidLoad() + + // fall back to active profile + if profile == nil { + profile = service.activeProfile + } + if let providerProfile = profile as? ProviderConnectionProfile { + lastInfrastructureUpdate = InfrastructureFactory.shared.modificationDate(for: providerProfile.name) + } + + title = profile?.title + navigationItem.leftBarButtonItem = splitViewController?.displayModeButtonItem + navigationItem.leftItemsSupplementBackButton = true + + labelWelcome.text = L10n.Service.Welcome.message + labelWelcome.apply(Theme.current) + + let nc = NotificationCenter.default + nc.addObserver(self, selector: #selector(applicationDidBecomeActive), name: UIApplication.didBecomeActiveNotification, object: nil) + nc.addObserver(self, selector: #selector(vpnDidUpdate), name: .VPNDidChangeStatus, object: nil) + + // run this no matter what + // XXX: convenient here vs AppDelegate for updating table + vpn.prepare(withProfile: profile) { +// self.reloadVpnStatus() + self.tableView.reloadData() + } + + updateViewsIfNeeded() + } + + override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(animated) + + hideProfileIfDeleted() + } + + override func viewDidAppear(_ animated: Bool) { + super.viewDidAppear(animated) + + clearSelection() + } + + override func didReceiveMemoryWarning() { + super.didReceiveMemoryWarning() + // Dispose of any resources that can be recreated. + } + + override func prepare(for segue: UIStoryboardSegue, sender: Any?) { + guard let sid = segue.identifier, let segueType = StoryboardSegue.Main(rawValue: sid) else { + return + } + + let destination = segue.destination + + switch segueType { + case .accountSegueIdentifier: + let vc = destination as? AccountViewController + vc?.currentCredentials = service.credentials(for: uncheckedProfile) + vc?.usernamePlaceholder = (profile as? ProviderConnectionProfile)?.infrastructure.defaults.username + vc?.infrastructureName = (profile as? ProviderConnectionProfile)?.infrastructure.name + vc?.delegate = self + + case .providerPoolSegueIdentifier: + let vc = destination as? ProviderPoolViewController + vc?.pools = uncheckedProviderProfile.sortedPools() + vc?.currentPoolId = uncheckedProviderProfile.poolId + vc?.delegate = self + + case .endpointSegueIdentifier: + let vc = destination as? EndpointViewController + vc?.dataSource = profile + vc?.delegate = self + vc?.modificationDelegate = self + + case .providerPresetSegueIdentifier: + let vc = destination as? ProviderPresetViewController + vc?.presets = uncheckedProviderProfile.infrastructure.presets + vc?.currentPresetId = uncheckedProviderProfile.presetId + vc?.delegate = self + + case .hostParametersSegueIdentifier: + let vc = destination as? ConfigurationViewController + vc?.title = L10n.Service.Cells.Host.Parameters.caption + vc?.initialConfiguration = uncheckedHostProfile.parameters + vc?.isEditable = true + vc?.delegate = self + + case .debugLogSegueIdentifier: + break + } + } + + // MARK: Actions + + func hideProfileIfDeleted() { + guard let profile = profile else { + return + } + if !service.containsProfile(profile) { + self.profile = nil + } + } + + // XXX: outlets can be nil here! + private func updateViewsIfNeeded() { + tableView?.reloadData() + viewWelcome?.isHidden = (profile != nil) + } + + @IBAction private func activate() { + service.activateProfile(uncheckedProfile) + TransientStore.shared.serialize() // activate + + reloadModel() + tableView.reloadData() + + vpn.disconnect(completionHandler: nil) + } + + private func toggleVpnService(cell: ToggleTableViewCell) { + if cell.isOn { + guard service.canActivate(uncheckedProfile) else { + let alert = Macros.alert( + L10n.Service.Sections.Vpn.header, + L10n.Service.Alerts.ConfigurationNeeded.message + ) + alert.addCancelAction(L10n.Global.ok) { + cell.setOn(false, animated: true) + } + present(alert, animated: true, completion: nil) + return + } + vpn.reconnect { (error) in + guard error == nil else { + cell.setOn(false, animated: true) + return + } + self.reloadVpnStatus() + } + } else { + vpn.disconnect { (error) in + self.reloadVpnStatus() + } + } + } + + private func confirmVpnReconnection() { + guard vpn.status == .disconnected else { + let alert = Macros.alert( + L10n.Service.Cells.ConnectionStatus.caption, + L10n.Service.Alerts.ReconnectVpn.message + ) + alert.addDefaultAction(L10n.Global.ok) { + self.vpn.reconnect(completionHandler: nil) + } + alert.addCancelAction(L10n.Global.cancel) + present(alert, animated: true, completion: nil) + return + } + vpn.reconnect(completionHandler: nil) + } + + private func refreshProviderInfrastructure() { + let hud = HUD() + let isUpdating = InfrastructureFactory.shared.update(uncheckedProviderProfile.name, notBeforeInterval: AppConstants.Providers.minimumUpdateInterval) { (response, error) in + hud.hide() + guard let response = response else { + return + } + self.lastInfrastructureUpdate = response.1 + self.tableView.reloadData() + } + if !isUpdating { + hud.hide() + } + } + + private func toggleDisconnectsOnSleep(_ isOn: Bool) { + service.preferences.disconnectsOnSleep = !isOn + if vpn.isEnabled { + vpn.reinstall(completionHandler: nil) + } + } + + private func toggleResolvesHostname(_ isOn: Bool) { + service.preferences.resolvesHostname = isOn + if vpn.isEnabled { + guard vpn.status == .disconnected else { + confirmVpnReconnection() + return + } + vpn.reinstall(completionHandler: nil) + } + } + + private func toggleRetainTrustedConnection(_ isOn: Bool, sender: ToggleTableViewCell) { + let completionHandler: () -> Void = { + self.service.preferences.trustPolicy = isOn ? .ignore : .disconnect + if self.vpn.isEnabled { + self.vpn.reinstall(completionHandler: nil) + } + } + + guard !isOn else { + completionHandler() + return + } + let alert = Macros.alert( + L10n.Service.Sections.Trusted.header, + L10n.Service.Alerts.Trusted.WillDisconnectPolicy.message + ) + alert.addDefaultAction(L10n.Global.ok) { + completionHandler() + } + alert.addCancelAction(L10n.Global.cancel) { + sender.setOn(true, animated: true) + } + present(alert, animated: true, completion: nil) + } + + private func confirmPotentialTrustedDisconnection(at rowIndex: Int?, completionHandler: @escaping () -> Void) { + let alert = Macros.alert( + L10n.Service.Sections.Trusted.header, + L10n.Service.Alerts.Trusted.WillDisconnectTrusted.message + ) + alert.addDefaultAction(L10n.Global.ok) { + completionHandler() + } + alert.addCancelAction(L10n.Global.cancel) { + guard let rowIndex = rowIndex else { + return + } + let indexPath = IndexPath(row: rowIndex, section: self.trustedSectionIndex) + let cell = self.tableView.cellForRow(at: indexPath) as? ToggleTableViewCell + cell?.setOn(false, animated: true) + } + present(alert, animated: true, completion: nil) + } + + private func testInternetConnectivity() { + let hud = HUD() + Utils.checkConnectivityURL(AppConstants.VPN.connectivityURL, timeout: AppConstants.VPN.connectivityTimeout) { + hud.hide() + + let V = L10n.Service.Alerts.TestConnectivity.Messages.self + let alert = Macros.alert( + L10n.Service.Alerts.TestConnectivity.title, + $0 ? V.success : V.failure + ) + alert.addCancelAction(L10n.Global.ok) + self.present(alert, animated: true, completion: nil) + } + } + + private func displayDataCount() { + guard vpn.isEnabled else { + let alert = Macros.alert( + L10n.Service.Cells.DataCount.caption, + L10n.Service.Alerts.DataCount.Messages.notAvailable + ) + alert.addCancelAction(L10n.Global.ok) + present(alert, animated: true, completion: nil) + return + } + + vpn.requestBytesCount { + let message: String + if let count = $0 { + message = L10n.Service.Alerts.DataCount.Messages.current(Int(count.0), Int(count.1)) + } else { + message = L10n.Service.Alerts.DataCount.Messages.notAvailable + } + let alert = Macros.alert( + L10n.Service.Cells.DataCount.caption, + message + ) + alert.addCancelAction(L10n.Global.ok) + self.present(alert, animated: true, completion: nil) + } + } + + private func reportIssue() { + IssueReporter.shared.present(in: self) + } + + // MARK: Notifications + + @objc private func vpnDidUpdate() { + reloadVpnStatus() + } + + @objc private func applicationDidBecomeActive() { + reloadVpnStatus() + } +} + +// MARK: - + +extension ServiceViewController: UITableViewDataSource, UITableViewDelegate, ToggleTableViewCellDelegate { + enum SectionType { + case vpn + + case authentication + + case hostProfile + + case configuration + + case providerInfrastructure + + case vpnResolvesHostname + + case vpnSurvivesSleep + + case trusted + + case trustedPolicy + + case diagnostics + + case contacts + } + + enum RowType: Int { + case vpnService + + case connectionStatus + + case useProfile + + case account + + case endpoint + + case providerPool + + case providerPreset + + case providerRefresh + + case hostParameters + + case vpnResolvesHostname + + case vpnSurvivesSleep + + case trustedMobile + + case trustedWiFi + + case trustedAddCurrentWiFi + + case trustedPolicy + + case testConnectivity + + case dataCount + + case debugLog + + case reportIssue + } + + private var trustedSectionIndex: Int { + return model.index(ofSection: .trusted) + } + + private var serviceIndexPath: IndexPath { + guard let ip = model.indexPath(row: .vpnService, section: .vpn) else { + fatalError("Could not locate serviceIndexPath") + } + return ip + } + + private var statusIndexPath: IndexPath { + guard let ip = model.indexPath(row: .connectionStatus, section: .vpn) else { + fatalError("Could not locate statusIndexPath") + } + return ip + } + + private var endpointIndexPath: IndexPath { + guard let ip = model.indexPath(row: .endpoint, section: .configuration) else { + fatalError("Could not locate endpointIndexPath") + } + return ip + } + + private var providerPresetIndexPath: IndexPath { + guard let ip = model.indexPath(row: .providerPreset, section: .configuration) else { + fatalError("Could not locate providerPresetIndexPath") + } + return ip + } + + func numberOfSections(in tableView: UITableView) -> Int { + return model.count + } + + func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? { + return model.header(for: section) + } + + func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { + guard let title = model.header(for: section) else { + return 1.0 + } + guard !title.isEmpty else { + return 0.0 + } + return UITableView.automaticDimension + } + + func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String? { + let rows = model.rows(for: section) + if rows.contains(.providerRefresh), let date = lastInfrastructureUpdate { + return L10n.Service.Sections.ProviderInfrastructure.footer(date.timestamp) + } + return model.footer(for: section) + } + + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return model.count(for: section) + } + + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let row = model.row(at: indexPath) + switch row { + case .vpnService: + guard service.isActiveProfile(uncheckedProfile) else { + fatalError("Do not show vpnService in non-active profile") + } + + let cell = Cells.toggle.dequeue(from: tableView, for: indexPath, tag: row.rawValue, delegate: self) + cell.caption = L10n.Service.Cells.VpnService.caption + cell.isOn = vpn.isEnabled + return cell + + case .connectionStatus: + guard service.isActiveProfile(uncheckedProfile) else { + fatalError("Do not show connectionStatus in non-active profile") + } + + let cell = Cells.setting.dequeue(from: tableView, for: indexPath) + cell.applyVPN(Theme.current, with: vpn.isEnabled ? vpn.status : nil) + cell.leftText = L10n.Service.Cells.ConnectionStatus.caption + cell.accessoryType = .none + cell.isTappable = service.canActivate(uncheckedProfile) && vpn.isEnabled + return cell + + case .useProfile: + let cell = Cells.setting.dequeue(from: tableView, for: indexPath) + cell.applyAction(Theme.current) + cell.leftText = L10n.Service.Cells.UseProfile.caption + return cell + + // shared cells + + case .account: + let cell = Cells.setting.dequeue(from: tableView, for: indexPath) + cell.leftText = L10n.Service.Cells.Account.caption + cell.rightText = profile?.username + return cell + + case .endpoint: + let cell = Cells.setting.dequeue(from: tableView, for: indexPath) + cell.leftText = L10n.Service.Cells.Endpoint.caption + + let V = L10n.Service.Cells.Endpoint.Value.self + if let provider = profile as? ProviderConnectionProfile { + cell.rightText = provider.usesProviderEndpoint ? V.manual : V.automatic + } else { + cell.rightText = profile?.mainAddress + } + return cell + + // provider cells + + case .providerPool: + let cell = Cells.setting.dequeue(from: tableView, for: indexPath) + cell.leftText = L10n.Service.Cells.Provider.Pool.caption + cell.rightText = uncheckedProviderProfile.pool?.name + return cell + + case .providerPreset: + let cell = Cells.setting.dequeue(from: tableView, for: indexPath) + cell.leftText = L10n.Service.Cells.Provider.Preset.caption + cell.rightText = uncheckedProviderProfile.preset?.name // XXX: localize? + return cell + + case .providerRefresh: + let cell = Cells.setting.dequeue(from: tableView, for: indexPath) + cell.applyAction(Theme.current) + cell.leftText = L10n.Service.Cells.Provider.Refresh.caption + return cell + + // host cells + + case .hostParameters: + let parameters = uncheckedHostProfile.parameters + let cell = Cells.setting.dequeue(from: tableView, for: indexPath) + cell.leftText = L10n.Service.Cells.Host.Parameters.caption + let V = L10n.Service.Cells.Host.Parameters.Value.self + if !parameters.cipher.embedsDigest { + cell.rightText = V.cipherDigest(parameters.cipher.genericName, parameters.digest.genericName) + } else { + cell.rightText = V.cipher(parameters.cipher.genericName) + } + return cell + + // VPN preferences + + case .vpnResolvesHostname: + let cell = Cells.toggle.dequeue(from: tableView, for: indexPath, tag: row.rawValue, delegate: self) + cell.caption = L10n.Service.Cells.VpnResolvesHostname.caption + cell.isOn = service.preferences.resolvesHostname + return cell + + case .vpnSurvivesSleep: + let cell = Cells.toggle.dequeue(from: tableView, for: indexPath, tag: row.rawValue, delegate: self) + cell.caption = L10n.Service.Cells.VpnSurvivesSleep.caption + cell.isOn = !service.preferences.disconnectsOnSleep + return cell + + case .trustedMobile: + let cell = Cells.toggle.dequeue(from: tableView, for: indexPath, tag: row.rawValue, delegate: self) + cell.caption = L10n.Service.Cells.TrustedMobile.caption + cell.isOn = service.preferences.trustsMobileNetwork + return cell + + case .trustedWiFi: + let wifi = trustedNetworks.wifi(at: indexPath.row) + let cell = Cells.toggle.dequeue(from: tableView, for: indexPath, tag: row.rawValue, delegate: self) + cell.caption = L10n.Service.Cells.TrustedWifi.caption(wifi.0) + cell.isOn = wifi.1 + return cell + + case .trustedAddCurrentWiFi: + let cell = Cells.setting.dequeue(from: tableView, for: indexPath) + cell.applyAction(Theme.current) + cell.leftText = L10n.Service.Cells.TrustedAddWifi.caption + return cell + + case .trustedPolicy: + let cell = Cells.toggle.dequeue(from: tableView, for: indexPath, tag: row.rawValue, delegate: self) + cell.caption = L10n.Service.Cells.TrustedPolicy.caption + cell.isOn = (service.preferences.trustPolicy == .ignore) + return cell + + // diagnostics + + case .testConnectivity: + let cell = Cells.setting.dequeue(from: tableView, for: indexPath) + cell.leftText = L10n.Service.Cells.TestConnectivity.caption + return cell + + case .dataCount: + let cell = Cells.setting.dequeue(from: tableView, for: indexPath) + cell.leftText = L10n.Service.Cells.DataCount.caption + return cell + + case .debugLog: + let cell = Cells.setting.dequeue(from: tableView, for: indexPath) + cell.leftText = L10n.Service.Cells.DebugLog.caption + return cell + + // contacts + + case .reportIssue: + let cell = Cells.setting.dequeue(from: tableView, for: indexPath) + cell.leftText = L10n.IssueReporter.title + return cell + } + } + +// func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) { +// cell.isSelected = (indexPath == lastSelectedIndexPath) +// } + + // MARK: Actions + + func tableView(_ tableView: UITableView, willSelectRowAt indexPath: IndexPath) -> IndexPath? { + guard let cell = tableView.cellForRow(at: indexPath) else { + return nil + } + if let settingCell = cell as? SettingTableViewCell { + guard settingCell.isTappable else { + return nil + } + } + guard handle(row: model.row(at: indexPath), cell: cell) else { + return nil + } + return indexPath + } + + func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool { + return model.row(at: indexPath) == .trustedWiFi + } + + func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) { + precondition(indexPath.section == model.index(ofSection: .trusted)) + trustedNetworks.removeWifi(at: indexPath.row) + } + + func toggleCell(_ cell: ToggleTableViewCell, didToggleToValue value: Bool) { + guard let item = RowType(rawValue: cell.tag) else { + return + } + handle(row: item, cell: cell) + } + + // true if enters subscreen + private func handle(row: RowType, cell: UITableViewCell) -> Bool { + switch row { + case .connectionStatus: + confirmVpnReconnection() + + case .useProfile: + activate() + + case .account: + perform(segue: StoryboardSegue.Main.accountSegueIdentifier, sender: cell) + return true + + case .endpoint: + perform(segue: StoryboardSegue.Main.endpointSegueIdentifier, sender: cell) + return true + + case .providerPool: + perform(segue: StoryboardSegue.Main.providerPoolSegueIdentifier, sender: cell) + return true + + case .providerPreset: + perform(segue: StoryboardSegue.Main.providerPresetSegueIdentifier, sender: cell) + return true + + case .providerRefresh: + refreshProviderInfrastructure() + return false + + case .hostParameters: + perform(segue: StoryboardSegue.Main.hostParametersSegueIdentifier, sender: cell) + return true + + case .trustedAddCurrentWiFi: + guard trustedNetworks.addCurrentWifi() else { + let alert = Macros.alert( + L10n.Service.Sections.Trusted.header, + L10n.Service.Alerts.Trusted.NoNetwork.message + ) + alert.addCancelAction(L10n.Global.ok) + present(alert, animated: true, completion: nil) + return false + } + + case .testConnectivity: + testInternetConnectivity() + + case .dataCount: + displayDataCount() + + case .debugLog: + perform(segue: StoryboardSegue.Main.debugLogSegueIdentifier, sender: cell) + return true + + case .reportIssue: + reportIssue() + + default: + break + } + return false + } + + private func handle(row: RowType, cell: ToggleTableViewCell) { + switch row { + case .vpnService: + toggleVpnService(cell: cell) + + case .vpnResolvesHostname: + toggleResolvesHostname(cell.isOn) + + case .vpnSurvivesSleep: + toggleDisconnectsOnSleep(cell.isOn) + + case .trustedMobile: + trustedNetworks.setMobile(cell.isOn) + + case .trustedWiFi: + guard let indexPath = tableView.indexPath(for: cell) else { + return + } + if cell.isOn { + trustedNetworks.enableWifi(at: indexPath.row) + } else { + trustedNetworks.disableWifi(at: indexPath.row) + } + + case .trustedPolicy: + toggleRetainTrustedConnection(cell.isOn, sender: cell) + + default: + break + } + } + + // MARK: Updates + + func reloadModel() { + model.clear() + + guard let profile = profile else { + return + } +// assert(profile != nil, "Profile not set") + + let isActiveProfile = service.isActiveProfile(profile) + let isProvider = (profile as? ProviderConnectionProfile) != nil + + // sections + model.add(.vpn) + if isProvider { + model.add(.authentication) + } + model.add(.configuration) + if isProvider { + model.add(.providerInfrastructure) + } + if isActiveProfile { + if isProvider { + model.add(.vpnResolvesHostname) + } + model.add(.vpnSurvivesSleep) + model.add(.trusted) + model.add(.trustedPolicy) + model.add(.diagnostics) + model.add(.contacts) + } + + // headers + model.setHeader(L10n.Service.Sections.Vpn.header, for: .vpn) + if isProvider { + model.setHeader(L10n.Service.Sections.Configuration.header, for: .authentication) + } else { + model.setHeader(L10n.Service.Sections.Configuration.header, for: .configuration) + } + if isActiveProfile { + if isProvider { + model.setHeader("", for: .vpnResolvesHostname) + model.setHeader("", for: .vpnSurvivesSleep) + } + model.setHeader(L10n.Service.Sections.Trusted.header, for: .trusted) + model.setHeader(L10n.Service.Sections.Diagnostics.header, for: .diagnostics) + } + + // footers + if isActiveProfile { + model.setFooter(L10n.Service.Sections.Vpn.footer, for: .vpn) + if isProvider { + model.setFooter(L10n.Service.Sections.VpnResolvesHostname.footer, for: .vpnResolvesHostname) + } + model.setFooter(L10n.Service.Sections.VpnSurvivesSleep.footer, for: .vpnSurvivesSleep) + model.setFooter(L10n.Service.Sections.Trusted.footer, for: .trustedPolicy) + } + + // rows + if isActiveProfile { + model.set([.vpnService, .connectionStatus], in: .vpn) + } else { + model.set([.useProfile], in: .vpn) + } + if isProvider { + model.set([.account], in: .authentication) + model.set([.providerPool, .endpoint, .providerPreset], in: .configuration) + model.set([.providerRefresh], in: .providerInfrastructure) + } else { + model.set([.account, .endpoint, .hostParameters], in: .configuration) + } + if isActiveProfile { + if isProvider { + model.set([.vpnResolvesHostname], in: .vpnResolvesHostname) + } + model.set([.vpnSurvivesSleep], in: .vpnSurvivesSleep) + model.set([.trustedPolicy], in: .trustedPolicy) + model.set([.testConnectivity, .dataCount, .debugLog], in: .diagnostics) + model.set([.reportIssue], in: .contacts) + } + + trustedNetworks.delegate = self + trustedNetworks.load(from: service.preferences) + model.set(trustedNetworks.rows, in: .trusted) + } + + private func reloadVpnStatus() { + guard let profile = profile else { + return + } + guard service.isActiveProfile(profile) else { + return + } + tableView.reloadRows(at: [statusIndexPath], with: .automatic) + } + + func reloadSelectedRow(andRowAt indexPath: IndexPath? = nil) { + guard let selectedIP = tableView.indexPathForSelectedRow else { + return + } + var outdatedIPs = [selectedIP] + if let otherIP = indexPath { + outdatedIPs.append(otherIP) + } + tableView.reloadRows(at: outdatedIPs, with: .none) + tableView.selectRow(at: selectedIP, animated: false, scrollPosition: .none) + } + + func clearSelection() { + guard let selected = tableView.indexPathForSelectedRow else { + return + } + tableView.deselectRow(at: selected, animated: true) + } +} + +// MARK: - + +extension ServiceViewController: TrustedNetworksModelDelegate { + func trustedNetworksCouldDisconnect(_: TrustedNetworksModel) -> Bool { + return (service.preferences.trustPolicy == .disconnect) && (vpn.status != .disconnected) + } + + func trustedNetworksShouldConfirmDisconnection(_: TrustedNetworksModel, triggeredAt rowIndex: Int, completionHandler: @escaping () -> Void) { + confirmPotentialTrustedDisconnection(at: rowIndex, completionHandler: completionHandler) + } + + func trustedNetworks(_: TrustedNetworksModel, shouldInsertWifiAt rowIndex: Int) { + model.set(trustedNetworks.rows, in: .trusted) + tableView.insertRows(at: [IndexPath(row: rowIndex, section: trustedSectionIndex)], with: .bottom) + } + + func trustedNetworks(_: TrustedNetworksModel, shouldReloadWifiAt rowIndex: Int, isTrusted: Bool) { + let genericCell = tableView.cellForRow(at: IndexPath(row: rowIndex, section: trustedSectionIndex)) + guard let cell = genericCell as? ToggleTableViewCell else { + fatalError("Not a trusted Wi-Fi cell (\(type(of: genericCell)) != ToggleTableViewCell)") + } + guard isTrusted != cell.isOn else { + return + } + cell.setOn(isTrusted, animated: true) + } + + func trustedNetworks(_: TrustedNetworksModel, shouldDeleteWifiAt rowIndex: Int) { + model.set(trustedNetworks.rows, in: .trusted) + tableView.deleteRows(at: [IndexPath(row: rowIndex, section: trustedSectionIndex)], with: .top) + } + + func trustedNetworksShouldReinstall(_: TrustedNetworksModel) { + service.preferences.trustsMobileNetwork = trustedNetworks.trustsMobileNetwork + service.preferences.trustedWifis = trustedNetworks.trustedWifis + if vpn.isEnabled { + vpn.reinstall(completionHandler: nil) + } + } +} + +// MARK: - + +extension ServiceViewController: ConfigurationModificationDelegate { + func configuration(didUpdate newConfiguration: TunnelKitProvider.Configuration) { + if let hostProfile = profile as? HostConnectionProfile { + hostProfile.parameters = newConfiguration + } + reloadSelectedRow() + } + + func configurationShouldReinstall() { + vpn.reinstallIfEnabled() + } +} + +extension ServiceViewController: AccountViewControllerDelegate { + func accountController(_ vc: AccountViewController, didEnterCredentials credentials: Credentials) { + } + + func accountControllerDidComplete(_ accountVC: AccountViewController) { + navigationController?.popViewController(animated: true) + + let credentials = accountVC.credentials + guard credentials != service.credentials(for: uncheckedProfile) else { + return + } + try? service.setCredentials(credentials, for: uncheckedProfile) + reloadSelectedRow() + vpn.reinstallIfEnabled() + } +} + +extension ServiceViewController: EndpointViewControllerDelegate { + func endpointController(_: EndpointViewController, didUpdateWithNewAddress newAddress: String?, newProtocol: TunnelKitProvider.EndpointProtocol?) { + if let providerProfile = profile as? ProviderConnectionProfile { + providerProfile.manualAddress = newAddress + providerProfile.manualProtocol = newProtocol + } + reloadSelectedRow() + } +} + +extension ServiceViewController: ProviderPoolViewControllerDelegate { + func providerPoolController(_ vc: ProviderPoolViewController, didSelectPool pool: Pool) { + navigationController?.popViewController(animated: true) + + guard pool.id != uncheckedProviderProfile.poolId else { + return + } + uncheckedProviderProfile.poolId = pool.id + reloadSelectedRow(andRowAt: endpointIndexPath) + vpn.reinstallIfEnabled() + } +} + +extension ServiceViewController: ProviderPresetViewControllerDelegate { + func providerPresetController(_: ProviderPresetViewController, didSelectPreset preset: InfrastructurePreset) { + navigationController?.popViewController(animated: true) + + guard preset.id != uncheckedProviderProfile.presetId else { + return + } + uncheckedProviderProfile.presetId = preset.id + reloadSelectedRow(andRowAt: endpointIndexPath) + vpn.reinstallIfEnabled() + } +} + +// MARK: - + +private extension ServiceViewController { + private var uncheckedProfile: ConnectionProfile { + guard let profile = profile else { + fatalError("Expected non-nil profile here") + } + return profile + } + + private var uncheckedProviderProfile: ProviderConnectionProfile { + guard let profile = profile as? ProviderConnectionProfile else { + fatalError("Expected ProviderConnectionProfile (found: \(type(of: self.profile)))") + } + return profile + } + + private var uncheckedHostProfile: HostConnectionProfile { + guard let profile = profile as? HostConnectionProfile else { + fatalError("Expected HostConnectionProfile (found: \(type(of: self.profile)))") + } + return profile + } +} diff --git a/Passepartout-iOS/Tables/TableModel.swift b/Passepartout-iOS/Tables/TableModel.swift new file mode 100644 index 00000000..8deedeea --- /dev/null +++ b/Passepartout-iOS/Tables/TableModel.swift @@ -0,0 +1,159 @@ +// +// TableModel.swift +// Passepartout-iOS +// +// Created by Davide De Rosa on 6/25/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import Foundation + +protocol TableModelHost { + associatedtype S: Hashable + + associatedtype R: Equatable + + var model: TableModel { get } + + func reloadModel() +} + +class TableModel { + private var sections: [S] + + private var headerBySection: [S: String] + + private var footerBySection: [S: String] + + private var rowsBySection: [S: [R]] + + init() { + sections = [] + headerBySection = [:] + footerBySection = [:] + rowsBySection = [:] + } + + func clear() { + sections = [] + headerBySection = [:] + footerBySection = [:] + rowsBySection = [:] + } + + // MARK: Access + + var count: Int { + return sections.count + } + + func section(for sectionIndex: Int) -> S { + return sections[sectionIndex] + } + + func index(ofSection sectionObject: S) -> Int { + guard let sectionIndex = sections.index(of: sectionObject) else { + fatalError("Missing section: \(sectionObject)") + } + return sectionIndex + } + + func rows(for sectionIndex: Int) -> [R] { + let sectionObject = sections[sectionIndex] + guard let rows = rowsBySection[sectionObject] else { + fatalError("Missing section: \(sectionObject)") + } + return rows + } + + func row(at indexPath: IndexPath) -> R { + return rows(for: indexPath.section)[indexPath.row] + } + + func count(for sectionIndex: Int) -> Int { + return rows(for: sectionIndex).count + } + + func indexPath(row rowObject: R, section sectionObject: S) -> IndexPath? { + guard let sectionIndex = sections.index(of: sectionObject) else { + fatalError("Missing section: \(sectionObject)") + } + guard let row = rowsBySection[sectionObject]?.index(of: rowObject) else { + return nil + } + return IndexPath(row: row, section: sectionIndex) + } + + func header(for sectionIndex: Int) -> String? { + let sectionObject = sections[sectionIndex] + return headerBySection[sectionObject] + } + + func header(for sectionObject: S) -> String? { + return headerBySection[sectionObject] + } + + func footer(for sectionIndex: Int) -> String? { + let sectionObject = sections[sectionIndex] + return footerBySection[sectionObject] + } + + func footer(for sectionObject: S) -> String? { + return footerBySection[sectionObject] + } + + // MARK: Modification + + func add(_ section: S) { + sections.append(section) + } + + func setHeader(_ header: String, for sectionObject: S) { + headerBySection[sectionObject] = header + } + + func removeHeader(for sectionObject: S) { + headerBySection.removeValue(forKey: sectionObject) + } + + func setFooter(_ footer: String, for sectionObject: S) { + footerBySection[sectionObject] = footer + } + + func removeFooter(for sectionObject: S) { + footerBySection.removeValue(forKey: sectionObject) + } + + func set(_ rows: [R], in sectionObject: S) { + rowsBySection[sectionObject] = rows + } + + func set(_ row: R, count: Int, in sectionObject: S) { + rowsBySection[sectionObject] = [R](repeating: row, count: count) + } + + func deleteRow(at indexPath: IndexPath) { + deleteRow(in: section(for: indexPath.section), at: indexPath.row) + } + + func deleteRow(in sectionObject: S, at rowIndex: Int) { + rowsBySection[sectionObject]?.remove(at: rowIndex) + } +} diff --git a/Passepartout-iOS/en.lproj/LaunchScreen.storyboard b/Passepartout-iOS/en.lproj/LaunchScreen.storyboard new file mode 100644 index 00000000..b5600727 --- /dev/null +++ b/Passepartout-iOS/en.lproj/LaunchScreen.storyboard @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Passepartout-iOS/en.lproj/Main.storyboard b/Passepartout-iOS/en.lproj/Main.storyboard new file mode 100644 index 00000000..393a3dfd --- /dev/null +++ b/Passepartout-iOS/en.lproj/Main.storyboard @@ -0,0 +1,538 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Passepartout-iOS/en.lproj/Organizer.storyboard b/Passepartout-iOS/en.lproj/Organizer.storyboard new file mode 100644 index 00000000..18027ad4 --- /dev/null +++ b/Passepartout-iOS/en.lproj/Organizer.storyboard @@ -0,0 +1,496 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Passepartout.xcodeproj/project.pbxproj b/Passepartout.xcodeproj/project.pbxproj new file mode 100644 index 00000000..638f0a01 --- /dev/null +++ b/Passepartout.xcodeproj/project.pbxproj @@ -0,0 +1,1231 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { + +/* Begin PBXBuildFile section */ + 0E05C5D420D1645F006EE732 /* FieldTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E05C5CE20D139AF006EE732 /* FieldTableViewCell.swift */; }; + 0E05C5D520D1645F006EE732 /* SettingTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ED824CD20D12DBE00F2FE9E /* SettingTableViewCell.swift */; }; + 0E05C5D620D1645F006EE732 /* SwiftGen+Storyboards.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EDE8DE320C89028004C739C /* SwiftGen+Storyboards.swift */; }; + 0E05C5D720D1645F006EE732 /* ToggleTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ED824C920D12B8700F2FE9E /* ToggleTableViewCell.swift */; }; + 0E05C5DC20D198B9006EE732 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 0E05C5DF20D198B9006EE732 /* Localizable.strings */; }; + 0E05C5E420D1993C006EE732 /* SwiftGen+Strings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E05C5E320D1993C006EE732 /* SwiftGen+Strings.swift */; }; + 0E05C61D20D27C82006EE732 /* Theme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E05C61C20D27C82006EE732 /* Theme.swift */; }; + 0E1066C920E0F84A004F98B7 /* Cells.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E1066C820E0F84A004F98B7 /* Cells.swift */; }; + 0E158ADA20E11B0B00C85A82 /* EndpointViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E158AD920E11B0B00C85A82 /* EndpointViewController.swift */; }; + 0E1D72B2213BFFCF00BA1586 /* ProviderPresetViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E1D72B1213BFFCF00BA1586 /* ProviderPresetViewController.swift */; }; + 0E1D72B4213C118500BA1586 /* ConfigurationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E1D72B3213C118500BA1586 /* ConfigurationViewController.swift */; }; + 0E2B494020FCFF990094784C /* Theme+Titles.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E2B493F20FCFF990094784C /* Theme+Titles.swift */; }; + 0E2B494220FD16540094784C /* TransientStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E2B494120FD16540094784C /* TransientStore.swift */; }; + 0E39BCF0214B9EF10035E9DE /* WebServices.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E39BCEF214B9EF10035E9DE /* WebServices.swift */; }; + 0E39BCF3214DA9310035E9DE /* AppConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E39BCF2214DA9310035E9DE /* AppConstants.swift */; }; + 0E3DA371215CB5BF00B40FC9 /* VersionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E3DA370215CB5BF00B40FC9 /* VersionViewController.swift */; }; + 0E4C9CB920DB9BC600A0C59C /* TrustedNetworks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E4C9CB820DB9BC600A0C59C /* TrustedNetworks.swift */; }; + 0E4C9CBB20DCF0D600A0C59C /* DestructiveTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E4C9CBA20DCF0D600A0C59C /* DestructiveTableViewCell.swift */; }; + 0E4FD7DE20D3E49A002221FF /* StandardVPNProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E4FD7DD20D3E49A002221FF /* StandardVPNProvider.swift */; }; + 0E4FD7E120D3E4C5002221FF /* MockVPNProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E4FD7E020D3E4C5002221FF /* MockVPNProvider.swift */; }; + 0E4FD7EE20D539A0002221FF /* Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E4FD7ED20D539A0002221FF /* Utils.swift */; }; + 0E4FD7F120D58618002221FF /* Macros.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E4FD7F020D58618002221FF /* Macros.swift */; }; + 0E57F63C20C83FC5008323CF /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E57F63B20C83FC5008323CF /* AppDelegate.swift */; }; + 0E57F63E20C83FC5008323CF /* ServiceViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E57F63D20C83FC5008323CF /* ServiceViewController.swift */; }; + 0E57F64120C83FC5008323CF /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0E57F63F20C83FC5008323CF /* Main.storyboard */; }; + 0E57F64320C83FC7008323CF /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0E57F64220C83FC7008323CF /* Assets.xcassets */; }; + 0E57F64620C83FC7008323CF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0E57F64420C83FC7008323CF /* LaunchScreen.storyboard */; }; + 0E5E5DDF215119AF00E318A3 /* VPNStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E5E5DDE215119AF00E318A3 /* VPNStatus.swift */; }; + 0E5E5DE2215119DD00E318A3 /* VPNConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E5E5DE1215119DD00E318A3 /* VPNConfiguration.swift */; }; + 0E5E5DE521511C5F00E318A3 /* GracefulVPN.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E5E5DE421511C5F00E318A3 /* GracefulVPN.swift */; }; + 0E6BE13A20CFB76800A6DD36 /* ApplicationError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E6BE13920CFB76800A6DD36 /* ApplicationError.swift */; }; + 0E6BE13F20CFBAB300A6DD36 /* DebugLogViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E6BE13E20CFBAB300A6DD36 /* DebugLogViewController.swift */; }; + 0E89DFC5213DF7AE00741BA1 /* Preferences.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E89DFC4213DF7AE00741BA1 /* Preferences.swift */; }; + 0E89DFC8213E8FC500741BA1 /* TunnelKitProvider+Communication.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E89DFC7213E8FC500741BA1 /* TunnelKitProvider+Communication.swift */; }; + 0E89DFCE213EEDFA00741BA1 /* WizardProviderViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E89DFCD213EEDFA00741BA1 /* WizardProviderViewController.swift */; }; + 0E89DFD0213F223400741BA1 /* Wizard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E89DFCF213F223400741BA1 /* Wizard.swift */; }; + 0E8D97E221388B52006FB4A0 /* InfrastructurePreset.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E8D97E121388B52006FB4A0 /* InfrastructurePreset.swift */; }; + 0E8D97E521389277006FB4A0 /* pia.json in Resources */ = {isa = PBXBuildFile; fileRef = 0E8D97E421389276006FB4A0 /* pia.json */; }; + 0EAAD71920E6669A0088754A /* GroupConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EDE8DED20C93E4C004C739C /* GroupConstants.swift */; }; + 0EB60FDA2111136E00AD27F3 /* UITextView+Search.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EB60FD92111136E00AD27F3 /* UITextView+Search.swift */; }; + 0EBE3A79213C4E5500BFA2F5 /* OrganizerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EBE3A78213C4E5400BFA2F5 /* OrganizerViewController.swift */; }; + 0EBE3A84213C6ADE00BFA2F5 /* InfrastructureFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EBE3A83213C6ADE00BFA2F5 /* InfrastructureFactory.swift */; }; + 0EBE3A90213C6F4000BFA2F5 /* TrustPolicy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EBE3A8F213C6F4000BFA2F5 /* TrustPolicy.swift */; }; + 0EBE3AA0213DC1A100BFA2F5 /* ConnectionProfile.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EBE3A9E213DC1A100BFA2F5 /* ConnectionProfile.swift */; }; + 0EBE3AA1213DC1A100BFA2F5 /* ConnectionService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EBE3A9F213DC1A100BFA2F5 /* ConnectionService.swift */; }; + 0EBE3AA5213DC1B000BFA2F5 /* HostConnectionProfile.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EBE3AA3213DC1B000BFA2F5 /* HostConnectionProfile.swift */; }; + 0EBE3AA6213DC1B000BFA2F5 /* ProviderConnectionProfile.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EBE3AA4213DC1B000BFA2F5 /* ProviderConnectionProfile.swift */; }; + 0EBE3AAC213DEB8800BFA2F5 /* ConnectionProfileHolder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EBE3AAB213DEB8800BFA2F5 /* ConnectionProfileHolder.swift */; }; + 0EC7F20520E24308004EA58E /* DebugLog.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EC7F20420E24308004EA58E /* DebugLog.swift */; }; + 0ECEE44E20E1122200A6BB43 /* TableModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ECEE44D20E1122200A6BB43 /* TableModel.swift */; }; + 0ECEE45020E1182E00A6BB43 /* Theme+Cells.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ECEE44F20E1182E00A6BB43 /* Theme+Cells.swift */; }; + 0ED31C1020CF09A30027975F /* Pool.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ED31C0F20CF09A30027975F /* Pool.swift */; }; + 0ED31C1220CF0ABA0027975F /* Infrastructure.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ED31C1120CF0ABA0027975F /* Infrastructure.swift */; }; + 0ED31C2720CF257C0027975F /* InfrastructureTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ED31C2620CF257C0027975F /* InfrastructureTests.swift */; }; + 0ED31C2920CF2A340027975F /* AccountViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ED31C2820CF2A340027975F /* AccountViewController.swift */; }; + 0ED31C2C20CF2D6F0027975F /* ProviderPoolViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ED31C2B20CF2D6F0027975F /* ProviderPoolViewController.swift */; }; + 0ED31C3720CF38D10027975F /* VPN.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ED31C3620CF38D10027975F /* VPN.swift */; }; + 0ED31C3A20CF39510027975F /* NetworkExtension.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0ED31C3920CF39510027975F /* NetworkExtension.framework */; }; + 0ED31C3D20CF396E0027975F /* NetworkExtension.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0ED31C3920CF39510027975F /* NetworkExtension.framework */; }; + 0ED38AD9213F33150004D387 /* WizardHostViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ED38AD8213F33150004D387 /* WizardHostViewController.swift */; }; + 0ED38ADA213F44D00004D387 /* Organizer.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0ED38ADC213F44D00004D387 /* Organizer.storyboard */; }; + 0ED38ADE213F4E980004D387 /* TunnelKitProvider+FileConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ED38ADD213F4E980004D387 /* TunnelKitProvider+FileConfiguration.swift */; }; + 0ED38AE1213F51370004D387 /* FileConfigurationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ED38AE0213F51370004D387 /* FileConfigurationTests.swift */; }; + 0ED38AE3213F517D0004D387 /* pia-hungary.ovpn in Resources */ = {isa = PBXBuildFile; fileRef = 0ED38AE2213F517D0004D387 /* pia-hungary.ovpn */; }; + 0ED38AE721404F100004D387 /* EndpointDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ED38AE621404F100004D387 /* EndpointDataSource.swift */; }; + 0ED38AEA214054A50004D387 /* OptionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ED38AE9214054A50004D387 /* OptionViewController.swift */; }; + 0ED38AEC2141260D0004D387 /* ConfigurationModificationDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ED38AEB2141260D0004D387 /* ConfigurationModificationDelegate.swift */; }; + 0ED38AF2214177920004D387 /* VPNProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ED38AF1214177920004D387 /* VPNProvider.swift */; }; + 0EDE8DC420C86910004C739C /* PacketTunnelProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EDE8DC320C86910004C739C /* PacketTunnelProvider.swift */; }; + 0EDE8DC820C86910004C739C /* Passepartout-iOS-Tunnel.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 0EDE8DBF20C86910004C739C /* Passepartout-iOS-Tunnel.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; + 0EDE8DE720C93945004C739C /* Credentials.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EDE8DE620C93945004C739C /* Credentials.swift */; }; + 0EDE8DEE20C93E4C004C739C /* GroupConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EDE8DED20C93E4C004C739C /* GroupConstants.swift */; }; + 0EE3BBB2215ED3A900F30952 /* AboutViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EE3BBB1215ED3A900F30952 /* AboutViewController.swift */; }; + 0EF5CF252141CE58004FF1BD /* HUD.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EF5CF242141CE58004FF1BD /* HUD.swift */; }; + 0EF5CF292141F31F004FF1BD /* Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E4FD7ED20D539A0002221FF /* Utils.swift */; }; + 0EFD943E215BE10800529B64 /* IssueReporter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EFD943D215BE10800529B64 /* IssueReporter.swift */; }; + 0EFD9440215BED8E00529B64 /* CreditsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EFD943F215BED8E00529B64 /* CreditsViewController.swift */; }; + 390EEC911382C4814FB97475 /* Pods_Passepartout_iOS_Tunnel.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4D0C619B826C7140001C0F32 /* Pods_Passepartout_iOS_Tunnel.framework */; }; + 61E05ED5CCEEA859AD1752F3 /* Pods_Passepartout_iOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E9FBA5419C4B758FB5D68E96 /* Pods_Passepartout_iOS.framework */; }; + CB086D724184B22B368E5BEF /* Pods_PassepartoutTests_iOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E80C2390BBF547A62D4D277 /* Pods_PassepartoutTests_iOS.framework */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 0E57F64D20C83FC7008323CF /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 0E57F63020C83FC5008323CF /* Project object */; + proxyType = 1; + remoteGlobalIDString = 0E57F63720C83FC5008323CF; + remoteInfo = Passepartout; + }; + 0EDE8DC620C86910004C739C /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 0E57F63020C83FC5008323CF /* Project object */; + proxyType = 1; + remoteGlobalIDString = 0EDE8DBE20C86910004C739C; + remoteInfo = "Passepartout-iOS-Tunnel"; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 0EDE8DCC20C86910004C739C /* Embed App Extensions */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 13; + files = ( + 0EDE8DC820C86910004C739C /* Passepartout-iOS-Tunnel.appex in Embed App Extensions */, + ); + name = "Embed App Extensions"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 05C743241486C000F882DE79 /* Pods-Passepartout-iOS.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Passepartout-iOS.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Passepartout-iOS/Pods-Passepartout-iOS.debug.xcconfig"; sourceTree = ""; }; + 0E05C5CE20D139AF006EE732 /* FieldTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FieldTableViewCell.swift; sourceTree = ""; }; + 0E05C5DE20D198B9006EE732 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = ""; }; + 0E05C5E020D198D6006EE732 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = en; path = en.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 0E05C5E120D198D6006EE732 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = en; path = en.lproj/Main.storyboard; sourceTree = ""; }; + 0E05C5E320D1993C006EE732 /* SwiftGen+Strings.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "SwiftGen+Strings.swift"; sourceTree = ""; }; + 0E05C61C20D27C82006EE732 /* Theme.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Theme.swift; sourceTree = ""; }; + 0E1066C820E0F84A004F98B7 /* Cells.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Cells.swift; sourceTree = ""; }; + 0E158AD920E11B0B00C85A82 /* EndpointViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EndpointViewController.swift; sourceTree = ""; }; + 0E1D72B1213BFFCF00BA1586 /* ProviderPresetViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProviderPresetViewController.swift; sourceTree = ""; }; + 0E1D72B3213C118500BA1586 /* ConfigurationViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConfigurationViewController.swift; sourceTree = ""; }; + 0E2B493F20FCFF990094784C /* Theme+Titles.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Theme+Titles.swift"; sourceTree = ""; }; + 0E2B494120FD16540094784C /* TransientStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransientStore.swift; sourceTree = ""; }; + 0E39BCEF214B9EF10035E9DE /* WebServices.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebServices.swift; sourceTree = ""; }; + 0E39BCF2214DA9310035E9DE /* AppConstants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppConstants.swift; sourceTree = ""; }; + 0E3DA370215CB5BF00B40FC9 /* VersionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VersionViewController.swift; sourceTree = ""; }; + 0E4C9CB820DB9BC600A0C59C /* TrustedNetworks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrustedNetworks.swift; sourceTree = ""; }; + 0E4C9CBA20DCF0D600A0C59C /* DestructiveTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DestructiveTableViewCell.swift; sourceTree = ""; }; + 0E4FD7DD20D3E49A002221FF /* StandardVPNProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StandardVPNProvider.swift; sourceTree = ""; }; + 0E4FD7E020D3E4C5002221FF /* MockVPNProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockVPNProvider.swift; sourceTree = ""; }; + 0E4FD7ED20D539A0002221FF /* Utils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Utils.swift; sourceTree = ""; }; + 0E4FD7F020D58618002221FF /* Macros.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Macros.swift; sourceTree = ""; }; + 0E4FD80420D683A2002221FF /* NetworkExtension.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = NetworkExtension.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/NetworkExtension.framework; sourceTree = DEVELOPER_DIR; }; + 0E57F63820C83FC5008323CF /* Passepartout-iOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Passepartout-iOS.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 0E57F63B20C83FC5008323CF /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 0E57F63D20C83FC5008323CF /* ServiceViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServiceViewController.swift; sourceTree = ""; }; + 0E57F64220C83FC7008323CF /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 0E57F64720C83FC7008323CF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 0E57F64C20C83FC7008323CF /* PassepartoutTests-iOS.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "PassepartoutTests-iOS.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; + 0E57F65220C83FC7008323CF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 0E5E5DDE215119AF00E318A3 /* VPNStatus.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VPNStatus.swift; sourceTree = ""; }; + 0E5E5DE1215119DD00E318A3 /* VPNConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VPNConfiguration.swift; sourceTree = ""; }; + 0E5E5DE421511C5F00E318A3 /* GracefulVPN.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GracefulVPN.swift; sourceTree = ""; }; + 0E6BE13920CFB76800A6DD36 /* ApplicationError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApplicationError.swift; sourceTree = ""; }; + 0E6BE13E20CFBAB300A6DD36 /* DebugLogViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DebugLogViewController.swift; sourceTree = ""; }; + 0E89DFC4213DF7AE00741BA1 /* Preferences.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Preferences.swift; sourceTree = ""; }; + 0E89DFC7213E8FC500741BA1 /* TunnelKitProvider+Communication.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "TunnelKitProvider+Communication.swift"; sourceTree = ""; }; + 0E89DFCD213EEDFA00741BA1 /* WizardProviderViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WizardProviderViewController.swift; sourceTree = ""; }; + 0E89DFCF213F223400741BA1 /* Wizard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Wizard.swift; sourceTree = ""; }; + 0E8D97E121388B52006FB4A0 /* InfrastructurePreset.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InfrastructurePreset.swift; sourceTree = ""; }; + 0E8D97E421389276006FB4A0 /* pia.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = pia.json; sourceTree = ""; }; + 0EB60FD92111136E00AD27F3 /* UITextView+Search.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UITextView+Search.swift"; sourceTree = ""; }; + 0EBE3A78213C4E5400BFA2F5 /* OrganizerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrganizerViewController.swift; sourceTree = ""; }; + 0EBE3A83213C6ADE00BFA2F5 /* InfrastructureFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InfrastructureFactory.swift; sourceTree = ""; }; + 0EBE3A8F213C6F4000BFA2F5 /* TrustPolicy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrustPolicy.swift; sourceTree = ""; }; + 0EBE3A9E213DC1A100BFA2F5 /* ConnectionProfile.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConnectionProfile.swift; sourceTree = ""; }; + 0EBE3A9F213DC1A100BFA2F5 /* ConnectionService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConnectionService.swift; sourceTree = ""; }; + 0EBE3AA3213DC1B000BFA2F5 /* HostConnectionProfile.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HostConnectionProfile.swift; sourceTree = ""; }; + 0EBE3AA4213DC1B000BFA2F5 /* ProviderConnectionProfile.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProviderConnectionProfile.swift; sourceTree = ""; }; + 0EBE3AAB213DEB8800BFA2F5 /* ConnectionProfileHolder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConnectionProfileHolder.swift; sourceTree = ""; }; + 0EC7F20420E24308004EA58E /* DebugLog.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DebugLog.swift; sourceTree = ""; }; + 0ECEE44D20E1122200A6BB43 /* TableModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TableModel.swift; sourceTree = ""; }; + 0ECEE44F20E1182E00A6BB43 /* Theme+Cells.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Theme+Cells.swift"; sourceTree = ""; }; + 0ED31C0F20CF09A30027975F /* Pool.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Pool.swift; sourceTree = ""; }; + 0ED31C1120CF0ABA0027975F /* Infrastructure.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Infrastructure.swift; sourceTree = ""; }; + 0ED31C2620CF257C0027975F /* InfrastructureTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InfrastructureTests.swift; sourceTree = ""; }; + 0ED31C2820CF2A340027975F /* AccountViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountViewController.swift; sourceTree = ""; }; + 0ED31C2B20CF2D6F0027975F /* ProviderPoolViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProviderPoolViewController.swift; sourceTree = ""; }; + 0ED31C3620CF38D10027975F /* VPN.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VPN.swift; sourceTree = ""; }; + 0ED31C3920CF39510027975F /* NetworkExtension.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = NetworkExtension.framework; path = System/Library/Frameworks/NetworkExtension.framework; sourceTree = SDKROOT; }; + 0ED31C3B20CF39510027975F /* Tunnel.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Tunnel.entitlements; sourceTree = ""; }; + 0ED38AD8213F33150004D387 /* WizardHostViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WizardHostViewController.swift; sourceTree = ""; }; + 0ED38ADB213F44D00004D387 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = en; path = en.lproj/Organizer.storyboard; sourceTree = ""; }; + 0ED38ADD213F4E980004D387 /* TunnelKitProvider+FileConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "TunnelKitProvider+FileConfiguration.swift"; sourceTree = ""; }; + 0ED38AE0213F51370004D387 /* FileConfigurationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileConfigurationTests.swift; sourceTree = ""; }; + 0ED38AE2213F517D0004D387 /* pia-hungary.ovpn */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "pia-hungary.ovpn"; sourceTree = ""; }; + 0ED38AE621404F100004D387 /* EndpointDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EndpointDataSource.swift; sourceTree = ""; }; + 0ED38AE9214054A50004D387 /* OptionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OptionViewController.swift; sourceTree = ""; }; + 0ED38AEB2141260D0004D387 /* ConfigurationModificationDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConfigurationModificationDelegate.swift; sourceTree = ""; }; + 0ED38AF1214177920004D387 /* VPNProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VPNProvider.swift; sourceTree = ""; }; + 0ED824C920D12B8700F2FE9E /* ToggleTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToggleTableViewCell.swift; sourceTree = ""; }; + 0ED824CD20D12DBE00F2FE9E /* SettingTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingTableViewCell.swift; sourceTree = ""; }; + 0EDE8DBF20C86910004C739C /* Passepartout-iOS-Tunnel.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = "Passepartout-iOS-Tunnel.appex"; sourceTree = BUILT_PRODUCTS_DIR; }; + 0EDE8DC320C86910004C739C /* PacketTunnelProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PacketTunnelProvider.swift; sourceTree = ""; }; + 0EDE8DC520C86910004C739C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 0EDE8DD220C86978004C739C /* NotificationCenter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = NotificationCenter.framework; path = System/Library/Frameworks/NotificationCenter.framework; sourceTree = SDKROOT; }; + 0EDE8DE220C86A13004C739C /* Passepartout.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Passepartout.entitlements; sourceTree = ""; }; + 0EDE8DE320C89028004C739C /* SwiftGen+Storyboards.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "SwiftGen+Storyboards.swift"; sourceTree = ""; }; + 0EDE8DE620C93945004C739C /* Credentials.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Credentials.swift; sourceTree = ""; }; + 0EDE8DED20C93E4C004C739C /* GroupConstants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GroupConstants.swift; sourceTree = ""; }; + 0EE3BBB1215ED3A900F30952 /* AboutViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AboutViewController.swift; sourceTree = ""; }; + 0EF5CF242141CE58004FF1BD /* HUD.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HUD.swift; sourceTree = ""; }; + 0EFD943D215BE10800529B64 /* IssueReporter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IssueReporter.swift; sourceTree = ""; }; + 0EFD943F215BED8E00529B64 /* CreditsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreditsViewController.swift; sourceTree = ""; }; + 28B2E6590DE79C3B403348DC /* Pods-Passepartout-iOS.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Passepartout-iOS.debug.xcconfig"; path = "Target Support Files/Pods-Passepartout-iOS/Pods-Passepartout-iOS.debug.xcconfig"; sourceTree = ""; }; + 2F14CE1B8BBCB7B187610A9E /* Pods-PassepartoutTests-iOS.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PassepartoutTests-iOS.debug.xcconfig"; path = "Pods/Target Support Files/Pods-PassepartoutTests-iOS/Pods-PassepartoutTests-iOS.debug.xcconfig"; sourceTree = ""; }; + 3E7BC601C2DEB273955334A5 /* Pods-PassepartoutTests-iOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PassepartoutTests-iOS.release.xcconfig"; path = "Pods/Target Support Files/Pods-PassepartoutTests-iOS/Pods-PassepartoutTests-iOS.release.xcconfig"; sourceTree = ""; }; + 4982BB989C57CA2A92283691 /* Pods-Passepartout-iOS-Tunnel.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Passepartout-iOS-Tunnel.debug.xcconfig"; path = "Target Support Files/Pods-Passepartout-iOS-Tunnel/Pods-Passepartout-iOS-Tunnel.debug.xcconfig"; sourceTree = ""; }; + 4D0C619B826C7140001C0F32 /* Pods_Passepartout_iOS_Tunnel.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Passepartout_iOS_Tunnel.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 5428008455E78CDD2DC495D7 /* Pods-Passepartout-iOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Passepartout-iOS.release.xcconfig"; path = "Target Support Files/Pods-Passepartout-iOS/Pods-Passepartout-iOS.release.xcconfig"; sourceTree = ""; }; + 5C8E20D86DFCED1B5A793273 /* Pods-Passepartout-iOS-Tunnel.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Passepartout-iOS-Tunnel.release.xcconfig"; path = "Pods/Target Support Files/Pods-Passepartout-iOS-Tunnel/Pods-Passepartout-iOS-Tunnel.release.xcconfig"; sourceTree = ""; }; + 5E80C2390BBF547A62D4D277 /* Pods_PassepartoutTests_iOS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_PassepartoutTests_iOS.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 8DEBC5E475CE971530D3A24F /* Pods-Passepartout-iOS-Tunnel.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Passepartout-iOS-Tunnel.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Passepartout-iOS-Tunnel/Pods-Passepartout-iOS-Tunnel.debug.xcconfig"; sourceTree = ""; }; + A341F6829A4440DCD6F7AFE8 /* Pods-PassepartoutTests-iOS.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PassepartoutTests-iOS.debug.xcconfig"; path = "Target Support Files/Pods-PassepartoutTests-iOS/Pods-PassepartoutTests-iOS.debug.xcconfig"; sourceTree = ""; }; + BA76378B386C75892BEFA73E /* Pods-Passepartout-iOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Passepartout-iOS.release.xcconfig"; path = "Pods/Target Support Files/Pods-Passepartout-iOS/Pods-Passepartout-iOS.release.xcconfig"; sourceTree = ""; }; + C2B52DCF4BB363FEDC19E003 /* Pods-Passepartout-iOS-Tunnel.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Passepartout-iOS-Tunnel.release.xcconfig"; path = "Target Support Files/Pods-Passepartout-iOS-Tunnel/Pods-Passepartout-iOS-Tunnel.release.xcconfig"; sourceTree = ""; }; + E9FBA5419C4B758FB5D68E96 /* Pods_Passepartout_iOS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Passepartout_iOS.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + F55E5FC695C594928582A031 /* Pods-PassepartoutTests-iOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PassepartoutTests-iOS.release.xcconfig"; path = "Target Support Files/Pods-PassepartoutTests-iOS/Pods-PassepartoutTests-iOS.release.xcconfig"; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 0E57F63520C83FC5008323CF /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 0ED31C3D20CF396E0027975F /* NetworkExtension.framework in Frameworks */, + 61E05ED5CCEEA859AD1752F3 /* Pods_Passepartout_iOS.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 0E57F64920C83FC7008323CF /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + CB086D724184B22B368E5BEF /* Pods_PassepartoutTests_iOS.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 0EDE8DBC20C86910004C739C /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 0ED31C3A20CF39510027975F /* NetworkExtension.framework in Frameworks */, + 390EEC911382C4814FB97475 /* Pods_Passepartout_iOS_Tunnel.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 0E1066CA20E0F85C004F98B7 /* Cells */ = { + isa = PBXGroup; + children = ( + 0E1066C820E0F84A004F98B7 /* Cells.swift */, + 0E4C9CBA20DCF0D600A0C59C /* DestructiveTableViewCell.swift */, + 0E05C5CE20D139AF006EE732 /* FieldTableViewCell.swift */, + 0ED824CD20D12DBE00F2FE9E /* SettingTableViewCell.swift */, + 0ED824C920D12B8700F2FE9E /* ToggleTableViewCell.swift */, + ); + path = Cells; + sourceTree = ""; + }; + 0E4FD7D920D3E43F002221FF /* VPN */ = { + isa = PBXGroup; + children = ( + 0E5E5DE421511C5F00E318A3 /* GracefulVPN.swift */, + 0E4FD7E020D3E4C5002221FF /* MockVPNProvider.swift */, + 0E4FD7DD20D3E49A002221FF /* StandardVPNProvider.swift */, + 0ED38ADD213F4E980004D387 /* TunnelKitProvider+FileConfiguration.swift */, + 0ED31C3620CF38D10027975F /* VPN.swift */, + 0E5E5DE1215119DD00E318A3 /* VPNConfiguration.swift */, + 0ED38AF1214177920004D387 /* VPNProvider.swift */, + 0E5E5DDE215119AF00E318A3 /* VPNStatus.swift */, + ); + path = VPN; + sourceTree = ""; + }; + 0E57F62F20C83FC5008323CF = { + isa = PBXGroup; + children = ( + 0EDE8DEF20C93EBB004C739C /* Passepartout */, + 0E57F63A20C83FC5008323CF /* Passepartout-iOS */, + 0EDE8DC020C86910004C739C /* Passepartout-iOS-Tunnel */, + 0E57F64F20C83FC7008323CF /* PassepartoutTests-iOS */, + 0E57F63920C83FC5008323CF /* Products */, + 374B9F085E1148C37CF9117A /* Frameworks */, + ECB6C4CA315B2CB2AFE7ACBB /* Pods */, + ); + sourceTree = ""; + }; + 0E57F63920C83FC5008323CF /* Products */ = { + isa = PBXGroup; + children = ( + 0E57F63820C83FC5008323CF /* Passepartout-iOS.app */, + 0E57F64C20C83FC7008323CF /* PassepartoutTests-iOS.xctest */, + 0EDE8DBF20C86910004C739C /* Passepartout-iOS-Tunnel.appex */, + ); + name = Products; + sourceTree = ""; + }; + 0E57F63A20C83FC5008323CF /* Passepartout-iOS */ = { + isa = PBXGroup; + children = ( + 0EDE8DEC20C93E3B004C739C /* Global */, + 0E1066CA20E0F85C004F98B7 /* Cells */, + 0ECEE44C20E1120F00A6BB43 /* Tables */, + 0EDE8DF120C93ED8004C739C /* Scenes */, + 0EDE8DE220C86A13004C739C /* Passepartout.entitlements */, + 0E57F63B20C83FC5008323CF /* AppDelegate.swift */, + 0E57F63F20C83FC5008323CF /* Main.storyboard */, + 0ED38ADC213F44D00004D387 /* Organizer.storyboard */, + 0E57F64220C83FC7008323CF /* Assets.xcassets */, + 0E57F64420C83FC7008323CF /* LaunchScreen.storyboard */, + 0E57F64720C83FC7008323CF /* Info.plist */, + ); + path = "Passepartout-iOS"; + sourceTree = ""; + }; + 0E57F64F20C83FC7008323CF /* PassepartoutTests-iOS */ = { + isa = PBXGroup; + children = ( + 0ED38AE2213F517D0004D387 /* pia-hungary.ovpn */, + 0ED38AE0213F51370004D387 /* FileConfigurationTests.swift */, + 0ED31C2620CF257C0027975F /* InfrastructureTests.swift */, + 0E57F65220C83FC7008323CF /* Info.plist */, + ); + path = "PassepartoutTests-iOS"; + sourceTree = ""; + }; + 0E89DFCC213EEDE700741BA1 /* Organizer */ = { + isa = PBXGroup; + children = ( + 0EE3BBB1215ED3A900F30952 /* AboutViewController.swift */, + 0EFD943F215BED8E00529B64 /* CreditsViewController.swift */, + 0EBE3A78213C4E5400BFA2F5 /* OrganizerViewController.swift */, + 0E3DA370215CB5BF00B40FC9 /* VersionViewController.swift */, + 0ED38AD8213F33150004D387 /* WizardHostViewController.swift */, + 0E89DFCD213EEDFA00741BA1 /* WizardProviderViewController.swift */, + ); + path = Organizer; + sourceTree = ""; + }; + 0E8D97C621388679006FB4A0 /* Infrastructures */ = { + isa = PBXGroup; + children = ( + 0E8D97E421389276006FB4A0 /* pia.json */, + ); + path = Infrastructures; + sourceTree = ""; + }; + 0EBE3AA2213DC1B000BFA2F5 /* Profiles */ = { + isa = PBXGroup; + children = ( + 0EBE3AA3213DC1B000BFA2F5 /* HostConnectionProfile.swift */, + 0EBE3AA4213DC1B000BFA2F5 /* ProviderConnectionProfile.swift */, + ); + path = Profiles; + sourceTree = ""; + }; + 0ECEE44C20E1120F00A6BB43 /* Tables */ = { + isa = PBXGroup; + children = ( + 0ECEE44D20E1122200A6BB43 /* TableModel.swift */, + ); + path = Tables; + sourceTree = ""; + }; + 0ED31C0E20CF09890027975F /* Model */ = { + isa = PBXGroup; + children = ( + 0EBE3AA2213DC1B000BFA2F5 /* Profiles */, + 0EBE3A9E213DC1A100BFA2F5 /* ConnectionProfile.swift */, + 0EBE3AAB213DEB8800BFA2F5 /* ConnectionProfileHolder.swift */, + 0EBE3A9F213DC1A100BFA2F5 /* ConnectionService.swift */, + 0EDE8DE620C93945004C739C /* Credentials.swift */, + 0EC7F20420E24308004EA58E /* DebugLog.swift */, + 0ED38AE621404F100004D387 /* EndpointDataSource.swift */, + 0E89DFC4213DF7AE00741BA1 /* Preferences.swift */, + 0E89DFC7213E8FC500741BA1 /* TunnelKitProvider+Communication.swift */, + 0E2B494120FD16540094784C /* TransientStore.swift */, + 0E4C9CB820DB9BC600A0C59C /* TrustedNetworks.swift */, + 0EBE3A8F213C6F4000BFA2F5 /* TrustPolicy.swift */, + 0E89DFCF213F223400741BA1 /* Wizard.swift */, + ); + path = Model; + sourceTree = ""; + }; + 0ED31C1B20CF0ACE0027975F /* Services */ = { + isa = PBXGroup; + children = ( + 0ED31C1120CF0ABA0027975F /* Infrastructure.swift */, + 0EBE3A83213C6ADE00BFA2F5 /* InfrastructureFactory.swift */, + 0E8D97E121388B52006FB4A0 /* InfrastructurePreset.swift */, + 0ED31C0F20CF09A30027975F /* Pool.swift */, + 0E39BCEF214B9EF10035E9DE /* WebServices.swift */, + ); + path = Services; + sourceTree = ""; + }; + 0ED31C1C20CF17CC0027975F /* Resources */ = { + isa = PBXGroup; + children = ( + 0E8D97C621388679006FB4A0 /* Infrastructures */, + 0E05C5DF20D198B9006EE732 /* Localizable.strings */, + ); + path = Resources; + sourceTree = ""; + }; + 0EDE8DC020C86910004C739C /* Passepartout-iOS-Tunnel */ = { + isa = PBXGroup; + children = ( + 0ED31C3B20CF39510027975F /* Tunnel.entitlements */, + 0EDE8DC320C86910004C739C /* PacketTunnelProvider.swift */, + 0EDE8DC520C86910004C739C /* Info.plist */, + ); + path = "Passepartout-iOS-Tunnel"; + sourceTree = ""; + }; + 0EDE8DEC20C93E3B004C739C /* Global */ = { + isa = PBXGroup; + children = ( + 0EF5CF242141CE58004FF1BD /* HUD.swift */, + 0EFD943D215BE10800529B64 /* IssueReporter.swift */, + 0E4FD7F020D58618002221FF /* Macros.swift */, + 0ED38AE9214054A50004D387 /* OptionViewController.swift */, + 0EDE8DE320C89028004C739C /* SwiftGen+Storyboards.swift */, + 0E05C61C20D27C82006EE732 /* Theme.swift */, + 0ECEE44F20E1182E00A6BB43 /* Theme+Cells.swift */, + 0E2B493F20FCFF990094784C /* Theme+Titles.swift */, + 0EB60FD92111136E00AD27F3 /* UITextView+Search.swift */, + ); + path = Global; + sourceTree = ""; + }; + 0EDE8DEF20C93EBB004C739C /* Passepartout */ = { + isa = PBXGroup; + children = ( + 0ED31C1C20CF17CC0027975F /* Resources */, + 0EDE8DF020C93EBB004C739C /* Sources */, + ); + path = Passepartout; + sourceTree = ""; + }; + 0EDE8DF020C93EBB004C739C /* Sources */ = { + isa = PBXGroup; + children = ( + 0ED31C0E20CF09890027975F /* Model */, + 0ED31C1B20CF0ACE0027975F /* Services */, + 0E4FD7D920D3E43F002221FF /* VPN */, + 0E39BCF2214DA9310035E9DE /* AppConstants.swift */, + 0E6BE13920CFB76800A6DD36 /* ApplicationError.swift */, + 0EDE8DED20C93E4C004C739C /* GroupConstants.swift */, + 0E05C5E320D1993C006EE732 /* SwiftGen+Strings.swift */, + 0E4FD7ED20D539A0002221FF /* Utils.swift */, + ); + path = Sources; + sourceTree = ""; + }; + 0EDE8DF120C93ED8004C739C /* Scenes */ = { + isa = PBXGroup; + children = ( + 0E89DFCC213EEDE700741BA1 /* Organizer */, + 0ED31C2820CF2A340027975F /* AccountViewController.swift */, + 0ED38AEB2141260D0004D387 /* ConfigurationModificationDelegate.swift */, + 0E1D72B3213C118500BA1586 /* ConfigurationViewController.swift */, + 0E6BE13E20CFBAB300A6DD36 /* DebugLogViewController.swift */, + 0E158AD920E11B0B00C85A82 /* EndpointViewController.swift */, + 0ED31C2B20CF2D6F0027975F /* ProviderPoolViewController.swift */, + 0E1D72B1213BFFCF00BA1586 /* ProviderPresetViewController.swift */, + 0E57F63D20C83FC5008323CF /* ServiceViewController.swift */, + ); + path = Scenes; + sourceTree = ""; + }; + 374B9F085E1148C37CF9117A /* Frameworks */ = { + isa = PBXGroup; + children = ( + 0E4FD80420D683A2002221FF /* NetworkExtension.framework */, + 0ED31C3920CF39510027975F /* NetworkExtension.framework */, + 0EDE8DD220C86978004C739C /* NotificationCenter.framework */, + E9FBA5419C4B758FB5D68E96 /* Pods_Passepartout_iOS.framework */, + 4D0C619B826C7140001C0F32 /* Pods_Passepartout_iOS_Tunnel.framework */, + 5E80C2390BBF547A62D4D277 /* Pods_PassepartoutTests_iOS.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + ECB6C4CA315B2CB2AFE7ACBB /* Pods */ = { + isa = PBXGroup; + children = ( + 28B2E6590DE79C3B403348DC /* Pods-Passepartout-iOS.debug.xcconfig */, + 5428008455E78CDD2DC495D7 /* Pods-Passepartout-iOS.release.xcconfig */, + 4982BB989C57CA2A92283691 /* Pods-Passepartout-iOS-Tunnel.debug.xcconfig */, + C2B52DCF4BB363FEDC19E003 /* Pods-Passepartout-iOS-Tunnel.release.xcconfig */, + A341F6829A4440DCD6F7AFE8 /* Pods-PassepartoutTests-iOS.debug.xcconfig */, + F55E5FC695C594928582A031 /* Pods-PassepartoutTests-iOS.release.xcconfig */, + 05C743241486C000F882DE79 /* Pods-Passepartout-iOS.debug.xcconfig */, + BA76378B386C75892BEFA73E /* Pods-Passepartout-iOS.release.xcconfig */, + 8DEBC5E475CE971530D3A24F /* Pods-Passepartout-iOS-Tunnel.debug.xcconfig */, + 5C8E20D86DFCED1B5A793273 /* Pods-Passepartout-iOS-Tunnel.release.xcconfig */, + 2F14CE1B8BBCB7B187610A9E /* Pods-PassepartoutTests-iOS.debug.xcconfig */, + 3E7BC601C2DEB273955334A5 /* Pods-PassepartoutTests-iOS.release.xcconfig */, + ); + path = Pods; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 0E57F63720C83FC5008323CF /* Passepartout-iOS */ = { + isa = PBXNativeTarget; + buildConfigurationList = 0E57F65520C83FC7008323CF /* Build configuration list for PBXNativeTarget "Passepartout-iOS" */; + buildPhases = ( + 03F725174F868DC4FFE73BEB /* [CP] Check Pods Manifest.lock */, + 0E57F63420C83FC5008323CF /* Sources */, + 0E57F63520C83FC5008323CF /* Frameworks */, + 0E57F63620C83FC5008323CF /* Resources */, + 0EDE8DCC20C86910004C739C /* Embed App Extensions */, + 20711B9AA062AB9C5EF57B3C /* [CP] Embed Pods Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + 0EDE8DC720C86910004C739C /* PBXTargetDependency */, + ); + name = "Passepartout-iOS"; + productName = Passepartout; + productReference = 0E57F63820C83FC5008323CF /* Passepartout-iOS.app */; + productType = "com.apple.product-type.application"; + }; + 0E57F64B20C83FC7008323CF /* PassepartoutTests-iOS */ = { + isa = PBXNativeTarget; + buildConfigurationList = 0E57F65820C83FC7008323CF /* Build configuration list for PBXNativeTarget "PassepartoutTests-iOS" */; + buildPhases = ( + A5984A2DF2C43505FA7E4866 /* [CP] Check Pods Manifest.lock */, + 0E57F64820C83FC7008323CF /* Sources */, + 0E57F64920C83FC7008323CF /* Frameworks */, + 0E57F64A20C83FC7008323CF /* Resources */, + 9C7DFA86B13FF0B80CFED9EF /* [CP] Embed Pods Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + 0E57F64E20C83FC7008323CF /* PBXTargetDependency */, + ); + name = "PassepartoutTests-iOS"; + productName = PassepartoutTests; + productReference = 0E57F64C20C83FC7008323CF /* PassepartoutTests-iOS.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; + 0EDE8DBE20C86910004C739C /* Passepartout-iOS-Tunnel */ = { + isa = PBXNativeTarget; + buildConfigurationList = 0EDE8DC920C86910004C739C /* Build configuration list for PBXNativeTarget "Passepartout-iOS-Tunnel" */; + buildPhases = ( + AA4FF3773FA990DA571956B9 /* [CP] Check Pods Manifest.lock */, + 0EDE8DBB20C86910004C739C /* Sources */, + 0EDE8DBC20C86910004C739C /* Frameworks */, + 0EDE8DBD20C86910004C739C /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "Passepartout-iOS-Tunnel"; + productName = "Passepartout-iOS-Tunnel"; + productReference = 0EDE8DBF20C86910004C739C /* Passepartout-iOS-Tunnel.appex */; + productType = "com.apple.product-type.app-extension"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 0E57F63020C83FC5008323CF /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 1000; + LastUpgradeCheck = 0940; + ORGANIZATIONNAME = "Davide De Rosa"; + TargetAttributes = { + 0E57F63720C83FC5008323CF = { + CreatedOnToolsVersion = 9.4; + LastSwiftMigration = 1000; + SystemCapabilities = { + com.apple.AccessWiFi = { + enabled = 1; + }; + com.apple.ApplicationGroups.iOS = { + enabled = 1; + }; + com.apple.NetworkExtensions.iOS = { + enabled = 1; + }; + }; + }; + 0E57F64B20C83FC7008323CF = { + CreatedOnToolsVersion = 9.4; + LastSwiftMigration = 1000; + TestTargetID = 0E57F63720C83FC5008323CF; + }; + 0EDE8DBE20C86910004C739C = { + CreatedOnToolsVersion = 10.0; + LastSwiftMigration = 1000; + SystemCapabilities = { + com.apple.ApplicationGroups.iOS = { + enabled = 1; + }; + com.apple.NetworkExtensions.iOS = { + enabled = 1; + }; + }; + }; + }; + }; + buildConfigurationList = 0E57F63320C83FC5008323CF /* Build configuration list for PBXProject "Passepartout" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 0E57F62F20C83FC5008323CF; + productRefGroup = 0E57F63920C83FC5008323CF /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 0E57F63720C83FC5008323CF /* Passepartout-iOS */, + 0EDE8DBE20C86910004C739C /* Passepartout-iOS-Tunnel */, + 0E57F64B20C83FC7008323CF /* PassepartoutTests-iOS */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 0E57F63620C83FC5008323CF /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 0E05C5DC20D198B9006EE732 /* Localizable.strings in Resources */, + 0ED38ADA213F44D00004D387 /* Organizer.storyboard in Resources */, + 0E57F64620C83FC7008323CF /* LaunchScreen.storyboard in Resources */, + 0E57F64320C83FC7008323CF /* Assets.xcassets in Resources */, + 0E57F64120C83FC5008323CF /* Main.storyboard in Resources */, + 0E8D97E521389277006FB4A0 /* pia.json in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 0E57F64A20C83FC7008323CF /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 0ED38AE3213F517D0004D387 /* pia-hungary.ovpn in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 0EDE8DBD20C86910004C739C /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 03F725174F868DC4FFE73BEB /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-Passepartout-iOS-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; + 20711B9AA062AB9C5EF57B3C /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Passepartout-iOS/Pods-Passepartout-iOS-frameworks.sh", + "${BUILT_PRODUCTS_DIR}/MBProgressHUD/MBProgressHUD.framework", + "${PODS_ROOT}/OpenSSL-Apple/frameworks/iPhone/openssl.framework", + "${BUILT_PRODUCTS_DIR}/SwiftyBeaver/SwiftyBeaver.framework", + "${BUILT_PRODUCTS_DIR}/TunnelKit/TunnelKit.framework", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + ); + outputPaths = ( + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MBProgressHUD.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/openssl.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftyBeaver.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/TunnelKit.framework", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Passepartout-iOS/Pods-Passepartout-iOS-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + 9C7DFA86B13FF0B80CFED9EF /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-PassepartoutTests-iOS/Pods-PassepartoutTests-iOS-frameworks.sh", + "${PODS_ROOT}/OpenSSL-Apple/frameworks/iPhone/openssl.framework", + "${BUILT_PRODUCTS_DIR}/SwiftyBeaver/SwiftyBeaver.framework", + "${BUILT_PRODUCTS_DIR}/TunnelKit/TunnelKit.framework", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + ); + outputPaths = ( + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/openssl.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftyBeaver.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/TunnelKit.framework", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-PassepartoutTests-iOS/Pods-PassepartoutTests-iOS-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + A5984A2DF2C43505FA7E4866 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-PassepartoutTests-iOS-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; + AA4FF3773FA990DA571956B9 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-Passepartout-iOS-Tunnel-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 0E57F63420C83FC5008323CF /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 0E5E5DDF215119AF00E318A3 /* VPNStatus.swift in Sources */, + 0ECEE44E20E1122200A6BB43 /* TableModel.swift in Sources */, + 0ED38AD9213F33150004D387 /* WizardHostViewController.swift in Sources */, + 0EE3BBB2215ED3A900F30952 /* AboutViewController.swift in Sources */, + 0EBE3A79213C4E5500BFA2F5 /* OrganizerViewController.swift in Sources */, + 0E4FD7F120D58618002221FF /* Macros.swift in Sources */, + 0E05C5E420D1993C006EE732 /* SwiftGen+Strings.swift in Sources */, + 0EF5CF252141CE58004FF1BD /* HUD.swift in Sources */, + 0E05C5D720D1645F006EE732 /* ToggleTableViewCell.swift in Sources */, + 0ED31C1020CF09A30027975F /* Pool.swift in Sources */, + 0EBE3AA5213DC1B000BFA2F5 /* HostConnectionProfile.swift in Sources */, + 0E05C5D420D1645F006EE732 /* FieldTableViewCell.swift in Sources */, + 0E05C61D20D27C82006EE732 /* Theme.swift in Sources */, + 0ED38ADE213F4E980004D387 /* TunnelKitProvider+FileConfiguration.swift in Sources */, + 0EDE8DEE20C93E4C004C739C /* GroupConstants.swift in Sources */, + 0ED38AEC2141260D0004D387 /* ConfigurationModificationDelegate.swift in Sources */, + 0ECEE45020E1182E00A6BB43 /* Theme+Cells.swift in Sources */, + 0E5E5DE2215119DD00E318A3 /* VPNConfiguration.swift in Sources */, + 0EBE3AA0213DC1A100BFA2F5 /* ConnectionProfile.swift in Sources */, + 0E1066C920E0F84A004F98B7 /* Cells.swift in Sources */, + 0EBE3AA6213DC1B000BFA2F5 /* ProviderConnectionProfile.swift in Sources */, + 0E3DA371215CB5BF00B40FC9 /* VersionViewController.swift in Sources */, + 0E39BCF3214DA9310035E9DE /* AppConstants.swift in Sources */, + 0E05C5D620D1645F006EE732 /* SwiftGen+Storyboards.swift in Sources */, + 0E2B494220FD16540094784C /* TransientStore.swift in Sources */, + 0E89DFC5213DF7AE00741BA1 /* Preferences.swift in Sources */, + 0E6BE13A20CFB76800A6DD36 /* ApplicationError.swift in Sources */, + 0EFD9440215BED8E00529B64 /* CreditsViewController.swift in Sources */, + 0ED31C2C20CF2D6F0027975F /* ProviderPoolViewController.swift in Sources */, + 0E2B494020FCFF990094784C /* Theme+Titles.swift in Sources */, + 0E05C5D520D1645F006EE732 /* SettingTableViewCell.swift in Sources */, + 0EBE3A84213C6ADE00BFA2F5 /* InfrastructureFactory.swift in Sources */, + 0E4FD7DE20D3E49A002221FF /* StandardVPNProvider.swift in Sources */, + 0E89DFD0213F223400741BA1 /* Wizard.swift in Sources */, + 0E89DFCE213EEDFA00741BA1 /* WizardProviderViewController.swift in Sources */, + 0EBE3AA1213DC1A100BFA2F5 /* ConnectionService.swift in Sources */, + 0E1D72B2213BFFCF00BA1586 /* ProviderPresetViewController.swift in Sources */, + 0ED31C1220CF0ABA0027975F /* Infrastructure.swift in Sources */, + 0EC7F20520E24308004EA58E /* DebugLog.swift in Sources */, + 0E4FD7E120D3E4C5002221FF /* MockVPNProvider.swift in Sources */, + 0EBE3A90213C6F4000BFA2F5 /* TrustPolicy.swift in Sources */, + 0E6BE13F20CFBAB300A6DD36 /* DebugLogViewController.swift in Sources */, + 0E89DFC8213E8FC500741BA1 /* TunnelKitProvider+Communication.swift in Sources */, + 0ED38AEA214054A50004D387 /* OptionViewController.swift in Sources */, + 0EFD943E215BE10800529B64 /* IssueReporter.swift in Sources */, + 0EBE3AAC213DEB8800BFA2F5 /* ConnectionProfileHolder.swift in Sources */, + 0EB60FDA2111136E00AD27F3 /* UITextView+Search.swift in Sources */, + 0E57F63E20C83FC5008323CF /* ServiceViewController.swift in Sources */, + 0E39BCF0214B9EF10035E9DE /* WebServices.swift in Sources */, + 0EDE8DE720C93945004C739C /* Credentials.swift in Sources */, + 0ED38AF2214177920004D387 /* VPNProvider.swift in Sources */, + 0E4C9CB920DB9BC600A0C59C /* TrustedNetworks.swift in Sources */, + 0E57F63C20C83FC5008323CF /* AppDelegate.swift in Sources */, + 0ED38AE721404F100004D387 /* EndpointDataSource.swift in Sources */, + 0E8D97E221388B52006FB4A0 /* InfrastructurePreset.swift in Sources */, + 0ED31C3720CF38D10027975F /* VPN.swift in Sources */, + 0ED31C2920CF2A340027975F /* AccountViewController.swift in Sources */, + 0E5E5DE521511C5F00E318A3 /* GracefulVPN.swift in Sources */, + 0E158ADA20E11B0B00C85A82 /* EndpointViewController.swift in Sources */, + 0E1D72B4213C118500BA1586 /* ConfigurationViewController.swift in Sources */, + 0E4C9CBB20DCF0D600A0C59C /* DestructiveTableViewCell.swift in Sources */, + 0E4FD7EE20D539A0002221FF /* Utils.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 0E57F64820C83FC7008323CF /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 0ED38AE1213F51370004D387 /* FileConfigurationTests.swift in Sources */, + 0ED31C2720CF257C0027975F /* InfrastructureTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 0EDE8DBB20C86910004C739C /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 0EDE8DC420C86910004C739C /* PacketTunnelProvider.swift in Sources */, + 0EAAD71920E6669A0088754A /* GroupConstants.swift in Sources */, + 0EF5CF292141F31F004FF1BD /* Utils.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 0E57F64E20C83FC7008323CF /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 0E57F63720C83FC5008323CF /* Passepartout-iOS */; + targetProxy = 0E57F64D20C83FC7008323CF /* PBXContainerItemProxy */; + }; + 0EDE8DC720C86910004C739C /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 0EDE8DBE20C86910004C739C /* Passepartout-iOS-Tunnel */; + targetProxy = 0EDE8DC620C86910004C739C /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 0E05C5DF20D198B9006EE732 /* Localizable.strings */ = { + isa = PBXVariantGroup; + children = ( + 0E05C5DE20D198B9006EE732 /* en */, + ); + name = Localizable.strings; + sourceTree = ""; + }; + 0E57F63F20C83FC5008323CF /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 0E05C5E120D198D6006EE732 /* en */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 0E57F64420C83FC7008323CF /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 0E05C5E020D198D6006EE732 /* en */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; + 0ED38ADC213F44D00004D387 /* Organizer.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 0ED38ADB213F44D00004D387 /* en */, + ); + name = Organizer.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 0E57F65320C83FC7008323CF /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 974; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_BITCODE = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; + MACOSX_DEPLOYMENT_TARGET = 10.11; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 4.2; + }; + name = Debug; + }; + 0E57F65420C83FC7008323CF /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 974; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_BITCODE = NO; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; + MACOSX_DEPLOYMENT_TARGET = 10.11; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + SWIFT_VERSION = 4.2; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 0E57F65620C83FC7008323CF /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 28B2E6590DE79C3B403348DC /* Pods-Passepartout-iOS.debug.xcconfig */; + buildSettings = { + ARCHS = "$(ARCHS_STANDARD_64_BIT)"; + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = "Passepartout-iOS/Passepartout.entitlements"; + CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_STYLE = Manual; + DEVELOPMENT_TEAM = DTDYD63ZX9; + INFOPLIST_FILE = "Passepartout-iOS/Info.plist"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.algoritmico.ios.Passepartout; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = "match Development com.algoritmico.ios.Passepartout"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 0E57F65720C83FC7008323CF /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 5428008455E78CDD2DC495D7 /* Pods-Passepartout-iOS.release.xcconfig */; + buildSettings = { + ARCHS = "$(ARCHS_STANDARD_64_BIT)"; + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = "Passepartout-iOS/Passepartout.entitlements"; + CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_STYLE = Manual; + DEVELOPMENT_TEAM = DTDYD63ZX9; + INFOPLIST_FILE = "Passepartout-iOS/Info.plist"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.algoritmico.ios.Passepartout; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = "match Development com.algoritmico.ios.Passepartout"; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; + 0E57F65920C83FC7008323CF /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = A341F6829A4440DCD6F7AFE8 /* Pods-PassepartoutTests-iOS.debug.xcconfig */; + buildSettings = { + ARCHS = "$(ARCHS_STANDARD_64_BIT)"; + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Manual; + DEVELOPMENT_TEAM = ""; + INFOPLIST_FILE = "PassepartoutTests-iOS/Info.plist"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.privateinternetaccess.ios.PassepartoutTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; + TARGETED_DEVICE_FAMILY = "1,2"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Passepartout-iOS.app/Passepartout-iOS"; + }; + name = Debug; + }; + 0E57F65A20C83FC7008323CF /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = F55E5FC695C594928582A031 /* Pods-PassepartoutTests-iOS.release.xcconfig */; + buildSettings = { + ARCHS = "$(ARCHS_STANDARD_64_BIT)"; + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Manual; + DEVELOPMENT_TEAM = ""; + INFOPLIST_FILE = "PassepartoutTests-iOS/Info.plist"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.privateinternetaccess.ios.PassepartoutTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; + TARGETED_DEVICE_FAMILY = "1,2"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Passepartout-iOS.app/Passepartout-iOS"; + }; + name = Release; + }; + 0EDE8DCA20C86910004C739C /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 4982BB989C57CA2A92283691 /* Pods-Passepartout-iOS-Tunnel.debug.xcconfig */; + buildSettings = { + ARCHS = "$(ARCHS_STANDARD_64_BIT)"; + CODE_SIGN_ENTITLEMENTS = "Passepartout-iOS-Tunnel/Tunnel.entitlements"; + CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_STYLE = Manual; + DEVELOPMENT_TEAM = DTDYD63ZX9; + INFOPLIST_FILE = "Passepartout-iOS-Tunnel/Info.plist"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@executable_path/../../Frameworks", + ); + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + PRODUCT_BUNDLE_IDENTIFIER = com.algoritmico.ios.Passepartout.Tunnel; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = "match Development com.algoritmico.ios.Passepartout.Tunnel"; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 0EDE8DCB20C86910004C739C /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = C2B52DCF4BB363FEDC19E003 /* Pods-Passepartout-iOS-Tunnel.release.xcconfig */; + buildSettings = { + ARCHS = "$(ARCHS_STANDARD_64_BIT)"; + CODE_SIGN_ENTITLEMENTS = "Passepartout-iOS-Tunnel/Tunnel.entitlements"; + CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_STYLE = Manual; + DEVELOPMENT_TEAM = DTDYD63ZX9; + INFOPLIST_FILE = "Passepartout-iOS-Tunnel/Info.plist"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@executable_path/../../Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.algoritmico.ios.Passepartout.Tunnel; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = "match Development com.algoritmico.ios.Passepartout.Tunnel"; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 0E57F63320C83FC5008323CF /* Build configuration list for PBXProject "Passepartout" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 0E57F65320C83FC7008323CF /* Debug */, + 0E57F65420C83FC7008323CF /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 0E57F65520C83FC7008323CF /* Build configuration list for PBXNativeTarget "Passepartout-iOS" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 0E57F65620C83FC7008323CF /* Debug */, + 0E57F65720C83FC7008323CF /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 0E57F65820C83FC7008323CF /* Build configuration list for PBXNativeTarget "PassepartoutTests-iOS" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 0E57F65920C83FC7008323CF /* Debug */, + 0E57F65A20C83FC7008323CF /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 0EDE8DC920C86910004C739C /* Build configuration list for PBXNativeTarget "Passepartout-iOS-Tunnel" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 0EDE8DCA20C86910004C739C /* Debug */, + 0EDE8DCB20C86910004C739C /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 0E57F63020C83FC5008323CF /* Project object */; +} diff --git a/Passepartout.xcodeproj/xcshareddata/xcschemes/Passepartout-iOS.xcscheme b/Passepartout.xcodeproj/xcshareddata/xcschemes/Passepartout-iOS.xcscheme new file mode 100644 index 00000000..9ef17945 --- /dev/null +++ b/Passepartout.xcodeproj/xcshareddata/xcschemes/Passepartout-iOS.xcscheme @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Passepartout.xcworkspace/contents.xcworkspacedata b/Passepartout.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..08970be6 --- /dev/null +++ b/Passepartout.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/Passepartout.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Passepartout.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000..18d98100 --- /dev/null +++ b/Passepartout.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Passepartout/Resources/Infrastructures/pia.json b/Passepartout/Resources/Infrastructures/pia.json new file mode 100644 index 00000000..baa292c3 --- /dev/null +++ b/Passepartout/Resources/Infrastructures/pia.json @@ -0,0 +1,2 @@ +{"name":"PIA","pools":[{"id":"us-california","name":"US California","country":"US","hostname":"us-california.privateinternetaccess.com","addrs":[1540337575,1540337519,3119863772,1540337493,1540337518,1540337509,1540337531,1540337478,1540337583,1540337638,1540337644,1540337463,1540337491]},{"id":"us-east","name":"US East","country":"US","hostname":"us-east.privateinternetaccess.com","addrs":[3240492342,3258710811,3258710820,3240492324,3258710923,3258710947,3240492390,3258710850,3258710872,3258710858,3240492420,3240492338,3258710893]},{"id":"us-midwest","name":"US Midwest","country":"US","hostname":"us-midwest.privateinternetaccess.com","addrs":[3346297747,3346297743,3346297736,3346297740,3346297730,3346297742,3346297741,3346297734,3346297744,3346297732,3346297731,3346297746,3346297737]},{"id":"us-chicago","name":"US Chicago","country":"US","hostname":"us-chicago.privateinternetaccess.com","addrs":[1757976928,1757976912,1757976929,1757976914,1757976922,1757976926,1757976915,1757976904,1757976933,1757976934,1757976935,1757976923,1757976918]},{"id":"us-texas","name":"US Texas","country":"US","hostname":"us-texas.privateinternetaccess.com","addrs":[2732076666,2732076576,2732076548,2732076645,2732076574,2732076573,2732076690,2732076680,2732076650,2732076718,2732076714,2732076663,2732076661]},{"id":"us-florida","name":"US Florida","country":"US","hostname":"us-florida.privateinternetaccess.com","addrs":[3240492073,3240492144,3240492083,3240492040,3240492043,3240492107,3240492087,3240492039,3240492109,3240492153,3240492044,3240492139,3240492114]},{"id":"us-seattle","name":"US Seattle","country":"US","hostname":"us-seattle.privateinternetaccess.com","addrs":[1757977126,1757977158,1757977169,1757977184,1757977146,1757977098,1757977104,1757977179,1757977188,1757977097,1757977134,1757977173,1757977093]},{"id":"us-west","name":"US West","country":"US","hostname":"us-west.privateinternetaccess.com","addrs":[1757976369,1757976343,1757976393,1757976405,1757976337,1757976350,1757976396,1757976330,1757976364,1757976371,1757976403,1757976336,1757976362]},{"id":"us-siliconvalley","name":"US Silicon Valley","country":"US","hostname":"us-siliconvalley.privateinternetaccess.com","addrs":[3346298612,3346298595,3346298570,3346298546,3346298557,3346298514,3346298511,3346298522,3346298508,3346298597,3346298578,3346298589,3346298581]},{"id":"us-newyorkcity","name":"US New York City","country":"US","hostname":"us-newyorkcity.privateinternetaccess.com","addrs":[3512676909,3512676958,3512676921,3512676889,3512676914,2918506362,3512676934,3512676928,3512677024,3512676998,3512677011,3512677000,3512677022]},{"id":"us-washingtondc","name":"US Washington DC","country":"US","hostname":"us-washingtondc.privateinternetaccess.com","addrs":[1176502348,1176502346,1176502389,1176502388,1176502318,1176502325,1176502335,1176502383,1176502373,1176502327,1176502386,1176502320,1176502337]},{"id":"us-atlanta","name":"US Atlanta","country":"US","hostname":"us-atlanta.privateinternetaccess.com","addrs":[1112013033,2892124098,1807070954,1807069282,1807069287,2892124105,2892124103,1112013026,1112013032,1807069291,1112013028,2892124101,1807069292]},{"id":"us-lasvegas","name":"US Las Vegas","country":"US","hostname":"us-lasvegas.privateinternetaccess.com","addrs":[3347003515,2734418950,3347003479,3347003513,3347003508,3347003475,3347003507,3347003476,3347003514,3347003511,3347003510,3347003477,2734418951]},{"id":"us-houston","name":"US Houston","country":"US","hostname":"us-houston.privateinternetaccess.com","addrs":[3455816730,3455817362,3455816842,3455816762,3455816858,3455816834,3455816754,3455816890,3455817402,3455816802,3455817378,3455817434,3455817410]},{"id":"us-denver","name":"US Denver","country":"US","hostname":"us-denver.privateinternetaccess.com","addrs":[2927682066,2927681978,2927688218,2927684714,2927681898,2927681914,3346228994,2927686514,2927682058,2927681906,3331608914,3331610874,2927686498]},{"id":"uk-london","name":"UK London","country":"GB","hostname":"uk-london.privateinternetaccess.com","addrs":[1508809331,1508808215,1508808213,1508808204,1508809463,1508809379,1508809458,1508809393]},{"id":"uk-southampton","name":"UK Southampton","country":"GB","hostname":"uk-southampton.privateinternetaccess.com","addrs":[521724670,521724654,521724624,521724619,521724652,521725893,521724653,521724556,521724622,521724562,521725892,521724657,521724655]},{"id":"uk-manchester","name":"UK Manchester","country":"GB","hostname":"uk-manchester.privateinternetaccess.com","addrs":[1508805383,1508805429,1508804901,1508805384,1508804902,1508805389,1508804904,1508805432,1508805382,1508805381,1508805431,1508805380,1508805433]},{"id":"ca-toronto","name":"CA Toronto","country":"CA","hostname":"ca-toronto.privateinternetaccess.com","addrs":[2892120919,2892120932,2892120954,2892120873,2892120946,2892120904,2892120921,2892120891,2892120883,2892120930,2892120941,2892120841,2892120893]},{"id":"ca-montreal","name":"CA Montreal","country":"CA","hostname":"ca-montreal.privateinternetaccess.com","addrs":[3353737602,3353737636,3353737659,3353737643,3353737625,3353737628,3353737616,3353737629,3353737607,3353737624,3353737621,3353737620,3353737637]},{"id":"ca-vancouver","name":"CA Vancouver","country":"CA","hostname":"ca-vancouver.privateinternetaccess.com","addrs":[2891130904,2891130906,2891130898,2891130902,1807072593,2891130903,1807072587,2891130995,2891130900,2891130982,1807072589,2891130980,1807072585]},{"id":"au-sydney","name":"AU Sydney","country":"AU","hostname":"au-sydney.privateinternetaccess.com","addrs":[2302409885,2302409922,2302409881,2302409867,2302409865,2302409944,2302409894,2302409951,2302409906,2302409927,2302409882,2302409941,2302409919]},{"id":"au-melbourne","name":"AU Melbourne","country":"AU","hostname":"au-melbourne.privateinternetaccess.com","addrs":[2818657080,2818666570,2818663370,2818663378,2818657047,2818657085,2818663365,2818657079,2818663382,2818657033,2818666605,2818657063,2818663372]},{"id":"de-berlin","name":"DE Berlin","country":"DE","hostname":"de-berlin.privateinternetaccess.com","addrs":[3118890990,3118890994,3118890995,3118890983,3118890980,3118890981,3118890979,3118890982,3118890985,3118890987,3118890988,3118890986,3118890992]},{"id":"de-frankfurt","name":"DE Frankfurt","country":"DE","hostname":"de-frankfurt.privateinternetaccess.com","addrs":[3118220953,3118220934,3118220971,3118220935,3118220968,3118220965,3118220930,3118220941,3118220962,3118220973,3118220948,3118220966,3118220951]},{"id":"nz","name":"New Zealand","country":"NZ","hostname":"nz.privateinternetaccess.com","addrs":[1743215434,1743215430,1743215275,1743215427,1743215426,1743215398,1743215429,1743215277,1743215276,1743215274,1743215394,1743215428,1743215278]},{"id":"nl","name":"Netherlands","country":"NL","hostname":"nl.privateinternetaccess.com","addrs":[782679737,782678769,782679740,782678773,3562825881,782679765,782678745,782679734,782678778,782678771,782679239,1841928430,782679745]},{"id":"sweden","name":"Sweden","country":"SE","hostname":"sweden.privateinternetaccess.com","addrs":[787905307,787905431,787905440,787905434,787905286,787905323,787905326,787905338,787905282,787905437,787905319,787905313,787905359]},{"id":"no","name":"Norway","country":"NO","hostname":"no.privateinternetaccess.com","addrs":[1382423346,1382423372,1382423353,3117343198,1382423370,1382423351,3120390626,1382423352,1382423306,3120390628,1382423374,1382423371,1382423349]},{"id":"denmark","name":"Denmark","country":"DK","hostname":"denmark.privateinternetaccess.com","addrs":[1382421677,1382421676,1382421670,1382421685,1382421682,1382421668,1382421669,1382421680,1382421678,1382421684,1382421687,1382421673,1382421671]},{"id":"fi","name":"Finland","country":"FI","hostname":"fi.privateinternetaccess.com","addrs":[3223871245,3223871247,3223871248,3223871236,3223871234,3223871241,3223871242,3223871239,3223871244,3223871237,3223871250,3223871246,3223871238]},{"id":"swiss","name":"Switzerland","country":"CH","hostname":"swiss.privateinternetaccess.com","addrs":[3118890279,3118890288,3118890276,1382422695,3118890275,3118890322,1382422780,3118890334,3118890283,1382422779,3118890289,3118890280,3118890286]},{"id":"france","name":"France","country":"FR","hostname":"france.privateinternetaccess.com","addrs":[3267098942,3267099062,3267099063,3267099059,3267099065,3267098929,3261295252,3267098936,3267098933,3267098931,3267098914,3267098918,3267098934]},{"id":"belgium","name":"Belgium","country":"BE","hostname":"belgium.privateinternetaccess.com","addrs":[1307819798,1307819794,1307819796,1307819797,3110648346,1307819803,1307819802,3118994716,3118994715,1307819795,3118994717]},{"id":"austria","name":"Austria","country":"AT","hostname":"austria.privateinternetaccess.com","addrs":[3117603738,3117949673,3117603731,3117603740,3117949676,3117949678,3117949666,3117949669,3117949677,3117949668,3117949670,3117949667,3117949671]},{"id":"czech","name":"Czech Republic","country":"CZ","hostname":"czech.privateinternetaccess.com","addrs":[3117949763,3117949766,3117949764,1508817637,1508817635,3117949762,1508817636,1508817634]},{"id":"lu","name":"Luxembourg","country":"LU","hostname":"lu.privateinternetaccess.com","addrs":[1592976494,1592976429,3564485655,1592976434,1592976479,3564485652,1592976484,3564485653]},{"id":"ireland","name":"Ireland","country":"IE","hostname":"ireland.privateinternetaccess.com","addrs":[391937850,391937802,391937826,391937810,391937858,391937842,391937834,391937794]},{"id":"italy","name":"Italy","country":"IT","hostname":"italy.privateinternetaccess.com","addrs":[1382421971,1382421979,1382421974,1382421976,1382421975,1382421978,1382421970,1382421858,1382421973,1382421977,1382421972]},{"id":"spain","name":"Spain","country":"ES","hostname":"spain.privateinternetaccess.com","addrs":[3261294618,3118890034,3261294621,3261294620,3261294622,3118890036,3118890035,3261294619,3118890037,3118890038]},{"id":"ro","name":"Romania","country":"RO","hostname":"ro.privateinternetaccess.com","addrs":[1567819590,3117603428,3117603427,1449724330,3117603433,3117603429,3117603431,1588630563,3117603432,3117603426,3106737278,3117603430,3117603436]},{"id":"hungary","name":"Hungary","country":"HU","hostname":"hungary.privateinternetaccess.com","addrs":[3112180245,3112180246,3112180242,3112180244,3112180248,3116200546,3112180243,3112180247]},{"id":"poland","name":"Poland","country":"PL","hostname":"poland.privateinternetaccess.com","addrs":[3119830726,3119830727,3119830723,3119830722,3119830724,3119830725,3119830542,3119830728]},{"id":"turkey","name":"Turkey","country":"TR","hostname":"turkey.privateinternetaccess.com","addrs":[2956269010,2956269013,2956269011,2956269012]},{"id":"ae","name":"UAE","country":"AE","hostname":"ae.privateinternetaccess.com","addrs":[3478722180,3478722148,3478722149,3478722150,3478722179,3478722178,3478722146,3478722147]},{"id":"hk","name":"Hong Kong","country":"HK","hostname":"hk.privateinternetaccess.com","addrs":[2001831698,2001831685,2001831709,2001862118,2001831727,2001831731,2001862130,2001862102,2001862129,2001831733,2001862117]},{"id":"sg","name":"Singapore","country":"SG","hostname":"sg.privateinternetaccess.com","addrs":[3636029356,2001814223,2001814240,3636029326,2001814261,2001805081,3636029324,2001805118,3636029323,2001805086,2001814215,2001805087,2001814270]},{"id":"japan","name":"Japan","country":"JP","hostname":"japan.privateinternetaccess.com","addrs":[1741741193,1741741190,1741741194,1741741195,1741741187,1741741189,1741741188,1741741198,1741741186,1741741196,1741741197,1741741191,1741741192]},{"id":"israel","name":"Israel","country":"IL","hostname":"israel.privateinternetaccess.com","addrs":[531147922,531147918,531147923,531147912,531147919,531147921]},{"id":"mexico","name":"Mexico","country":"MX","hostname":"mexico.privateinternetaccess.com","addrs":[2839085274,2839085270,2839085303,2839085291,2839085289,2839085271,2839085268,2839085261,2839085292,2839085266,2839085272,2839085259,2839085280]},{"id":"brazil","name":"Brazil","country":"BR","hostname":"brazil.privateinternetaccess.com","addrs":[2979695562,2979696999,2979695557,2979695558,2979695559,2979695556,2979696996,2979695560,2979695563,2979696994,2979696995,2979696998,2979695555]},{"id":"in","name":"India","country":"IN","hostname":"in.privateinternetaccess.com","addrs":[2323690562,2323690634,2323690690,2323690570,2323690618,2323690594,2323690578]},{"id":"za","name":"South Africa","country":"ZA","hostname":"za.privateinternetaccess.com","addrs":[2617144131,2617144134,2617144136,2617144135,2617144133,2617144130,2617144132,2617144139]}],"presets":[{"id":"recommended","name":"Recommended","comment":"128-bit encryption","cfg":{"ep":["UDP:1198","TCP:502"],"cipher":"AES-128-CBC","auth":"SHA1","ca":"-----BEGIN CERTIFICATE-----\nMIIFqzCCBJOgAwIBAgIJAKZ7D5Yv87qDMA0GCSqGSIb3DQEBDQUAMIHoMQswCQYD\nVQQGEwJVUzELMAkGA1UECBMCQ0ExEzARBgNVBAcTCkxvc0FuZ2VsZXMxIDAeBgNV\nBAoTF1ByaXZhdGUgSW50ZXJuZXQgQWNjZXNzMSAwHgYDVQQLExdQcml2YXRlIElu\ndGVybmV0IEFjY2VzczEgMB4GA1UEAxMXUHJpdmF0ZSBJbnRlcm5ldCBBY2Nlc3Mx\nIDAeBgNVBCkTF1ByaXZhdGUgSW50ZXJuZXQgQWNjZXNzMS8wLQYJKoZIhvcNAQkB\nFiBzZWN1cmVAcHJpdmF0ZWludGVybmV0YWNjZXNzLmNvbTAeFw0xNDA0MTcxNzM1\nMThaFw0zNDA0MTIxNzM1MThaMIHoMQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0Ex\nEzARBgNVBAcTCkxvc0FuZ2VsZXMxIDAeBgNVBAoTF1ByaXZhdGUgSW50ZXJuZXQg\nQWNjZXNzMSAwHgYDVQQLExdQcml2YXRlIEludGVybmV0IEFjY2VzczEgMB4GA1UE\nAxMXUHJpdmF0ZSBJbnRlcm5ldCBBY2Nlc3MxIDAeBgNVBCkTF1ByaXZhdGUgSW50\nZXJuZXQgQWNjZXNzMS8wLQYJKoZIhvcNAQkBFiBzZWN1cmVAcHJpdmF0ZWludGVy\nbmV0YWNjZXNzLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAPXD\nL1L9tX6DGf36liA7UBTy5I869z0UVo3lImfOs/GSiFKPtInlesP65577nd7UNzzX\nlH/P/CnFPdBWlLp5ze3HRBCc/Avgr5CdMRkEsySL5GHBZsx6w2cayQ2EcRhVTwWp\ncdldeNO+pPr9rIgPrtXqT4SWViTQRBeGM8CDxAyTopTsobjSiYZCF9Ta1gunl0G/\n8Vfp+SXfYCC+ZzWvP+L1pFhPRqzQQ8k+wMZIovObK1s+nlwPaLyayzw9a8sUnvWB\n/5rGPdIYnQWPgoNlLN9HpSmsAcw2z8DXI9pIxbr74cb3/HSfuYGOLkRqrOk6h4RC\nOfuWoTrZup1uEOn+fw8CAwEAAaOCAVQwggFQMB0GA1UdDgQWBBQv63nQ/pJAt5tL\ny8VJcbHe22ZOsjCCAR8GA1UdIwSCARYwggESgBQv63nQ/pJAt5tLy8VJcbHe22ZO\nsqGB7qSB6zCB6DELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRMwEQYDVQQHEwpM\nb3NBbmdlbGVzMSAwHgYDVQQKExdQcml2YXRlIEludGVybmV0IEFjY2VzczEgMB4G\nA1UECxMXUHJpdmF0ZSBJbnRlcm5ldCBBY2Nlc3MxIDAeBgNVBAMTF1ByaXZhdGUg\nSW50ZXJuZXQgQWNjZXNzMSAwHgYDVQQpExdQcml2YXRlIEludGVybmV0IEFjY2Vz\nczEvMC0GCSqGSIb3DQEJARYgc2VjdXJlQHByaXZhdGVpbnRlcm5ldGFjY2Vzcy5j\nb22CCQCmew+WL/O6gzAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBDQUAA4IBAQAn\na5PgrtxfwTumD4+3/SYvwoD66cB8IcK//h1mCzAduU8KgUXocLx7QgJWo9lnZ8xU\nryXvWab2usg4fqk7FPi00bED4f4qVQFVfGfPZIH9QQ7/48bPM9RyfzImZWUCenK3\n7pdw4Bvgoys2rHLHbGen7f28knT2j/cbMxd78tQc20TIObGjo8+ISTRclSTRBtyC\nGohseKYpTS9himFERpUgNtefvYHbn70mIOzfOJFTVqfrptf9jXa9N8Mpy3ayfodz\n1wiqdteqFXkTYoSDctgKMiZ6GdocK9nMroQipIQtpnwd4yBDWIyC6Bvlkrq5TQUt\nYDQ8z9v+DMO6iwyIDRiU\n-----END CERTIFICATE-----\n","frame":1,"ping":10,"reneg":3600}},{"id":"strong","name":"Strong","comment":"256-bit encryption (slower)","cfg":{"ep":["UDP:1197","TCP:501"],"cipher":"AES-256-CBC","auth":"SHA256","ca":"-----BEGIN CERTIFICATE-----\nMIIHqzCCBZOgAwIBAgIJAJ0u+vODZJntMA0GCSqGSIb3DQEBDQUAMIHoMQswCQYD\nVQQGEwJVUzELMAkGA1UECBMCQ0ExEzARBgNVBAcTCkxvc0FuZ2VsZXMxIDAeBgNV\nBAoTF1ByaXZhdGUgSW50ZXJuZXQgQWNjZXNzMSAwHgYDVQQLExdQcml2YXRlIElu\ndGVybmV0IEFjY2VzczEgMB4GA1UEAxMXUHJpdmF0ZSBJbnRlcm5ldCBBY2Nlc3Mx\nIDAeBgNVBCkTF1ByaXZhdGUgSW50ZXJuZXQgQWNjZXNzMS8wLQYJKoZIhvcNAQkB\nFiBzZWN1cmVAcHJpdmF0ZWludGVybmV0YWNjZXNzLmNvbTAeFw0xNDA0MTcxNzQw\nMzNaFw0zNDA0MTIxNzQwMzNaMIHoMQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0Ex\nEzARBgNVBAcTCkxvc0FuZ2VsZXMxIDAeBgNVBAoTF1ByaXZhdGUgSW50ZXJuZXQg\nQWNjZXNzMSAwHgYDVQQLExdQcml2YXRlIEludGVybmV0IEFjY2VzczEgMB4GA1UE\nAxMXUHJpdmF0ZSBJbnRlcm5ldCBBY2Nlc3MxIDAeBgNVBCkTF1ByaXZhdGUgSW50\nZXJuZXQgQWNjZXNzMS8wLQYJKoZIhvcNAQkBFiBzZWN1cmVAcHJpdmF0ZWludGVy\nbmV0YWNjZXNzLmNvbTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBALVk\nhjumaqBbL8aSgj6xbX1QPTfTd1qHsAZd2B97m8Vw31c/2yQgZNf5qZY0+jOIHULN\nDe4R9TIvyBEbvnAg/OkPw8n/+ScgYOeH876VUXzjLDBnDb8DLr/+w9oVsuDeFJ9K\nV2UFM1OYX0SnkHnrYAN2QLF98ESK4NCSU01h5zkcgmQ+qKSfA9Ny0/UpsKPBFqsQ\n25NvjDWFhCpeqCHKUJ4Be27CDbSl7lAkBuHMPHJs8f8xPgAbHRXZOxVCpayZ2SND\nfCwsnGWpWFoMGvdMbygngCn6jA/W1VSFOlRlfLuuGe7QFfDwA0jaLCxuWt/BgZyl\np7tAzYKR8lnWmtUCPm4+BtjyVDYtDCiGBD9Z4P13RFWvJHw5aapx/5W/CuvVyI7p\nKwvc2IT+KPxCUhH1XI8ca5RN3C9NoPJJf6qpg4g0rJH3aaWkoMRrYvQ+5PXXYUzj\ntRHImghRGd/ydERYoAZXuGSbPkm9Y/p2X8unLcW+F0xpJD98+ZI+tzSsI99Zs5wi\njSUGYr9/j18KHFTMQ8n+1jauc5bCCegN27dPeKXNSZ5riXFL2XX6BkY68y58UaNz\nmeGMiUL9BOV1iV+PMb7B7PYs7oFLjAhh0EdyvfHkrh/ZV9BEhtFa7yXp8XR0J6vz\n1YV9R6DYJmLjOEbhU8N0gc3tZm4Qz39lIIG6w3FDAgMBAAGjggFUMIIBUDAdBgNV\nHQ4EFgQUrsRtyWJftjpdRM0+925Y6Cl08SUwggEfBgNVHSMEggEWMIIBEoAUrsRt\nyWJftjpdRM0+925Y6Cl08SWhge6kgeswgegxCzAJBgNVBAYTAlVTMQswCQYDVQQI\nEwJDQTETMBEGA1UEBxMKTG9zQW5nZWxlczEgMB4GA1UEChMXUHJpdmF0ZSBJbnRl\ncm5ldCBBY2Nlc3MxIDAeBgNVBAsTF1ByaXZhdGUgSW50ZXJuZXQgQWNjZXNzMSAw\nHgYDVQQDExdQcml2YXRlIEludGVybmV0IEFjY2VzczEgMB4GA1UEKRMXUHJpdmF0\nZSBJbnRlcm5ldCBBY2Nlc3MxLzAtBgkqhkiG9w0BCQEWIHNlY3VyZUBwcml2YXRl\naW50ZXJuZXRhY2Nlc3MuY29tggkAnS7684Nkme0wDAYDVR0TBAUwAwEB/zANBgkq\nhkiG9w0BAQ0FAAOCAgEAJsfhsPk3r8kLXLxY+v+vHzbr4ufNtqnL9/1Uuf8NrsCt\npXAoyZ0YqfbkWx3NHTZ7OE9ZRhdMP/RqHQE1p4N4Sa1nZKhTKasV6KhHDqSCt/dv\nEm89xWm2MVA7nyzQxVlHa9AkcBaemcXEiyT19XdpiXOP4Vhs+J1R5m8zQOxZlV1G\ntF9vsXmJqWZpOVPmZ8f35BCsYPvv4yMewnrtAC8PFEK/bOPeYcKN50bol22QYaZu\nLfpkHfNiFTnfMh8sl/ablPyNY7DUNiP5DRcMdIwmfGQxR5WEQoHL3yPJ42LkB5zs\n6jIm26DGNXfwura/mi105+ENH1CaROtRYwkiHb08U6qLXXJz80mWJkT90nr8Asj3\n5xN2cUppg74nG3YVav/38P48T56hG1NHbYF5uOCske19F6wi9maUoto/3vEr0rnX\nJUp2KODmKdvBI7co245lHBABWikk8VfejQSlCtDBXn644ZMtAdoxKNfR2WTFVEwJ\niyd1Fzx0yujuiXDROLhISLQDRjVVAvawrAtLZWYK31bY7KlezPlQnl/D9Asxe85l\n8jO5+0LdJ6VyOs/Hd4w52alDW/MFySDZSfQHMTIc30hLBJ8OnCEIvluVQQ2UQvoW\n+no177N9L2Y+M9TcTA62ZyMXShHQGeh20rb4kK8f+iFX8NxtdHVSkxMEFSfDDyQ=\n-----END CERTIFICATE-----\n","frame":1,"ping":10,"reneg":3600}}],"defaults":{"username":"p1234567","pool":"us-east","preset":"recommended"}} + diff --git a/Passepartout/Resources/en.lproj/Localizable.strings b/Passepartout/Resources/en.lproj/Localizable.strings new file mode 100644 index 00000000..ba3bbda8 --- /dev/null +++ b/Passepartout/Resources/en.lproj/Localizable.strings @@ -0,0 +1,176 @@ +// +// Localizable.strings +// Passepartout +// +// Created by Davide De Rosa on 6/13/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +"global.ok" = "OK"; +"global.cancel" = "Cancel"; +"global.next" = "Next"; + +"organizer.sections.providers.header" = "Networks"; +"organizer.sections.providers.footer" = "Here you find a few public infrastructures offering preset configuration profiles."; +"organizer.sections.hosts.header" = "Hosts"; +"organizer.sections.hosts.footer" = "Import hosts from raw .ovpn configuration files."; +"organizer.cells.add_provider.caption" = "Add new network"; +"organizer.cells.add_host.caption" = "Add new host"; +"organizer.cells.about.caption" = "About %@"; +"organizer.cells.uninstall.caption" = "Delete VPN profile"; +"organizer.alerts.exhausted_providers.message" = "You have created profiles for any available network."; +"organizer.alerts.add_host.message" = "Open an URL to an .ovpn configuration file from Safari, Mail or another app to set up a host profile."; +"organizer.alerts.delete_vpn_profile.message" = "Do you really want to delete the VPN profile from the device?"; + +"account.suggestion_footer.infrastructure.pia" = "Use your website credentials. Your username is usually numeric with a \"p\" prefix."; + +"wizards.host.cells.title_input.caption" = "Title"; +"wizards.host.cells.title_input.placeholder" = "My Profile"; +"wizards.host.sections.existing.header" = "Existing profiles"; +"wizards.host.alerts.existing" = "A host profile with the same title already exists. Replace it?"; +"wizards.host.alerts.parsing" = "Unable to parse the provided configuration file."; + +"service.welcome.message" = "Welcome to Passepartout!\n\nUse the organizer to add a new profile."; +"service.sections.general.header" = "General"; +"service.sections.vpn.header" = "VPN"; +"service.sections.status.header" = "Connection"; +"service.sections.diagnostics.header" = "Diagnostics"; + +"service.sections.vpn.footer" = "The connection will be established whenever necessary. Tap \"Status\" to enforce a reconnection."; +"service.sections.configuration.header" = "Configuration"; +"service.sections.provider_infrastructure.footer" = "Last updated on %@."; +"service.sections.vpn_survives_sleep.footer" = "Disable to improve battery usage, at the expense of occasional slowdowns due to wake-up reconnections."; +"service.sections.vpn_resolves_hostname.footer" = "Preferred in most networks and required in some IPv6 networks. Disable where DNS is blocked, or to speed up negotiation when DNS is slow to respond."; +//"service.sections.vpn_prefers_udp.footer" = "UDP is faster than TCP, but may not work in some networks. Disable in networks where UDP might be blocked."; +"service.sections.trusted.header" = "Trusted networks"; +"service.sections.trusted.footer" = "When entering a trusted network, an existing VPN connection will not be shut down by default. Disable to always enforce a disconnection."; +"service.sections.diagnostics.header" = "Diagnostics"; +//"service.sections.destruction.footer" = "Delete configuration from device settings."; + +"service.cells.vpn_service.caption" = "Enabled"; +"service.cells.connection_status.caption" = "Status"; +"service.cells.use_profile.caption" = "Use this profile"; +"service.cells.reconnect.caption" = "Reconnect"; +"service.cells.account.caption" = "Account"; +"service.cells.account.none" = "None configured"; +"service.cells.endpoint.caption" = "Endpoint"; +"service.cells.endpoint.value.automatic" = "Automatic"; +"service.cells.endpoint.value.manual" = "Manual"; +"service.cells.provider.pool.caption" = "Location"; +"service.cells.provider.preset.caption" = "Preset"; +"service.cells.provider.refresh.caption" = "Refresh infrastructure"; +"service.cells.host.parameters.caption" = "Parameters"; +"service.cells.host.parameters.value.cipher" = "%@"; +"service.cells.host.parameters.value.cipher_digest" = "%@ / %@"; +"service.cells.vpn_survives_sleep.caption" = "Keep alive on sleep"; +"service.cells.vpn_resolves_hostname.caption" = "Resolve server hostname"; +//"service.cells.vpn_prefers_udp.caption" = "Prefer UDP socket"; +"service.cells.trusted_mobile.caption" = "Cellular network"; +"service.cells.trusted_wifi.caption" = "%@"; +"service.cells.trusted_add_wifi.caption" = "Trust current Wi-Fi"; +"service.cells.trusted_policy.caption" = "Retain existing connection"; +"service.cells.test_connectivity.caption" = "Test connectivity"; +"service.cells.data_count.caption" = "Exchanged bytes count"; +"service.cells.debug_log.caption" = "Debug log"; + +"service.alerts.configuration_needed.message" = "You need to finish configuration first."; +"service.alerts.reconnect_vpn.message" = "Do you want to reconnect to the VPN?"; +"service.alerts.trusted.no_network.message" = "You are not connected to any Wi-Fi network."; +"service.alerts.trusted.will_disconnect_trusted.message" = "By trusting this network, the VPN may be disconnected. Continue?"; +"service.alerts.trusted.will_disconnect_policy.message" = "By changing the trust policy, the VPN may be disconnected. Continue?"; +"service.alerts.test_connectivity.title" = "Connectivity"; +"service.alerts.test_connectivity.messages.success" = "Your device is connected to the Internet!"; +"service.alerts.test_connectivity.messages.failure" = "Your device has no Internet connectivity, please review your profile parameters."; +"service.alerts.data_count.messages.current" = "Received: %llu\nSent: %llu"; +"service.alerts.data_count.messages.not_available" = "Information not available, are you connected?"; + +"account.cells.username.caption" = "Username"; +"account.cells.username.placeholder" = "username"; +"account.cells.password.caption" = "Password"; +"account.cells.password.placeholder" = "secret"; +"account.cells.password_confirm.caption" = "Confirm"; +"account.cells.password_confirm.mismatch" = "Passwords don't match!"; + +"endpoint.sections.location_addresses.header" = "Addresses"; +"endpoint.sections.location_protocols.header" = "Protocols"; +"endpoint.cells.any_address.caption" = "Any"; +"endpoint.cells.any_protocol.caption" = "Any"; + +"provider.preset.cells.tech_details.caption" = "Technical details"; +//"provider.preset.sections.main.footer" = "Tap info button to disclose technical details."; + +"configuration.sections.communication.header" = "Communication"; +"configuration.sections.communication.footer.editable" = "Make sure to match server communication parameters, otherwise you will end up with broken connectivity."; +"configuration.sections.tls.header" = "TLS"; +"configuration.sections.other.header" = "Other"; +"configuration.cells.cipher.caption" = "Cipher"; +"configuration.cells.digest.caption" = "Authentication"; +"configuration.cells.digest.value.embedded" = "Embedded"; +"configuration.cells.compression_frame.caption" = "Framing"; +"configuration.cells.compression_frame.value.disabled" = "None"; +"configuration.cells.compression_frame.value.lzo" = "LZO"; +"configuration.cells.compression_frame.value.compress" = "Compress"; +"configuration.cells.client.caption" = "Client certificate"; +"configuration.cells.client.value.enabled" = "Verified"; +"configuration.cells.client.value.disabled" = "Not verified"; +"configuration.cells.tls_wrapping.caption" = "Wrapping"; +"configuration.cells.tls_wrapping.value.auth" = "Authentication"; +"configuration.cells.tls_wrapping.value.crypt" = "Encryption"; +"configuration.cells.tls_wrapping.value.disabled" = "Disabled"; +"configuration.cells.compression_algorithm.caption" = "Compression"; +"configuration.cells.compression_algorithm.value.disabled" = "Disabled"; +"configuration.cells.keep_alive.caption" = "Keep-alive"; +"configuration.cells.keep_alive.value.seconds" = "%d seconds"; +"configuration.cells.keep_alive.value.never" = "Disabled"; +"configuration.cells.renegotiation_seconds.caption" = "Renegotiation"; +"configuration.cells.renegotiation_seconds.value.after" = "after %@"; +"configuration.cells.renegotiation_seconds.value.never" = "Disabled"; + +"debug_log.buttons.previous" = "Previous"; +"debug_log.buttons.next" = "Next"; +"debug_log.alerts.empty_log.message" = "The debug log is empty."; + +"vpn.connecting" = "Connecting"; +"vpn.active" = "Active"; +"vpn.disconnecting" = "Disconnecting"; +"vpn.inactive" = "Inactive"; +"vpn.disabled" = "Disabled"; + +"issue_reporter.title" = "Report issue"; +"issue_reporter.message" = "Do you want to attach the debug log of your latest connections? The log is crucial to resolve your connectivity issues and is completely anonymous."; +"issue_reporter.buttons.with_log" = "Attach debug log"; +"issue_reporter.buttons.without_log" = "Omit debug log"; +"issue_reporter.alerts.email_not_configured.message" = "No e-mail account is configured."; +"issue_reporter.email.subject" = "%@ - Report issue"; +"issue_reporter.email.body" = "Hi,\n\ndescription of the issue:\n\n%@\n\nRegards"; + +"about.title" = "About"; +"about.sections.info.header" = "General"; +"about.sections.source.header" = "Source code"; +"about.sections.feedback.header" = "Feedback"; +"about.cells.version.caption" = "Version"; +"about.cells.write_review.caption" = "Write a review"; +"about.cells.website.caption" = "Visit website"; + +"version.labels.intro" = "Passepartout and TunnelKit are written and maintained by Davide De Rosa (keeshux).\n\nTunnelKit is a native OpenVPN client originally forked from PIATunnel by Private Internet Access.\n\nSource code for Passepartout and TunnelKit is publicly available on GitHub under the GPLv3."; +"version.buttons.changelog" = "CHANGELOG"; + +"credits.title" = "Credits"; +"credits.labels.third_parties" = "Passepartout is a non-official client and is in no way affiliated with OpenVPN Inc.\n\nThe logo is taken from the awesome Circle Icons set by Nick Roach."; diff --git a/Passepartout/Sources/AppConstants.swift b/Passepartout/Sources/AppConstants.swift new file mode 100644 index 00000000..d893af81 --- /dev/null +++ b/Passepartout/Sources/AppConstants.swift @@ -0,0 +1,144 @@ +// +// AppConstants.swift +// Passepartout +// +// Created by Davide De Rosa on 9/15/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import Foundation +import TunnelKit +import SwiftyBeaver + +class AppConstants { + class Domain { + static let name = "passepartoutvpn.app" + } + + class Store { + static let serviceFilename = "ConnectionService.json" + + static let infrastructureCacheDirectory = "Infrastructures" + } + + class VPN { + static func tunnelConfiguration() -> TunnelKitProvider.Configuration { + var builder = TunnelKitProvider.ConfigurationBuilder(ca: CryptoContainer(pem: "")) + builder.mtu = 1250 + builder.shouldDebug = true +// builder.debugLogFormat = "$Dyyyy-MM-dd HH:mm:ss.SSS$d $L $N.$F:$l - $M" +// builder.debugLogFormat = "$DHH:mm:ss$d $N.$F:$l - $M" + builder.debugLogFormat = Log.debugFormat + builder.debugLogKey = "LastVPNLog" + return builder.build() + } + + private static let connectivityStrings: [String] = [ + "https://www.amazon.com", + "https://www.google.com", + "https://www.twitter.com", + "https://www.facebook.com", + "https://www.instagram.com" + ] + + static let connectivityURL = URL(string: connectivityStrings.customRandomElement())! + + static let connectivityTimeout: TimeInterval = 10.0 + } + + class Providers { + private static let baseURL = URL(string: "https://api.\(Domain.name)/v1/")! + + static func url(path: String) -> URL { + return baseURL.appendingPathComponent(path) + } + + static let webTimeout: TimeInterval = 3.0 + + static let minimumUpdateInterval: TimeInterval = 600.0 // 10 minutes + } + + class Log { + static let debugFormat = "$DHH:mm:ss$d - $M" + + static var debugSnapshot: () -> String = { TransientStore.shared.service.vpnLog } + + static var debugFilename: String { + let fmt = DateFormatter() + fmt.dateFormat = "yyyyMMdd-HHmmss" + let iso = fmt.string(from: Date()) + return "debug-\(iso).txt" + } + + static let viewerRefreshInterval: TimeInterval = 3.0 + + static func configure() { + let console = ConsoleDestination() + console.useNSLog = true + console.minLevel = .verbose + SwiftyBeaver.addDestination(console) + } + } + + class IssueReporter { + static let recipient = "issues@\(Domain.name)" + + static let attachmentMIME = "text/plain" + } + + class URLs { + static let website = URL(string: "https://\(Domain.name)")! + + static let changelog = Repos.passepartout.appendingPathComponent("blob/master/CHANGELOG.md") + + static func review(withId id: String) -> URL { + return URL(string: "https://itunes.apple.com/app/id\(id)?action=write-review")! + } + } + + class Repos { + private static let githubRoot = URL(string: "https://github.com/keeshux/")! + + private static func github(repo: String) -> URL { + return githubRoot.appendingPathComponent(repo) + } + + static let passepartout = github(repo: "passepartout-ios") + + static let tunnelKit = github(repo: "tunnelkit") + } + + class Notices { + private static let pia = "PIATunnel - Copyright (c) 2018-Present Private Internet Access" + + private static let swiftyBeaver = "SwiftyBeaver - Copyright (c) 2015 Sebastian Kreutzberger" + + private static let openVPN = "© 2002-2018 OpenVPN Inc. - OpenVPN is a registered trademark of OpenVPN Inc." + + private static let openSSL = "This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit. https://www.openssl.org/" + + static let all: [String] = [ + pia, + swiftyBeaver, + openVPN, + openSSL + ] + } +} diff --git a/Passepartout/Sources/ApplicationError.swift b/Passepartout/Sources/ApplicationError.swift new file mode 100644 index 00000000..d3c89ce4 --- /dev/null +++ b/Passepartout/Sources/ApplicationError.swift @@ -0,0 +1,44 @@ +// +// ApplicationError.swift +// Passepartout +// +// Created by Davide De Rosa on 6/12/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import Foundation + +enum ApplicationError: String, Error { + case missingProfile + + case missingCredentials + + case providerPool + + case providerPreset + + case hostEndpoints + + case missingCA + + case emptyRemotes + + case unsupportedConfiguration +} diff --git a/Passepartout/Sources/GroupConstants.swift b/Passepartout/Sources/GroupConstants.swift new file mode 100644 index 00000000..21ef0234 --- /dev/null +++ b/Passepartout/Sources/GroupConstants.swift @@ -0,0 +1,66 @@ +// +// GroupConstants.swift +// Passepartout +// +// Created by Davide De Rosa on 6/7/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import Foundation + +class GroupConstants { + class App { + static let name = "Passepartout" + + static let tunnelKitName = "TunnelKit" + + static let title = name +// static let title = "\u{1F511}" + + static var version: String? { + guard let info = Bundle.main.infoDictionary else { + return nil + } + let versionNumber = info["CFBundleShortVersionString"] as! String + let buildNumber = info[kCFBundleVersionKey as String] as! String + return "\(versionNumber) (\(buildNumber))" + } + + static let teamId = "5357M5NW9W" + + static let appId = "1433648537" + + #if os(iOS) + static let appGroup = "group.com.algoritmico.Passepartout" + + static let tunnelIdentifier = "com.algoritmico.ios.Passepartout.Tunnel" + #else + static let appGroup = "\(teamId).group.com.algoritmico.Passepartout" + + static let tunnelIdentifier = "com.algoritmico.macos.Passepartout.Tunnel" + #endif + } + + class VPN { + static let dnsTimeout = 5000 + + static let sessionMarker = "--- EOF ---" + } +} diff --git a/Passepartout/Sources/Model/ConnectionProfile.swift b/Passepartout/Sources/Model/ConnectionProfile.swift new file mode 100644 index 00000000..5aa7c3b3 --- /dev/null +++ b/Passepartout/Sources/Model/ConnectionProfile.swift @@ -0,0 +1,67 @@ +// +// ConnectionProfile.swift +// Passepartout +// +// Created by Davide De Rosa on 9/2/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import Foundation +import TunnelKit +import NetworkExtension + +protocol ConnectionProfile: class, EndpointDataSource { + var id: String { get } + + var title: String { get } + + var username: String? { get set } + + var isConfigured: Bool { get } + + func generate(from configuration: TunnelKitProvider.Configuration, preferences: Preferences) throws -> TunnelKitProvider.Configuration +} + +extension ConnectionProfile { + var passwordKey: String? { + guard let username = username else { + return nil + } + return "\(Bundle.main.bundleIdentifier!).\(id).\(username)" + } + + func password(in keychain: Keychain) -> String? { + guard let key = passwordKey else { + return nil + } + return try? keychain.password(for: key) + } + + func setPassword(_ password: String?, in keychain: Keychain) throws { + guard let key = passwordKey else { + return + } + guard let password = password else { + keychain.removePassword(for: key) + return + } + try keychain.set(password: password, for: key, label: key) + } +} diff --git a/Passepartout/Sources/Model/ConnectionProfileHolder.swift b/Passepartout/Sources/Model/ConnectionProfileHolder.swift new file mode 100644 index 00000000..ff795bc4 --- /dev/null +++ b/Passepartout/Sources/Model/ConnectionProfileHolder.swift @@ -0,0 +1,59 @@ +// +// ConnectionProfileHolder.swift +// Passepartout +// +// Created by Davide De Rosa on 9/3/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import Foundation +import TunnelKit + +class ConnectionProfileHolder: Codable { + private let provider: ProviderConnectionProfile? + + private let host: HostConnectionProfile? + + convenience init(_ profile: ConnectionProfile) { + if let p = profile as? ProviderConnectionProfile { + self.init(p) + } else if let p = profile as? HostConnectionProfile { + self.init(p) + } else { + fatalError("Unexpected ConnectionProfile subtype: \(type(of: profile))") + } + } + + init(_ provider: ProviderConnectionProfile) { + self.provider = provider + host = nil + } + + init(_ host: HostConnectionProfile) { + provider = nil + self.host = host + } + + var contained: ConnectionProfile? { + let found: ConnectionProfile? = provider ?? host + assert(found != nil, "Either provider or host must be non-nil") + return found + } +} diff --git a/Passepartout/Sources/Model/ConnectionService.swift b/Passepartout/Sources/Model/ConnectionService.swift new file mode 100644 index 00000000..e4734bdf --- /dev/null +++ b/Passepartout/Sources/Model/ConnectionService.swift @@ -0,0 +1,280 @@ +// +// ConnectionService.swift +// Passepartout +// +// Created by Davide De Rosa on 9/3/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import Foundation +import TunnelKit +import NetworkExtension +import SwiftyBeaver + +private let log = SwiftyBeaver.self + +protocol ConnectionServiceDelegate: class { + func connectionService(didActivate profile: ConnectionProfile) + + func connectionService(didDeactivate profile: ConnectionProfile) +} + +class ConnectionService: Codable { + enum CodingKeys: String, CodingKey { + case appGroup + + case tunnelConfiguration + + case profiles + + case activeProfileId + + case preferences + } + + private let appGroup: String + + private let defaults: UserDefaults + + private let keychain: Keychain + + var tunnelConfiguration: TunnelKitProvider.Configuration + + private var profiles: [String: ConnectionProfile] + + private var activeProfileId: String? { + willSet { + if let oldProfile = activeProfile { + delegate?.connectionService(didDeactivate: oldProfile) + } + } + didSet { + if let newProfile = activeProfile { + delegate?.connectionService(didActivate: newProfile) + } + } + } + + var activeProfile: ConnectionProfile? { + guard let id = activeProfileId else { + return nil + } + return profiles[id] + } + + let preferences: EditablePreferences + + weak var delegate: ConnectionServiceDelegate? + + init(withAppGroup appGroup: String, tunnelConfiguration: TunnelKitProvider.Configuration) { + guard let defaults = UserDefaults(suiteName: appGroup) else { + fatalError("No entitlements for group '\(appGroup)'") + } + self.appGroup = appGroup + self.defaults = defaults + keychain = Keychain(group: appGroup) + + self.tunnelConfiguration = tunnelConfiguration + profiles = [:] + activeProfileId = nil + preferences = EditablePreferences() + } + + // MARK: Codable + + required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + let appGroup = try container.decode(String.self, forKey: .appGroup) + guard let defaults = UserDefaults(suiteName: appGroup) else { + fatalError("No entitlements for group '\(appGroup)'") + } + self.appGroup = appGroup + self.defaults = defaults + keychain = Keychain(group: appGroup) + + tunnelConfiguration = try container.decode(TunnelKitProvider.Configuration.self, forKey: .tunnelConfiguration) + let profilesArray = try container.decode([ConnectionProfileHolder].self, forKey: .profiles).map { $0.contained } + var profiles: [String: ConnectionProfile] = [:] + profilesArray.forEach { + guard let p = $0 else { + return + } + profiles[p.id] = p + } + self.profiles = profiles + activeProfileId = try container.decodeIfPresent(String.self, forKey: .activeProfileId) + preferences = try container.decode(EditablePreferences.self, forKey: .preferences) + } + + func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(appGroup, forKey: .appGroup) + try container.encode(tunnelConfiguration, forKey: .tunnelConfiguration) + try container.encode(profiles.map { ConnectionProfileHolder($0.value) }, forKey: .profiles) + try container.encodeIfPresent(activeProfileId, forKey: .activeProfileId) + try container.encode(preferences, forKey: .preferences) + } + + // MARK: Profiles + + func profileIds() -> [String] { + return Array(profiles.keys) + } + + func profile(withId id: String) -> ConnectionProfile? { + return profiles[id] + } + + func addProfile(_ profile: ConnectionProfile, credentials: Credentials?) -> Bool { + guard profiles.index(forKey: profile.id) == nil else { + return false + } + addOrReplaceProfile(profile, credentials: credentials) + return true + } + + func addOrReplaceProfile(_ profile: ConnectionProfile, credentials: Credentials?) { + profiles[profile.id] = profile + try? setCredentials(credentials, for: profile) + if profiles.count == 1 { + activeProfileId = profile.id + } + } + + func removeProfile(_ profile: ConnectionProfile) { + guard let i = profiles.index(forKey: profile.id) else { + return + } + profiles.remove(at: i) + if profiles.isEmpty { + activeProfileId = nil + } + } + + func containsProfile(_ profile: ConnectionProfile) -> Bool { + return profiles.index(forKey: profile.id) != nil + } + + func hasActiveProfile() -> Bool { + return activeProfileId != nil + } + + func isActiveProfile(_ profile: ConnectionProfile) -> Bool { + return profile.id == activeProfileId + } + + func canActivate(_ profile: ConnectionProfile) -> Bool { + return profile.isConfigured && hasCredentials(for: profile) + } + + func activateProfile(_ profile: ConnectionProfile) { + activeProfileId = profile.id + } + + // MARK: Credentials + + func hasCredentials(for profile: ConnectionProfile) -> Bool { + guard let creds = credentials(for: profile) else { + return false + } + return !creds.isEmpty + } + + func credentials(for profile: ConnectionProfile) -> Credentials? { + guard let username = profile.username, let key = profile.passwordKey else { + return nil + } + guard let password = try? keychain.password(for: key) else { + return nil + } + return Credentials(username, password) + } + + func setCredentials(_ credentials: Credentials?, for profile: ConnectionProfile) throws { + profile.username = credentials?.username + try profile.setPassword(credentials?.password, in: keychain) + } + + // MARK: VPN + + func vpnConfiguration() throws -> NetworkExtensionVPNConfiguration { + guard let profile = activeProfile else { + throw ApplicationError.missingProfile + } + guard let credentials = credentials(for: profile) else { + throw ApplicationError.missingCredentials + } + + let cfg = try profile.generate(from: tunnelConfiguration, preferences: preferences) + let protocolConfiguration = try cfg.generatedTunnelProtocol( + withBundleIdentifier: GroupConstants.App.tunnelIdentifier, + appGroup: appGroup, + hostname: profile.mainAddress, + credentials: credentials + ) + protocolConfiguration.disconnectOnSleep = preferences.disconnectsOnSleep + + log.verbose("Configuration:") + log.verbose(protocolConfiguration) + + var rules: [NEOnDemandRule] = [] + #if os(iOS) + if preferences.trustsMobileNetwork { + let rule = policyRule() + rule.interfaceTypeMatch = .cellular + rules.append(rule) + } + #endif + let reallyTrustedWifis = Array(preferences.trustedWifis.filter { $1 }.keys) + if !reallyTrustedWifis.isEmpty { + let rule = policyRule() + rule.interfaceTypeMatch = .wiFi + rule.ssidMatch = reallyTrustedWifis + rules.append(rule) + } + rules.append(NEOnDemandRuleConnect()) + + return NetworkExtensionVPNConfiguration(protocolConfiguration: protocolConfiguration, onDemandRules: rules) + } + + private func policyRule() -> NEOnDemandRule { + switch preferences.trustPolicy { + case .ignore: + return NEOnDemandRuleIgnore() + + case .disconnect: + return NEOnDemandRuleDisconnect() + } + } + + var vpnLog: String { + guard let logKey = tunnelConfiguration.debugLogKey else { + return "" + } + guard let lines = defaults.array(forKey: logKey) as? [String] else { + return "" + } + return lines.joined(separator: "\n") + } + +// func eraseVpnLog() { +// defaults.removeObject(forKey: Keys.vpnLog) +// } +} diff --git a/Passepartout/Sources/Model/Credentials.swift b/Passepartout/Sources/Model/Credentials.swift new file mode 100644 index 00000000..1e89ef41 --- /dev/null +++ b/Passepartout/Sources/Model/Credentials.swift @@ -0,0 +1,41 @@ +// +// Credentials.swift +// Passepartout +// +// Created by Davide De Rosa on 6/7/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import Foundation +import TunnelKit + +typealias Credentials = SessionProxy.Credentials + +extension Credentials { + var isEmpty: Bool { + return username.isEmpty || password.isEmpty + } + + func trimmed() -> Credentials { + let trimmedUsername = username.trimmingCharacters(in: .whitespacesAndNewlines) + let trimmedPassword = password.trimmingCharacters(in: .whitespacesAndNewlines) + return Credentials(trimmedUsername, trimmedPassword) + } +} diff --git a/Passepartout/Sources/Model/DebugLog.swift b/Passepartout/Sources/Model/DebugLog.swift new file mode 100644 index 00000000..ecc38b82 --- /dev/null +++ b/Passepartout/Sources/Model/DebugLog.swift @@ -0,0 +1,86 @@ +// +// DebugLog.swift +// Passepartout +// +// Created by Davide De Rosa on 6/26/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import Foundation +#if os(iOS) +import UIKit +#else +import Cocoa +#endif + +struct DebugLog { + private let raw: String + + init(raw: String) { + self.raw = raw + } + + func string() -> String { + return raw + } + + func data() -> Data? { + return raw.data(using: .utf8) + } + + func decoratedString() -> String { + guard let appVersion = GroupConstants.App.version else { + fatalError("Could not find bundle app version?") + } + let appName = GroupConstants.App.name + + var metadata: [String] = [] + let osVersion: String + let deviceType: String? + + #if os(iOS) + let device = UIDevice.current + osVersion = "\(device.systemName) \(device.systemVersion)" + deviceType = device.model + #else + let os = ProcessInfo().operatingSystemVersion + osVersion = "macOS \(os.majorVersion).\(os.minorVersion).\(os.patchVersion)" + deviceType = nil + #endif + + metadata.append("App: \(appName) \(appVersion)") + metadata.append("OS: \(osVersion)") + if let deviceType = deviceType { + metadata.append("Device: \(deviceType)") + } + + var fullText = metadata.joined(separator: "\n") + fullText += "\n\n" + fullText += raw + return fullText + } + + func decoratedData() -> Data { + guard let data = decoratedString().data(using: .utf8) else { + fatalError("Could not encode log metadata to UTF8?") + } + return data + } +} diff --git a/Passepartout/Sources/Model/EndpointDataSource.swift b/Passepartout/Sources/Model/EndpointDataSource.swift new file mode 100644 index 00000000..50fcfc0c --- /dev/null +++ b/Passepartout/Sources/Model/EndpointDataSource.swift @@ -0,0 +1,41 @@ +// +// EndpointDataSource.swift +// Passepartout +// +// Created by Davide De Rosa on 9/5/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import Foundation +import TunnelKit + +protocol EndpointDataSource { + var mainAddress: String { get } + + var addresses: [String] { get } + + var protocols: [TunnelKitProvider.EndpointProtocol] { get } + + var canCustomizeEndpoint: Bool { get } + + var customAddress: String? { get } + + var customProtocol: TunnelKitProvider.EndpointProtocol? { get } +} diff --git a/Passepartout/Sources/Model/Preferences.swift b/Passepartout/Sources/Model/Preferences.swift new file mode 100644 index 00000000..e4aef0ac --- /dev/null +++ b/Passepartout/Sources/Model/Preferences.swift @@ -0,0 +1,54 @@ +// +// Preferences.swift +// Passepartout +// +// Created by Davide De Rosa on 9/4/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import Foundation + +protocol Preferences { + var resolvesHostname: Bool { get } + + var disconnectsOnSleep: Bool { get } + + #if os(iOS) + var trustsMobileNetwork: Bool { get } + #endif + + var trustedWifis: [String: Bool] { get } + + var trustPolicy: TrustPolicy { get } +} + +class EditablePreferences: Preferences, Codable { + var resolvesHostname: Bool = true + + var disconnectsOnSleep: Bool = false + + #if os(iOS) + var trustsMobileNetwork: Bool = false + #endif + + var trustedWifis: [String: Bool] = [:] + + var trustPolicy: TrustPolicy = .ignore +} diff --git a/Passepartout/Sources/Model/Profiles/HostConnectionProfile.swift b/Passepartout/Sources/Model/Profiles/HostConnectionProfile.swift new file mode 100644 index 00000000..3c47e54f --- /dev/null +++ b/Passepartout/Sources/Model/Profiles/HostConnectionProfile.swift @@ -0,0 +1,100 @@ +// +// HostConnectionProfile.m +// Passepartout +// +// Created by Davide De Rosa on 9/2/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import Foundation +import TunnelKit + +class HostConnectionProfile: ConnectionProfile, Codable, Equatable { + let hostname: String + + var parameters: TunnelKitProvider.Configuration + + init(title: String, hostname: String) { + self.title = title + self.hostname = hostname + parameters = TunnelKitProvider.ConfigurationBuilder(ca: CryptoContainer(pem: "")).build() + } + + // MARK: ConnectionProfile + + var id: String { + return "host.\(title)" + } + + var title: String + + var username: String? + + var isConfigured: Bool { + return !parameters.endpointProtocols.isEmpty + } + + func generate(from configuration: TunnelKitProvider.Configuration, preferences: Preferences) throws -> TunnelKitProvider.Configuration { + guard !parameters.endpointProtocols.isEmpty else { + throw ApplicationError.hostEndpoints + } + + // XXX: copy paste, error prone + var builder = parameters.builder() + builder.mtu = configuration.mtu + builder.shouldDebug = configuration.shouldDebug + builder.debugLogFormat = configuration.debugLogFormat + builder.debugLogKey = configuration.debugLogKey + + return builder.build() + } +} + +extension HostConnectionProfile { + static func ==(lhs: HostConnectionProfile, rhs: HostConnectionProfile) -> Bool { + return lhs.id == rhs.id + } +} + +extension HostConnectionProfile { + var mainAddress: String { + return hostname + } + + var addresses: [String] { + return [hostname] + } + + var protocols: [TunnelKitProvider.EndpointProtocol] { + return parameters.endpointProtocols + } + + var canCustomizeEndpoint: Bool { + return false + } + + var customAddress: String? { + return nil + } + + var customProtocol: TunnelKitProvider.EndpointProtocol? { + return nil + } +} diff --git a/Passepartout/Sources/Model/Profiles/ProviderConnectionProfile.swift b/Passepartout/Sources/Model/Profiles/ProviderConnectionProfile.swift new file mode 100644 index 00000000..1f66a73c --- /dev/null +++ b/Passepartout/Sources/Model/Profiles/ProviderConnectionProfile.swift @@ -0,0 +1,177 @@ +// +// ProviderConnectionProfile.swift +// Passepartout +// +// Created by Davide De Rosa on 9/2/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import Foundation +import TunnelKit + +class ProviderConnectionProfile: ConnectionProfile, Codable, Equatable { + let name: Infrastructure.Name + + var infrastructure: Infrastructure { + return InfrastructureFactory.shared.get(name) + } + + var poolId: String { + didSet { + validateEndpoint() + } + } + + var pool: Pool? { + return infrastructure.pool(for: poolId) + } + + var presetId: String { + didSet { + validateEndpoint() + } + } + + var preset: InfrastructurePreset? { + return infrastructure.preset(for: presetId) + } + + var manualAddress: String? + + var manualProtocol: TunnelKitProvider.EndpointProtocol? + + var usesProviderEndpoint: Bool { + return (manualAddress != nil) || (manualProtocol != nil) + } + + init(name: Infrastructure.Name) { + self.name = name + poolId = "" + presetId = "" + + id = "provider.\(name.rawValue)" + username = nil + + poolId = infrastructure.defaults.pool + presetId = infrastructure.defaults.preset + } + + func sortedPools() -> [Pool] { + return infrastructure.pools.sorted { $0.name < $1.name } + } + + private func validateEndpoint() { + guard let pool = pool, let preset = preset else { + manualAddress = nil + manualProtocol = nil + return + } + if let address = manualAddress, !pool.hasAddress(address) { + manualAddress = nil + } + if let proto = manualProtocol, !preset.hasProtocol(proto) { + manualProtocol = nil + } + } + + // MARK: ConnectionProfile + + let id: String + + var title: String { + return name.rawValue + } + + var username: String? + + var isConfigured: Bool { + return (pool != nil) && (preset != nil) + } + + func generate(from configuration: TunnelKitProvider.Configuration, preferences: Preferences) throws -> TunnelKitProvider.Configuration { + guard let pool = pool else { + throw ApplicationError.providerPool + } + guard let preset = preset else { + throw ApplicationError.providerPreset + } + +// assert(!pool.numericAddresses.isEmpty) + + // XXX: copy paste, error prone + var builder = preset.configuration.builder() + builder.mtu = configuration.mtu + builder.shouldDebug = configuration.shouldDebug + builder.debugLogFormat = configuration.debugLogFormat + builder.debugLogKey = configuration.debugLogKey + + if let address = manualAddress { + builder.prefersResolvedAddresses = true + builder.resolvedAddresses = [address] + } else { + builder.prefersResolvedAddresses = !preferences.resolvesHostname + builder.resolvedAddresses = pool.addresses(sorted: false) + } + + if let proto = manualProtocol { + builder.endpointProtocols = [proto] + } else { + builder.endpointProtocols = preset.configuration.endpointProtocols +// builder.endpointProtocols = [ +// TunnelKitProvider.EndpointProtocol(.udp, 8080), +// TunnelKitProvider.EndpointProtocol(.tcp, 443) +// ] + } + return builder.build() + } +} + +extension ProviderConnectionProfile { + static func ==(lhs: ProviderConnectionProfile, rhs: ProviderConnectionProfile) -> Bool { + return lhs.id == rhs.id + } +} + +extension ProviderConnectionProfile { + var mainAddress: String { + assert(pool != nil, "Getting provider main address but no pool set") + return pool?.hostname ?? "" + } + + var addresses: [String] { + return pool?.addresses(sorted: true) ?? [] + } + + var protocols: [TunnelKitProvider.EndpointProtocol] { + return preset?.configuration.endpointProtocols ?? [] + } + + var canCustomizeEndpoint: Bool { + return true + } + + var customAddress: String? { + return manualAddress + } + + var customProtocol: TunnelKitProvider.EndpointProtocol? { + return manualProtocol + } +} diff --git a/Passepartout/Sources/Model/TransientStore.swift b/Passepartout/Sources/Model/TransientStore.swift new file mode 100644 index 00000000..8125e194 --- /dev/null +++ b/Passepartout/Sources/Model/TransientStore.swift @@ -0,0 +1,69 @@ +// +// TransientStore.swift +// Passepartout +// +// Created by Davide De Rosa on 7/16/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import Foundation +import SwiftyBeaver + +private let log = SwiftyBeaver.self + +class TransientStore { + static let shared = TransientStore() + + private let servicePath: URL + + let service: ConnectionService + + private init() { + servicePath = FileManager.default.userURL( + for: .documentDirectory, + appending: AppConstants.Store.serviceFilename + ) + let cfg = AppConstants.VPN.tunnelConfiguration() + do { + let data = try Data(contentsOf: servicePath) + if let content = String(data: data, encoding: .utf8) { + log.verbose("Service JSON:") + log.verbose(content) + } + service = try JSONDecoder().decode(ConnectionService.self, from: data) + service.tunnelConfiguration = cfg + } catch let e { + log.error("Could not decode service: \(e)") + service = ConnectionService( + withAppGroup: GroupConstants.App.appGroup, + tunnelConfiguration: cfg + ) + +// // hardcoded loading +// _ = service.addProfile(ProviderConnectionProfile(name: .pia), credentials: nil) +// _ = service.addProfile(HostConnectionProfile(title: "vps"), credentials: Credentials(username: "foo", password: "bar")) +// service.activateProfile(service.profiles.first!) + } + } + + func serialize() { + try? JSONEncoder().encode(service).write(to: servicePath) + } +} diff --git a/Passepartout/Sources/Model/TrustPolicy.swift b/Passepartout/Sources/Model/TrustPolicy.swift new file mode 100644 index 00000000..697fa1a4 --- /dev/null +++ b/Passepartout/Sources/Model/TrustPolicy.swift @@ -0,0 +1,32 @@ +// +// TrustPolicy.swift +// Passepartout +// +// Created by Davide De Rosa on 9/2/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import Foundation + +enum TrustPolicy: String, Codable { + case ignore + + case disconnect +} diff --git a/Passepartout/Sources/Model/TrustedNetworks.swift b/Passepartout/Sources/Model/TrustedNetworks.swift new file mode 100644 index 00000000..cba89ce6 --- /dev/null +++ b/Passepartout/Sources/Model/TrustedNetworks.swift @@ -0,0 +1,217 @@ +// +// TrustedNetworks.swift +// Passepartout +// +// Created by Davide De Rosa on 6/21/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import Foundation + +protocol TrustedNetworksModelDelegate: class { + func trustedNetworksCouldDisconnect(_: TrustedNetworksModel) -> Bool + + func trustedNetworksShouldConfirmDisconnection(_: TrustedNetworksModel, triggeredAt rowIndex: Int, completionHandler: @escaping () -> Void) + + func trustedNetworks(_: TrustedNetworksModel, shouldInsertWifiAt rowIndex: Int) + + func trustedNetworks(_: TrustedNetworksModel, shouldReloadWifiAt rowIndex: Int, isTrusted: Bool) + + func trustedNetworks(_: TrustedNetworksModel, shouldDeleteWifiAt rowIndex: Int) + + func trustedNetworksShouldReinstall(_: TrustedNetworksModel) +} + +class TrustedNetworksModel { + private(set) var trustedWifis: [String: Bool] + + private(set) var sortedWifis: [String] + + #if os(iOS) + private let hasMobileNetwork: Bool + + private(set) var trustsMobileNetwork: Bool + + private(set) var rows: [ServiceViewController.RowType] + #endif + + weak var delegate: TrustedNetworksModelDelegate? + + init() { + trustedWifis = [:] + sortedWifis = [] + + #if os(iOS) + hasMobileNetwork = Utils.hasCellularData() + trustsMobileNetwork = false + rows = [] + #endif + } + + func load(from preferences: Preferences) { + trustedWifis = preferences.trustedWifis + sortedWifis = trustedWifis.keys.sorted() + + #if os(iOS) + trustsMobileNetwork = preferences.trustsMobileNetwork + rows.removeAll() + if hasMobileNetwork { + rows.append(.trustedMobile) + } + for _ in sortedWifis { + rows.append(.trustedWiFi) + } + rows.append(.trustedAddCurrentWiFi) + #endif + } + + #if os(iOS) + func setMobile(_ isTrusted: Bool) { + let completionHandler: () -> Void = { + self.trustsMobileNetwork = isTrusted + self.delegate?.trustedNetworksShouldReinstall(self) + } + guard !(isTrusted && mightDisconnect()) else { + delegate?.trustedNetworksShouldConfirmDisconnection(self, triggeredAt: 0, completionHandler: completionHandler) + return + } + completionHandler() + } + #endif + + func wifi(at rowIndex: Int) -> (String, Bool) { + let index = indexForWifi(at: rowIndex) + let wifiName = sortedWifis[index] + let isTrusted = trustedWifis[wifiName] ?? false + return (wifiName, isTrusted) + } + + func addCurrentWifi() -> Bool { + guard let currentWifi = Utils.currentWifiNetworkName() else { + return false + } + addWifi(currentWifi) + return true + } + + func addWifi(_ wifiToAdd: String) { + var index = 0 + var isDuplicate = false + for wifi in sortedWifis { + guard wifiToAdd != wifi else { + isDuplicate = true + break + } + guard wifiToAdd > wifi else { + break + } + index += 1 + } + + guard !(trustedWifis[wifiToAdd] ?? false) else { + return + } + + let rowIndex = rowIndexForWifi(at: index) + let completionHandler: () -> Void = { + self.trustedWifis[wifiToAdd] = true + + if !isDuplicate { + self.sortedWifis.insert(wifiToAdd, at: index) + #if os(iOS) + self.rows.insert(.trustedWiFi, at: rowIndex) + #endif + self.delegate?.trustedNetworks(self, shouldInsertWifiAt: rowIndex) + } else { + self.delegate?.trustedNetworks(self, shouldReloadWifiAt: rowIndex, isTrusted: true) + } + + self.delegate?.trustedNetworksShouldReinstall(self) + } + guard !mightDisconnect() else { + delegate?.trustedNetworksShouldConfirmDisconnection(self, triggeredAt: rowIndex, completionHandler: completionHandler) + return + } + completionHandler() + } + + func removeWifi(at rowIndex: Int) { + let index = indexForWifi(at: rowIndex) + let removedWifi = sortedWifis.remove(at: index) + trustedWifis.removeValue(forKey: removedWifi) + #if os(iOS) + rows.remove(at: rowIndex) + #endif + + delegate?.trustedNetworks(self, shouldDeleteWifiAt: rowIndex) + delegate?.trustedNetworksShouldReinstall(self) + } + + func enableWifi(at rowIndex: Int) { + let index = indexForWifi(at: rowIndex) + let wifi = sortedWifis[index] + + let completionHandler: () -> Void = { + self.trustedWifis[wifi] = true + + self.delegate?.trustedNetworks(self, shouldReloadWifiAt: rowIndex, isTrusted: true) + self.delegate?.trustedNetworksShouldReinstall(self) + } + guard !mightDisconnect() else { + delegate?.trustedNetworksShouldConfirmDisconnection(self, triggeredAt: rowIndex, completionHandler: completionHandler) + return + } + completionHandler() + } + + func disableWifi(at rowIndex: Int) { + let index = indexForWifi(at: rowIndex) + let wifi = sortedWifis[index] + + trustedWifis[wifi] = false + + delegate?.trustedNetworks(self, shouldReloadWifiAt: rowIndex, isTrusted: false) + delegate?.trustedNetworksShouldReinstall(self) + } + + func isTrusted(wifi: String) -> Bool { + return trustedWifis[wifi] ?? false + } + + private func indexForWifi(at rowIndex: Int) -> Int { + #if os(iOS) + return hasMobileNetwork ? (rowIndex - 1) : rowIndex + #else + return rowIndex + #endif + } + + private func rowIndexForWifi(at index: Int) -> Int { + #if os(iOS) + return index + (hasMobileNetwork ? 1 : 0) + #else + return index + #endif + } + + private func mightDisconnect() -> Bool { + return delegate?.trustedNetworksCouldDisconnect(self) ?? false + } +} diff --git a/Passepartout/Sources/Model/TunnelKitProvider+Communication.swift b/Passepartout/Sources/Model/TunnelKitProvider+Communication.swift new file mode 100644 index 00000000..b732ba34 --- /dev/null +++ b/Passepartout/Sources/Model/TunnelKitProvider+Communication.swift @@ -0,0 +1,41 @@ +// +// TunnelKitProvider+Communication.swift +// Passepartout +// +// Created by Davide De Rosa on 9/4/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import Foundation +import TunnelKit + +extension TunnelKitProvider.ConfigurationBuilder { +// mutating func copyCommunication(from other: TunnelKitProvider.ConfigurationBuilder) { +// cipher = other.cipher +// digest = other.digest +// compressionFraming = other.compressionFraming +// } + + func canCommunicate(with other: TunnelKitProvider.Configuration) -> Bool { + return (cipher == other.cipher) && + ((digest == other.digest) || cipher.embedsDigest) && + (compressionFraming == other.compressionFraming) + } +} diff --git a/Passepartout/Sources/Model/Wizard.swift b/Passepartout/Sources/Model/Wizard.swift new file mode 100644 index 00000000..6f04923b --- /dev/null +++ b/Passepartout/Sources/Model/Wizard.swift @@ -0,0 +1,34 @@ +// +// Wizard.swift +// Passepartout +// +// Created by Davide De Rosa on 9/4/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import Foundation + +protocol Wizard: class { + var delegate: WizardDelegate? { get set } +} + +protocol WizardDelegate: class { + func wizard(didCreate profile: ConnectionProfile, withCredentials credentials: Credentials) +} diff --git a/Passepartout/Sources/Services/Infrastructure.swift b/Passepartout/Sources/Services/Infrastructure.swift new file mode 100644 index 00000000..4dee2aca --- /dev/null +++ b/Passepartout/Sources/Services/Infrastructure.swift @@ -0,0 +1,66 @@ +// +// Infrastructure.swift +// Passepartout +// +// Created by Davide De Rosa on 6/11/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import Foundation +import TunnelKit + +struct Infrastructure: Codable { + enum Name: String, Codable { + case pia = "PIA" + + var webName: String { + return rawValue.lowercased() + } + } + + struct Defaults: Codable { + let username: String? + + let pool: String + + let preset: String + } + + let name: Name + + let pools: [Pool] + + let presets: [InfrastructurePreset] + + let defaults: Defaults + + static func loaded(from url: URL) throws -> Infrastructure { + let json = try Data(contentsOf: url) + return try JSONDecoder().decode(Infrastructure.self, from: json) + } + + func pool(for identifier: String) -> Pool? { + return pools.first { $0.id == identifier } + } + + func preset(for identifier: String) -> InfrastructurePreset? { + return presets.first { $0.id == identifier } + } +} diff --git a/Passepartout/Sources/Services/InfrastructureFactory.swift b/Passepartout/Sources/Services/InfrastructureFactory.swift new file mode 100644 index 00000000..819450b7 --- /dev/null +++ b/Passepartout/Sources/Services/InfrastructureFactory.swift @@ -0,0 +1,214 @@ +// +// InfrastructureFactory.swift +// Passepartout +// +// Created by Davide De Rosa on 9/2/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import Foundation +import SwiftyBeaver + +private let log = SwiftyBeaver.self + +class InfrastructureFactory { + private static func embedded(withName name: Infrastructure.Name) -> Infrastructure { + guard let url = Bundle.main.url(forResource: name.webName, withExtension: "json") else { + fatalError("Cannot find JSON for infrastructure '\(name)'") + } + do { + return try Infrastructure.loaded(from: url) + } catch let e { + fatalError("Cannot parse JSON for infrastructure '\(name)': \(e)") + } + } + + private static func isNewer(cachedEntry: URL, thanBundleWithName name: Infrastructure.Name) -> Bool { + guard let cacheDate = FileManager.default.modificationDate(of: cachedEntry.path) else { + return false + } + guard let bundleURL = Bundle.main.url(forResource: name.webName, withExtension: "json") else { + return true + } + guard let bundleDate = FileManager.default.modificationDate(of: bundleURL.path) else { + return true + } + return cacheDate > bundleDate + } + + static let shared = InfrastructureFactory(withCacheDirectory: AppConstants.Store.infrastructureCacheDirectory) + + let allNames: [Infrastructure.Name] = [ + .pia + ] + + private let bundle: [Infrastructure.Name: Infrastructure] + + private let cachePath: URL + + private var cache: [Infrastructure.Name: Infrastructure] + + private var lastUpdate: [Infrastructure.Name: Date] + + private init(withCacheDirectory cacheDirectory: String) { + var bundle: [Infrastructure.Name: Infrastructure] = [:] + allNames.forEach { + bundle[$0] = InfrastructureFactory.embedded(withName: $0) + } + self.bundle = bundle + + cachePath = FileManager.default.userURL(for: .cachesDirectory, appending: cacheDirectory) + cache = [:] + lastUpdate = [:] + } + + func loadCache() { + let cacheEntries: [URL] + do { + cacheEntries = try FileManager.default.contentsOfDirectory(at: cachePath, includingPropertiesForKeys: nil) + } catch let e { + log.verbose("Error loading cache: \(e)") + return + } + + let decoder = JSONDecoder() + for entry in cacheEntries { + guard let data = try? Data(contentsOf: entry) else { + continue + } + guard let infra = try? decoder.decode(Infrastructure.self, from: data) else { + continue + } + + // supersede if older than embedded + guard InfrastructureFactory.isNewer(cachedEntry: entry, thanBundleWithName: infra.name) else { + log.warning("Bundle is newer than cache, superseding cache for \(infra.name)") + cache[infra.name] = bundle[infra.name] + continue + } + + cache[infra.name] = infra + log.debug("Loading cache for \(infra.name)") + } + } + + func get(_ name: Infrastructure.Name) -> Infrastructure { + guard let infra = cache[name] ?? bundle[name] else { + fatalError("No infrastructure embedded nor cached for '\(name)'") + } + return infra + } + + func update(_ name: Infrastructure.Name, notBeforeInterval minInterval: TimeInterval?, completionHandler: @escaping ((Infrastructure, Date?)?, Error?) -> Void) -> Bool { + let ifModifiedSince = modificationDate(for: name) + + if let lastInfrastructureUpdate = lastUpdate[name] { + log.debug("Last update for \(name): \(lastUpdate)") + + if let minInterval = minInterval { + let elapsed = -lastInfrastructureUpdate.timeIntervalSinceNow + guard elapsed >= minInterval else { + log.warning("Skipping update, only \(elapsed) seconds elapsed (< \(minInterval))") + return false + } + } + } + + WebServices.shared.network(with: name, ifModifiedSince: ifModifiedSince) { (response, error) in + if error == nil { + self.lastUpdate[name] = Date() + } + + guard let response = response, let infra = response.value, let lastModified = response.lastModified else { + log.error("No response from web service or missing Last-Modified") + DispatchQueue.main.async { + completionHandler(nil, error) + } + return + } + + var isNewer = true + if let bundleDate = self.bundleModificationDate(for: name) { + log.verbose("Bundle date: \(bundleDate)") + log.verbose("Web date: \(lastModified)") + + isNewer = lastModified > bundleDate + } + guard isNewer else { + log.warning("Web service infrastructure is older than bundle, discarding") + DispatchQueue.main.async { + completionHandler(nil, error) + } + return + } + + self.save(name, with: infra, lastModified: lastModified) + + DispatchQueue.main.async { + completionHandler((infra, response.lastModified), nil) + } + } + return true + } + + func modificationDate(for name: Infrastructure.Name) -> Date? { + let optBundleDate = bundleModificationDate(for: name) + guard let cacheDate = cacheModificationDate(for: name) else { + return optBundleDate + } + guard let bundleDate = optBundleDate else { + return cacheDate + } + return max(cacheDate, bundleDate) + } + + private func save(_ name: Infrastructure.Name, with infrastructure: Infrastructure, lastModified: Date) { + cache[name] = infrastructure + + let fm = FileManager.default + let url = cacheURL(for: name) + do { + try fm.createDirectory(at: cachePath, withIntermediateDirectories: true, attributes: nil) + let data = try JSONEncoder().encode(infrastructure) + try data.write(to: url) + try fm.setAttributes([.modificationDate: lastModified], ofItemAtPath: url.path) + } catch let e { + log.error("Error saving cache: \(e)") + } + } + + private func cacheURL(for name: Infrastructure.Name) -> URL { + return cachePath.appendingPathComponent("\(name.webName).json") + } + + private func cacheModificationDate(for name: Infrastructure.Name) -> Date? { + let url = cacheURL(for: name) + return FileManager.default.modificationDate(of: url.path) + } + + private func bundleURL(for name: Infrastructure.Name) -> URL { + return Bundle.main.url(forResource: name.webName, withExtension: "json")! + } + + private func bundleModificationDate(for name: Infrastructure.Name) -> Date? { + let url = bundleURL(for: name) + return FileManager.default.modificationDate(of: url.path) + } +} diff --git a/Passepartout/Sources/Services/InfrastructurePreset.swift b/Passepartout/Sources/Services/InfrastructurePreset.swift new file mode 100644 index 00000000..540a6ff7 --- /dev/null +++ b/Passepartout/Sources/Services/InfrastructurePreset.swift @@ -0,0 +1,116 @@ +// +// InfrastructurePreset.swift +// Passepartout +// +// Created by Davide De Rosa on 8/30/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import Foundation +import TunnelKit + +// supports a subset of TunnelKitProvider.Configuration +// ignores new JSON keys + +struct InfrastructurePreset: Codable { + enum PresetKeys: String, CodingKey { + case id + + case name + + case comment + + case configuration = "cfg" + } + + enum ConfigurationKeys: String, CodingKey { + case endpointProtocols = "ep" + + case cipher + + case digest = "auth" + + case ca + + case clientCertificate = "client" + + case clientKey = "key" + + case compressionFraming = "frame" + + case keepAliveSeconds = "ping" + + case renegotiatesAfterSeconds = "reneg" + } + + let id: String + + let name: String + + let comment: String + + let configuration: TunnelKitProvider.Configuration + + func hasProtocol(_ proto: TunnelKitProvider.EndpointProtocol) -> Bool { + return configuration.endpointProtocols.index(of: proto) != nil + } + + // MARK: Codable + + init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: PresetKeys.self) + id = try container.decode(String.self, forKey: .id) + name = try container.decode(String.self, forKey: .name) + comment = try container.decode(String.self, forKey: .comment) + + let cfgContainer = try container.nestedContainer(keyedBy: ConfigurationKeys.self, forKey: .configuration) + let ca = try cfgContainer.decode(CryptoContainer.self, forKey: .ca) + var builder = TunnelKitProvider.ConfigurationBuilder(ca: ca) + builder.endpointProtocols = try cfgContainer.decode([TunnelKitProvider.EndpointProtocol].self, forKey: .endpointProtocols) + builder.cipher = try cfgContainer.decode(SessionProxy.Cipher.self, forKey: .cipher) + if let digest = try cfgContainer.decodeIfPresent(SessionProxy.Digest.self, forKey: .digest) { + builder.digest = digest + } + builder.clientCertificate = try cfgContainer.decodeIfPresent(CryptoContainer.self, forKey: .clientCertificate) + builder.clientKey = try cfgContainer.decodeIfPresent(CryptoContainer.self, forKey: .clientKey) + builder.compressionFraming = try cfgContainer.decode(SessionProxy.CompressionFraming.self, forKey: .compressionFraming) + builder.keepAliveSeconds = try cfgContainer.decodeIfPresent(Int.self, forKey: .keepAliveSeconds) + builder.renegotiatesAfterSeconds = try cfgContainer.decodeIfPresent(Int.self, forKey: .renegotiatesAfterSeconds) + configuration = builder.build() + } + + func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: PresetKeys.self) + try container.encode(id, forKey: .id) + try container.encode(name, forKey: .name) + try container.encode(comment, forKey: .comment) + + var cfgContainer = container.nestedContainer(keyedBy: ConfigurationKeys.self, forKey: .configuration) + try cfgContainer.encode(configuration.endpointProtocols, forKey: .endpointProtocols) + try cfgContainer.encode(configuration.cipher, forKey: .cipher) + try cfgContainer.encode(configuration.digest, forKey: .digest) + try cfgContainer.encodeIfPresent(configuration.ca, forKey: .ca) + try cfgContainer.encodeIfPresent(configuration.clientCertificate, forKey: .clientCertificate) + try cfgContainer.encodeIfPresent(configuration.clientKey, forKey: .clientKey) + try cfgContainer.encode(configuration.compressionFraming, forKey: .compressionFraming) + try cfgContainer.encodeIfPresent(configuration.keepAliveSeconds, forKey: .keepAliveSeconds) + try cfgContainer.encodeIfPresent(configuration.renegotiatesAfterSeconds, forKey: .renegotiatesAfterSeconds) + } +} diff --git a/Passepartout/Sources/Services/Pool.swift b/Passepartout/Sources/Services/Pool.swift new file mode 100644 index 00000000..3e1b9067 --- /dev/null +++ b/Passepartout/Sources/Services/Pool.swift @@ -0,0 +1,77 @@ +// +// Pool.swift +// Passepartout +// +// Created by Davide De Rosa on 6/11/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import Foundation +import TunnelKit + +struct Pool: Codable, CustomStringConvertible { + enum CodingKeys: String, CodingKey { + case id + + case name + + case country + +// case location + + case hostname + + case numericAddresses = "addrs" + } + + let id: String + + let name: String + + let country: String + +// let location: (Double, Double) + + let hostname: String + + let numericAddresses: [UInt32] + + func hasAddress(_ address: String) -> Bool { + guard let ipv4 = DNSResolver.ipv4(fromString: address) else { + return false + } + return numericAddresses.contains(ipv4) + } + + // XXX: inefficient, can't easily use lazy on struct + func addresses(sorted: Bool) -> [String] { + var addrs = (sorted ? numericAddresses.sorted() : numericAddresses).map { + return DNSResolver.string(fromIPv4: $0.bigEndian) + } + addrs.insert(hostname, at: 0) + return addrs + } + + // MARK: CustomStringConvertible + + var description: String { + return "{[\(id)] \"\(name)\"}" + } +} diff --git a/Passepartout/Sources/Services/WebServices.swift b/Passepartout/Sources/Services/WebServices.swift new file mode 100644 index 00000000..043956e2 --- /dev/null +++ b/Passepartout/Sources/Services/WebServices.swift @@ -0,0 +1,126 @@ +// +// WebServices.swift +// Passepartout +// +// Created by Davide De Rosa on 9/14/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import Foundation +import SwiftyBeaver + +private let log = SwiftyBeaver.self + +class WebServices { + enum Endpoint { + case network(Infrastructure.Name) + + var path: String { + switch self { + case .network(let name): + return "net/\(name.webName).json" + } + } + } + + struct Response { + let value: T? + + let lastModifiedString: String? + + var lastModified: Date? { + guard let string = lastModifiedString else { + return nil + } + return lmFormatter.date(from: string) + } + + let isCached: Bool + } + + static let shared = WebServices() + + private static let lmFormatter: DateFormatter = { + let fmt = DateFormatter() + fmt.timeZone = TimeZone(abbreviation: "GMT") + fmt.dateFormat = "EEE, dd LLL yyyy HH:mm:ss zzz" + return fmt + }() + + func network(with name: Infrastructure.Name, ifModifiedSince lastModified: Date?, completionHandler: @escaping (Response?, Error?) -> Void) { + var request = get(.network(name)) + if let lastModified = lastModified { + request.addValue(WebServices.lmFormatter.string(from: lastModified), forHTTPHeaderField: "If-Modified-Since") + } + parse(Infrastructure.self, request: request, completionHandler: completionHandler) + } + + private func get(_ endpoint: Endpoint) -> URLRequest { + let url = AppConstants.Providers.url(path: endpoint.path) + return URLRequest(url: url, cachePolicy: .reloadIgnoringCacheData, timeoutInterval: AppConstants.Providers.webTimeout) + } + + private func parse(_ type: T.Type, request: URLRequest, completionHandler: @escaping (Response?, Error?) -> Void) { + log.debug("GET \(request.url!)") + log.debug("Request headers: \(request.allHTTPHeaderFields?.description ?? "")") + + let session = URLSession(configuration: .default) + session.dataTask(with: request) { (data, response, error) in + guard let httpResponse = response as? HTTPURLResponse else { + log.error("Error (response): \(error?.localizedDescription ?? "nil")") + completionHandler(nil, error) + return + } + + let statusCode = httpResponse.statusCode + log.debug("Response status: \(statusCode)") + if let responseHeaders = httpResponse.allHeaderFields as? [String: String] { + log.debug("Response headers: \(responseHeaders)") + } + + // 304: cache hit + if statusCode == 304 { + log.debug("Response is cached") + completionHandler(Response(value: nil, lastModifiedString: nil, isCached: true), nil) + return + } + + // 200: cache miss + let value: T + let lastModifiedString: String? + guard statusCode == 200, let data = data else { + log.error("Error (network): \(error?.localizedDescription ?? "nil")") + completionHandler(nil, error) + return + } + do { + value = try JSONDecoder().decode(type, from: data) + } catch let e { + log.error("Error (parsing): \(e)") + completionHandler(nil, error) + return + } + lastModifiedString = httpResponse.allHeaderFields["Last-Modified"] as? String + + let response = Response(value: value, lastModifiedString: lastModifiedString, isCached: false) + completionHandler(response, nil) + }.resume() + } +} diff --git a/Passepartout/Sources/SwiftGen+Strings.swift b/Passepartout/Sources/SwiftGen+Strings.swift new file mode 100644 index 00000000..a86214ff --- /dev/null +++ b/Passepartout/Sources/SwiftGen+Strings.swift @@ -0,0 +1,694 @@ +// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen + +import Foundation + +// swiftlint:disable superfluous_disable_command +// swiftlint:disable file_length + +// swiftlint:disable explicit_type_interface identifier_name line_length nesting type_body_length type_name +internal enum L10n { + + internal enum About { + /// About + internal static let title = L10n.tr("Localizable", "about.title") + + internal enum Cells { + + internal enum Version { + /// Version + internal static let caption = L10n.tr("Localizable", "about.cells.version.caption") + } + + internal enum Website { + /// Visit website + internal static let caption = L10n.tr("Localizable", "about.cells.website.caption") + } + + internal enum WriteReview { + /// Write a review + internal static let caption = L10n.tr("Localizable", "about.cells.write_review.caption") + } + } + + internal enum Sections { + + internal enum Feedback { + /// Feedback + internal static let header = L10n.tr("Localizable", "about.sections.feedback.header") + } + + internal enum Info { + /// General + internal static let header = L10n.tr("Localizable", "about.sections.info.header") + } + + internal enum Source { + /// Source code + internal static let header = L10n.tr("Localizable", "about.sections.source.header") + } + } + } + + internal enum Account { + + internal enum Cells { + + internal enum Password { + /// Password + internal static let caption = L10n.tr("Localizable", "account.cells.password.caption") + /// secret + internal static let placeholder = L10n.tr("Localizable", "account.cells.password.placeholder") + } + + internal enum PasswordConfirm { + /// Confirm + internal static let caption = L10n.tr("Localizable", "account.cells.password_confirm.caption") + /// Passwords don't match! + internal static let mismatch = L10n.tr("Localizable", "account.cells.password_confirm.mismatch") + } + + internal enum Username { + /// Username + internal static let caption = L10n.tr("Localizable", "account.cells.username.caption") + /// username + internal static let placeholder = L10n.tr("Localizable", "account.cells.username.placeholder") + } + } + + internal enum SuggestionFooter { + + internal enum Infrastructure { + /// Use your website credentials. Your username is usually numeric with a "p" prefix. + internal static let pia = L10n.tr("Localizable", "account.suggestion_footer.infrastructure.pia") + } + } + } + + internal enum Configuration { + + internal enum Cells { + + internal enum Cipher { + /// Cipher + internal static let caption = L10n.tr("Localizable", "configuration.cells.cipher.caption") + } + + internal enum Client { + /// Client certificate + internal static let caption = L10n.tr("Localizable", "configuration.cells.client.caption") + + internal enum Value { + /// Not verified + internal static let disabled = L10n.tr("Localizable", "configuration.cells.client.value.disabled") + /// Verified + internal static let enabled = L10n.tr("Localizable", "configuration.cells.client.value.enabled") + } + } + + internal enum CompressionAlgorithm { + /// Compression + internal static let caption = L10n.tr("Localizable", "configuration.cells.compression_algorithm.caption") + + internal enum Value { + /// Disabled + internal static let disabled = L10n.tr("Localizable", "configuration.cells.compression_algorithm.value.disabled") + } + } + + internal enum CompressionFrame { + /// Framing + internal static let caption = L10n.tr("Localizable", "configuration.cells.compression_frame.caption") + + internal enum Value { + /// Compress + internal static let compress = L10n.tr("Localizable", "configuration.cells.compression_frame.value.compress") + /// None + internal static let disabled = L10n.tr("Localizable", "configuration.cells.compression_frame.value.disabled") + /// LZO + internal static let lzo = L10n.tr("Localizable", "configuration.cells.compression_frame.value.lzo") + } + } + + internal enum Digest { + /// Authentication + internal static let caption = L10n.tr("Localizable", "configuration.cells.digest.caption") + + internal enum Value { + /// Embedded + internal static let embedded = L10n.tr("Localizable", "configuration.cells.digest.value.embedded") + } + } + + internal enum KeepAlive { + /// Keep-alive + internal static let caption = L10n.tr("Localizable", "configuration.cells.keep_alive.caption") + + internal enum Value { + /// Disabled + internal static let never = L10n.tr("Localizable", "configuration.cells.keep_alive.value.never") + /// %d seconds + internal static func seconds(_ p1: Int) -> String { + return L10n.tr("Localizable", "configuration.cells.keep_alive.value.seconds", p1) + } + } + } + + internal enum RenegotiationSeconds { + /// Renegotiation + internal static let caption = L10n.tr("Localizable", "configuration.cells.renegotiation_seconds.caption") + + internal enum Value { + /// after %@ + internal static func after(_ p1: String) -> String { + return L10n.tr("Localizable", "configuration.cells.renegotiation_seconds.value.after", p1) + } + /// Disabled + internal static let never = L10n.tr("Localizable", "configuration.cells.renegotiation_seconds.value.never") + } + } + + internal enum TlsWrapping { + /// Wrapping + internal static let caption = L10n.tr("Localizable", "configuration.cells.tls_wrapping.caption") + + internal enum Value { + /// Authentication + internal static let auth = L10n.tr("Localizable", "configuration.cells.tls_wrapping.value.auth") + /// Encryption + internal static let crypt = L10n.tr("Localizable", "configuration.cells.tls_wrapping.value.crypt") + /// Disabled + internal static let disabled = L10n.tr("Localizable", "configuration.cells.tls_wrapping.value.disabled") + } + } + } + + internal enum Sections { + + internal enum Communication { + /// Communication + internal static let header = L10n.tr("Localizable", "configuration.sections.communication.header") + + internal enum Footer { + /// Make sure to match server communication parameters, otherwise you will end up with broken connectivity. + internal static let editable = L10n.tr("Localizable", "configuration.sections.communication.footer.editable") + } + } + + internal enum Other { + /// Other + internal static let header = L10n.tr("Localizable", "configuration.sections.other.header") + } + + internal enum Tls { + /// TLS + internal static let header = L10n.tr("Localizable", "configuration.sections.tls.header") + } + } + } + + internal enum Credits { + /// Credits + internal static let title = L10n.tr("Localizable", "credits.title") + + internal enum Labels { + /// Passepartout is a non-official client and is in no way affiliated with OpenVPN Inc.\n\nThe logo is taken from the awesome Circle Icons set by Nick Roach. + internal static let thirdParties = L10n.tr("Localizable", "credits.labels.third_parties") + } + } + + internal enum DebugLog { + + internal enum Alerts { + + internal enum EmptyLog { + /// The debug log is empty. + internal static let message = L10n.tr("Localizable", "debug_log.alerts.empty_log.message") + } + } + + internal enum Buttons { + /// Next + internal static let next = L10n.tr("Localizable", "debug_log.buttons.next") + /// Previous + internal static let previous = L10n.tr("Localizable", "debug_log.buttons.previous") + } + } + + internal enum Endpoint { + + internal enum Cells { + + internal enum AnyAddress { + /// Any + internal static let caption = L10n.tr("Localizable", "endpoint.cells.any_address.caption") + } + + internal enum AnyProtocol { + /// Any + internal static let caption = L10n.tr("Localizable", "endpoint.cells.any_protocol.caption") + } + } + + internal enum Sections { + + internal enum LocationAddresses { + /// Addresses + internal static let header = L10n.tr("Localizable", "endpoint.sections.location_addresses.header") + } + + internal enum LocationProtocols { + /// Protocols + internal static let header = L10n.tr("Localizable", "endpoint.sections.location_protocols.header") + } + } + } + + internal enum Global { + /// Cancel + internal static let cancel = L10n.tr("Localizable", "global.cancel") + /// Next + internal static let next = L10n.tr("Localizable", "global.next") + /// OK + internal static let ok = L10n.tr("Localizable", "global.ok") + } + + internal enum IssueReporter { + /// Do you want to attach the debug log of your latest connections? The log is crucial to resolve your connectivity issues and is completely anonymous. + internal static let message = L10n.tr("Localizable", "issue_reporter.message") + /// Report issue + internal static let title = L10n.tr("Localizable", "issue_reporter.title") + + internal enum Alerts { + + internal enum EmailNotConfigured { + /// No e-mail account is configured. + internal static let message = L10n.tr("Localizable", "issue_reporter.alerts.email_not_configured.message") + } + } + + internal enum Buttons { + /// Attach debug log + internal static let withLog = L10n.tr("Localizable", "issue_reporter.buttons.with_log") + /// Omit debug log + internal static let withoutLog = L10n.tr("Localizable", "issue_reporter.buttons.without_log") + } + + internal enum Email { + /// Hi,\n\ndescription of the issue:\n\n%@\n\nRegards + internal static func body(_ p1: String) -> String { + return L10n.tr("Localizable", "issue_reporter.email.body", p1) + } + /// %@ - Report issue + internal static func subject(_ p1: String) -> String { + return L10n.tr("Localizable", "issue_reporter.email.subject", p1) + } + } + } + + internal enum Organizer { + + internal enum Alerts { + + internal enum AddHost { + /// Open an URL to an .ovpn configuration file from Safari, Mail or another app to set up a host profile. + internal static let message = L10n.tr("Localizable", "organizer.alerts.add_host.message") + } + + internal enum DeleteVpnProfile { + /// Do you really want to delete the VPN profile from the device? + internal static let message = L10n.tr("Localizable", "organizer.alerts.delete_vpn_profile.message") + } + + internal enum ExhaustedProviders { + /// You have created profiles for any available network. + internal static let message = L10n.tr("Localizable", "organizer.alerts.exhausted_providers.message") + } + } + + internal enum Cells { + + internal enum About { + /// About %@ + internal static func caption(_ p1: String) -> String { + return L10n.tr("Localizable", "organizer.cells.about.caption", p1) + } + } + + internal enum AddHost { + /// Add new host + internal static let caption = L10n.tr("Localizable", "organizer.cells.add_host.caption") + } + + internal enum AddProvider { + /// Add new network + internal static let caption = L10n.tr("Localizable", "organizer.cells.add_provider.caption") + } + + internal enum Uninstall { + /// Delete VPN profile + internal static let caption = L10n.tr("Localizable", "organizer.cells.uninstall.caption") + } + } + + internal enum Sections { + + internal enum Hosts { + /// Import hosts from raw .ovpn configuration files. + internal static let footer = L10n.tr("Localizable", "organizer.sections.hosts.footer") + /// Hosts + internal static let header = L10n.tr("Localizable", "organizer.sections.hosts.header") + } + + internal enum Providers { + /// Here you find a few public infrastructures offering preset configuration profiles. + internal static let footer = L10n.tr("Localizable", "organizer.sections.providers.footer") + /// Networks + internal static let header = L10n.tr("Localizable", "organizer.sections.providers.header") + } + } + } + + internal enum Provider { + + internal enum Preset { + + internal enum Cells { + + internal enum TechDetails { + /// Technical details + internal static let caption = L10n.tr("Localizable", "provider.preset.cells.tech_details.caption") + } + } + } + } + + internal enum Service { + + internal enum Alerts { + + internal enum ConfigurationNeeded { + /// You need to finish configuration first. + internal static let message = L10n.tr("Localizable", "service.alerts.configuration_needed.message") + } + + internal enum DataCount { + + internal enum Messages { + /// Received: %llu\nSent: %llu + internal static func current(_ p1: Int, _ p2: Int) -> String { + return L10n.tr("Localizable", "service.alerts.data_count.messages.current", p1, p2) + } + /// Information not available, are you connected? + internal static let notAvailable = L10n.tr("Localizable", "service.alerts.data_count.messages.not_available") + } + } + + internal enum ReconnectVpn { + /// Do you want to reconnect to the VPN? + internal static let message = L10n.tr("Localizable", "service.alerts.reconnect_vpn.message") + } + + internal enum TestConnectivity { + /// Connectivity + internal static let title = L10n.tr("Localizable", "service.alerts.test_connectivity.title") + + internal enum Messages { + /// Your device has no Internet connectivity, please review your profile parameters. + internal static let failure = L10n.tr("Localizable", "service.alerts.test_connectivity.messages.failure") + /// Your device is connected to the Internet! + internal static let success = L10n.tr("Localizable", "service.alerts.test_connectivity.messages.success") + } + } + + internal enum Trusted { + + internal enum NoNetwork { + /// You are not connected to any Wi-Fi network. + internal static let message = L10n.tr("Localizable", "service.alerts.trusted.no_network.message") + } + + internal enum WillDisconnectPolicy { + /// By changing the trust policy, the VPN may be disconnected. Continue? + internal static let message = L10n.tr("Localizable", "service.alerts.trusted.will_disconnect_policy.message") + } + + internal enum WillDisconnectTrusted { + /// By trusting this network, the VPN may be disconnected. Continue? + internal static let message = L10n.tr("Localizable", "service.alerts.trusted.will_disconnect_trusted.message") + } + } + } + + internal enum Cells { + + internal enum Account { + /// Account + internal static let caption = L10n.tr("Localizable", "service.cells.account.caption") + /// None configured + internal static let `none` = L10n.tr("Localizable", "service.cells.account.none") + } + + internal enum ConnectionStatus { + /// Status + internal static let caption = L10n.tr("Localizable", "service.cells.connection_status.caption") + } + + internal enum DataCount { + /// Exchanged bytes count + internal static let caption = L10n.tr("Localizable", "service.cells.data_count.caption") + } + + internal enum DebugLog { + /// Debug log + internal static let caption = L10n.tr("Localizable", "service.cells.debug_log.caption") + } + + internal enum Endpoint { + /// Endpoint + internal static let caption = L10n.tr("Localizable", "service.cells.endpoint.caption") + + internal enum Value { + /// Automatic + internal static let automatic = L10n.tr("Localizable", "service.cells.endpoint.value.automatic") + /// Manual + internal static let manual = L10n.tr("Localizable", "service.cells.endpoint.value.manual") + } + } + + internal enum Host { + + internal enum Parameters { + /// Parameters + internal static let caption = L10n.tr("Localizable", "service.cells.host.parameters.caption") + + internal enum Value { + /// %@ + internal static func cipher(_ p1: String) -> String { + return L10n.tr("Localizable", "service.cells.host.parameters.value.cipher", p1) + } + /// %@ / %@ + internal static func cipherDigest(_ p1: String, _ p2: String) -> String { + return L10n.tr("Localizable", "service.cells.host.parameters.value.cipher_digest", p1, p2) + } + } + } + } + + internal enum Provider { + + internal enum Pool { + /// Location + internal static let caption = L10n.tr("Localizable", "service.cells.provider.pool.caption") + } + + internal enum Preset { + /// Preset + internal static let caption = L10n.tr("Localizable", "service.cells.provider.preset.caption") + } + + internal enum Refresh { + /// Refresh infrastructure + internal static let caption = L10n.tr("Localizable", "service.cells.provider.refresh.caption") + } + } + + internal enum Reconnect { + /// Reconnect + internal static let caption = L10n.tr("Localizable", "service.cells.reconnect.caption") + } + + internal enum TestConnectivity { + /// Test connectivity + internal static let caption = L10n.tr("Localizable", "service.cells.test_connectivity.caption") + } + + internal enum TrustedAddWifi { + /// Trust current Wi-Fi + internal static let caption = L10n.tr("Localizable", "service.cells.trusted_add_wifi.caption") + } + + internal enum TrustedMobile { + /// Cellular network + internal static let caption = L10n.tr("Localizable", "service.cells.trusted_mobile.caption") + } + + internal enum TrustedPolicy { + /// Retain existing connection + internal static let caption = L10n.tr("Localizable", "service.cells.trusted_policy.caption") + } + + internal enum TrustedWifi { + /// %@ + internal static func caption(_ p1: String) -> String { + return L10n.tr("Localizable", "service.cells.trusted_wifi.caption", p1) + } + } + + internal enum UseProfile { + /// Use this profile + internal static let caption = L10n.tr("Localizable", "service.cells.use_profile.caption") + } + + internal enum VpnResolvesHostname { + /// Resolve server hostname + internal static let caption = L10n.tr("Localizable", "service.cells.vpn_resolves_hostname.caption") + } + + internal enum VpnService { + /// Enabled + internal static let caption = L10n.tr("Localizable", "service.cells.vpn_service.caption") + } + + internal enum VpnSurvivesSleep { + /// Keep alive on sleep + internal static let caption = L10n.tr("Localizable", "service.cells.vpn_survives_sleep.caption") + } + } + + internal enum Sections { + + internal enum Configuration { + /// Configuration + internal static let header = L10n.tr("Localizable", "service.sections.configuration.header") + } + + internal enum Diagnostics { + /// Diagnostics + internal static let header = L10n.tr("Localizable", "service.sections.diagnostics.header") + } + + internal enum General { + /// General + internal static let header = L10n.tr("Localizable", "service.sections.general.header") + } + + internal enum ProviderInfrastructure { + /// Last updated on %@. + internal static func footer(_ p1: String) -> String { + return L10n.tr("Localizable", "service.sections.provider_infrastructure.footer", p1) + } + } + + internal enum Status { + /// Connection + internal static let header = L10n.tr("Localizable", "service.sections.status.header") + } + + internal enum Trusted { + /// When entering a trusted network, an existing VPN connection will not be shut down by default. Disable to always enforce a disconnection. + internal static let footer = L10n.tr("Localizable", "service.sections.trusted.footer") + /// Trusted networks + internal static let header = L10n.tr("Localizable", "service.sections.trusted.header") + } + + internal enum Vpn { + /// The connection will be established whenever necessary. Tap "Status" to enforce a reconnection. + internal static let footer = L10n.tr("Localizable", "service.sections.vpn.footer") + /// VPN + internal static let header = L10n.tr("Localizable", "service.sections.vpn.header") + } + + internal enum VpnResolvesHostname { + /// Preferred in most networks and required in some IPv6 networks. Disable where DNS is blocked, or to speed up negotiation when DNS is slow to respond. + internal static let footer = L10n.tr("Localizable", "service.sections.vpn_resolves_hostname.footer") + } + + internal enum VpnSurvivesSleep { + /// Disable to improve battery usage, at the expense of occasional slowdowns due to wake-up reconnections. + internal static let footer = L10n.tr("Localizable", "service.sections.vpn_survives_sleep.footer") + } + } + + internal enum Welcome { + /// Welcome to Passepartout!\n\nUse the organizer to add a new profile. + internal static let message = L10n.tr("Localizable", "service.welcome.message") + } + } + + internal enum Version { + + internal enum Buttons { + /// CHANGELOG + internal static let changelog = L10n.tr("Localizable", "version.buttons.changelog") + } + + internal enum Labels { + /// Passepartout and TunnelKit are written and maintained by Davide De Rosa (keeshux).\n\nTunnelKit is a native OpenVPN client originally forked from PIATunnel by Private Internet Access.\n\nSource code for Passepartout and TunnelKit is publicly available on GitHub under the GPLv3. + internal static let intro = L10n.tr("Localizable", "version.labels.intro") + } + } + + internal enum Vpn { + /// Active + internal static let active = L10n.tr("Localizable", "vpn.active") + /// Connecting + internal static let connecting = L10n.tr("Localizable", "vpn.connecting") + /// Disabled + internal static let disabled = L10n.tr("Localizable", "vpn.disabled") + /// Disconnecting + internal static let disconnecting = L10n.tr("Localizable", "vpn.disconnecting") + /// Inactive + internal static let inactive = L10n.tr("Localizable", "vpn.inactive") + } + + internal enum Wizards { + + internal enum Host { + + internal enum Alerts { + /// A host profile with the same title already exists. Replace it? + internal static let existing = L10n.tr("Localizable", "wizards.host.alerts.existing") + /// Unable to parse the provided configuration file. + internal static let parsing = L10n.tr("Localizable", "wizards.host.alerts.parsing") + } + + internal enum Cells { + + internal enum TitleInput { + /// Title + internal static let caption = L10n.tr("Localizable", "wizards.host.cells.title_input.caption") + /// My Profile + internal static let placeholder = L10n.tr("Localizable", "wizards.host.cells.title_input.placeholder") + } + } + + internal enum Sections { + + internal enum Existing { + /// Existing profiles + internal static let header = L10n.tr("Localizable", "wizards.host.sections.existing.header") + } + } + } + } +} +// swiftlint:enable explicit_type_interface identifier_name line_length nesting type_body_length type_name + +extension L10n { + private static func tr(_ table: String, _ key: String, _ args: CVarArg...) -> String { + let format = NSLocalizedString(key, tableName: table, bundle: Bundle(for: BundleToken.self), comment: "") + return String(format: format, locale: Locale.current, arguments: args) + } +} + +private final class BundleToken {} diff --git a/Passepartout/Sources/Utils.swift b/Passepartout/Sources/Utils.swift new file mode 100644 index 00000000..f4a46423 --- /dev/null +++ b/Passepartout/Sources/Utils.swift @@ -0,0 +1,193 @@ +// +// Utils.swift +// Passepartout +// +// Created by Davide De Rosa on 6/16/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import Foundation +#if os(iOS) +import SystemConfiguration.CaptiveNetwork +#else +import CoreWLAN +#endif +import SwiftyBeaver + +private let log = SwiftyBeaver.self + +class Utils { + fileprivate static let timestampFormatter: DateFormatter = { + let fmt = DateFormatter() + fmt.dateStyle = .medium + fmt.timeStyle = .medium + return fmt + }() + + fileprivate static let componentsFormatter: DateComponentsFormatter = { + let fmt = DateComponentsFormatter() + fmt.unitsStyle = .full + return fmt + }() + + static func versionString() -> String { + let info = Bundle.main.infoDictionary + guard let version = info?["CFBundleShortVersionString"] else { + fatalError("No bundle version?") + } + guard let build = info?["CFBundleVersion"] else { + fatalError("No bundle build number?") + } + return "\(version) (\(build))" + } + + #if targetEnvironment(simulator) + static func hasCellularData() -> Bool { + return true + } + #else + static func hasCellularData() -> Bool { + var addrs: UnsafeMutablePointer? + guard getifaddrs(&addrs) == 0 else { + return false + } + var isFound = false + var cursor = addrs?.pointee + while let ifa = cursor { + let name = String(cString: ifa.ifa_name) + if name == "pdp_ip0" { + isFound = true + break + } + cursor = ifa.ifa_next?.pointee + } + freeifaddrs(addrs) + return isFound + } + #endif + + #if targetEnvironment(simulator) + static func currentWifiNetworkName() -> String? { +// return nil + return ["FOO", "BAR", "WIFI"].customRandomElement() + } + #else + static func currentWifiNetworkName() -> String? { + #if os(iOS) + guard let interfaceNames = CNCopySupportedInterfaces() as? [CFString] else { + return nil + } + for name in interfaceNames { + guard let iface = CNCopyCurrentNetworkInfo(name) as? [String: Any] else { + continue + } + if let ssid = iface["SSID"] as? String { + return ssid + } + } + return nil + #else + return CWWiFiClient.shared().interface()?.ssid() + #endif + } + #endif + + static func regex(_ pattern: String) -> NSRegularExpression { + return try! NSRegularExpression(pattern: pattern, options: []) + } + + static func checkConnectivityURL(_ url: URL, timeout: TimeInterval, completionHandler: @escaping (Bool) -> Void) { + let session = URLSession(configuration: .ephemeral) + let request = URLRequest(url: url, cachePolicy: .reloadIgnoringLocalAndRemoteCacheData, timeoutInterval: timeout) + + log.info("Check connectivity via \(url)") + session.dataTask(with: request) { (_, response, error) in + if let response = response as? HTTPURLResponse { + log.debug("Response code: \(response.statusCode)") + } + if let error = error { + log.error("Connectivity failed: \(error)") + } else { + log.info("Connectivity succeeded!") + } + DispatchQueue.main.async { + completionHandler(error == nil) + } + }.resume() + } + + private init() { + } +} + +extension FileManager { + func userURL(for searchPath: SearchPathDirectory, appending: String?) -> URL { + let paths = urls(for: .documentDirectory, in: .userDomainMask) + var directory = paths[0] + if let appending = appending { + directory.appendPathComponent(appending) + } + return directory + } + + func modificationDate(of path: String) -> Date? { + guard let attrs = try? attributesOfItem(atPath: path) else { + return nil + } + return attrs[.modificationDate] as? Date + } +} + +extension Date { + var timestamp: String { + return Utils.timestampFormatter.string(from: self) + } +} + +extension TimeInterval { + var localized: String { + guard let str = Utils.componentsFormatter.string(from: self) else { + fatalError("Could not format a TimeInterval?") + } + return str + } +} + +extension Sequence { + func stableSorted(by areInIncreasingOrder: (Element, Element) throws -> Bool) rethrows -> [Element] { + return try enumerated().sorted { + return try areInIncreasingOrder($0.element, $1.element) || + ($0.offset < $1.offset && !areInIncreasingOrder($1.element, $0.element)) + }.map { $0.element } + } +} + +extension Array { + func customRandomElement() -> Element { + let i = Int(arc4random() % UInt32(count)) + return self[i] + } +} + +extension StringProtocol where Index == String.Index { + func nsRange(from range: Range) -> NSRange { + return NSRange(range, in: self) + } +} diff --git a/Passepartout/Sources/VPN/GracefulVPN.swift b/Passepartout/Sources/VPN/GracefulVPN.swift new file mode 100644 index 00000000..561d2448 --- /dev/null +++ b/Passepartout/Sources/VPN/GracefulVPN.swift @@ -0,0 +1,105 @@ +// +// GracefulVPN.swift +// Passepartout +// +// Created by Davide De Rosa on 9/18/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import Foundation +import SwiftyBeaver + +private let log = SwiftyBeaver.self + +class GracefulVPN { + private let service: ConnectionService + + private var profile: ConnectionProfile? + + private var vpn: VPNProvider? { + guard let profile = profile else { + return nil + } + guard service.isActiveProfile(profile) else { + return nil + } + return VPN.shared + } + + var isEnabled: Bool { + return vpn?.isEnabled ?? false + } + + var status: VPNStatus? { + return vpn?.status + } + + init(service: ConnectionService) { + self.service = service + } + + func prepare(withProfile profile: ConnectionProfile?, completionHandler: (() -> Void)?) { + self.profile = profile + log.info("Preparing...") + vpn?.prepare(completionHandler: completionHandler) + } + + func reconnect(completionHandler: ((Error?) -> Void)?) { + do { + log.info("Reconnecting...") + try vpn?.reconnect(configuration: service.vpnConfiguration(), completionHandler: completionHandler) + } catch let e { + log.error("Could not reconnect: \(e)") + } + } + + func reinstall(completionHandler: ((Error?) -> Void)?) { + do { + log.info("Reinstalling...") + try vpn?.install(configuration: service.vpnConfiguration(), completionHandler: completionHandler) + } catch let e { + log.error("Could not reinstall: \(e)") + } + } + + func reinstallIfEnabled() { + guard isEnabled else { + log.warning("Not reinstalling (VPN is disabled)") + return + } + if status != .disconnected { + reconnect(completionHandler: nil) + } else { + reinstall(completionHandler: nil) + } + } + + func disconnect(completionHandler: ((Error?) -> Void)?) { + vpn?.disconnect(completionHandler: completionHandler) + } + + func uninstall(completionHandler: (() -> Void)?) { + vpn?.uninstall(completionHandler: completionHandler) + } + + func requestBytesCount(completionHandler: @escaping ((UInt, UInt)?) -> Void) { + vpn?.requestBytesCount(completionHandler: completionHandler) + } +} diff --git a/Passepartout/Sources/VPN/MockVPNProvider.swift b/Passepartout/Sources/VPN/MockVPNProvider.swift new file mode 100644 index 00000000..942b7451 --- /dev/null +++ b/Passepartout/Sources/VPN/MockVPNProvider.swift @@ -0,0 +1,81 @@ +// +// MockVPNProvider.swift +// Passepartout +// +// Created by Davide De Rosa on 6/15/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import Foundation + +class MockVPNProvider: VPNProvider { + let isPrepared: Bool = true + + private(set) var isEnabled: Bool = false + + private(set) var status: VPNStatus = .disconnected + + func prepare(completionHandler: (() -> Void)?) { + NotificationCenter.default.post(name: .VPNDidPrepare, object: nil) + completionHandler?() + } + + func install(configuration: VPNConfiguration, completionHandler: ((Error?) -> Void)?) { + isEnabled = true + completionHandler?(nil) + } + + func connect(completionHandler: ((Error?) -> Void)?) { + isEnabled = true + status = .connected + NotificationCenter.default.post(name: .VPNDidChangeStatus, object: self) + completionHandler?(nil) + } + + func disconnect(completionHandler: ((Error?) -> Void)?) { + isEnabled = false + status = .disconnected + NotificationCenter.default.post(name: .VPNDidChangeStatus, object: self) + completionHandler?(nil) + } + + func reconnect(configuration: VPNConfiguration, completionHandler: ((Error?) -> Void)?) { + isEnabled = true + status = .connected + NotificationCenter.default.post(name: .VPNDidChangeStatus, object: self) + completionHandler?(nil) + } + + func uninstall(completionHandler: (() -> Void)?) { + isEnabled = false + status = .disconnected + NotificationCenter.default.post(name: .VPNDidChangeStatus, object: self) + completionHandler?() + } + + func requestDebugLog(fallback: (() -> String)?, completionHandler: @escaping (String) -> Void) { + let log = [String](repeating: "lorem ipsum", count: 1000).joined(separator: " ") + completionHandler(log) + } + + func requestBytesCount(completionHandler: @escaping ((UInt, UInt)?) -> Void) { + completionHandler((0, 0)) + } +} diff --git a/Passepartout/Sources/VPN/StandardVPNProvider.swift b/Passepartout/Sources/VPN/StandardVPNProvider.swift new file mode 100644 index 00000000..4fd0af85 --- /dev/null +++ b/Passepartout/Sources/VPN/StandardVPNProvider.swift @@ -0,0 +1,267 @@ +// +// StandardVPNProvider.swift +// Passepartout +// +// Created by Davide De Rosa on 6/15/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import Foundation +import NetworkExtension +import TunnelKit + +class StandardVPNProvider: VPNProvider { + private let bundleIdentifier: String + + private var manager: NETunnelProviderManager? + + private var lastNotifiedStatus: VPNStatus? + + init(bundleIdentifier: String) { + self.bundleIdentifier = bundleIdentifier + + NotificationCenter.default.addObserver(self, selector: #selector(vpnDidUpdate(_:)), name: .NEVPNStatusDidChange, object: nil) + } + + deinit { + NotificationCenter.default.removeObserver(self) + } + + // MARK: VPNProvider + + var isPrepared: Bool { + return manager != nil + } + + var isEnabled: Bool { + guard let manager = manager else { + return false + } + return manager.isEnabled && manager.isOnDemandEnabled + } + + var status: VPNStatus { + guard let neStatus = manager?.connection.status else { + return .disconnected + } + switch neStatus { + case .connected: + return .connected + + case .connecting, .reasserting: + return .connecting + + case .disconnecting: + return .disconnecting + + case .disconnected, .invalid: + return .disconnected + } + } + + func prepare(completionHandler: (() -> Void)?) { + find(with: bundleIdentifier) { + self.manager = $0 + NotificationCenter.default.post(name: .VPNDidPrepare, object: nil) + completionHandler?() + } + } + + func install(configuration: VPNConfiguration, completionHandler: ((Error?) -> Void)?) { + guard let configuration = configuration as? NetworkExtensionVPNConfiguration else { + fatalError("Not a NetworkExtensionVPNConfiguration") + } + find(with: bundleIdentifier) { + self.manager = $0 + self.manager?.protocolConfiguration = configuration.protocolConfiguration + self.manager?.onDemandRules = configuration.onDemandRules + self.manager?.isOnDemandEnabled = true + self.manager?.isEnabled = true + self.manager?.saveToPreferences { (error) in + guard error == nil else { + self.manager?.isOnDemandEnabled = false + self.manager?.isEnabled = false + completionHandler?(error) + return + } + self.manager?.loadFromPreferences { (error) in + completionHandler?(error) + } + } + } + } + + func connect(completionHandler: ((Error?) -> Void)?) { + do { + try manager?.connection.startVPNTunnel() + completionHandler?(nil) + } catch let e { + completionHandler?(e) + } + } + + func disconnect(completionHandler: ((Error?) -> Void)?) { + manager?.connection.stopVPNTunnel() + manager?.isOnDemandEnabled = false + manager?.isEnabled = false + manager?.saveToPreferences(completionHandler: completionHandler) + } + + func reconnect(configuration: VPNConfiguration, completionHandler: ((Error?) -> Void)?) { + guard let configuration = configuration as? NetworkExtensionVPNConfiguration else { + fatalError("Not a NetworkExtensionVPNConfiguration") + } + install(configuration: configuration) { (error) in + guard error == nil else { + completionHandler?(nil) + return + } + let connectBlock = { + self.connect(completionHandler: completionHandler) + } + if self.status != .disconnected { + self.manager?.connection.stopVPNTunnel() + DispatchQueue.main.asyncAfter(deadline: .now() + 2.0, execute: connectBlock) + } else { + connectBlock() + } + } + } + + func uninstall(completionHandler: (() -> Void)?) { + find(with: bundleIdentifier) { (manager) in + manager?.connection.stopVPNTunnel() + manager?.removeFromPreferences { (error) in + self.manager = nil + completionHandler?() + } + } + } + + func requestDebugLog(fallback: (() -> String)?, completionHandler: @escaping (String) -> Void) { + guard status != .disconnected else { + completionHandler(fallback?() ?? "") + return + } + findAndRequestDebugLog { (recent) in + DispatchQueue.main.async { + guard let recent = recent else { + completionHandler(fallback?() ?? "") + return + } + completionHandler(recent) + } + } + } + + func requestBytesCount(completionHandler: @escaping ((UInt, UInt)?) -> Void) { + find(with: bundleIdentifier) { + self.manager = $0 + guard let session = self.manager?.connection as? NETunnelProviderSession else { + DispatchQueue.main.async { + completionHandler(nil) + } + return + } + do { + try session.sendProviderMessage(TunnelKitProvider.Message.dataCount.data) { (data) in + guard let data = data, data.count == 16 else { + DispatchQueue.main.async { + completionHandler(nil) + } + return + } + let bytesIn: UInt = data.subdata(in: 0..<8).withUnsafeBytes { $0.pointee } + let bytesOut: UInt = data.subdata(in: 8..<16).withUnsafeBytes { $0.pointee } + DispatchQueue.main.async { + completionHandler((bytesIn, bytesOut)) + } + } + } catch { + DispatchQueue.main.async { + completionHandler(nil) + } + } + } + } + + // MARK: Helpers + + private func find(with bundleIdentifier: String, completionHandler: @escaping (NETunnelProviderManager?) -> Void) { + NETunnelProviderManager.loadAllFromPreferences { (managers, error) in + guard error == nil else { + completionHandler(nil) + return + } + let manager = managers?.first { + guard let ptm = $0.protocolConfiguration as? NETunnelProviderProtocol else { + return false + } + return (ptm.providerBundleIdentifier == bundleIdentifier) + } + completionHandler(manager ?? NETunnelProviderManager()) + } + } + + private func findAndRequestDebugLog(completionHandler: @escaping (String?) -> Void) { + find(with: bundleIdentifier) { + self.manager = $0 + guard let session = self.manager?.connection as? NETunnelProviderSession else { + completionHandler(nil) + return + } + StandardVPNProvider.requestDebugLog(session: session, completionHandler: completionHandler) + } + } + + private static func requestDebugLog(session: NETunnelProviderSession, completionHandler: @escaping (String?) -> Void) { + do { + try session.sendProviderMessage(TunnelKitProvider.Message.requestLog.data) { (data) in + guard let data = data, !data.isEmpty else { + completionHandler(nil) + return + } + let newestLog = String(data: data, encoding: .utf8) + completionHandler(newestLog) + } + } catch { + completionHandler(nil) + } + } + + // MARK: Notifications + + @objc private func vpnDidUpdate(_ notification: Notification) { +// guard let connection = notification.object as? NETunnelProviderSession else { +// return +// } +// log.debug("VPN status did change: \(connection.status.rawValue)") + + let status = self.status + if let last = lastNotifiedStatus { + guard status != last else { + return + } + } + lastNotifiedStatus = status + + NotificationCenter.default.post(name: .VPNDidChangeStatus, object: self) + } +} diff --git a/Passepartout/Sources/VPN/TunnelKitProvider+FileConfiguration.swift b/Passepartout/Sources/VPN/TunnelKitProvider+FileConfiguration.swift new file mode 100644 index 00000000..9b2699f0 --- /dev/null +++ b/Passepartout/Sources/VPN/TunnelKitProvider+FileConfiguration.swift @@ -0,0 +1,276 @@ +// +// TunnelKitProvider+FileConfiguration.swift +// Passepartout +// +// Created by Davide De Rosa on 9/5/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import Foundation +import TunnelKit +import SwiftyBeaver + +private let log = SwiftyBeaver.self + +extension TunnelKitProvider.Configuration { + private struct Regex { + static let proto = Utils.regex("proto +(udp6?|tcp6?)") + + static let port = Utils.regex("port +\\d+") + + static let remote = Utils.regex("remote +[^ ]+( +\\d+)?( +(udp6?|tcp6?))?") + + static let cipher = Utils.regex("cipher +[\\w\\-]+") + + static let auth = Utils.regex("auth +[\\w\\-]+") + + static let compLZO = Utils.regex("comp-lzo") + + static let compress = Utils.regex("compress") + + static let ping = Utils.regex("ping +\\d+") + + static let renegSec = Utils.regex("reneg-sec +\\d+") + + static let fragment = Utils.regex("fragment +\\d+") + + static let keyDirection = Utils.regex("key-direction +\\d") + + static let blockBegin = Utils.regex("<[\\w\\-]+>") + + static let blockEnd = Utils.regex("<\\/[\\w\\-]+>") + } + + static func parsed(from url: URL) throws -> (String, TunnelKitProvider.Configuration) { + let content = try String(contentsOf: url) + let lines = content.components(separatedBy: .newlines).map { $0.trimmingCharacters(in: .whitespacesAndNewlines) }.filter { !$0.isEmpty } + + var defaultProto: TunnelKitProvider.SocketType? + var defaultPort: UInt16? + var remotes: [(String, UInt16?, TunnelKitProvider.SocketType?)] = [] + + var cipher: SessionProxy.Cipher? + var digest: SessionProxy.Digest? + var compressionFraming: SessionProxy.CompressionFraming = .disabled + var optCA: CryptoContainer? + var clientCertificate: CryptoContainer? + var clientKey: CryptoContainer? + var keepAliveSeconds: Int? + var renegotiateAfterSeconds: Int? + + var currentBlockName: String? + var currentBlock: [String] = [] + var unsupportedError: ApplicationError? = nil + + log.verbose("Configuration file:") + for line in lines { + log.verbose(line) + + Regex.blockBegin.enumerateComponents(in: line) { + let tag = $0.first! + let from = tag.index(after: tag.startIndex) + let to = tag.index(before: tag.endIndex) + + currentBlockName = String(tag[from.. 1 { + port = UInt16($0[1]) + } + if $0.count > 2 { + proto = TunnelKitProvider.SocketType(protoString: $0[2]) + } + remotes.append((hostname, port, proto)) + } + Regex.cipher.enumerateArguments(in: line) { + guard let rawValue = $0.first else { + return + } + cipher = SessionProxy.Cipher(rawValue: rawValue.uppercased()) + } + Regex.auth.enumerateArguments(in: line) { + guard let rawValue = $0.first else { + return + } + digest = SessionProxy.Digest(rawValue: rawValue.uppercased()) + } + Regex.compLZO.enumerateComponents(in: line) { _ in + compressionFraming = .compLZO + } + Regex.compress.enumerateComponents(in: line) { _ in + compressionFraming = .compress + } + Regex.ping.enumerateArguments(in: line) { + guard let arg = $0.first else { + return + } + keepAliveSeconds = Int(arg) + } + Regex.renegSec.enumerateArguments(in: line) { + guard let arg = $0.first else { + return + } + renegotiateAfterSeconds = Int(arg) + } + Regex.fragment.enumerateArguments(in: line) { (_) in + unsupportedError = ApplicationError.unsupportedConfiguration + } + + if let error = unsupportedError { + throw error + } + } + + guard let ca = optCA else { + throw ApplicationError.missingCA + } + + // XXX: only reads first remote +// hostnames = remotes.map { $0.0 } + guard !remotes.isEmpty else { + throw ApplicationError.emptyRemotes + } + let hostname = remotes[0].0 + + defaultProto = defaultProto ?? .udp + defaultPort = defaultPort ?? 1194 + + // XXX: reads endpoints from remotes with matching hostname + var endpointProtocols: [TunnelKitProvider.EndpointProtocol] = [] + remotes.forEach { + guard $0.0 == hostname else { + return + } + guard let port = $0.1 ?? defaultPort else { + return + } + guard let socketType = $0.2 ?? defaultProto else { + return + } + endpointProtocols.append(TunnelKitProvider.EndpointProtocol(socketType, port)) + } + + assert(!endpointProtocols.isEmpty, "Must define an endpoint protocol") + + var builder = TunnelKitProvider.ConfigurationBuilder(ca: ca) + builder.endpointProtocols = endpointProtocols + builder.cipher = cipher ?? .aes128cbc + builder.digest = digest ?? .sha1 + builder.compressionFraming = compressionFraming + builder.clientCertificate = clientCertificate + builder.clientKey = clientKey + builder.keepAliveSeconds = keepAliveSeconds + builder.renegotiatesAfterSeconds = renegotiateAfterSeconds + + return (hostname, builder.build()) + } +} + +private extension TunnelKitProvider.SocketType { + init?(protoString: String) { + var str = protoString + if str.hasSuffix("6") { + str.removeLast() + } + self.init(rawValue: str.uppercased()) + } +} + +private extension NSRegularExpression { + func enumerateComponents(in string: String, using block: ([String]) -> Void) { + enumerateMatches(in: string, options: [], range: NSMakeRange(0, string.count)) { (result, flags, stop) in + guard let range = result?.range else { + return + } + let match = (string as NSString).substring(with: range) + let tokens = match.components(separatedBy: " ") + block(tokens) + } + } + + func enumerateArguments(in string: String, using block: ([String]) -> Void) { + enumerateMatches(in: string, options: [], range: NSMakeRange(0, string.count)) { (result, flags, stop) in + guard let range = result?.range else { + return + } + let match = (string as NSString).substring(with: range) + var tokens = match.components(separatedBy: " ") + tokens.removeFirst() + block(tokens) + } + } +} diff --git a/Passepartout/Sources/VPN/VPN.swift b/Passepartout/Sources/VPN/VPN.swift new file mode 100644 index 00000000..f6be4a78 --- /dev/null +++ b/Passepartout/Sources/VPN/VPN.swift @@ -0,0 +1,34 @@ +// +// VPN.swift +// Passepartout +// +// Created by Davide De Rosa on 6/12/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import Foundation + +class VPN { + #if targetEnvironment(simulator) + static let shared = MockVPNProvider() + #else + static let shared = StandardVPNProvider(bundleIdentifier: GroupConstants.App.tunnelIdentifier) + #endif +} diff --git a/Passepartout/Sources/VPN/VPNConfiguration.swift b/Passepartout/Sources/VPN/VPNConfiguration.swift new file mode 100644 index 00000000..f18706b0 --- /dev/null +++ b/Passepartout/Sources/VPN/VPNConfiguration.swift @@ -0,0 +1,36 @@ +// +// VPNConfiguration.swift +// Passepartout +// +// Created by Davide De Rosa on 9/18/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import Foundation +import NetworkExtension + +protocol VPNConfiguration { +} + +struct NetworkExtensionVPNConfiguration: VPNConfiguration { + let protocolConfiguration: NETunnelProviderProtocol + + let onDemandRules: [NEOnDemandRule] +} diff --git a/Passepartout/Sources/VPN/VPNProvider.swift b/Passepartout/Sources/VPN/VPNProvider.swift new file mode 100644 index 00000000..3502d258 --- /dev/null +++ b/Passepartout/Sources/VPN/VPNProvider.swift @@ -0,0 +1,56 @@ +// +// VPNProvider.swift +// Passepartout +// +// Created by Davide De Rosa on 9/6/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import Foundation + +protocol VPNProvider: class { + var isPrepared: Bool { get } + + var isEnabled: Bool { get } + + var status: VPNStatus { get } + + func prepare(completionHandler: (() -> Void)?) + + func install(configuration: VPNConfiguration, completionHandler: ((Error?) -> Void)?) + + func connect(completionHandler: ((Error?) -> Void)?) + + func disconnect(completionHandler: ((Error?) -> Void)?) + + func reconnect(configuration: VPNConfiguration, completionHandler: ((Error?) -> Void)?) + + func uninstall(completionHandler: (() -> Void)?) + + func requestDebugLog(fallback: (() -> String)?, completionHandler: @escaping (String) -> Void) + + func requestBytesCount(completionHandler: @escaping ((UInt, UInt)?) -> Void) +} + +extension Notification.Name { + static let VPNDidPrepare = Notification.Name("VPNDidPrepare") + + static let VPNDidChangeStatus = Notification.Name("VPNDidChangeStatus") +} diff --git a/Passepartout/Sources/VPN/VPNStatus.swift b/Passepartout/Sources/VPN/VPNStatus.swift new file mode 100644 index 00000000..541de6d4 --- /dev/null +++ b/Passepartout/Sources/VPN/VPNStatus.swift @@ -0,0 +1,36 @@ +// +// VPNStatus.swift +// Passepartout +// +// Created by Davide De Rosa on 9/18/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import Foundation + +enum VPNStatus { + case connected + + case connecting + + case disconnected + + case disconnecting +} diff --git a/PassepartoutTests-iOS/FileConfigurationTests.swift b/PassepartoutTests-iOS/FileConfigurationTests.swift new file mode 100644 index 00000000..aa5a02ab --- /dev/null +++ b/PassepartoutTests-iOS/FileConfigurationTests.swift @@ -0,0 +1,51 @@ +// +// FileConfigurationTests.swift +// PassepartoutTests-iOS +// +// Created by Davide De Rosa on 9/5/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import XCTest +import TunnelKit +@testable import Passepartout_iOS + +class FileConfigurationTests: XCTestCase { + override func setUp() { + super.setUp() + // Put setup code here. This method is called before the invocation of each test method in the class. + } + + override func tearDown() { + // Put teardown code here. This method is called after the invocation of each test method in the class. + super.tearDown() + } + + func testPIA() throws { + let cfg = try TunnelKitProvider.Configuration.parsed(from: url(withName: "pia-hungary")).1 + XCTAssertEqual(cfg.cipher, .aes128cbc) + XCTAssertEqual(cfg.digest, .sha1) + } + + private func url(withName name: String) -> URL { + return Bundle(for: FileConfigurationTests.self).url(forResource: name, withExtension: "ovpn")! + } + +} diff --git a/PassepartoutTests-iOS/Info.plist b/PassepartoutTests-iOS/Info.plist new file mode 100644 index 00000000..6c40a6cd --- /dev/null +++ b/PassepartoutTests-iOS/Info.plist @@ -0,0 +1,22 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + + diff --git a/PassepartoutTests-iOS/InfrastructureTests.swift b/PassepartoutTests-iOS/InfrastructureTests.swift new file mode 100644 index 00000000..3fd900db --- /dev/null +++ b/PassepartoutTests-iOS/InfrastructureTests.swift @@ -0,0 +1,84 @@ +// +// InfrastructureTests.swift +// PassepartoutTests-iOS +// +// Created by Davide De Rosa on 6/11/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/keeshux +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import XCTest +@testable import Passepartout_iOS +import TunnelKit + +class InfrastructureTests: XCTestCase { + private let infra = InfrastructureFactory.shared.get(.pia) + + override func setUp() { + } + + override func tearDown() { + // Put teardown code here. This method is called after the invocation of each test method in the class. + } + + func testParsing() { + print(infra.pools) + XCTAssertEqual(infra.pools.count, 53) + } + + func testIdentifier() { + let id = "us-east" + guard let pool = infra.pool(for: id) else { + XCTAssert(false) + return + } + print(pool) + XCTAssertEqual(pool.id, id) + } + + func testStableSort() { + let original: [TunnelKitProvider.EndpointProtocol] = [ + TunnelKitProvider.EndpointProtocol(.udp, 1194), + TunnelKitProvider.EndpointProtocol(.udp, 8080), + TunnelKitProvider.EndpointProtocol(.udp, 9201), + TunnelKitProvider.EndpointProtocol(.udp, 53), + TunnelKitProvider.EndpointProtocol(.udp, 1197), + TunnelKitProvider.EndpointProtocol(.udp, 198), + TunnelKitProvider.EndpointProtocol(.tcp, 443), + TunnelKitProvider.EndpointProtocol(.tcp, 110), + TunnelKitProvider.EndpointProtocol(.tcp, 80), + TunnelKitProvider.EndpointProtocol(.tcp, 500), + TunnelKitProvider.EndpointProtocol(.tcp, 501), + TunnelKitProvider.EndpointProtocol(.tcp, 502) + ] + var preferredType: TunnelKitProvider.SocketType + + preferredType = .udp + let sorted1 = original.stableSorted { + return ($0.socketType == preferredType) && ($1.socketType != preferredType) + } + XCTAssertEqual(sorted1, original) + + preferredType = .tcp + let sorted2 = original.stableSorted { + return ($0.socketType == preferredType) && ($1.socketType != preferredType) + } + XCTAssertNotEqual(sorted2, original) + } +} diff --git a/PassepartoutTests-iOS/pia-hungary.ovpn b/PassepartoutTests-iOS/pia-hungary.ovpn new file mode 100644 index 00000000..bb6859ea --- /dev/null +++ b/PassepartoutTests-iOS/pia-hungary.ovpn @@ -0,0 +1,72 @@ +client +dev tun +remote hungary.privateinternetaccess.com 1198 udp +remote hungary.privateinternetaccess.com 502 tcp +resolv-retry infinite +nobind +persist-key +persist-tun +setenv CLIENT_CERT 0 + + +-----BEGIN CERTIFICATE----- +MIIFqzCCBJOgAwIBAgIJAKZ7D5Yv87qDMA0GCSqGSIb3DQEBDQUAMIHoMQswCQYD +VQQGEwJVUzELMAkGA1UECBMCQ0ExEzARBgNVBAcTCkxvc0FuZ2VsZXMxIDAeBgNV +BAoTF1ByaXZhdGUgSW50ZXJuZXQgQWNjZXNzMSAwHgYDVQQLExdQcml2YXRlIElu +dGVybmV0IEFjY2VzczEgMB4GA1UEAxMXUHJpdmF0ZSBJbnRlcm5ldCBBY2Nlc3Mx +IDAeBgNVBCkTF1ByaXZhdGUgSW50ZXJuZXQgQWNjZXNzMS8wLQYJKoZIhvcNAQkB +FiBzZWN1cmVAcHJpdmF0ZWludGVybmV0YWNjZXNzLmNvbTAeFw0xNDA0MTcxNzM1 +MThaFw0zNDA0MTIxNzM1MThaMIHoMQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0Ex +EzARBgNVBAcTCkxvc0FuZ2VsZXMxIDAeBgNVBAoTF1ByaXZhdGUgSW50ZXJuZXQg +QWNjZXNzMSAwHgYDVQQLExdQcml2YXRlIEludGVybmV0IEFjY2VzczEgMB4GA1UE +AxMXUHJpdmF0ZSBJbnRlcm5ldCBBY2Nlc3MxIDAeBgNVBCkTF1ByaXZhdGUgSW50 +ZXJuZXQgQWNjZXNzMS8wLQYJKoZIhvcNAQkBFiBzZWN1cmVAcHJpdmF0ZWludGVy +bmV0YWNjZXNzLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAPXD +L1L9tX6DGf36liA7UBTy5I869z0UVo3lImfOs/GSiFKPtInlesP65577nd7UNzzX +lH/P/CnFPdBWlLp5ze3HRBCc/Avgr5CdMRkEsySL5GHBZsx6w2cayQ2EcRhVTwWp +cdldeNO+pPr9rIgPrtXqT4SWViTQRBeGM8CDxAyTopTsobjSiYZCF9Ta1gunl0G/ +8Vfp+SXfYCC+ZzWvP+L1pFhPRqzQQ8k+wMZIovObK1s+nlwPaLyayzw9a8sUnvWB +/5rGPdIYnQWPgoNlLN9HpSmsAcw2z8DXI9pIxbr74cb3/HSfuYGOLkRqrOk6h4RC +OfuWoTrZup1uEOn+fw8CAwEAAaOCAVQwggFQMB0GA1UdDgQWBBQv63nQ/pJAt5tL +y8VJcbHe22ZOsjCCAR8GA1UdIwSCARYwggESgBQv63nQ/pJAt5tLy8VJcbHe22ZO +sqGB7qSB6zCB6DELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRMwEQYDVQQHEwpM +b3NBbmdlbGVzMSAwHgYDVQQKExdQcml2YXRlIEludGVybmV0IEFjY2VzczEgMB4G +A1UECxMXUHJpdmF0ZSBJbnRlcm5ldCBBY2Nlc3MxIDAeBgNVBAMTF1ByaXZhdGUg +SW50ZXJuZXQgQWNjZXNzMSAwHgYDVQQpExdQcml2YXRlIEludGVybmV0IEFjY2Vz +czEvMC0GCSqGSIb3DQEJARYgc2VjdXJlQHByaXZhdGVpbnRlcm5ldGFjY2Vzcy5j +b22CCQCmew+WL/O6gzAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBDQUAA4IBAQAn +a5PgrtxfwTumD4+3/SYvwoD66cB8IcK//h1mCzAduU8KgUXocLx7QgJWo9lnZ8xU +ryXvWab2usg4fqk7FPi00bED4f4qVQFVfGfPZIH9QQ7/48bPM9RyfzImZWUCenK3 +7pdw4Bvgoys2rHLHbGen7f28knT2j/cbMxd78tQc20TIObGjo8+ISTRclSTRBtyC +GohseKYpTS9himFERpUgNtefvYHbn70mIOzfOJFTVqfrptf9jXa9N8Mpy3ayfodz +1wiqdteqFXkTYoSDctgKMiZ6GdocK9nMroQipIQtpnwd4yBDWIyC6Bvlkrq5TQUt +YDQ8z9v+DMO6iwyIDRiU +-----END CERTIFICATE----- + + +cipher aes-128-cbc +auth sha1 +tls-client +remote-cert-tls server +auth-user-pass +comp-lzo no +verb 1 +reneg-sec 0 + + +-----BEGIN X509 CRL----- +MIICWDCCAUAwDQYJKoZIhvcNAQENBQAwgegxCzAJBgNVBAYTAlVTMQswCQYDVQQI +EwJDQTETMBEGA1UEBxMKTG9zQW5nZWxlczEgMB4GA1UEChMXUHJpdmF0ZSBJbnRl +cm5ldCBBY2Nlc3MxIDAeBgNVBAsTF1ByaXZhdGUgSW50ZXJuZXQgQWNjZXNzMSAw +HgYDVQQDExdQcml2YXRlIEludGVybmV0IEFjY2VzczEgMB4GA1UEKRMXUHJpdmF0 +ZSBJbnRlcm5ldCBBY2Nlc3MxLzAtBgkqhkiG9w0BCQEWIHNlY3VyZUBwcml2YXRl +aW50ZXJuZXRhY2Nlc3MuY29tFw0xNjA3MDgxOTAwNDZaFw0zNjA3MDMxOTAwNDZa +MCYwEQIBARcMMTYwNzA4MTkwMDQ2MBECAQYXDDE2MDcwODE5MDA0NjANBgkqhkiG +9w0BAQ0FAAOCAQEAQZo9X97ci8EcPYu/uK2HB152OZbeZCINmYyluLDOdcSvg6B5 +jI+ffKN3laDvczsG6CxmY3jNyc79XVpEYUnq4rT3FfveW1+Ralf+Vf38HdpwB8EW +B4hZlQ205+21CALLvZvR8HcPxC9KEnev1mU46wkTiov0EKc+EdRxkj5yMgv0V2Re +ze7AP+NQ9ykvDScH4eYCsmufNpIjBLhpLE2cuZZXBLcPhuRzVoU3l7A9lvzG9mjA +5YijHJGHNjlWFqyrn1CfYS6koa4TGEPngBoAziWRbDGdhEgJABHrpoaFYaL61zqy +MR6jC0K2ps9qyZAN74LEBedEfK7tBOzWMwr58A== +-----END X509 CRL----- + diff --git a/Podfile b/Podfile new file mode 100644 index 00000000..cc02b39d --- /dev/null +++ b/Podfile @@ -0,0 +1,21 @@ +source 'https://github.com/cocoapods/specs.git' +use_frameworks! + +def shared_pods + pod 'TunnelKit', '~> 1.1.1' + #pod 'TunnelKit', :git => 'https://github.com/keeshux/tunnelkit', :commit => '1234567' +end + +target 'Passepartout-iOS' do + platform :ios, '11.0' + shared_pods + pod 'MBProgressHUD' +end +target 'Passepartout-iOS-Tunnel' do + platform :ios, '11.0' + shared_pods +end +target 'PassepartoutTests-iOS' do + platform :ios, '11.0' + shared_pods +end diff --git a/Podfile.lock b/Podfile.lock new file mode 100644 index 00000000..339baee9 --- /dev/null +++ b/Podfile.lock @@ -0,0 +1,34 @@ +PODS: + - MBProgressHUD (1.1.0) + - OpenSSL-Apple (1.1.0i-v2) + - SwiftyBeaver (1.6.1) + - TunnelKit (1.1.1): + - TunnelKit/AppExtension (= 1.1.1) + - TunnelKit/Core (= 1.1.1) + - TunnelKit/AppExtension (1.1.1): + - SwiftyBeaver + - TunnelKit/Core + - TunnelKit/Core (1.1.1): + - OpenSSL-Apple (~> 1.1.0h) + - SwiftyBeaver + +DEPENDENCIES: + - MBProgressHUD + - TunnelKit (~> 1.1.1) + +SPEC REPOS: + https://github.com/cocoapods/specs.git: + - MBProgressHUD + - OpenSSL-Apple + - SwiftyBeaver + - TunnelKit + +SPEC CHECKSUMS: + MBProgressHUD: e7baa36a220447d8aeb12769bf0585582f3866d9 + OpenSSL-Apple: a93b8f2eec8783ff40d9a9304de180ab68bb647c + SwiftyBeaver: ccfcdf85a04d429f1633f668650b0ce8020bda3a + TunnelKit: 601b96ec6361ea513ff0ed655ea9c587038912c1 + +PODFILE CHECKSUM: 903efc9e8c066aeabc212601779b22a55b1b47e1 + +COCOAPODS: 1.6.0.beta.1 diff --git a/README.md b/README.md new file mode 100644 index 00000000..c2b52ebe --- /dev/null +++ b/README.md @@ -0,0 +1,170 @@ +# Passepartout + +Passepartout is a non-official, user-friendly [OpenVPN®][openvpn] client for iOS. + +Passepartout relies on [TunnelKit][dep-tunnelkit] for most VPN functionality. + +## Beta + +Passepartout is in public beta. You can get early versions of the app via [TestFlight][about-testflight]. + +By using a beta version of the app, you understand that the software might be unstable, unreliable or plain broken from time to time. + +## Overview + +### All profiles in one place + +Passepartout lets you handle multiple profiles in one single place and quickly switch between them. + +![snap-home] + +### Ease of use + +With its native look & feel, Passepartout focuses on ease of use. It does so by stripping the .ovpn flags that are today obsolete or rarely used. With good approximation, it mimics the most relevant features you will find in OpenVPN 2.4.x. + +![snap-profile] + +### Trusted networks + +Trust cellular or Wi-Fi networks to fine-grain your connectivity. You can then choose to retain a VPN connection when entering a trusted network, or prevent it completely. + +![snap-trusted] + +### See your connection parameters + +Passepartout strives for transparency, by showing a fairly detailed yet understandable resume of your connection parameters. + +![snap-parameters] + +### Disconnect on sleep + +Keeping the VPN active in the background provides smoother operation, but may be tough for the battery. You might want to use this feature if you're concerned about battery life. When the device goes to sleep, the VPN will disconnect to then reconnect on device wake-up. + +### No unrequested activity + +Passepartout is a VPN client and does absolutely nothing else without your consent. The providers infrastructures are obtained via web services only and only if you manually refresh them. + +### Presets for major providers + +Passepartout can connect to a few well-known VPN providers with an existing account: + +- [Private Internet Access][net-pia] +- ...more soon! + +In preset mode, you can pick pre-resolved IPv4 endpoints when DNS is problematic. + +### Import .ovpn profiles + +Passepartout can import .ovpn configuration files. This way you can fine-tune encryption without tweaking and reimporting a new configuration. Below are a few limitations worth mentioning. + +Unsupported (yet): + +- TLS wrapping + - `--tls-auth` + - `--tls-crypt` +- UDP fragmentation, i.e. `--fragment` + +Unsupported (probably ever): + +- Compression + - `--comp-lzo` other than `no` + - `--compress` other than empty +- External file references (inline `` only) + +Ignored: + +- MTU overrides + - `--*-mtu` and variants + - `--mssfix` +- Multiple `--remote` (first wins) + +Other flags are ignored too but planned to be implemented. + +## Installation + +### Requirements + +- iOS 11.0+ +- Xcode 10+ (Swift 4.2) +- Git (preinstalled with Xcode Command Line Tools) +- Ruby (preinstalled with macOS) +- [CocoaPods 1.4.0][dep-cocoapods] + +It's highly recommended to use the Git and Ruby packages provided by [Homebrew][dep-brew]. + +### Testing + +Download the app codebase locally: + + $ git clone https://github.com/keeshux/passepartout-ios.git + +Assuming you have a [working CocoaPods environment][dep-cocoapods], setting up the app workspace only requires installing the pod dependencies: + + $ pod install + +After that, open `Passepartout.xcworkspace` in Xcode and run the `Passepartout-iOS` target. + +For the VPN to work properly, the app requires: + +- _App Groups_ and _Keychain Sharing_ capabilities +- App IDs with _Packet Tunnel_ entitlements + +both in the main app and the tunnel extension target. + +## License + +This project is licensed under the [GPLv3][license-content]. + +### Contributing + +By contributing to this project you are agreeing to the terms stated in the [Contributor License Agreement (CLA)][contrib-cla]. For more details please see [CONTRIBUTING][contrib-readme]. + +## Credits + +The logo is taken from the awesome Circle Icons set by Nick Roach. + +© 2002-2018 OpenVPN Inc. - OpenVPN is a registered trademark of OpenVPN Inc. + +## Disclaimer + +Passepartout is a VPN client based on independent work. As such, the developer -while making his best efforts to avoid this- takes no responsibility about any damage caused by the use of this software. + +Additionally, the developer takes no responsibility about data usage, monitoring, logging etc. by the servers you connect to. Passepartout is not even involved in the above choices, as they're part of server-side policies. + +For more information about data usage by third parties, please review the privacy policy of your VPN provider. + +## Contacts + +Twitter: [@keeshux][about-twitter] + +Website: [passepartoutvpn.app][about-website] + +## Donations + +Passepartout is free software, donations are extremely welcome. + +Bitcoin address: [16w2AWamiH2SS68NYSMDcrbh5MnZ1c5eju][about-btc] + +[openvpn]: https://openvpn.net/index.php/open-source/overview.html + +[net-pia]: https://www.privateinternetaccess.com + +[snap-home]: res/snap-home.png +[snap-profile]: res/snap-profile.png +[snap-trusted]: res/snap-trusted.png +[snap-parameters]: res/snap-parameters.png + +[dep-cocoapods]: https://guides.cocoapods.org/using/getting-started.html +[dep-jazzy]: https://github.com/realm/jazzy +[dep-brew]: https://brew.sh/ +[dep-tunnelkit]: https://github.com/keeshux/tunnelkit +[dep-openssl]: https://www.openssl.org/ + +[license-content]: LICENSE +[contrib-cla]: CLA.rst +[contrib-readme]: CONTRIBUTING.md + +[about-twitter]: https://twitter.com/keeshux +[about-website]: https://passepartoutvpn.app +[about-testflight]: https://testflight.apple.com/join/XHzgXj6m +[about-btc]: bitcoin:16w2AWamiH2SS68NYSMDcrbh5MnZ1c5eju diff --git a/ci/beta-archive.sh b/ci/beta-archive.sh new file mode 100755 index 00000000..f7d631f5 --- /dev/null +++ b/ci/beta-archive.sh @@ -0,0 +1,2 @@ +#!/bin/sh +TARGET="beta" bundle exec fastlane --env secret-codesign,beta-archive create_archive diff --git a/ci/beta-deploy.sh b/ci/beta-deploy.sh new file mode 100755 index 00000000..574d0f84 --- /dev/null +++ b/ci/beta-deploy.sh @@ -0,0 +1,5 @@ +#!/bin/sh +TARGET="beta" bundle exec fastlane --env secret-deploy,beta-deploy beta_deploy +VERSION=`agvtool mvers -terse1` +BUILD=`agvtool vers -terse` +git tag "v$VERSION-b$BUILD" diff --git a/ci/dev-archive.sh b/ci/dev-archive.sh new file mode 100755 index 00000000..f3f0190b --- /dev/null +++ b/ci/dev-archive.sh @@ -0,0 +1,2 @@ +#!/bin/sh +TARGET="dev" bundle exec fastlane --env secret-codesign,dev-archive create_archive diff --git a/ci/dev-deploy.sh b/ci/dev-deploy.sh new file mode 100755 index 00000000..3456a939 --- /dev/null +++ b/ci/dev-deploy.sh @@ -0,0 +1,5 @@ +#!/bin/sh +TARGET="dev" bundle exec fastlane --env secret-deploy,dev-deploy dev_deploy +VERSION=`agvtool mvers -terse1` +BUILD=`agvtool vers -terse` +git tag "v$VERSION-a$BUILD" diff --git a/ci/downscale-icon.sh b/ci/downscale-icon.sh new file mode 100755 index 00000000..0bd3c932 --- /dev/null +++ b/ci/downscale-icon.sh @@ -0,0 +1,7 @@ +#!/bin/sh +SIZES="120 152 167 180 76" + +cd Passepartout-iOS/Assets.xcassets/AppIcon.appiconset +for S in $SIZES; do + convert -geometry "${S}x${S}" AppIcon-1024.png AppIcon-$S.png +done diff --git a/ci/reset-archive.sh b/ci/reset-archive.sh new file mode 100755 index 00000000..0d0f4dcb --- /dev/null +++ b/ci/reset-archive.sh @@ -0,0 +1,3 @@ +#!/bin/sh +git checkout Passepartout*/Info.plist +git checkout Passepartout*.pbxproj diff --git a/ci/set-version.sh b/ci/set-version.sh new file mode 100755 index 00000000..3a3cff34 --- /dev/null +++ b/ci/set-version.sh @@ -0,0 +1,2 @@ +#!/bin/sh +agvtool new-marketing-version $1 diff --git a/ci/update-asc-metadata.sh b/ci/update-asc-metadata.sh new file mode 100755 index 00000000..6945b9d3 --- /dev/null +++ b/ci/update-asc-metadata.sh @@ -0,0 +1,2 @@ +#!/bin/sh +bundle exec fastlane --env secret-deploy update_metadata diff --git a/ci/update-asc-screenshots.sh b/ci/update-asc-screenshots.sh new file mode 100755 index 00000000..2b01f540 --- /dev/null +++ b/ci/update-asc-screenshots.sh @@ -0,0 +1,2 @@ +#!/bin/sh +bundle exec fastlane --env secret-deploy update_screenshots diff --git a/fastlane/Appfile b/fastlane/Appfile new file mode 100644 index 00000000..c94e220e --- /dev/null +++ b/fastlane/Appfile @@ -0,0 +1,5 @@ +app_identifier("com.algoritmico.ios.Passepartout") # The bundle identifier of your app + + +# For more information about the Appfile, see: +# https://docs.fastlane.tools/advanced/#appfile diff --git a/fastlane/Deliverfile b/fastlane/Deliverfile new file mode 100644 index 00000000..ec4db9d9 --- /dev/null +++ b/fastlane/Deliverfile @@ -0,0 +1,5 @@ +# The Deliverfile allows you to store various App Store Connect metadata +# For more information, check out the docs +# https://docs.fastlane.tools/actions/deliver/ + +skip_binary_upload true diff --git a/fastlane/Fastfile b/fastlane/Fastfile new file mode 100644 index 00000000..e945ec40 --- /dev/null +++ b/fastlane/Fastfile @@ -0,0 +1,64 @@ +# This file contains the fastlane.tools configuration +# You can find the documentation at https://docs.fastlane.tools +# +# For a list of all available actions, check out +# +# https://docs.fastlane.tools/actions +# +# For a list of all available plugins, check out +# +# https://docs.fastlane.tools/plugins/available-plugins +# + +# Uncomment the line if you want fastlane to automatically update itself +# update_fastlane + +default_platform(:ios) + +platform :ios do + desc "Archive a new build" + lane :create_archive do + ensure_git_status_clean + cocoapods + get_build_number + base_build_number = lane_context[SharedValues::BUILD_NUMBER].to_i + increment_build_number( + build_number: base_build_number + number_of_commits + ) + match + gym + end + + desc "Set build changelog" + lane :set_build_changelog do + lane_context[SharedValues::FL_CHANGELOG] = File.read("../#{ENV["BUILD_CHANGELOG_PATH"]}") + end + + desc "Submit a build to HockeyApp" + lane :dev_deploy do + set_build_changelog + hockey + end + + desc "Submit a build to TestFlight" + lane :beta_deploy do + set_build_changelog + pilot( + beta_app_description: lane_context[SharedValues::FL_CHANGELOG] + ) + end + + desc "Update App Store metadata" + lane :update_metadata do + deliver( + skip_screenshots: true + ) + end + + desc "Update App Store screenshots" + lane :update_screenshots do + deliver( + skip_metadata: true + ) + end +end diff --git a/fastlane/Gymfile b/fastlane/Gymfile new file mode 100644 index 00000000..90e62cf2 --- /dev/null +++ b/fastlane/Gymfile @@ -0,0 +1,22 @@ +# For more information about this configuration visit +# https://docs.fastlane.tools/actions/gym/#gymfile + +# In general, you can use the options available +# fastlane gym --help + +# Remove the # in front of the line to enable the option + +# scheme "Example" + +# sdk "iphoneos9.0" + +derived_data_path ENV["STAGE_BUILD_PATH"] +buildlog_path ENV["STAGE_BUILD_PATH"] +build_path ENV["STAGE_BUILD_PATH"] +output_directory ENV["STAGE_ARTIFACTS_PATH"] +output_name ENV["STAGE_ARCHIVE_NAME"] + +clean true +silent false +include_bitcode false +skip_profile_detection true diff --git a/fastlane/Matchfile b/fastlane/Matchfile new file mode 100644 index 00000000..7885fa90 --- /dev/null +++ b/fastlane/Matchfile @@ -0,0 +1,9 @@ +type "development" # The default type, can be: appstore, adhoc, enterprise or development + +app_identifier [ + "com.algoritmico.ios.Passepartout", + "com.algoritmico.ios.Passepartout.Tunnel" +] + +# For all available options run `fastlane match --help` +# Remove the # in the beginning of the line to enable the other options diff --git a/fastlane/Precheckfile b/fastlane/Precheckfile new file mode 100644 index 00000000..4bbea73a --- /dev/null +++ b/fastlane/Precheckfile @@ -0,0 +1,29 @@ +# For more information about this configuration visit +# https://docs.fastlane.tools/actions/precheck/ + +# In general, you can use the options available +# fastlane precheck --help + +# Remove the # in front of the line to enable the option + +# You have three possible values for each rule options +# :skip +# indicates that your metadata will not be checked by this rule + +# :warn +# when triggered, this rule will warn you of a potential problem + +# :error +# when triggered, this rule will cause an error to be displayed and it will prevent any further fastlane commands from running after precheck finishes + +# Examples: +# negative_apple_sentiment(level: :skip) +# curse_words(level: :warn) +# future_functionality(level: :error) +# other_platforms(level: :error) +# placeholder_text(level: :error) +# test_words(level: :error) +# unreachable_urls(level: :error) +# custom_text(data: ["fabric"], level: :warn) + +include_in_app_purchases false diff --git a/res/snap-home.png b/res/snap-home.png new file mode 100644 index 00000000..e323af8e Binary files /dev/null and b/res/snap-home.png differ diff --git a/res/snap-parameters.png b/res/snap-parameters.png new file mode 100644 index 00000000..c2af5429 Binary files /dev/null and b/res/snap-parameters.png differ diff --git a/res/snap-profile.png b/res/snap-profile.png new file mode 100644 index 00000000..60a224b8 Binary files /dev/null and b/res/snap-profile.png differ diff --git a/res/snap-trusted.png b/res/snap-trusted.png new file mode 100644 index 00000000..bd15796d Binary files /dev/null and b/res/snap-trusted.png differ diff --git a/swiftgen.yml b/swiftgen.yml new file mode 100644 index 00000000..30cc2e28 --- /dev/null +++ b/swiftgen.yml @@ -0,0 +1,14 @@ +strings: + paths: + - Passepartout/Resources/en.lproj/Localizable.strings + templateName: structured-swift4 + output: Passepartout/Sources/SwiftGen+Strings.swift + +storyboards: + paths: + - Passepartout-iOS/en.lproj/Main.storyboard + - Passepartout-iOS/en.lproj/Organizer.storyboard + templateName: swift4 + output: Passepartout-iOS/Global/SwiftGen+Storyboards.swift + params: + module: Passepartout