Initial commit
|
@ -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"
|
|
@ -0,0 +1,2 @@
|
||||||
|
MATCH_TYPE="appstore"
|
||||||
|
GYM_EXPORT_METHOD="app-store"
|
|
@ -0,0 +1,3 @@
|
||||||
|
PILOT_IPA=$IPA_OUTPUT_PATH
|
||||||
|
PILOT_DISTRIBUTE_EXTERNAL="true"
|
||||||
|
DEMO_ACCOUNT_REQUIRED="true"
|
|
@ -0,0 +1,2 @@
|
||||||
|
MATCH_TYPE="adhoc"
|
||||||
|
GYM_EXPORT_METHOD="ad-hoc"
|
|
@ -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"
|
|
@ -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
|
|
@ -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.
|
|
@ -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.
|
|
@ -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.
|
|
@ -0,0 +1,5 @@
|
||||||
|
source "https://rubygems.org"
|
||||||
|
|
||||||
|
gem "fastlane"
|
||||||
|
gem "cocoapods", ">= 1.6.0.beta"
|
||||||
|
gem "dotenv"
|
|
@ -0,0 +1,674 @@
|
||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
|
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.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
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 <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
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:
|
||||||
|
|
||||||
|
<program> Copyright (C) <year> <name of author>
|
||||||
|
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
|
||||||
|
<https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
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
|
||||||
|
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
|
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
||||||
|
<key>CFBundleDisplayName</key>
|
||||||
|
<string>Passepartout-iOS-Tunnel</string>
|
||||||
|
<key>CFBundleExecutable</key>
|
||||||
|
<string>$(EXECUTABLE_NAME)</string>
|
||||||
|
<key>CFBundleIdentifier</key>
|
||||||
|
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||||
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
|
<string>6.0</string>
|
||||||
|
<key>CFBundleName</key>
|
||||||
|
<string>$(PRODUCT_NAME)</string>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>XPC!</string>
|
||||||
|
<key>CFBundleShortVersionString</key>
|
||||||
|
<string>1.0</string>
|
||||||
|
<key>CFBundleVersion</key>
|
||||||
|
<string>1</string>
|
||||||
|
<key>NSExtension</key>
|
||||||
|
<dict>
|
||||||
|
<key>NSExtensionPointIdentifier</key>
|
||||||
|
<string>com.apple.networkextension.packet-tunnel</string>
|
||||||
|
<key>NSExtensionPrincipalClass</key>
|
||||||
|
<string>$(PRODUCT_MODULE_NAME).PacketTunnelProvider</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>com.apple.developer.networking.networkextension</key>
|
||||||
|
<array>
|
||||||
|
<string>packet-tunnel-provider</string>
|
||||||
|
</array>
|
||||||
|
<key>com.apple.security.application-groups</key>
|
||||||
|
<array>
|
||||||
|
<string>group.com.algoritmico.Passepartout</string>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 2.7 KiB |
After Width: | Height: | Size: 2.7 KiB |
After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 1.5 KiB |
|
@ -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"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"info" : {
|
||||||
|
"version" : 1,
|
||||||
|
"author" : "xcode"
|
||||||
|
}
|
||||||
|
}
|
|
@ -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"
|
||||||
|
}
|
||||||
|
}
|
After Width: | Height: | Size: 6.1 KiB |
After Width: | Height: | Size: 9.3 KiB |
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
|
||||||
|
struct Cells {
|
||||||
|
}
|
||||||
|
|
||||||
|
extension UITableView {
|
||||||
|
func dequeue<T: UITableViewCell>(_ 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)
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
// 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)
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
|
||||||
|
protocol OptionViewControllerDelegate: class {
|
||||||
|
func optionController<T: Hashable>(_: OptionViewController<T>, descriptionFor option: T) -> String
|
||||||
|
|
||||||
|
func optionController<T: Hashable>(_: OptionViewController<T>, didSelect option: T)
|
||||||
|
}
|
||||||
|
|
||||||
|
class OptionViewController<T: Hashable>: 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)
|
||||||
|
}
|
||||||
|
}
|
|
@ -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<T: Any> {
|
||||||
|
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<T: Any> {
|
||||||
|
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<S: SegueType>(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<UISplitViewController>(storyboard: Main.self)
|
||||||
|
|
||||||
|
internal static let accountIdentifier = SceneType<Passepartout_iOS.AccountViewController>(storyboard: Main.self, identifier: "AccountIdentifier")
|
||||||
|
|
||||||
|
internal static let configurationIdentifier = SceneType<Passepartout_iOS.ConfigurationViewController>(storyboard: Main.self, identifier: "ConfigurationIdentifier")
|
||||||
|
|
||||||
|
internal static let serviceIdentifier = SceneType<UINavigationController>(storyboard: Main.self, identifier: "ServiceIdentifier")
|
||||||
|
}
|
||||||
|
internal enum Organizer: StoryboardType {
|
||||||
|
internal static let storyboardName = "Organizer"
|
||||||
|
|
||||||
|
internal static let initialScene = InitialSceneType<UINavigationController>(storyboard: Organizer.self)
|
||||||
|
|
||||||
|
internal static let provider = SceneType<UINavigationController>(storyboard: Organizer.self, identifier: "Provider")
|
||||||
|
|
||||||
|
internal static let wizardHostIdentifier = SceneType<UINavigationController>(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 {}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
|
||||||
|
extension UIViewController {
|
||||||
|
func applyMasterTitle(_ theme: Theme) {
|
||||||
|
navigationItem.largeTitleDisplayMode = theme.masterTitleDisplayMode
|
||||||
|
}
|
||||||
|
|
||||||
|
func applyDetailTitle(_ theme: Theme) {
|
||||||
|
navigationItem.largeTitleDisplayMode = theme.detailTitleDisplayMode
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
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..<last
|
||||||
|
guard let found = text.range(of: string, options: .backwards, range: context) else {
|
||||||
|
scrollToBegin()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let nsRange = text.nsRange(from: found)
|
||||||
|
// log.debug(">>> found: \(nsRange)")
|
||||||
|
scrollRangeToVisible(nsRange)
|
||||||
|
// scrollRangeToTop(nsRange)
|
||||||
|
}
|
||||||
|
|
||||||
|
func findNext(string: String) {
|
||||||
|
let first = text.index(text.startIndex, offsetBy: lastVisibleIndex())
|
||||||
|
let context = first..<text.endIndex
|
||||||
|
guard let found = text.range(of: string, range: context) else {
|
||||||
|
scrollToEnd()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let nsRange = text.nsRange(from: found)
|
||||||
|
// log.debug(">>> 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))
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,72 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
|
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
||||||
|
<key>CFBundleDisplayName</key>
|
||||||
|
<string>Passepartout</string>
|
||||||
|
<key>CFBundleDocumentTypes</key>
|
||||||
|
<array>
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleTypeIconFiles</key>
|
||||||
|
<array/>
|
||||||
|
<key>CFBundleTypeName</key>
|
||||||
|
<string>OpenVPN</string>
|
||||||
|
<key>CFBundleTypeRole</key>
|
||||||
|
<string>Viewer</string>
|
||||||
|
<key>LSHandlerRank</key>
|
||||||
|
<string>Owner</string>
|
||||||
|
<key>LSItemContentTypes</key>
|
||||||
|
<array>
|
||||||
|
<string>net.openvpn.formats.ovpn</string>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
</array>
|
||||||
|
<key>CFBundleExecutable</key>
|
||||||
|
<string>$(EXECUTABLE_NAME)</string>
|
||||||
|
<key>CFBundleIdentifier</key>
|
||||||
|
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||||
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
|
<string>6.0</string>
|
||||||
|
<key>CFBundleName</key>
|
||||||
|
<string>$(PRODUCT_NAME)</string>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>APPL</string>
|
||||||
|
<key>CFBundleShortVersionString</key>
|
||||||
|
<string>1.0</string>
|
||||||
|
<key>CFBundleVersion</key>
|
||||||
|
<string>1</string>
|
||||||
|
<key>ITSAppUsesNonExemptEncryption</key>
|
||||||
|
<false/>
|
||||||
|
<key>LSRequiresIPhoneOS</key>
|
||||||
|
<true/>
|
||||||
|
<key>LSSupportsOpeningDocumentsInPlace</key>
|
||||||
|
<true/>
|
||||||
|
<key>UILaunchStoryboardName</key>
|
||||||
|
<string>LaunchScreen</string>
|
||||||
|
<key>UIMainStoryboardFile</key>
|
||||||
|
<string>Main</string>
|
||||||
|
<key>UIRequiredDeviceCapabilities</key>
|
||||||
|
<array>
|
||||||
|
<string>arm64</string>
|
||||||
|
</array>
|
||||||
|
<key>UIStatusBarStyle</key>
|
||||||
|
<string>UIStatusBarStyleLightContent</string>
|
||||||
|
<key>UISupportedInterfaceOrientations</key>
|
||||||
|
<array>
|
||||||
|
<string>UIInterfaceOrientationPortrait</string>
|
||||||
|
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||||
|
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||||
|
</array>
|
||||||
|
<key>UISupportedInterfaceOrientations~ipad</key>
|
||||||
|
<array>
|
||||||
|
<string>UIInterfaceOrientationPortrait</string>
|
||||||
|
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
||||||
|
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||||
|
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||||
|
</array>
|
||||||
|
<key>UIViewControllerBasedStatusBarAppearance</key>
|
||||||
|
<false/>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>com.apple.developer.networking.networkextension</key>
|
||||||
|
<array>
|
||||||
|
<string>packet-tunnel-provider</string>
|
||||||
|
</array>
|
||||||
|
<key>com.apple.developer.networking.wifi-info</key>
|
||||||
|
<true/>
|
||||||
|
<key>com.apple.security.application-groups</key>
|
||||||
|
<array>
|
||||||
|
<string>group.com.algoritmico.Passepartout</string>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
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<SectionType, RowType> = {
|
||||||
|
let model: TableModel<SectionType, RowType> = 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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import TunnelKit
|
||||||
|
|
||||||
|
protocol ConfigurationModificationDelegate: class {
|
||||||
|
func configuration(didUpdate newConfiguration: TunnelKitProvider.Configuration)
|
||||||
|
|
||||||
|
func configurationShouldReinstall()
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
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<SectionType, RowType> = {
|
||||||
|
let model: TableModel<SectionType, RowType> = 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<SessionProxy.Cipher>()
|
||||||
|
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<SessionProxy.Digest>()
|
||||||
|
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<SessionProxy.CompressionFraming>()
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
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()
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
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<SectionType, RowType> = {
|
||||||
|
let model: TableModel<SectionType, RowType> = 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
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
import UIKit
|
||||||
|
|
||||||
|
class AboutViewController: UITableViewController, TableModelHost {
|
||||||
|
|
||||||
|
// MARK: TableModelHost
|
||||||
|
|
||||||
|
let model: TableModel<SectionType, RowType> = {
|
||||||
|
let model: TableModel<SectionType, RowType> = 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)
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
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<SectionType, RowType> = {
|
||||||
|
let model: TableModel<SectionType, RowType> = 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)
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
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<SectionType, RowType> = {
|
||||||
|
let model: TableModel<SectionType, RowType> = 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)
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
protocol TableModelHost {
|
||||||
|
associatedtype S: Hashable
|
||||||
|
|
||||||
|
associatedtype R: Equatable
|
||||||
|
|
||||||
|
var model: TableModel<S, R> { get }
|
||||||
|
|
||||||
|
func reloadModel()
|
||||||
|
}
|
||||||
|
|
||||||
|
class TableModel<S: Hashable, R: Equatable> {
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14313.18" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
|
||||||
|
<device id="retina4_7" orientation="portrait">
|
||||||
|
<adaptation id="fullscreen"/>
|
||||||
|
</device>
|
||||||
|
<dependencies>
|
||||||
|
<deployment identifier="iOS"/>
|
||||||
|
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14283.14"/>
|
||||||
|
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
||||||
|
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||||
|
</dependencies>
|
||||||
|
<scenes>
|
||||||
|
<!--View Controller-->
|
||||||
|
<scene sceneID="EHf-IW-A2E">
|
||||||
|
<objects>
|
||||||
|
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
|
||||||
|
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
|
<subviews>
|
||||||
|
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="logo" translatesAutoresizingMaskIntoConstraints="NO" id="OHJ-SJ-aQy">
|
||||||
|
<rect key="frame" x="87.5" y="233.5" width="200" height="200"/>
|
||||||
|
</imageView>
|
||||||
|
</subviews>
|
||||||
|
<color key="backgroundColor" red="0.31764705882352939" green="0.36470588235294116" blue="0.44313725490196076" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||||
|
<constraints>
|
||||||
|
<constraint firstItem="OHJ-SJ-aQy" firstAttribute="centerX" secondItem="Ze5-6b-2t3" secondAttribute="centerX" id="863-BE-Wxx"/>
|
||||||
|
<constraint firstItem="OHJ-SJ-aQy" firstAttribute="centerY" secondItem="Ze5-6b-2t3" secondAttribute="centerY" id="v66-aa-68F"/>
|
||||||
|
</constraints>
|
||||||
|
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
|
||||||
|
</view>
|
||||||
|
</viewController>
|
||||||
|
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||||
|
</objects>
|
||||||
|
<point key="canvasLocation" x="53" y="375"/>
|
||||||
|
</scene>
|
||||||
|
</scenes>
|
||||||
|
<resources>
|
||||||
|
<image name="logo" width="200" height="200"/>
|
||||||
|
</resources>
|
||||||
|
</document>
|
|
@ -0,0 +1,538 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="AAm-3V-G5F">
|
||||||
|
<device id="retina4_7" orientation="portrait">
|
||||||
|
<adaptation id="fullscreen"/>
|
||||||
|
</device>
|
||||||
|
<dependencies>
|
||||||
|
<deployment identifier="iOS"/>
|
||||||
|
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
|
||||||
|
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
||||||
|
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||||
|
</dependencies>
|
||||||
|
<scenes>
|
||||||
|
<!--Split View Controller-->
|
||||||
|
<scene sceneID="mtV-Kx-cNM">
|
||||||
|
<objects>
|
||||||
|
<splitViewController id="AAm-3V-G5F" sceneMemberID="viewController">
|
||||||
|
<connections>
|
||||||
|
<segue destination="8zN-e3-7hB" kind="relationship" relationship="detailViewController" id="gxF-pa-sWQ"/>
|
||||||
|
<segue destination="sf1-t3-FaZ" kind="relationship" relationship="masterViewController" id="yEo-mn-o0h"/>
|
||||||
|
</connections>
|
||||||
|
</splitViewController>
|
||||||
|
<placeholder placeholderIdentifier="IBFirstResponder" id="PSk-4K-2dU" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||||
|
</objects>
|
||||||
|
<point key="canvasLocation" x="-2222" y="-152"/>
|
||||||
|
</scene>
|
||||||
|
<!--Organizer-->
|
||||||
|
<scene sceneID="uDt-Dj-UYa">
|
||||||
|
<objects>
|
||||||
|
<viewControllerPlaceholder storyboardName="Organizer" id="sf1-t3-FaZ" sceneMemberID="viewController"/>
|
||||||
|
<placeholder placeholderIdentifier="IBFirstResponder" id="Xqq-TY-oVa" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||||
|
</objects>
|
||||||
|
<point key="canvasLocation" x="-1098" y="-659"/>
|
||||||
|
</scene>
|
||||||
|
<!--Navigation Controller-->
|
||||||
|
<scene sceneID="0a4-uz-gbg">
|
||||||
|
<objects>
|
||||||
|
<navigationController storyboardIdentifier="ServiceIdentifier" id="8zN-e3-7hB" sceneMemberID="viewController">
|
||||||
|
<navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" largeTitles="YES" id="mJT-ro-YBB">
|
||||||
|
<rect key="frame" x="0.0" y="20" width="375" height="44"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
</navigationBar>
|
||||||
|
<connections>
|
||||||
|
<segue destination="BYZ-38-t0r" kind="relationship" relationship="rootViewController" id="ANq-cl-tbl"/>
|
||||||
|
</connections>
|
||||||
|
</navigationController>
|
||||||
|
<placeholder placeholderIdentifier="IBFirstResponder" id="aMF-g9-dYa" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||||
|
</objects>
|
||||||
|
<point key="canvasLocation" x="-1097" y="109"/>
|
||||||
|
</scene>
|
||||||
|
<!--Endpoint View Controller-->
|
||||||
|
<scene sceneID="fdx-Ws-pNk">
|
||||||
|
<objects>
|
||||||
|
<viewController id="45O-Za-20g" customClass="EndpointViewController" customModule="Passepartout_iOS" customModuleProvider="target" sceneMemberID="viewController">
|
||||||
|
<view key="view" contentMode="scaleToFill" id="S0h-YJ-nFv">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
|
<subviews>
|
||||||
|
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="grouped" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" translatesAutoresizingMaskIntoConstraints="NO" id="gKP-Lr-dsV">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||||
|
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
|
||||||
|
<prototypes>
|
||||||
|
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="ToggleTableViewCell" textLabel="tkJ-X8-ifj" style="IBUITableViewCellStyleDefault" id="zPV-mL-RCK" customClass="ToggleTableViewCell" customModule="Passepartout_iOS" customModuleProvider="target">
|
||||||
|
<rect key="frame" x="0.0" y="55.5" width="375" height="44"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="zPV-mL-RCK" id="Ybl-SJ-ptH">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
<subviews>
|
||||||
|
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="tkJ-X8-ifj">
|
||||||
|
<rect key="frame" x="15" y="0.0" width="345" height="43.5"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||||
|
<nil key="textColor"/>
|
||||||
|
<nil key="highlightedColor"/>
|
||||||
|
</label>
|
||||||
|
</subviews>
|
||||||
|
</tableViewCellContentView>
|
||||||
|
</tableViewCell>
|
||||||
|
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" reuseIdentifier="SettingTableViewCell" textLabel="gkx-ms-Uex" detailTextLabel="9lm-24-5Gs" style="IBUITableViewCellStyleValue1" id="2y0-w2-QJ4" customClass="SettingTableViewCell" customModule="Passepartout_iOS" customModuleProvider="target">
|
||||||
|
<rect key="frame" x="0.0" y="99.5" width="375" height="44"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="2y0-w2-QJ4" id="yVx-vY-0hM">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="342" height="43.5"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
<subviews>
|
||||||
|
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="gkx-ms-Uex">
|
||||||
|
<rect key="frame" x="15" y="12" width="33.5" height="20.5"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||||
|
<nil key="textColor"/>
|
||||||
|
<nil key="highlightedColor"/>
|
||||||
|
</label>
|
||||||
|
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Detail" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="9lm-24-5Gs">
|
||||||
|
<rect key="frame" x="296" y="12" width="44" height="20.5"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||||
|
<nil key="textColor"/>
|
||||||
|
<nil key="highlightedColor"/>
|
||||||
|
</label>
|
||||||
|
</subviews>
|
||||||
|
</tableViewCellContentView>
|
||||||
|
</tableViewCell>
|
||||||
|
</prototypes>
|
||||||
|
<connections>
|
||||||
|
<outlet property="dataSource" destination="45O-Za-20g" id="F6A-9V-eFM"/>
|
||||||
|
<outlet property="delegate" destination="45O-Za-20g" id="hBE-Ob-9zo"/>
|
||||||
|
</connections>
|
||||||
|
</tableView>
|
||||||
|
</subviews>
|
||||||
|
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||||
|
<constraints>
|
||||||
|
<constraint firstItem="gKP-Lr-dsV" firstAttribute="trailing" secondItem="S0h-YJ-nFv" secondAttribute="trailing" id="3U8-I6-yUs"/>
|
||||||
|
<constraint firstItem="gKP-Lr-dsV" firstAttribute="bottom" secondItem="S0h-YJ-nFv" secondAttribute="bottom" id="TgE-vI-gI3"/>
|
||||||
|
<constraint firstItem="gKP-Lr-dsV" firstAttribute="leading" secondItem="S0h-YJ-nFv" secondAttribute="leading" id="bl8-tX-vMC"/>
|
||||||
|
<constraint firstItem="gKP-Lr-dsV" firstAttribute="top" secondItem="S0h-YJ-nFv" secondAttribute="top" id="svj-fR-YOY"/>
|
||||||
|
</constraints>
|
||||||
|
<viewLayoutGuide key="safeArea" id="qzr-z1-5L2"/>
|
||||||
|
</view>
|
||||||
|
<navigationItem key="navigationItem" id="fiO-wZ-IA1"/>
|
||||||
|
<connections>
|
||||||
|
<outlet property="tableView" destination="gKP-Lr-dsV" id="FCc-On-xwo"/>
|
||||||
|
</connections>
|
||||||
|
</viewController>
|
||||||
|
<placeholder placeholderIdentifier="IBFirstResponder" id="zHV-nY-ULw" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||||
|
</objects>
|
||||||
|
<point key="canvasLocation" x="1623" y="615"/>
|
||||||
|
</scene>
|
||||||
|
<!--Service View Controller-->
|
||||||
|
<scene sceneID="tne-QT-ifu">
|
||||||
|
<objects>
|
||||||
|
<viewController id="BYZ-38-t0r" customClass="ServiceViewController" customModule="Passepartout_iOS" customModuleProvider="target" sceneMemberID="viewController">
|
||||||
|
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
|
<subviews>
|
||||||
|
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="grouped" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" translatesAutoresizingMaskIntoConstraints="NO" id="14D-an-pBY">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||||
|
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
|
||||||
|
<prototypes>
|
||||||
|
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" reuseIdentifier="SettingTableViewCell" textLabel="SdF-Z2-0bH" detailTextLabel="SoE-OW-Xz5" style="IBUITableViewCellStyleValue1" id="RoI-rn-Np8" customClass="SettingTableViewCell" customModule="Passepartout_iOS" customModuleProvider="target">
|
||||||
|
<rect key="frame" x="0.0" y="55.5" width="375" height="44"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="RoI-rn-Np8" id="Dcf-DQ-j3p">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="342" height="43.5"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
<subviews>
|
||||||
|
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="SdF-Z2-0bH">
|
||||||
|
<rect key="frame" x="15" y="12" width="33.5" height="20.5"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||||
|
<nil key="textColor"/>
|
||||||
|
<nil key="highlightedColor"/>
|
||||||
|
</label>
|
||||||
|
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Detail" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="SoE-OW-Xz5">
|
||||||
|
<rect key="frame" x="296" y="12" width="44" height="20.5"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||||
|
<nil key="textColor"/>
|
||||||
|
<nil key="highlightedColor"/>
|
||||||
|
</label>
|
||||||
|
</subviews>
|
||||||
|
</tableViewCellContentView>
|
||||||
|
</tableViewCell>
|
||||||
|
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="ToggleTableViewCell" textLabel="RKE-mt-dZB" style="IBUITableViewCellStyleDefault" id="4W2-Qu-LR8" customClass="ToggleTableViewCell" customModule="Passepartout_iOS" customModuleProvider="target">
|
||||||
|
<rect key="frame" x="0.0" y="99.5" width="375" height="44"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="4W2-Qu-LR8" id="6pB-5d-FaW">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
<subviews>
|
||||||
|
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="RKE-mt-dZB">
|
||||||
|
<rect key="frame" x="15" y="0.0" width="345" height="43.5"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||||
|
<nil key="textColor"/>
|
||||||
|
<nil key="highlightedColor"/>
|
||||||
|
</label>
|
||||||
|
</subviews>
|
||||||
|
</tableViewCellContentView>
|
||||||
|
</tableViewCell>
|
||||||
|
</prototypes>
|
||||||
|
<sections/>
|
||||||
|
<connections>
|
||||||
|
<outlet property="dataSource" destination="BYZ-38-t0r" id="2LA-qH-TqY"/>
|
||||||
|
<outlet property="delegate" destination="BYZ-38-t0r" id="S9s-2h-akx"/>
|
||||||
|
</connections>
|
||||||
|
</tableView>
|
||||||
|
<view hidden="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="p0F-IK-RD6">
|
||||||
|
<rect key="frame" x="0.0" y="64" width="375" height="603"/>
|
||||||
|
<subviews>
|
||||||
|
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="<welcome>" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="jEt-mV-gjN">
|
||||||
|
<rect key="frame" x="143" y="291.5" width="89.5" height="20.5"/>
|
||||||
|
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||||
|
<nil key="textColor"/>
|
||||||
|
<nil key="highlightedColor"/>
|
||||||
|
</label>
|
||||||
|
</subviews>
|
||||||
|
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||||
|
<constraints>
|
||||||
|
<constraint firstItem="jEt-mV-gjN" firstAttribute="centerY" secondItem="p0F-IK-RD6" secondAttribute="centerY" id="Gme-i6-g3Z"/>
|
||||||
|
<constraint firstItem="jEt-mV-gjN" firstAttribute="centerX" secondItem="p0F-IK-RD6" secondAttribute="centerX" id="Lg2-5C-GNx"/>
|
||||||
|
</constraints>
|
||||||
|
</view>
|
||||||
|
</subviews>
|
||||||
|
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||||
|
<constraints>
|
||||||
|
<constraint firstItem="14D-an-pBY" firstAttribute="top" secondItem="8bC-Xf-vdC" secondAttribute="top" id="HVp-vg-BJX"/>
|
||||||
|
<constraint firstItem="6Tk-OE-BBY" firstAttribute="bottom" secondItem="p0F-IK-RD6" secondAttribute="bottom" id="gHw-iZ-1Gv"/>
|
||||||
|
<constraint firstItem="6Tk-OE-BBY" firstAttribute="trailing" secondItem="p0F-IK-RD6" secondAttribute="trailing" id="jpS-Od-4G6"/>
|
||||||
|
<constraint firstItem="p0F-IK-RD6" firstAttribute="top" secondItem="6Tk-OE-BBY" secondAttribute="top" id="jwb-dv-4gm"/>
|
||||||
|
<constraint firstItem="14D-an-pBY" firstAttribute="bottom" secondItem="8bC-Xf-vdC" secondAttribute="bottom" id="qXf-dM-c5N"/>
|
||||||
|
<constraint firstItem="p0F-IK-RD6" firstAttribute="leading" secondItem="6Tk-OE-BBY" secondAttribute="leading" id="uEy-gN-Z07"/>
|
||||||
|
<constraint firstItem="14D-an-pBY" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leading" id="uZ4-xs-T0H"/>
|
||||||
|
<constraint firstItem="14D-an-pBY" firstAttribute="trailing" secondItem="8bC-Xf-vdC" secondAttribute="trailing" id="vW1-46-4h4"/>
|
||||||
|
</constraints>
|
||||||
|
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
|
||||||
|
</view>
|
||||||
|
<navigationItem key="navigationItem" id="Vwa-AG-OnN"/>
|
||||||
|
<connections>
|
||||||
|
<outlet property="labelWelcome" destination="jEt-mV-gjN" id="kaN-fX-eRE"/>
|
||||||
|
<outlet property="tableView" destination="14D-an-pBY" id="qzB-YR-Pss"/>
|
||||||
|
<outlet property="viewWelcome" destination="p0F-IK-RD6" id="pGB-3J-Rwj"/>
|
||||||
|
<segue destination="eIk-8Z-CLS" kind="show" identifier="AccountSegueIdentifier" id="M6O-ZR-bXH"/>
|
||||||
|
<segue destination="Q5h-Xw-Yfl" kind="show" identifier="ProviderPoolSegueIdentifier" id="JvU-ao-HXO"/>
|
||||||
|
<segue destination="45O-Za-20g" kind="show" identifier="EndpointSegueIdentifier" id="gTn-CW-bgB"/>
|
||||||
|
<segue destination="NJT-2N-LTa" kind="show" identifier="HostParametersSegueIdentifier" id="aL8-H6-znA"/>
|
||||||
|
<segue destination="9Kr-G1-asf" kind="show" identifier="ProviderPresetSegueIdentifier" id="kGf-Yu-KdY"/>
|
||||||
|
<segue destination="KmS-dJ-DVx" kind="show" identifier="DebugLogSegueIdentifier" id="XyI-by-AhD"/>
|
||||||
|
</connections>
|
||||||
|
</viewController>
|
||||||
|
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
|
||||||
|
</objects>
|
||||||
|
<point key="canvasLocation" x="-39" y="111"/>
|
||||||
|
</scene>
|
||||||
|
<!--Provider Pool View Controller-->
|
||||||
|
<scene sceneID="JAC-Ym-zYJ">
|
||||||
|
<objects>
|
||||||
|
<viewController id="Q5h-Xw-Yfl" customClass="ProviderPoolViewController" customModule="Passepartout_iOS" customModuleProvider="target" sceneMemberID="viewController">
|
||||||
|
<view key="view" contentMode="scaleToFill" id="v5z-OX-y5O">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
|
<subviews>
|
||||||
|
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="grouped" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" translatesAutoresizingMaskIntoConstraints="NO" id="xwz-QO-tUV">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||||
|
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
|
||||||
|
<prototypes>
|
||||||
|
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="SettingTableViewCell" textLabel="NBI-92-bcL" detailTextLabel="YdD-0I-AU2" style="IBUITableViewCellStyleValue1" id="5Tr-TW-Ejx" customClass="SettingTableViewCell" customModule="Passepartout_iOS" customModuleProvider="target">
|
||||||
|
<rect key="frame" x="0.0" y="55.5" width="375" height="44"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="5Tr-TW-Ejx" id="B1l-Jy-Mbs">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
<subviews>
|
||||||
|
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="NBI-92-bcL">
|
||||||
|
<rect key="frame" x="15" y="12" width="33.5" height="20.5"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||||
|
<nil key="textColor"/>
|
||||||
|
<nil key="highlightedColor"/>
|
||||||
|
</label>
|
||||||
|
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Detail" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="YdD-0I-AU2">
|
||||||
|
<rect key="frame" x="316" y="12" width="44" height="20.5"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||||
|
<nil key="textColor"/>
|
||||||
|
<nil key="highlightedColor"/>
|
||||||
|
</label>
|
||||||
|
</subviews>
|
||||||
|
</tableViewCellContentView>
|
||||||
|
</tableViewCell>
|
||||||
|
</prototypes>
|
||||||
|
<connections>
|
||||||
|
<outlet property="dataSource" destination="Q5h-Xw-Yfl" id="ptT-cZ-akw"/>
|
||||||
|
<outlet property="delegate" destination="Q5h-Xw-Yfl" id="LAh-2w-jq5"/>
|
||||||
|
</connections>
|
||||||
|
</tableView>
|
||||||
|
</subviews>
|
||||||
|
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||||
|
<constraints>
|
||||||
|
<constraint firstItem="xwz-QO-tUV" firstAttribute="top" secondItem="v5z-OX-y5O" secondAttribute="top" id="8J6-dJ-W3A"/>
|
||||||
|
<constraint firstAttribute="bottom" secondItem="xwz-QO-tUV" secondAttribute="bottom" id="N4v-Ws-cEb"/>
|
||||||
|
<constraint firstItem="xwz-QO-tUV" firstAttribute="leading" secondItem="v5z-OX-y5O" secondAttribute="leading" id="XCR-OS-Avt"/>
|
||||||
|
<constraint firstAttribute="trailing" secondItem="xwz-QO-tUV" secondAttribute="trailing" id="qeY-5E-sQX"/>
|
||||||
|
</constraints>
|
||||||
|
<viewLayoutGuide key="safeArea" id="VS5-U2-fwN"/>
|
||||||
|
</view>
|
||||||
|
<navigationItem key="navigationItem" id="VPL-mG-8ge"/>
|
||||||
|
<connections>
|
||||||
|
<outlet property="tableView" destination="xwz-QO-tUV" id="VV6-a9-a19"/>
|
||||||
|
</connections>
|
||||||
|
</viewController>
|
||||||
|
<placeholder placeholderIdentifier="IBFirstResponder" id="chi-8J-JrP" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||||
|
</objects>
|
||||||
|
<point key="canvasLocation" x="2492" y="110"/>
|
||||||
|
</scene>
|
||||||
|
<!--Account View Controller-->
|
||||||
|
<scene sceneID="ZzS-JO-Pmj">
|
||||||
|
<objects>
|
||||||
|
<viewController storyboardIdentifier="AccountIdentifier" id="eIk-8Z-CLS" customClass="AccountViewController" customModule="Passepartout_iOS" customModuleProvider="target" sceneMemberID="viewController">
|
||||||
|
<view key="view" contentMode="scaleToFill" id="anF-dH-Q6h">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
|
<subviews>
|
||||||
|
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="grouped" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" translatesAutoresizingMaskIntoConstraints="NO" id="HjI-gQ-Awz">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||||
|
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
|
||||||
|
<prototypes>
|
||||||
|
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="FieldTableViewCell" textLabel="VNs-lr-Nfh" style="IBUITableViewCellStyleDefault" id="Tqr-a6-Dqp" customClass="FieldTableViewCell" customModule="Passepartout_iOS" customModuleProvider="target">
|
||||||
|
<rect key="frame" x="0.0" y="55.5" width="375" height="44"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="Tqr-a6-Dqp" id="CnP-ta-5hH">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
<subviews>
|
||||||
|
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="VNs-lr-Nfh">
|
||||||
|
<rect key="frame" x="15" y="0.0" width="345" height="43.5"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||||
|
<nil key="textColor"/>
|
||||||
|
<nil key="highlightedColor"/>
|
||||||
|
</label>
|
||||||
|
</subviews>
|
||||||
|
</tableViewCellContentView>
|
||||||
|
</tableViewCell>
|
||||||
|
</prototypes>
|
||||||
|
<connections>
|
||||||
|
<outlet property="dataSource" destination="eIk-8Z-CLS" id="GbK-wM-Fhp"/>
|
||||||
|
<outlet property="delegate" destination="eIk-8Z-CLS" id="CR2-xl-Rkg"/>
|
||||||
|
</connections>
|
||||||
|
</tableView>
|
||||||
|
</subviews>
|
||||||
|
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||||
|
<constraints>
|
||||||
|
<constraint firstItem="HjI-gQ-Awz" firstAttribute="trailing" secondItem="anF-dH-Q6h" secondAttribute="trailing" id="BC2-R9-g4c"/>
|
||||||
|
<constraint firstItem="HjI-gQ-Awz" firstAttribute="leading" secondItem="anF-dH-Q6h" secondAttribute="leading" id="IlW-DP-QKw"/>
|
||||||
|
<constraint firstItem="HjI-gQ-Awz" firstAttribute="top" secondItem="anF-dH-Q6h" secondAttribute="top" id="srj-XD-AxT"/>
|
||||||
|
<constraint firstAttribute="bottom" secondItem="HjI-gQ-Awz" secondAttribute="bottom" id="tpn-BA-Y0W"/>
|
||||||
|
</constraints>
|
||||||
|
<viewLayoutGuide key="safeArea" id="DqQ-wf-Y7N"/>
|
||||||
|
</view>
|
||||||
|
<navigationItem key="navigationItem" id="b9d-7O-Oqc">
|
||||||
|
<barButtonItem key="rightBarButtonItem" style="done" systemItem="done" id="HCq-qr-aUa">
|
||||||
|
<connections>
|
||||||
|
<action selector="done" destination="eIk-8Z-CLS" id="d4H-u9-q4F"/>
|
||||||
|
</connections>
|
||||||
|
</barButtonItem>
|
||||||
|
</navigationItem>
|
||||||
|
<connections>
|
||||||
|
<outlet property="tableView" destination="HjI-gQ-Awz" id="RGI-n1-8Yx"/>
|
||||||
|
</connections>
|
||||||
|
</viewController>
|
||||||
|
<placeholder placeholderIdentifier="IBFirstResponder" id="0a1-SZ-QPS" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||||
|
</objects>
|
||||||
|
<point key="canvasLocation" x="1622" y="-270"/>
|
||||||
|
</scene>
|
||||||
|
<!--Debug Log View Controller-->
|
||||||
|
<scene sceneID="Icu-BA-Eze">
|
||||||
|
<objects>
|
||||||
|
<viewController extendedLayoutIncludesOpaqueBars="YES" id="KmS-dJ-DVx" customClass="DebugLogViewController" customModule="Passepartout_iOS" customModuleProvider="target" sceneMemberID="viewController">
|
||||||
|
<view key="view" contentMode="scaleToFill" id="DQA-dJ-PeF">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
|
<subviews>
|
||||||
|
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" editable="NO" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="Aex-ay-Bvb">
|
||||||
|
<rect key="frame" x="0.0" y="64" width="375" height="559"/>
|
||||||
|
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||||
|
<fontDescription key="fontDescription" name="CourierNewPSMT" family="Courier New" pointSize="14"/>
|
||||||
|
<textInputTraits key="textInputTraits" autocorrectionType="no"/>
|
||||||
|
</textView>
|
||||||
|
<toolbar opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="L2r-Gc-jgW">
|
||||||
|
<rect key="frame" x="0.0" y="623" width="375" height="44"/>
|
||||||
|
<items>
|
||||||
|
<barButtonItem systemItem="rewind" id="dzc-CH-vwc">
|
||||||
|
<connections>
|
||||||
|
<action selector="previousSession" destination="KmS-dJ-DVx" id="mbh-60-0C4"/>
|
||||||
|
</connections>
|
||||||
|
</barButtonItem>
|
||||||
|
<barButtonItem width="30" style="plain" systemItem="fixedSpace" id="S80-Iu-dbj"/>
|
||||||
|
<barButtonItem systemItem="fastForward" id="XdD-tV-5tf">
|
||||||
|
<connections>
|
||||||
|
<action selector="nextSession" destination="KmS-dJ-DVx" id="IMg-vd-A8K"/>
|
||||||
|
</connections>
|
||||||
|
</barButtonItem>
|
||||||
|
<barButtonItem systemItem="flexibleSpace" id="5Nm-qF-X75"/>
|
||||||
|
<barButtonItem systemItem="action" id="dDq-i9-dB0">
|
||||||
|
<connections>
|
||||||
|
<action selector="share:" destination="KmS-dJ-DVx" id="32r-VS-qvc"/>
|
||||||
|
</connections>
|
||||||
|
</barButtonItem>
|
||||||
|
</items>
|
||||||
|
</toolbar>
|
||||||
|
</subviews>
|
||||||
|
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||||
|
<constraints>
|
||||||
|
<constraint firstItem="EID-0c-3tN" firstAttribute="trailing" secondItem="Aex-ay-Bvb" secondAttribute="trailing" id="MxQ-FS-qWF"/>
|
||||||
|
<constraint firstItem="Aex-ay-Bvb" firstAttribute="top" secondItem="EID-0c-3tN" secondAttribute="top" id="dQv-Al-Hx5"/>
|
||||||
|
<constraint firstItem="L2r-Gc-jgW" firstAttribute="top" secondItem="Aex-ay-Bvb" secondAttribute="bottom" id="e6U-Xm-pES"/>
|
||||||
|
<constraint firstItem="L2r-Gc-jgW" firstAttribute="leading" secondItem="DQA-dJ-PeF" secondAttribute="leading" id="iuO-hK-K2Z"/>
|
||||||
|
<constraint firstItem="L2r-Gc-jgW" firstAttribute="bottom" secondItem="EID-0c-3tN" secondAttribute="bottom" id="lG5-6f-HvB"/>
|
||||||
|
<constraint firstAttribute="trailing" secondItem="L2r-Gc-jgW" secondAttribute="trailing" id="paj-ca-wpL"/>
|
||||||
|
<constraint firstItem="Aex-ay-Bvb" firstAttribute="leading" secondItem="EID-0c-3tN" secondAttribute="leading" id="uaR-uG-IC6"/>
|
||||||
|
</constraints>
|
||||||
|
<viewLayoutGuide key="safeArea" id="EID-0c-3tN"/>
|
||||||
|
</view>
|
||||||
|
<toolbarItems/>
|
||||||
|
<navigationItem key="navigationItem" id="Wbs-3b-OSm"/>
|
||||||
|
<connections>
|
||||||
|
<outlet property="textLog" destination="Aex-ay-Bvb" id="9l9-Nk-Dz3"/>
|
||||||
|
</connections>
|
||||||
|
</viewController>
|
||||||
|
<placeholder placeholderIdentifier="IBFirstResponder" id="r7q-e9-kra" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||||
|
</objects>
|
||||||
|
<point key="canvasLocation" x="-39" y="1248"/>
|
||||||
|
</scene>
|
||||||
|
<!--Provider Preset View Controller-->
|
||||||
|
<scene sceneID="H2q-58-oRM">
|
||||||
|
<objects>
|
||||||
|
<viewController id="9Kr-G1-asf" customClass="ProviderPresetViewController" customModule="Passepartout_iOS" customModuleProvider="target" sceneMemberID="viewController">
|
||||||
|
<view key="view" contentMode="scaleToFill" id="E57-aB-gwD">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
|
<subviews>
|
||||||
|
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="grouped" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" translatesAutoresizingMaskIntoConstraints="NO" id="cxM-eb-MEZ">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||||
|
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
|
||||||
|
<prototypes>
|
||||||
|
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="SettingTableViewCell" textLabel="8XN-Gu-lda" detailTextLabel="yBN-RJ-fm3" style="IBUITableViewCellStyleValue1" id="lIy-Qd-iAj" customClass="SettingTableViewCell" customModule="Passepartout_iOS" customModuleProvider="target">
|
||||||
|
<rect key="frame" x="0.0" y="55.5" width="375" height="44"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="lIy-Qd-iAj" id="XAe-s1-42s">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
<subviews>
|
||||||
|
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="8XN-Gu-lda">
|
||||||
|
<rect key="frame" x="15" y="12" width="33.5" height="20.5"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||||
|
<nil key="textColor"/>
|
||||||
|
<nil key="highlightedColor"/>
|
||||||
|
</label>
|
||||||
|
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Detail" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="yBN-RJ-fm3">
|
||||||
|
<rect key="frame" x="316" y="12" width="44" height="20.5"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||||
|
<nil key="textColor"/>
|
||||||
|
<nil key="highlightedColor"/>
|
||||||
|
</label>
|
||||||
|
</subviews>
|
||||||
|
</tableViewCellContentView>
|
||||||
|
</tableViewCell>
|
||||||
|
</prototypes>
|
||||||
|
<connections>
|
||||||
|
<outlet property="dataSource" destination="9Kr-G1-asf" id="xAV-uA-DFZ"/>
|
||||||
|
<outlet property="delegate" destination="9Kr-G1-asf" id="wlJ-YK-rg7"/>
|
||||||
|
</connections>
|
||||||
|
</tableView>
|
||||||
|
</subviews>
|
||||||
|
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||||
|
<constraints>
|
||||||
|
<constraint firstItem="cxM-eb-MEZ" firstAttribute="leading" secondItem="E57-aB-gwD" secondAttribute="leading" id="2pk-uW-DBz"/>
|
||||||
|
<constraint firstAttribute="bottom" secondItem="cxM-eb-MEZ" secondAttribute="bottom" id="DGv-dv-gas"/>
|
||||||
|
<constraint firstAttribute="trailing" secondItem="cxM-eb-MEZ" secondAttribute="trailing" id="OT5-Ub-x8H"/>
|
||||||
|
<constraint firstItem="cxM-eb-MEZ" firstAttribute="top" secondItem="E57-aB-gwD" secondAttribute="top" id="taR-9T-Xfg"/>
|
||||||
|
</constraints>
|
||||||
|
<viewLayoutGuide key="safeArea" id="hzA-6T-Vhp"/>
|
||||||
|
</view>
|
||||||
|
<navigationItem key="navigationItem" id="fK5-TM-XrY"/>
|
||||||
|
<connections>
|
||||||
|
<outlet property="tableView" destination="cxM-eb-MEZ" id="5cU-gK-AAP"/>
|
||||||
|
</connections>
|
||||||
|
</viewController>
|
||||||
|
<placeholder placeholderIdentifier="IBFirstResponder" id="V40-jg-kYG" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||||
|
</objects>
|
||||||
|
<point key="canvasLocation" x="1274" y="1744"/>
|
||||||
|
</scene>
|
||||||
|
<!--Configuration View Controller-->
|
||||||
|
<scene sceneID="EIh-pV-nh3">
|
||||||
|
<objects>
|
||||||
|
<viewController storyboardIdentifier="ConfigurationIdentifier" id="NJT-2N-LTa" customClass="ConfigurationViewController" customModule="Passepartout_iOS" customModuleProvider="target" sceneMemberID="viewController">
|
||||||
|
<view key="view" contentMode="scaleToFill" id="SJB-KR-s1d">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
|
<subviews>
|
||||||
|
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="grouped" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" translatesAutoresizingMaskIntoConstraints="NO" id="SxK-m5-gVR">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||||
|
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
|
||||||
|
<prototypes>
|
||||||
|
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="SettingTableViewCell" textLabel="Bao-7G-pd5" detailTextLabel="Def-Vc-dwD" style="IBUITableViewCellStyleValue1" id="i8V-jj-yVi" customClass="SettingTableViewCell" customModule="Passepartout_iOS" customModuleProvider="target">
|
||||||
|
<rect key="frame" x="0.0" y="55.5" width="375" height="44"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="i8V-jj-yVi" id="zoa-z4-XD8">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
<subviews>
|
||||||
|
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Bao-7G-pd5">
|
||||||
|
<rect key="frame" x="15" y="12" width="33.5" height="20.5"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||||
|
<nil key="textColor"/>
|
||||||
|
<nil key="highlightedColor"/>
|
||||||
|
</label>
|
||||||
|
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Detail" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Def-Vc-dwD">
|
||||||
|
<rect key="frame" x="316" y="12" width="44" height="20.5"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||||
|
<nil key="textColor"/>
|
||||||
|
<nil key="highlightedColor"/>
|
||||||
|
</label>
|
||||||
|
</subviews>
|
||||||
|
</tableViewCellContentView>
|
||||||
|
</tableViewCell>
|
||||||
|
</prototypes>
|
||||||
|
<connections>
|
||||||
|
<outlet property="dataSource" destination="NJT-2N-LTa" id="3pM-K5-BEB"/>
|
||||||
|
<outlet property="delegate" destination="NJT-2N-LTa" id="rjV-75-FWK"/>
|
||||||
|
</connections>
|
||||||
|
</tableView>
|
||||||
|
</subviews>
|
||||||
|
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||||
|
<constraints>
|
||||||
|
<constraint firstItem="SxK-m5-gVR" firstAttribute="top" secondItem="SJB-KR-s1d" secondAttribute="top" id="5QV-lg-FxE"/>
|
||||||
|
<constraint firstAttribute="trailing" secondItem="SxK-m5-gVR" secondAttribute="trailing" id="DeF-ch-Glu"/>
|
||||||
|
<constraint firstAttribute="bottom" secondItem="SxK-m5-gVR" secondAttribute="bottom" id="i7B-ZQ-T9I"/>
|
||||||
|
<constraint firstItem="SxK-m5-gVR" firstAttribute="leading" secondItem="SJB-KR-s1d" secondAttribute="leading" id="t3h-6l-6Mw"/>
|
||||||
|
</constraints>
|
||||||
|
<viewLayoutGuide key="safeArea" id="GXg-wT-b0T"/>
|
||||||
|
</view>
|
||||||
|
<navigationItem key="navigationItem" id="wDl-3N-4fH"/>
|
||||||
|
<connections>
|
||||||
|
<outlet property="tableView" destination="SxK-m5-gVR" id="mVu-Gh-xX8"/>
|
||||||
|
</connections>
|
||||||
|
</viewController>
|
||||||
|
<placeholder placeholderIdentifier="IBFirstResponder" id="98f-S5-Fft" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||||
|
</objects>
|
||||||
|
<point key="canvasLocation" x="2338" y="1744"/>
|
||||||
|
</scene>
|
||||||
|
</scenes>
|
||||||
|
</document>
|
|
@ -0,0 +1,496 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14313.18" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="Sge-vR-hZB">
|
||||||
|
<device id="retina4_7" orientation="portrait">
|
||||||
|
<adaptation id="fullscreen"/>
|
||||||
|
</device>
|
||||||
|
<dependencies>
|
||||||
|
<deployment identifier="iOS"/>
|
||||||
|
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14283.14"/>
|
||||||
|
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
||||||
|
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||||
|
</dependencies>
|
||||||
|
<scenes>
|
||||||
|
<!--Wizard Provider View Controller-->
|
||||||
|
<scene sceneID="amb-wT-98R">
|
||||||
|
<objects>
|
||||||
|
<tableViewController id="Ooz-PQ-fgV" customClass="WizardProviderViewController" customModule="Passepartout_iOS" customModuleProvider="target" sceneMemberID="viewController">
|
||||||
|
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="grouped" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" id="FrB-tA-bkJ">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
|
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
|
||||||
|
<prototypes>
|
||||||
|
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="SettingTableViewCell" textLabel="ZFw-Xo-SgJ" detailTextLabel="LZg-Pu-uBW" style="IBUITableViewCellStyleValue1" id="vez-pF-zsL" customClass="SettingTableViewCell" customModule="Passepartout_iOS" customModuleProvider="target">
|
||||||
|
<rect key="frame" x="0.0" y="55.5" width="375" height="44"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="vez-pF-zsL" id="tAg-9p-gaM">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
<subviews>
|
||||||
|
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="ZFw-Xo-SgJ">
|
||||||
|
<rect key="frame" x="16" y="12" width="33.5" height="20.5"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||||
|
<nil key="textColor"/>
|
||||||
|
<nil key="highlightedColor"/>
|
||||||
|
</label>
|
||||||
|
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Detail" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="LZg-Pu-uBW">
|
||||||
|
<rect key="frame" x="315" y="12" width="44" height="20.5"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||||
|
<nil key="textColor"/>
|
||||||
|
<nil key="highlightedColor"/>
|
||||||
|
</label>
|
||||||
|
</subviews>
|
||||||
|
</tableViewCellContentView>
|
||||||
|
</tableViewCell>
|
||||||
|
</prototypes>
|
||||||
|
<connections>
|
||||||
|
<outlet property="dataSource" destination="Ooz-PQ-fgV" id="CoS-Ll-LbG"/>
|
||||||
|
<outlet property="delegate" destination="Ooz-PQ-fgV" id="X6u-nS-CpS"/>
|
||||||
|
</connections>
|
||||||
|
</tableView>
|
||||||
|
<navigationItem key="navigationItem" id="ve6-nw-Dpo">
|
||||||
|
<barButtonItem key="leftBarButtonItem" systemItem="cancel" id="OmE-OH-wEb">
|
||||||
|
<connections>
|
||||||
|
<action selector="close" destination="Ooz-PQ-fgV" id="AXq-hC-Keu"/>
|
||||||
|
</connections>
|
||||||
|
</barButtonItem>
|
||||||
|
</navigationItem>
|
||||||
|
</tableViewController>
|
||||||
|
<placeholder placeholderIdentifier="IBFirstResponder" id="8S7-Jg-ciK" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||||
|
</objects>
|
||||||
|
<point key="canvasLocation" x="-833" y="-1277"/>
|
||||||
|
</scene>
|
||||||
|
<!--Navigation Controller-->
|
||||||
|
<scene sceneID="MJY-S2-2mG">
|
||||||
|
<objects>
|
||||||
|
<navigationController storyboardIdentifier="Provider" id="NVA-bQ-iIE" sceneMemberID="viewController">
|
||||||
|
<navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="q89-MA-DTo">
|
||||||
|
<rect key="frame" x="0.0" y="20" width="375" height="44"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
</navigationBar>
|
||||||
|
<connections>
|
||||||
|
<segue destination="Ooz-PQ-fgV" kind="relationship" relationship="rootViewController" id="vZ3-zX-6Gj"/>
|
||||||
|
</connections>
|
||||||
|
</navigationController>
|
||||||
|
<placeholder placeholderIdentifier="IBFirstResponder" id="9VL-6o-IYm" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||||
|
</objects>
|
||||||
|
<point key="canvasLocation" x="-1786" y="-1277"/>
|
||||||
|
</scene>
|
||||||
|
<!--Wizard Host View Controller-->
|
||||||
|
<scene sceneID="cDq-OT-Nr8">
|
||||||
|
<objects>
|
||||||
|
<tableViewController id="oga-go-FqD" customClass="WizardHostViewController" customModule="Passepartout_iOS" customModuleProvider="target" sceneMemberID="viewController">
|
||||||
|
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="grouped" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" id="RpT-29-VW0">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
|
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
|
||||||
|
<prototypes>
|
||||||
|
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="FieldTableViewCell" textLabel="aLA-eA-uGX" style="IBUITableViewCellStyleDefault" id="wnp-T1-bf6" customClass="FieldTableViewCell" customModule="Passepartout_iOS" customModuleProvider="target">
|
||||||
|
<rect key="frame" x="0.0" y="55.5" width="375" height="44"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="wnp-T1-bf6" id="YiA-B5-bel">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
<subviews>
|
||||||
|
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="aLA-eA-uGX">
|
||||||
|
<rect key="frame" x="16" y="0.0" width="343" height="43.5"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||||
|
<nil key="textColor"/>
|
||||||
|
<nil key="highlightedColor"/>
|
||||||
|
</label>
|
||||||
|
</subviews>
|
||||||
|
</tableViewCellContentView>
|
||||||
|
</tableViewCell>
|
||||||
|
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="SettingTableViewCell" textLabel="isC-Oi-HuO" detailTextLabel="REc-9m-82J" style="IBUITableViewCellStyleValue1" id="mg5-6A-smS" customClass="SettingTableViewCell" customModule="Passepartout_iOS" customModuleProvider="target">
|
||||||
|
<rect key="frame" x="0.0" y="99.5" width="375" height="44"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="mg5-6A-smS" id="oTs-dD-rvG">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
<subviews>
|
||||||
|
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="isC-Oi-HuO">
|
||||||
|
<rect key="frame" x="16" y="12" width="33.5" height="20.5"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||||
|
<nil key="textColor"/>
|
||||||
|
<nil key="highlightedColor"/>
|
||||||
|
</label>
|
||||||
|
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Detail" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="REc-9m-82J">
|
||||||
|
<rect key="frame" x="315" y="12" width="44" height="20.5"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||||
|
<nil key="textColor"/>
|
||||||
|
<nil key="highlightedColor"/>
|
||||||
|
</label>
|
||||||
|
</subviews>
|
||||||
|
</tableViewCellContentView>
|
||||||
|
</tableViewCell>
|
||||||
|
</prototypes>
|
||||||
|
<connections>
|
||||||
|
<outlet property="dataSource" destination="oga-go-FqD" id="M6h-EV-mko"/>
|
||||||
|
<outlet property="delegate" destination="oga-go-FqD" id="Q6f-xx-mFM"/>
|
||||||
|
</connections>
|
||||||
|
</tableView>
|
||||||
|
<navigationItem key="navigationItem" id="BUy-H3-hFr">
|
||||||
|
<barButtonItem key="leftBarButtonItem" systemItem="cancel" id="nbt-nF-e1S">
|
||||||
|
<connections>
|
||||||
|
<action selector="close" destination="oga-go-FqD" id="6Vp-fM-8pO"/>
|
||||||
|
</connections>
|
||||||
|
</barButtonItem>
|
||||||
|
<barButtonItem key="rightBarButtonItem" title="<next>" style="done" id="xPK-yw-Cep">
|
||||||
|
<connections>
|
||||||
|
<action selector="next" destination="oga-go-FqD" id="cBA-Ka-CBV"/>
|
||||||
|
</connections>
|
||||||
|
</barButtonItem>
|
||||||
|
</navigationItem>
|
||||||
|
<connections>
|
||||||
|
<outlet property="itemNext" destination="xPK-yw-Cep" id="eEo-lj-Zlp"/>
|
||||||
|
</connections>
|
||||||
|
</tableViewController>
|
||||||
|
<placeholder placeholderIdentifier="IBFirstResponder" id="Ztq-io-WSI" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||||
|
</objects>
|
||||||
|
<point key="canvasLocation" x="-834" y="-356"/>
|
||||||
|
</scene>
|
||||||
|
<!--ServiceIdentifier-->
|
||||||
|
<scene sceneID="YUB-k7-E5Y">
|
||||||
|
<objects>
|
||||||
|
<viewControllerPlaceholder storyboardName="Main" referencedIdentifier="ServiceIdentifier" id="pel-Q7-aOe" sceneMemberID="viewController"/>
|
||||||
|
<placeholder placeholderIdentifier="IBFirstResponder" id="fYp-JZ-abh" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||||
|
</objects>
|
||||||
|
<point key="canvasLocation" x="-2815" y="-279"/>
|
||||||
|
</scene>
|
||||||
|
<!--Navigation Controller-->
|
||||||
|
<scene sceneID="ajI-cA-lhi">
|
||||||
|
<objects>
|
||||||
|
<navigationController storyboardIdentifier="WizardHostIdentifier" id="xKb-d1-xzB" sceneMemberID="viewController">
|
||||||
|
<navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="7oY-rT-q4A">
|
||||||
|
<rect key="frame" x="0.0" y="20" width="375" height="44"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
</navigationBar>
|
||||||
|
<connections>
|
||||||
|
<segue destination="oga-go-FqD" kind="relationship" relationship="rootViewController" id="qQl-B5-moM"/>
|
||||||
|
</connections>
|
||||||
|
</navigationController>
|
||||||
|
<placeholder placeholderIdentifier="IBFirstResponder" id="BvG-Pe-O1S" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||||
|
</objects>
|
||||||
|
<point key="canvasLocation" x="-1786" y="-356"/>
|
||||||
|
</scene>
|
||||||
|
<!--Organizer View Controller-->
|
||||||
|
<scene sceneID="H6i-Tl-Gnq">
|
||||||
|
<objects>
|
||||||
|
<tableViewController id="hNf-xP-0pR" customClass="OrganizerViewController" customModule="Passepartout_iOS" customModuleProvider="target" sceneMemberID="viewController">
|
||||||
|
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="grouped" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" id="ZTL-7K-8ld">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
|
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
|
||||||
|
<prototypes>
|
||||||
|
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="SettingTableViewCell" textLabel="mFP-Zm-Yaa" detailTextLabel="NYd-C0-mki" style="IBUITableViewCellStyleValue1" id="VMR-pG-t8h" customClass="SettingTableViewCell" customModule="Passepartout_iOS" customModuleProvider="target">
|
||||||
|
<rect key="frame" x="0.0" y="55.5" width="375" height="44"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="VMR-pG-t8h" id="yQx-3t-6fR">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
<subviews>
|
||||||
|
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="mFP-Zm-Yaa">
|
||||||
|
<rect key="frame" x="16" y="12" width="33.5" height="20.5"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||||
|
<nil key="textColor"/>
|
||||||
|
<nil key="highlightedColor"/>
|
||||||
|
</label>
|
||||||
|
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Detail" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="NYd-C0-mki">
|
||||||
|
<rect key="frame" x="315" y="12" width="44" height="20.5"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||||
|
<nil key="textColor"/>
|
||||||
|
<nil key="highlightedColor"/>
|
||||||
|
</label>
|
||||||
|
</subviews>
|
||||||
|
</tableViewCellContentView>
|
||||||
|
<connections>
|
||||||
|
<segue destination="pel-Q7-aOe" kind="showDetail" identifier="SelectProfileSegueIdentifier" id="wW2-CO-Y42"/>
|
||||||
|
</connections>
|
||||||
|
</tableViewCell>
|
||||||
|
</prototypes>
|
||||||
|
<connections>
|
||||||
|
<outlet property="dataSource" destination="hNf-xP-0pR" id="GDb-KD-vxs"/>
|
||||||
|
<outlet property="delegate" destination="hNf-xP-0pR" id="0qi-6Z-40E"/>
|
||||||
|
</connections>
|
||||||
|
</tableView>
|
||||||
|
<navigationItem key="navigationItem" id="Unq-7n-HX6"/>
|
||||||
|
<connections>
|
||||||
|
<segue destination="NVA-bQ-iIE" kind="presentation" identifier="AddProviderSegueIdentifier" modalPresentationStyle="formSheet" id="Win-5U-mIc"/>
|
||||||
|
<segue destination="a3d-vD-Pr7" kind="presentation" identifier="AboutSegueIdentifier" id="fd4-we-46n"/>
|
||||||
|
</connections>
|
||||||
|
</tableViewController>
|
||||||
|
<placeholder placeholderIdentifier="IBFirstResponder" id="bGp-H5-24W" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||||
|
</objects>
|
||||||
|
<point key="canvasLocation" x="-2814" y="-815"/>
|
||||||
|
</scene>
|
||||||
|
<!--Navigation Controller-->
|
||||||
|
<scene sceneID="tnh-I2-7NH">
|
||||||
|
<objects>
|
||||||
|
<navigationController id="Sge-vR-hZB" sceneMemberID="viewController">
|
||||||
|
<navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" largeTitles="YES" id="hGv-XV-ZJ4">
|
||||||
|
<rect key="frame" x="0.0" y="20" width="375" height="96"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
</navigationBar>
|
||||||
|
<connections>
|
||||||
|
<segue destination="hNf-xP-0pR" kind="relationship" relationship="rootViewController" id="RCs-ya-Cmp"/>
|
||||||
|
</connections>
|
||||||
|
</navigationController>
|
||||||
|
<placeholder placeholderIdentifier="IBFirstResponder" id="z9U-fd-OOM" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||||
|
</objects>
|
||||||
|
<point key="canvasLocation" x="-3756" y="-815"/>
|
||||||
|
</scene>
|
||||||
|
<!--Version View Controller-->
|
||||||
|
<scene sceneID="dbE-eJ-wli">
|
||||||
|
<objects>
|
||||||
|
<viewController id="PMT-gj-ARE" customClass="VersionViewController" customModule="Passepartout_iOS" customModuleProvider="target" sceneMemberID="viewController">
|
||||||
|
<view key="view" contentMode="scaleToFill" id="UOK-GX-kRH">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
|
<subviews>
|
||||||
|
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="olL-k1-XZi">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||||
|
<subviews>
|
||||||
|
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Kan-Ro-DbI">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="375" height="448"/>
|
||||||
|
<subviews>
|
||||||
|
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="RP1-au-v0h">
|
||||||
|
<rect key="frame" x="28" y="40" width="319" height="368"/>
|
||||||
|
<subviews>
|
||||||
|
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="logo" translatesAutoresizingMaskIntoConstraints="NO" id="eRj-AM-Edq">
|
||||||
|
<rect key="frame" x="59.5" y="0.0" width="200" height="200"/>
|
||||||
|
</imageView>
|
||||||
|
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="<title>" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Zek-qD-saW">
|
||||||
|
<rect key="frame" x="0.0" y="220" width="319" height="29"/>
|
||||||
|
<fontDescription key="fontDescription" type="boldSystem" pointSize="24"/>
|
||||||
|
<nil key="textColor"/>
|
||||||
|
<nil key="highlightedColor"/>
|
||||||
|
</label>
|
||||||
|
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="<version>" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="tOJ-Gb-6TL">
|
||||||
|
<rect key="frame" x="0.0" y="254" width="319" height="20.5"/>
|
||||||
|
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||||
|
<nil key="textColor"/>
|
||||||
|
<nil key="highlightedColor"/>
|
||||||
|
</label>
|
||||||
|
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="<intro>" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="F6g-5X-yGY">
|
||||||
|
<rect key="frame" x="0.0" y="294.5" width="319" height="20.5"/>
|
||||||
|
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||||
|
<nil key="textColor"/>
|
||||||
|
<nil key="highlightedColor"/>
|
||||||
|
</label>
|
||||||
|
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="wV2-Nx-RuF">
|
||||||
|
<rect key="frame" x="0.0" y="335" width="319" height="33"/>
|
||||||
|
<fontDescription key="fontDescription" type="boldSystem" pointSize="17"/>
|
||||||
|
<state key="normal" title="<CL>"/>
|
||||||
|
<connections>
|
||||||
|
<action selector="visitChangelog" destination="PMT-gj-ARE" eventType="touchUpInside" id="hSv-6o-eXI"/>
|
||||||
|
</connections>
|
||||||
|
</button>
|
||||||
|
</subviews>
|
||||||
|
<constraints>
|
||||||
|
<constraint firstAttribute="trailing" secondItem="wV2-Nx-RuF" secondAttribute="trailing" id="1jj-cq-2Ja"/>
|
||||||
|
<constraint firstItem="eRj-AM-Edq" firstAttribute="centerX" secondItem="RP1-au-v0h" secondAttribute="centerX" id="39V-6k-m1r"/>
|
||||||
|
<constraint firstAttribute="trailing" secondItem="F6g-5X-yGY" secondAttribute="trailing" id="4NF-Ha-rCB"/>
|
||||||
|
<constraint firstItem="Zek-qD-saW" firstAttribute="leading" secondItem="RP1-au-v0h" secondAttribute="leading" id="4r5-es-LKj"/>
|
||||||
|
<constraint firstItem="tOJ-Gb-6TL" firstAttribute="top" secondItem="Zek-qD-saW" secondAttribute="bottom" constant="5" id="5EV-6h-af6"/>
|
||||||
|
<constraint firstItem="F6g-5X-yGY" firstAttribute="leading" secondItem="RP1-au-v0h" secondAttribute="leading" id="Bbh-jl-eyk"/>
|
||||||
|
<constraint firstItem="Zek-qD-saW" firstAttribute="top" secondItem="eRj-AM-Edq" secondAttribute="bottom" constant="20" id="E5v-Gd-4FH"/>
|
||||||
|
<constraint firstItem="wV2-Nx-RuF" firstAttribute="leading" secondItem="RP1-au-v0h" secondAttribute="leading" id="Iop-zX-3fL"/>
|
||||||
|
<constraint firstItem="F6g-5X-yGY" firstAttribute="top" secondItem="tOJ-Gb-6TL" secondAttribute="bottom" constant="20" id="Vla-uy-lL8"/>
|
||||||
|
<constraint firstAttribute="trailing" secondItem="Zek-qD-saW" secondAttribute="trailing" id="WL1-SB-5gf"/>
|
||||||
|
<constraint firstAttribute="trailing" secondItem="tOJ-Gb-6TL" secondAttribute="trailing" id="a5o-c7-BD5"/>
|
||||||
|
<constraint firstItem="tOJ-Gb-6TL" firstAttribute="leading" secondItem="RP1-au-v0h" secondAttribute="leading" id="grT-YM-rGi"/>
|
||||||
|
<constraint firstAttribute="bottom" secondItem="wV2-Nx-RuF" secondAttribute="bottom" id="m4p-a0-sqe"/>
|
||||||
|
<constraint firstItem="eRj-AM-Edq" firstAttribute="top" secondItem="RP1-au-v0h" secondAttribute="top" id="q35-KT-uTl"/>
|
||||||
|
<constraint firstItem="wV2-Nx-RuF" firstAttribute="top" secondItem="F6g-5X-yGY" secondAttribute="bottom" constant="20" id="y5I-Du-MiY"/>
|
||||||
|
</constraints>
|
||||||
|
</view>
|
||||||
|
</subviews>
|
||||||
|
<constraints>
|
||||||
|
<constraint firstAttribute="bottom" secondItem="RP1-au-v0h" secondAttribute="bottom" constant="40" id="1nJ-q3-71e"/>
|
||||||
|
<constraint firstItem="RP1-au-v0h" firstAttribute="top" secondItem="Kan-Ro-DbI" secondAttribute="top" constant="40" id="JpQ-Sm-6E9"/>
|
||||||
|
<constraint firstItem="RP1-au-v0h" firstAttribute="leading" secondItem="Kan-Ro-DbI" secondAttribute="leadingMargin" constant="20" id="QVw-kf-Ruk"/>
|
||||||
|
<constraint firstAttribute="trailingMargin" secondItem="RP1-au-v0h" secondAttribute="trailing" constant="20" id="uOx-j1-ncW"/>
|
||||||
|
</constraints>
|
||||||
|
</view>
|
||||||
|
</subviews>
|
||||||
|
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||||
|
<constraints>
|
||||||
|
<constraint firstAttribute="trailing" secondItem="Kan-Ro-DbI" secondAttribute="trailing" id="Ce5-DN-GeK"/>
|
||||||
|
<constraint firstItem="Kan-Ro-DbI" firstAttribute="top" secondItem="olL-k1-XZi" secondAttribute="top" id="Smc-j7-mlw"/>
|
||||||
|
<constraint firstItem="Kan-Ro-DbI" firstAttribute="leading" secondItem="olL-k1-XZi" secondAttribute="leading" id="exE-qj-8Z3"/>
|
||||||
|
<constraint firstItem="Kan-Ro-DbI" firstAttribute="width" secondItem="olL-k1-XZi" secondAttribute="width" id="fTu-x9-FVW"/>
|
||||||
|
<constraint firstAttribute="bottom" secondItem="Kan-Ro-DbI" secondAttribute="bottom" id="hd1-bh-hFF"/>
|
||||||
|
</constraints>
|
||||||
|
</scrollView>
|
||||||
|
</subviews>
|
||||||
|
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||||
|
<constraints>
|
||||||
|
<constraint firstItem="olL-k1-XZi" firstAttribute="leading" secondItem="UOK-GX-kRH" secondAttribute="leading" id="8cy-xd-xvK"/>
|
||||||
|
<constraint firstAttribute="trailing" secondItem="olL-k1-XZi" secondAttribute="trailing" id="WuP-mp-YXX"/>
|
||||||
|
<constraint firstAttribute="bottom" secondItem="olL-k1-XZi" secondAttribute="bottom" id="bYU-ed-Scg"/>
|
||||||
|
<constraint firstItem="olL-k1-XZi" firstAttribute="top" secondItem="UOK-GX-kRH" secondAttribute="top" id="hYG-bS-MUP"/>
|
||||||
|
</constraints>
|
||||||
|
<viewLayoutGuide key="safeArea" id="1um-xX-wxp"/>
|
||||||
|
</view>
|
||||||
|
<connections>
|
||||||
|
<outlet property="buttonChangelog" destination="wV2-Nx-RuF" id="E0X-ek-Ii2"/>
|
||||||
|
<outlet property="labelIntro" destination="F6g-5X-yGY" id="QSg-VO-Wf4"/>
|
||||||
|
<outlet property="labelTitle" destination="Zek-qD-saW" id="TL8-Vb-B58"/>
|
||||||
|
<outlet property="labelVersion" destination="tOJ-Gb-6TL" id="O7w-Ne-L0R"/>
|
||||||
|
<outlet property="scrollView" destination="olL-k1-XZi" id="4f7-Kw-k8j"/>
|
||||||
|
</connections>
|
||||||
|
</viewController>
|
||||||
|
<placeholder placeholderIdentifier="IBFirstResponder" id="n7m-Yv-Puo" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||||
|
</objects>
|
||||||
|
<point key="canvasLocation" x="-2551.1999999999998" y="-2224.1379310344828"/>
|
||||||
|
</scene>
|
||||||
|
<!--Navigation Controller-->
|
||||||
|
<scene sceneID="bMd-7b-j9C">
|
||||||
|
<objects>
|
||||||
|
<navigationController id="a3d-vD-Pr7" sceneMemberID="viewController">
|
||||||
|
<navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="wkf-Oy-qON">
|
||||||
|
<rect key="frame" x="0.0" y="20" width="375" height="44"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
</navigationBar>
|
||||||
|
<connections>
|
||||||
|
<segue destination="SuC-Dh-OPk" kind="relationship" relationship="rootViewController" id="YUY-JD-4Od"/>
|
||||||
|
</connections>
|
||||||
|
</navigationController>
|
||||||
|
<placeholder placeholderIdentifier="IBFirstResponder" id="1Hw-2N-MEB" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||||
|
</objects>
|
||||||
|
<point key="canvasLocation" x="-4396" y="-1784"/>
|
||||||
|
</scene>
|
||||||
|
<!--About View Controller-->
|
||||||
|
<scene sceneID="jWz-41-sji">
|
||||||
|
<objects>
|
||||||
|
<tableViewController id="SuC-Dh-OPk" customClass="AboutViewController" customModule="Passepartout_iOS" customModuleProvider="target" sceneMemberID="viewController">
|
||||||
|
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="grouped" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" id="m0n-o6-NhG">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
|
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
|
||||||
|
<prototypes>
|
||||||
|
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="SettingTableViewCell" textLabel="skM-jg-ICe" detailTextLabel="iON-s3-zdv" style="IBUITableViewCellStyleValue1" id="Ur6-zm-9xA" customClass="SettingTableViewCell" customModule="Passepartout_iOS" customModuleProvider="target">
|
||||||
|
<rect key="frame" x="0.0" y="55.5" width="375" height="44"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="Ur6-zm-9xA" id="k8G-g0-As7">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
<subviews>
|
||||||
|
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="skM-jg-ICe">
|
||||||
|
<rect key="frame" x="16" y="12" width="33.5" height="20.5"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||||
|
<nil key="textColor"/>
|
||||||
|
<nil key="highlightedColor"/>
|
||||||
|
</label>
|
||||||
|
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Detail" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="iON-s3-zdv">
|
||||||
|
<rect key="frame" x="315" y="12" width="44" height="20.5"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||||
|
<nil key="textColor"/>
|
||||||
|
<nil key="highlightedColor"/>
|
||||||
|
</label>
|
||||||
|
</subviews>
|
||||||
|
</tableViewCellContentView>
|
||||||
|
</tableViewCell>
|
||||||
|
</prototypes>
|
||||||
|
<connections>
|
||||||
|
<outlet property="dataSource" destination="SuC-Dh-OPk" id="kBQ-4F-rCf"/>
|
||||||
|
<outlet property="delegate" destination="SuC-Dh-OPk" id="QsS-f8-F7k"/>
|
||||||
|
</connections>
|
||||||
|
</tableView>
|
||||||
|
<navigationItem key="navigationItem" id="SOR-2l-C78">
|
||||||
|
<barButtonItem key="leftBarButtonItem" systemItem="stop" id="SJM-bE-0QY">
|
||||||
|
<connections>
|
||||||
|
<action selector="dismiss" destination="SuC-Dh-OPk" id="F1n-Mk-Njo"/>
|
||||||
|
</connections>
|
||||||
|
</barButtonItem>
|
||||||
|
</navigationItem>
|
||||||
|
<connections>
|
||||||
|
<segue destination="2d7-Ad-AZr" kind="show" identifier="CreditsSegueIdentifier" id="tGv-dr-20P"/>
|
||||||
|
<segue destination="PMT-gj-ARE" kind="show" identifier="VersionSegueIdentifier" id="uYt-4N-PPL"/>
|
||||||
|
</connections>
|
||||||
|
</tableViewController>
|
||||||
|
<placeholder placeholderIdentifier="IBFirstResponder" id="AnH-Vt-JJn" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||||
|
</objects>
|
||||||
|
<point key="canvasLocation" x="-3558" y="-1784"/>
|
||||||
|
</scene>
|
||||||
|
<!--Credits View Controller-->
|
||||||
|
<scene sceneID="1v7-O6-Ddh">
|
||||||
|
<objects>
|
||||||
|
<viewController id="2d7-Ad-AZr" customClass="CreditsViewController" customModule="Passepartout_iOS" customModuleProvider="target" sceneMemberID="viewController">
|
||||||
|
<view key="view" contentMode="scaleToFill" id="e1G-CS-7AH">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
|
<subviews>
|
||||||
|
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="6iI-GI-SMq">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||||
|
<subviews>
|
||||||
|
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Qme-Hw-Egq">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="375" height="78"/>
|
||||||
|
<subviews>
|
||||||
|
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="UkA-Yl-a47">
|
||||||
|
<rect key="frame" x="23" y="30" width="329" height="18"/>
|
||||||
|
<subviews>
|
||||||
|
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="<third_parties>" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="KWp-cG-SuG">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="329" height="18"/>
|
||||||
|
<fontDescription key="fontDescription" type="system" pointSize="15"/>
|
||||||
|
<nil key="textColor"/>
|
||||||
|
<nil key="highlightedColor"/>
|
||||||
|
</label>
|
||||||
|
</subviews>
|
||||||
|
<constraints>
|
||||||
|
<constraint firstItem="KWp-cG-SuG" firstAttribute="leading" secondItem="UkA-Yl-a47" secondAttribute="leading" id="Ail-Dw-eRH"/>
|
||||||
|
<constraint firstAttribute="bottom" secondItem="KWp-cG-SuG" secondAttribute="bottom" id="PUx-et-0i2"/>
|
||||||
|
<constraint firstAttribute="trailing" secondItem="KWp-cG-SuG" secondAttribute="trailing" id="c5g-Os-X0q"/>
|
||||||
|
<constraint firstItem="KWp-cG-SuG" firstAttribute="top" secondItem="UkA-Yl-a47" secondAttribute="top" id="i8Q-LU-n9f"/>
|
||||||
|
</constraints>
|
||||||
|
</view>
|
||||||
|
</subviews>
|
||||||
|
<constraints>
|
||||||
|
<constraint firstItem="UkA-Yl-a47" firstAttribute="top" secondItem="Qme-Hw-Egq" secondAttribute="top" constant="30" id="1SG-jG-FaL"/>
|
||||||
|
<constraint firstItem="UkA-Yl-a47" firstAttribute="leading" secondItem="Qme-Hw-Egq" secondAttribute="leadingMargin" constant="15" id="94s-Tx-w6b"/>
|
||||||
|
<constraint firstAttribute="bottom" secondItem="UkA-Yl-a47" secondAttribute="bottom" constant="30" id="fTE-5j-vZb"/>
|
||||||
|
<constraint firstAttribute="trailingMargin" secondItem="UkA-Yl-a47" secondAttribute="trailing" constant="15" id="v1z-AF-PXL"/>
|
||||||
|
</constraints>
|
||||||
|
</view>
|
||||||
|
</subviews>
|
||||||
|
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||||
|
<constraints>
|
||||||
|
<constraint firstItem="Qme-Hw-Egq" firstAttribute="leading" secondItem="6iI-GI-SMq" secondAttribute="leading" id="8sL-sx-VDd"/>
|
||||||
|
<constraint firstAttribute="trailing" secondItem="Qme-Hw-Egq" secondAttribute="trailing" id="D6C-fc-tRa"/>
|
||||||
|
<constraint firstItem="Qme-Hw-Egq" firstAttribute="top" secondItem="6iI-GI-SMq" secondAttribute="top" id="hqt-PH-Y32"/>
|
||||||
|
<constraint firstAttribute="bottom" secondItem="Qme-Hw-Egq" secondAttribute="bottom" id="pv4-CI-T9m"/>
|
||||||
|
<constraint firstItem="Qme-Hw-Egq" firstAttribute="width" secondItem="6iI-GI-SMq" secondAttribute="width" id="urL-Uu-OBn"/>
|
||||||
|
</constraints>
|
||||||
|
</scrollView>
|
||||||
|
</subviews>
|
||||||
|
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||||
|
<constraints>
|
||||||
|
<constraint firstAttribute="bottom" secondItem="6iI-GI-SMq" secondAttribute="bottom" id="O7t-Z4-Wgz"/>
|
||||||
|
<constraint firstItem="6iI-GI-SMq" firstAttribute="top" secondItem="e1G-CS-7AH" secondAttribute="top" id="moK-Ck-mjj"/>
|
||||||
|
<constraint firstItem="6iI-GI-SMq" firstAttribute="leading" secondItem="e1G-CS-7AH" secondAttribute="leading" id="rLL-Mv-Pet"/>
|
||||||
|
<constraint firstAttribute="trailing" secondItem="6iI-GI-SMq" secondAttribute="trailing" id="smW-RU-D8F"/>
|
||||||
|
</constraints>
|
||||||
|
<viewLayoutGuide key="safeArea" id="skL-cM-vUB"/>
|
||||||
|
</view>
|
||||||
|
<connections>
|
||||||
|
<outlet property="labelThirdParties" destination="KWp-cG-SuG" id="Q8g-Wp-C1j"/>
|
||||||
|
<outlet property="scrollView" destination="6iI-GI-SMq" id="uWc-do-1WG"/>
|
||||||
|
</connections>
|
||||||
|
</viewController>
|
||||||
|
<placeholder placeholderIdentifier="IBFirstResponder" id="Urb-bq-a19" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||||
|
</objects>
|
||||||
|
<point key="canvasLocation" x="-2551" y="-1537"/>
|
||||||
|
</scene>
|
||||||
|
</scenes>
|
||||||
|
<resources>
|
||||||
|
<image name="logo" width="200" height="200"/>
|
||||||
|
</resources>
|
||||||
|
</document>
|
|
@ -0,0 +1,115 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Scheme
|
||||||
|
LastUpgradeVersion = "1000"
|
||||||
|
version = "1.3">
|
||||||
|
<BuildAction
|
||||||
|
parallelizeBuildables = "YES"
|
||||||
|
buildImplicitDependencies = "YES">
|
||||||
|
<BuildActionEntries>
|
||||||
|
<BuildActionEntry
|
||||||
|
buildForTesting = "YES"
|
||||||
|
buildForRunning = "YES"
|
||||||
|
buildForProfiling = "YES"
|
||||||
|
buildForArchiving = "YES"
|
||||||
|
buildForAnalyzing = "YES">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "0E57F63720C83FC5008323CF"
|
||||||
|
BuildableName = "Passepartout-iOS.app"
|
||||||
|
BlueprintName = "Passepartout-iOS"
|
||||||
|
ReferencedContainer = "container:Passepartout.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildActionEntry>
|
||||||
|
<BuildActionEntry
|
||||||
|
buildForTesting = "YES"
|
||||||
|
buildForRunning = "YES"
|
||||||
|
buildForProfiling = "YES"
|
||||||
|
buildForArchiving = "YES"
|
||||||
|
buildForAnalyzing = "YES">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "0EDE8DBE20C86910004C739C"
|
||||||
|
BuildableName = "Passepartout-iOS-Tunnel.appex"
|
||||||
|
BlueprintName = "Passepartout-iOS-Tunnel"
|
||||||
|
ReferencedContainer = "container:Passepartout.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildActionEntry>
|
||||||
|
</BuildActionEntries>
|
||||||
|
</BuildAction>
|
||||||
|
<TestAction
|
||||||
|
buildConfiguration = "Debug"
|
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||||
|
<Testables>
|
||||||
|
<TestableReference
|
||||||
|
skipped = "NO">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "0E57F64B20C83FC7008323CF"
|
||||||
|
BuildableName = "PassepartoutTests-iOS.xctest"
|
||||||
|
BlueprintName = "PassepartoutTests-iOS"
|
||||||
|
ReferencedContainer = "container:Passepartout.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</TestableReference>
|
||||||
|
</Testables>
|
||||||
|
<MacroExpansion>
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "0E57F63720C83FC5008323CF"
|
||||||
|
BuildableName = "Passepartout-iOS.app"
|
||||||
|
BlueprintName = "Passepartout-iOS"
|
||||||
|
ReferencedContainer = "container:Passepartout.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</MacroExpansion>
|
||||||
|
<AdditionalOptions>
|
||||||
|
</AdditionalOptions>
|
||||||
|
</TestAction>
|
||||||
|
<LaunchAction
|
||||||
|
buildConfiguration = "Debug"
|
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
launchStyle = "0"
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
ignoresPersistentStateOnLaunch = "NO"
|
||||||
|
debugDocumentVersioning = "YES"
|
||||||
|
debugServiceExtension = "internal"
|
||||||
|
allowLocationSimulation = "YES">
|
||||||
|
<BuildableProductRunnable
|
||||||
|
runnableDebuggingMode = "0">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "0E57F63720C83FC5008323CF"
|
||||||
|
BuildableName = "Passepartout-iOS.app"
|
||||||
|
BlueprintName = "Passepartout-iOS"
|
||||||
|
ReferencedContainer = "container:Passepartout.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildableProductRunnable>
|
||||||
|
<AdditionalOptions>
|
||||||
|
</AdditionalOptions>
|
||||||
|
</LaunchAction>
|
||||||
|
<ProfileAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||||
|
savedToolIdentifier = ""
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
debugDocumentVersioning = "YES">
|
||||||
|
<BuildableProductRunnable
|
||||||
|
runnableDebuggingMode = "0">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "0E57F63720C83FC5008323CF"
|
||||||
|
BuildableName = "Passepartout-iOS.app"
|
||||||
|
BlueprintName = "Passepartout-iOS"
|
||||||
|
ReferencedContainer = "container:Passepartout.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildableProductRunnable>
|
||||||
|
</ProfileAction>
|
||||||
|
<AnalyzeAction
|
||||||
|
buildConfiguration = "Debug">
|
||||||
|
</AnalyzeAction>
|
||||||
|
<ArchiveAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
revealArchiveInOrganizer = "YES">
|
||||||
|
</ArchiveAction>
|
||||||
|
</Scheme>
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Workspace
|
||||||
|
version = "1.0">
|
||||||
|
<FileRef
|
||||||
|
location = "group:Passepartout.xcodeproj">
|
||||||
|
</FileRef>
|
||||||
|
<FileRef
|
||||||
|
location = "group:Pods/Pods.xcodeproj">
|
||||||
|
</FileRef>
|
||||||
|
</Workspace>
|
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>IDEDidComputeMac32BitWarning</key>
|
||||||
|
<true/>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
"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.";
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
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
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
enum ApplicationError: String, Error {
|
||||||
|
case missingProfile
|
||||||
|
|
||||||
|
case missingCredentials
|
||||||
|
|
||||||
|
case providerPool
|
||||||
|
|
||||||
|
case providerPreset
|
||||||
|
|
||||||
|
case hostEndpoints
|
||||||
|
|
||||||
|
case missingCA
|
||||||
|
|
||||||
|
case emptyRemotes
|
||||||
|
|
||||||
|
case unsupportedConfiguration
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
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 ---"
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
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)
|
||||||
|
// }
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
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 }
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
enum TrustPolicy: String, Codable {
|
||||||
|
case ignore
|
||||||
|
|
||||||
|
case disconnect
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
protocol Wizard: class {
|
||||||
|
var delegate: WizardDelegate? { get set }
|
||||||
|
}
|
||||||
|
|
||||||
|
protocol WizardDelegate: class {
|
||||||
|
func wizard(didCreate profile: ConnectionProfile, withCredentials credentials: Credentials)
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
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 }
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
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)\"}"
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
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<T> {
|
||||||
|
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<Infrastructure>?, 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<T: Decodable>(_ type: T.Type, request: URLRequest, completionHandler: @escaping (Response<T>?, 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()
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 {}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
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<ifaddrs>?
|
||||||
|
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<Index>) -> NSRange {
|
||||||
|
return NSRange(range, in: self)
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
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))
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
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..<to])
|
||||||
|
currentBlock = []
|
||||||
|
}
|
||||||
|
Regex.blockEnd.enumerateComponents(in: line) {
|
||||||
|
let tag = $0.first!
|
||||||
|
let from = tag.index(tag.startIndex, offsetBy: 2)
|
||||||
|
let to = tag.index(before: tag.endIndex)
|
||||||
|
|
||||||
|
let blockName = String(tag[from..<to])
|
||||||
|
guard blockName == currentBlockName else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// first is opening tag
|
||||||
|
currentBlock.removeFirst()
|
||||||
|
switch blockName {
|
||||||
|
case "ca":
|
||||||
|
optCA = CryptoContainer(pem: currentBlock.joined(separator: "\n"))
|
||||||
|
|
||||||
|
case "cert":
|
||||||
|
clientCertificate = CryptoContainer(pem: currentBlock.joined(separator: "\n"))
|
||||||
|
|
||||||
|
case "key":
|
||||||
|
clientKey = CryptoContainer(pem: currentBlock.joined(separator: "\n"))
|
||||||
|
|
||||||
|
case "tls-auth":
|
||||||
|
unsupportedError = ApplicationError.unsupportedConfiguration
|
||||||
|
|
||||||
|
case "tls-crypt":
|
||||||
|
unsupportedError = ApplicationError.unsupportedConfiguration
|
||||||
|
|
||||||
|
default:
|
||||||
|
break
|
||||||
|
}
|
||||||
|
currentBlockName = nil
|
||||||
|
currentBlock = []
|
||||||
|
}
|
||||||
|
if let _ = currentBlockName {
|
||||||
|
currentBlock.append(line)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
Regex.proto.enumerateArguments(in: line) {
|
||||||
|
guard let str = $0.first else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defaultProto = TunnelKitProvider.SocketType(protoString: str)
|
||||||
|
}
|
||||||
|
Regex.port.enumerateArguments(in: line) {
|
||||||
|
guard let str = $0.first else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defaultPort = UInt16(str)
|
||||||
|
}
|
||||||
|
Regex.remote.enumerateArguments(in: line) {
|
||||||
|
guard let hostname = $0.first else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var port: UInt16?
|
||||||
|
var proto: TunnelKitProvider.SocketType?
|
||||||
|
if $0.count > 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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
class VPN {
|
||||||
|
#if targetEnvironment(simulator)
|
||||||
|
static let shared = MockVPNProvider()
|
||||||
|
#else
|
||||||
|
static let shared = StandardVPNProvider(bundleIdentifier: GroupConstants.App.tunnelIdentifier)
|
||||||
|
#endif
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import NetworkExtension
|
||||||
|
|
||||||
|
protocol VPNConfiguration {
|
||||||
|
}
|
||||||
|
|
||||||
|
struct NetworkExtensionVPNConfiguration: VPNConfiguration {
|
||||||
|
let protocolConfiguration: NETunnelProviderProtocol
|
||||||
|
|
||||||
|
let onDemandRules: [NEOnDemandRule]
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
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")
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
enum VPNStatus {
|
||||||
|
case connected
|
||||||
|
|
||||||
|
case connecting
|
||||||
|
|
||||||
|
case disconnected
|
||||||
|
|
||||||
|
case disconnecting
|
||||||
|
}
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
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")!
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
|
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
||||||
|
<key>CFBundleExecutable</key>
|
||||||
|
<string>$(EXECUTABLE_NAME)</string>
|
||||||
|
<key>CFBundleIdentifier</key>
|
||||||
|
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||||
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
|
<string>6.0</string>
|
||||||
|
<key>CFBundleName</key>
|
||||||
|
<string>$(PRODUCT_NAME)</string>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>BNDL</string>
|
||||||
|
<key>CFBundleShortVersionString</key>
|
||||||
|
<string>1.0</string>
|
||||||
|
<key>CFBundleVersion</key>
|
||||||
|
<string>1</string>
|
||||||
|
</dict>
|
||||||
|
</plist>
|