├── .github
└── workflows
│ ├── build.yml
│ └── lint.yml
├── CMakeLists.txt
├── LEGAL_ru.md
├── LICENSE.md
├── LICENSE_ru.md
├── LICENSE_th.md
├── README.md
├── android
├── .gitignore
├── .idea
│ ├── .gitignore
│ ├── .name
│ ├── AndroidProjectSystem.xml
│ ├── codeStyles
│ │ ├── Project.xml
│ │ └── codeStyleConfig.xml
│ ├── compiler.xml
│ ├── deploymentTargetSelector.xml
│ ├── gradle.xml
│ ├── kotlinc.xml
│ ├── migrations.xml
│ ├── misc.xml
│ ├── runConfigurations.xml
│ └── vcs.xml
├── app
│ ├── .gitignore
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src
│ │ ├── androidTest
│ │ └── java
│ │ │ └── click
│ │ │ └── vpnclient
│ │ │ └── engine
│ │ │ └── android
│ │ │ └── ExampleInstrumentedTest.kt
│ │ ├── main
│ │ ├── AndroidManifest.xml
│ │ ├── java
│ │ │ └── click
│ │ │ │ └── vpnclient
│ │ │ │ └── engine
│ │ │ │ ├── VPNManager.kt
│ │ │ │ └── service
│ │ │ │ ├── MainActivity.kt
│ │ │ │ ├── VPNService.kt
│ │ │ │ └── ui
│ │ │ │ └── theme
│ │ │ │ ├── Color.kt
│ │ │ │ ├── Theme.kt
│ │ │ │ └── Type.kt
│ │ └── res
│ │ │ ├── drawable-v24
│ │ │ └── ic_launcher_foreground.xml
│ │ │ ├── drawable
│ │ │ └── ic_launcher_background.xml
│ │ │ ├── mipmap-anydpi-v26
│ │ │ ├── ic_launcher.xml
│ │ │ └── ic_launcher_round.xml
│ │ │ ├── mipmap-hdpi
│ │ │ ├── ic_launcher.webp
│ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-mdpi
│ │ │ ├── ic_launcher.webp
│ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-xhdpi
│ │ │ ├── ic_launcher.webp
│ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-xxhdpi
│ │ │ ├── ic_launcher.webp
│ │ │ └── ic_launcher_round.webp
│ │ │ ├── mipmap-xxxhdpi
│ │ │ ├── ic_launcher.webp
│ │ │ └── ic_launcher_round.webp
│ │ │ ├── values
│ │ │ ├── colors.xml
│ │ │ ├── strings.xml
│ │ │ └── themes.xml
│ │ │ └── xml
│ │ │ ├── backup_rules.xml
│ │ │ └── data_extraction_rules.xml
│ │ └── test
│ │ └── java
│ │ └── click
│ │ └── vpnclient
│ │ └── engine
│ │ └── android
│ │ └── ExampleUnitTest.kt
├── build.gradle
├── gradle.properties
├── gradle
│ ├── libs.versions.toml
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
├── include
└── vpnclient_engine.h
├── ios
├── Info.plist
├── PackageTunnelProvider.entitlements
└── PacketTunnelProvider.swift
├── src
├── core
│ └── vpnclient_engine.cpp
├── engines
│ ├── singbox.cpp
│ └── wireguard.cpp
└── proxies
│ └── tun2socks.cpp
├── tests
└── test_vpnclient_engine.cpp
└── vpnclient_engine.mmd
/.github/workflows/build.yml:
--------------------------------------------------------------------------------
1 | name: Android CI
2 |
3 | on:
4 | push:
5 | branches: [ main, develop ]
6 | pull_request:
7 | branches: [ main ]
8 |
9 | jobs:
10 | build:
11 | runs-on: ubuntu-latest
12 |
13 | steps:
14 | - name: Checkout code
15 | uses: actions/checkout@v4
16 |
17 | - name: Set up JDK 17
18 | uses: actions/setup-java@v3
19 | with:
20 | java-version: '17'
21 | distribution: 'temurin'
22 |
23 | - name: Cache Gradle
24 | uses: actions/cache@v3
25 | with:
26 | path: |
27 | ~/.gradle/caches
28 | ~/.gradle/wrapper
29 | key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
30 | restore-keys: |
31 | ${{ runner.os }}-gradle-
32 |
33 | - name: Build with Gradle
34 | run: ./gradlew assembleDebug
35 |
36 | - name: Run unit tests
37 | run: ./gradlew test
38 |
39 | # - name: Run instrumentation tests
40 | # uses: reactivecircus/android-emulator-runner@v2
41 | # with:
42 | # api-level: 33
43 | # script: ./gradlew connectedCheck
44 |
45 |
--------------------------------------------------------------------------------
/.github/workflows/lint.yml:
--------------------------------------------------------------------------------
1 | name: Lint and Code Quality
2 |
3 | on: [push, pull_request]
4 |
5 | jobs:
6 | quality:
7 | runs-on: ubuntu-latest
8 |
9 | steps:
10 | - uses: actions/checkout@v4
11 |
12 | - name: Set up JDK 17
13 | uses: actions/setup-java@v3
14 | with:
15 | java-version: '17'
16 | distribution: 'temurin'
17 |
18 | - name: Run ktlint
19 | run: ./gradlew ktlintCheck
20 |
21 | - name: Run detekt
22 | run: ./gradlew detekt
23 |
24 | - name: Run dependency checks
25 | run: ./gradlew dependencyUpdates
26 |
--------------------------------------------------------------------------------
/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.15)
2 | project(vpnclient_engine)
3 |
4 | set(CMAKE_CXX_STANDARD 17)
5 |
6 | # Подключаем зависимости
7 | find_package(OpenSSL REQUIRED)
8 | find_package(VPNclientXRAY REQUIRED)
9 | find_package(XRay REQUIRED)
10 | find_package(SingBox REQUIRED)
11 | find_package(WireGuard REQUIRED)
12 |
13 | # Основная библиотека
14 | add_library(vpnclient_engine STATIC
15 | src/core/vpnclient_engine.cpp
16 | src/engines/wireguard_engine.cpp
17 | src/engines/singbox_engine.cpp
18 | src/engines/xray_engine.cpp
19 | src/proxies/tun2socks.cpp
20 | src/proxies/hev_socks5.cpp
21 | src/proxies/approxy.cpp
22 | )
23 |
24 | target_include_directories(vpnclient_engine PUBLIC include)
25 | target_link_libraries(vpnclient_engine
26 | OpenSSL::SSL
27 | VPNclientXRAY::VPNclientXRAY
28 | XRay::XRay
29 | SingBox::SingBox
30 | WireGuard::WireGuard
31 | )
32 |
33 |
34 | # Пример
35 | add_executable(test_vpnclient_engine tests/test_vpnclient_engine.cpp)
36 | target_link_libraries(test_vpnclient_engine vpnclient_engine)
37 |
--------------------------------------------------------------------------------
/LEGAL_ru.md:
--------------------------------------------------------------------------------
1 | # Юридическое уведомление
2 |
3 | Программное обеспечение VPNclient представляется исключительно в целях улучшения пользовательского опыта при работе с зарубежными интернет-магистралями и обеспечения стабильного доступа к международным ресурсам а так же доступ к локальным ресурсам из зарубежа.
4 |
5 | **Запрещается использование VPNclient в следующих целях:**
6 | - Обход установленных законодательством Российской Федерации блокировок сайтов, ресурсов или сервисов.
7 | - Получение доступа к ресурсам, запрещенным или ограниченным в соответствии с законодательством Российской Федерации.
8 | - Осуществление иной противоправной деятельности, предусмотренной законодательством Российской Федерации и международным правом.
9 |
10 | Пользователи и компании, использующие программное обеспечение VPNclient, несут личную и корпоративную ответственность за любое неправомерное использование данного программного продукта. Разработчики програмного продукта не несут ответственности за действия пользователей и компаний, совершённые с использованием продукта, которые нарушают законодательство Российской Федерации и других стран.
11 |
12 | Используя программное обеспечение VPNclient, пользователь подтверждает, что полностью ознакомлен с данным юридическим уведомлением и обязуется использовать продукт исключительно в рамках действующего законодательства.
13 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | # VPNсlient Extended GNU General Public License v3 (GPL v3)
2 |
3 | The VPNсlient project is licensed under GPL v3, with the following additional conditions in accordance with GPL v3 Section 7. Failure to comply with these terms may result in requests to app stores to remove or restrict access to your app.
4 |
5 | ## Additional Conditions to GPL v3:
6 |
7 | 1. **Copyright Notice: VPNclient License**
8 | Copyright (c) 2010-2025 NativeMind Inc. All rights reserved.
9 | "VPNclient" is a trademark of NativeMind Inc.
10 |
11 | 2. **Open Source Software Bundling Notice**
12 | The VPNclient is bundled with other open source software components, some of which fall under different licenses. By using VPNclient or any of the bundled components, you agree to be bound by the conditions of the license for each respective component. A copy of the LICENSE is also distributed in the file LICENSE.md.
13 |
14 | 3. **Source Code Availability**
15 | If you use any part of this code, you must publish your source code on GitHub as a fork of the VPNclient repository and keep it up-to-date with any published app releases. Your repository should visibly indicate that it is a fork of [https://github.com/VPNclient](https://github.com/VPNclient).
16 |
17 | 4. **Automated Release**
18 | All releases must be made using GitHub Actions.
19 |
20 | 5. **Attribution**
21 | You must give appropriate credit to VPNclient , link to [https://github.com/VPNclient](https://github.com/VPNclient), link to the original license, and document any changes you have made in your repository’s README.
22 |
23 | 6. **No Malware**
24 | Adding any malware or malicious code to the app is strictly prohibited.
25 |
26 | 7. **Naming and Interface Restrictions**
27 | You are not permitted to publish the app on any app store (e.g., AppStore, Google Play, F-Droid, Microsoft) with a name or user interface that closely resembles VPNclient (e.g., names like VPNclient or similar UI are prohibited).
28 |
29 | 8. **NonCommercial Use Only**
30 | You may not use this material for commercial purposes, including selling and advertising, without prior written consent.
31 |
32 | 9. **ShareAlike Requirement**
33 | If you remix, transform, or build upon the material, you must distribute your contributions under this same license as an open-source fork of [https://github.com/VPNclient](https://github.com/VPNclient).
34 |
35 | GNU General Public License
36 | ==========================
37 |
38 | _Version 3, 29 June 2007_
39 | _Copyright © 2007 Free Software Foundation, Inc. <>_
40 |
41 | Everyone is permitted to copy and distribute verbatim copies of this license
42 | document, but changing it is not allowed.
43 |
44 | ## Preamble
45 |
46 | The GNU General Public License is a free, copyleft license for software and other
47 | kinds of works.
48 |
49 | The licenses for most software and other practical works are designed to take away
50 | your freedom to share and change the works. By contrast, the GNU General Public
51 | License is intended to guarantee your freedom to share and change all versions of a
52 | program--to make sure it remains free software for all its users. We, the Free
53 | Software Foundation, use the GNU General Public License for most of our software; it
54 | applies also to any other work released this way by its authors. You can apply it to
55 | your programs, too.
56 |
57 | When we speak of free software, we are referring to freedom, not price. Our General
58 | Public Licenses are designed to make sure that you have the freedom to distribute
59 | copies of free software (and charge for them if you wish), that you receive source
60 | code or can get it if you want it, that you can change the software or use pieces of
61 | it in new free programs, and that you know you can do these things.
62 |
63 | To protect your rights, we need to prevent others from denying you these rights or
64 | asking you to surrender the rights. Therefore, you have certain responsibilities if
65 | you distribute copies of the software, or if you modify it: responsibilities to
66 | respect the freedom of others.
67 |
68 | For example, if you distribute copies of such a program, whether gratis or for a fee,
69 | you must pass on to the recipients the same freedoms that you received. You must make
70 | sure that they, too, receive or can get the source code. And you must show them these
71 | terms so they know their rights.
72 |
73 | Developers that use the GNU GPL protect your rights with two steps: **(1)** assert
74 | copyright on the software, and **(2)** offer you this License giving you legal permission
75 | to copy, distribute and/or modify it.
76 |
77 | For the developers' and authors' protection, the GPL clearly explains that there is
78 | no warranty for this free software. For both users' and authors' sake, the GPL
79 | requires that modified versions be marked as changed, so that their problems will not
80 | be attributed erroneously to authors of previous versions.
81 |
82 | Some devices are designed to deny users access to install or run modified versions of
83 | the software inside them, although the manufacturer can do so. This is fundamentally
84 | incompatible with the aim of protecting users' freedom to change the software. The
85 | systematic pattern of such abuse occurs in the area of products for individuals to
86 | use, which is precisely where it is most unacceptable. Therefore, we have designed
87 | this version of the GPL to prohibit the practice for those products. If such problems
88 | arise substantially in other domains, we stand ready to extend this provision to
89 | those domains in future versions of the GPL, as needed to protect the freedom of
90 | users.
91 |
92 | Finally, every program is threatened constantly by software patents. States should
93 | not allow patents to restrict development and use of software on general-purpose
94 | computers, but in those that do, we wish to avoid the special danger that patents
95 | applied to a free program could make it effectively proprietary. To prevent this, the
96 | GPL assures that patents cannot be used to render the program non-free.
97 |
98 | The precise terms and conditions for copying, distribution and modification follow.
99 |
100 | ## TERMS AND CONDITIONS
101 |
102 | ### 0. Definitions
103 |
104 | “This License” refers to version 3 of the GNU General Public License.
105 |
106 | “Copyright” also means copyright-like laws that apply to other kinds of
107 | works, such as semiconductor masks.
108 |
109 | “The Program” refers to any copyrightable work licensed under this
110 | License. Each licensee is addressed as “you”. “Licensees” and
111 | “recipients” may be individuals or organizations.
112 |
113 | To “modify” a work means to copy from or adapt all or part of the work in
114 | a fashion requiring copyright permission, other than the making of an exact copy. The
115 | resulting work is called a “modified version” of the earlier work or a
116 | work “based on” the earlier work.
117 |
118 | A “covered work” means either the unmodified Program or a work based on
119 | the Program.
120 |
121 | To “propagate” a work means to do anything with it that, without
122 | permission, would make you directly or secondarily liable for infringement under
123 | applicable copyright law, except executing it on a computer or modifying a private
124 | copy. Propagation includes copying, distribution (with or without modification),
125 | making available to the public, and in some countries other activities as well.
126 |
127 | To “convey” a work means any kind of propagation that enables other
128 | parties to make or receive copies. Mere interaction with a user through a computer
129 | network, with no transfer of a copy, is not conveying.
130 |
131 | An interactive user interface displays “Appropriate Legal Notices” to the
132 | extent that it includes a convenient and prominently visible feature that **(1)**
133 | displays an appropriate copyright notice, and **(2)** tells the user that there is no
134 | warranty for the work (except to the extent that warranties are provided), that
135 | licensees may convey the work under this License, and how to view a copy of this
136 | License. If the interface presents a list of user commands or options, such as a
137 | menu, a prominent item in the list meets this criterion.
138 |
139 | ### 1. Source Code
140 |
141 | The “source code” for a work means the preferred form of the work for
142 | making modifications to it. “Object code” means any non-source form of a
143 | work.
144 |
145 | A “Standard Interface” means an interface that either is an official
146 | standard defined by a recognized standards body, or, in the case of interfaces
147 | specified for a particular programming language, one that is widely used among
148 | developers working in that language.
149 |
150 | The “System Libraries” of an executable work include anything, other than
151 | the work as a whole, that **(a)** is included in the normal form of packaging a Major
152 | Component, but which is not part of that Major Component, and **(b)** serves only to
153 | enable use of the work with that Major Component, or to implement a Standard
154 | Interface for which an implementation is available to the public in source code form.
155 | A “Major Component”, in this context, means a major essential component
156 | (kernel, window system, and so on) of the specific operating system (if any) on which
157 | the executable work runs, or a compiler used to produce the work, or an object code
158 | interpreter used to run it.
159 |
160 | The “Corresponding Source” for a work in object code form means all the
161 | source code needed to generate, install, and (for an executable work) run the object
162 | code and to modify the work, including scripts to control those activities. However,
163 | it does not include the work's System Libraries, or general-purpose tools or
164 | generally available free programs which are used unmodified in performing those
165 | activities but which are not part of the work. For example, Corresponding Source
166 | includes interface definition files associated with source files for the work, and
167 | the source code for shared libraries and dynamically linked subprograms that the work
168 | is specifically designed to require, such as by intimate data communication or
169 | control flow between those subprograms and other parts of the work.
170 |
171 | The Corresponding Source need not include anything that users can regenerate
172 | automatically from other parts of the Corresponding Source.
173 |
174 | The Corresponding Source for a work in source code form is that same work.
175 |
176 | ### 2. Basic Permissions
177 |
178 | All rights granted under this License are granted for the term of copyright on the
179 | Program, and are irrevocable provided the stated conditions are met. This License
180 | explicitly affirms your unlimited permission to run the unmodified Program. The
181 | output from running a covered work is covered by this License only if the output,
182 | given its content, constitutes a covered work. This License acknowledges your rights
183 | of fair use or other equivalent, as provided by copyright law.
184 |
185 | You may make, run and propagate covered works that you do not convey, without
186 | conditions so long as your license otherwise remains in force. You may convey covered
187 | works to others for the sole purpose of having them make modifications exclusively
188 | for you, or provide you with facilities for running those works, provided that you
189 | comply with the terms of this License in conveying all material for which you do not
190 | control copyright. Those thus making or running the covered works for you must do so
191 | exclusively on your behalf, under your direction and control, on terms that prohibit
192 | them from making any copies of your copyrighted material outside their relationship
193 | with you.
194 |
195 | Conveying under any other circumstances is permitted solely under the conditions
196 | stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
197 |
198 | ### 3. Protecting Users' Legal Rights From Anti-Circumvention Law
199 |
200 | No covered work shall be deemed part of an effective technological measure under any
201 | applicable law fulfilling obligations under article 11 of the WIPO copyright treaty
202 | adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention
203 | of such measures.
204 |
205 | When you convey a covered work, you waive any legal power to forbid circumvention of
206 | technological measures to the extent such circumvention is effected by exercising
207 | rights under this License with respect to the covered work, and you disclaim any
208 | intention to limit operation or modification of the work as a means of enforcing,
209 | against the work's users, your or third parties' legal rights to forbid circumvention
210 | of technological measures.
211 |
212 | ### 4. Conveying Verbatim Copies
213 |
214 | You may convey verbatim copies of the Program's source code as you receive it, in any
215 | medium, provided that you conspicuously and appropriately publish on each copy an
216 | appropriate copyright notice; keep intact all notices stating that this License and
217 | any non-permissive terms added in accord with section 7 apply to the code; keep
218 | intact all notices of the absence of any warranty; and give all recipients a copy of
219 | this License along with the Program.
220 |
221 | You may charge any price or no price for each copy that you convey, and you may offer
222 | support or warranty protection for a fee.
223 |
224 | ### 5. Conveying Modified Source Versions
225 |
226 | You may convey a work based on the Program, or the modifications to produce it from
227 | the Program, in the form of source code under the terms of section 4, provided that
228 | you also meet all of these conditions:
229 |
230 | * **a)** The work must carry prominent notices stating that you modified it, and giving a
231 | relevant date.
232 | * **b)** The work must carry prominent notices stating that it is released under this
233 | License and any conditions added under section 7. This requirement modifies the
234 | requirement in section 4 to “keep intact all notices”.
235 | * **c)** You must license the entire work, as a whole, under this License to anyone who
236 | comes into possession of a copy. This License will therefore apply, along with any
237 | applicable section 7 additional terms, to the whole of the work, and all its parts,
238 | regardless of how they are packaged. This License gives no permission to license the
239 | work in any other way, but it does not invalidate such permission if you have
240 | separately received it.
241 | * **d)** If the work has interactive user interfaces, each must display Appropriate Legal
242 | Notices; however, if the Program has interactive interfaces that do not display
243 | Appropriate Legal Notices, your work need not make them do so.
244 |
245 | A compilation of a covered work with other separate and independent works, which are
246 | not by their nature extensions of the covered work, and which are not combined with
247 | it such as to form a larger program, in or on a volume of a storage or distribution
248 | medium, is called an “aggregate” if the compilation and its resulting
249 | copyright are not used to limit the access or legal rights of the compilation's users
250 | beyond what the individual works permit. Inclusion of a covered work in an aggregate
251 | does not cause this License to apply to the other parts of the aggregate.
252 |
253 | ### 6. Conveying Non-Source Forms
254 |
255 | You may convey a covered work in object code form under the terms of sections 4 and
256 | 5, provided that you also convey the machine-readable Corresponding Source under the
257 | terms of this License, in one of these ways:
258 |
259 | * **a)** Convey the object code in, or embodied in, a physical product (including a
260 | physical distribution medium), accompanied by the Corresponding Source fixed on a
261 | durable physical medium customarily used for software interchange.
262 | * **b)** Convey the object code in, or embodied in, a physical product (including a
263 | physical distribution medium), accompanied by a written offer, valid for at least
264 | three years and valid for as long as you offer spare parts or customer support for
265 | that product model, to give anyone who possesses the object code either **(1)** a copy of
266 | the Corresponding Source for all the software in the product that is covered by this
267 | License, on a durable physical medium customarily used for software interchange, for
268 | a price no more than your reasonable cost of physically performing this conveying of
269 | source, or **(2)** access to copy the Corresponding Source from a network server at no
270 | charge.
271 | * **c)** Convey individual copies of the object code with a copy of the written offer to
272 | provide the Corresponding Source. This alternative is allowed only occasionally and
273 | noncommercially, and only if you received the object code with such an offer, in
274 | accord with subsection 6b.
275 | * **d)** Convey the object code by offering access from a designated place (gratis or for
276 | a charge), and offer equivalent access to the Corresponding Source in the same way
277 | through the same place at no further charge. You need not require recipients to copy
278 | the Corresponding Source along with the object code. If the place to copy the object
279 | code is a network server, the Corresponding Source may be on a different server
280 | (operated by you or a third party) that supports equivalent copying facilities,
281 | provided you maintain clear directions next to the object code saying where to find
282 | the Corresponding Source. Regardless of what server hosts the Corresponding Source,
283 | you remain obligated to ensure that it is available for as long as needed to satisfy
284 | these requirements.
285 | * **e)** Convey the object code using peer-to-peer transmission, provided you inform
286 | other peers where the object code and Corresponding Source of the work are being
287 | offered to the general public at no charge under subsection 6d.
288 |
289 | A separable portion of the object code, whose source code is excluded from the
290 | Corresponding Source as a System Library, need not be included in conveying the
291 | object code work.
292 |
293 | A “User Product” is either **(1)** a “consumer product”, which
294 | means any tangible personal property which is normally used for personal, family, or
295 | household purposes, or **(2)** anything designed or sold for incorporation into a
296 | dwelling. In determining whether a product is a consumer product, doubtful cases
297 | shall be resolved in favor of coverage. For a particular product received by a
298 | particular user, “normally used” refers to a typical or common use of
299 | that class of product, regardless of the status of the particular user or of the way
300 | in which the particular user actually uses, or expects or is expected to use, the
301 | product. A product is a consumer product regardless of whether the product has
302 | substantial commercial, industrial or non-consumer uses, unless such uses represent
303 | the only significant mode of use of the product.
304 |
305 | “Installation Information” for a User Product means any methods,
306 | procedures, authorization keys, or other information required to install and execute
307 | modified versions of a covered work in that User Product from a modified version of
308 | its Corresponding Source. The information must suffice to ensure that the continued
309 | functioning of the modified object code is in no case prevented or interfered with
310 | solely because modification has been made.
311 |
312 | If you convey an object code work under this section in, or with, or specifically for
313 | use in, a User Product, and the conveying occurs as part of a transaction in which
314 | the right of possession and use of the User Product is transferred to the recipient
315 | in perpetuity or for a fixed term (regardless of how the transaction is
316 | characterized), the Corresponding Source conveyed under this section must be
317 | accompanied by the Installation Information. But this requirement does not apply if
318 | neither you nor any third party retains the ability to install modified object code
319 | on the User Product (for example, the work has been installed in ROM).
320 |
321 | The requirement to provide Installation Information does not include a requirement to
322 | continue to provide support service, warranty, or updates for a work that has been
323 | modified or installed by the recipient, or for the User Product in which it has been
324 | modified or installed. Access to a network may be denied when the modification itself
325 | materially and adversely affects the operation of the network or violates the rules
326 | and protocols for communication across the network.
327 |
328 | Corresponding Source conveyed, and Installation Information provided, in accord with
329 | this section must be in a format that is publicly documented (and with an
330 | implementation available to the public in source code form), and must require no
331 | special password or key for unpacking, reading or copying.
332 |
333 | ### 7. Additional Terms
334 |
335 | “Additional permissions” are terms that supplement the terms of this
336 | License by making exceptions from one or more of its conditions. Additional
337 | permissions that are applicable to the entire Program shall be treated as though they
338 | were included in this License, to the extent that they are valid under applicable
339 | law. If additional permissions apply only to part of the Program, that part may be
340 | used separately under those permissions, but the entire Program remains governed by
341 | this License without regard to the additional permissions.
342 |
343 | When you convey a copy of a covered work, you may at your option remove any
344 | additional permissions from that copy, or from any part of it. (Additional
345 | permissions may be written to require their own removal in certain cases when you
346 | modify the work.) You may place additional permissions on material, added by you to a
347 | covered work, for which you have or can give appropriate copyright permission.
348 |
349 | Notwithstanding any other provision of this License, for material you add to a
350 | covered work, you may (if authorized by the copyright holders of that material)
351 | supplement the terms of this License with terms:
352 |
353 | * **a)** Disclaiming warranty or limiting liability differently from the terms of
354 | sections 15 and 16 of this License; or
355 | * **b)** Requiring preservation of specified reasonable legal notices or author
356 | attributions in that material or in the Appropriate Legal Notices displayed by works
357 | containing it; or
358 | * **c)** Prohibiting misrepresentation of the origin of that material, or requiring that
359 | modified versions of such material be marked in reasonable ways as different from the
360 | original version; or
361 | * **d)** Limiting the use for publicity purposes of names of licensors or authors of the
362 | material; or
363 | * **e)** Declining to grant rights under trademark law for use of some trade names,
364 | trademarks, or service marks; or
365 | * **f)** Requiring indemnification of licensors and authors of that material by anyone
366 | who conveys the material (or modified versions of it) with contractual assumptions of
367 | liability to the recipient, for any liability that these contractual assumptions
368 | directly impose on those licensors and authors.
369 |
370 | All other non-permissive additional terms are considered “further
371 | restrictions” within the meaning of section 10. If the Program as you received
372 | it, or any part of it, contains a notice stating that it is governed by this License
373 | along with a term that is a further restriction, you may remove that term. If a
374 | license document contains a further restriction but permits relicensing or conveying
375 | under this License, you may add to a covered work material governed by the terms of
376 | that license document, provided that the further restriction does not survive such
377 | relicensing or conveying.
378 |
379 | If you add terms to a covered work in accord with this section, you must place, in
380 | the relevant source files, a statement of the additional terms that apply to those
381 | files, or a notice indicating where to find the applicable terms.
382 |
383 | Additional terms, permissive or non-permissive, may be stated in the form of a
384 | separately written license, or stated as exceptions; the above requirements apply
385 | either way.
386 |
387 | ### 8. Termination
388 |
389 | You may not propagate or modify a covered work except as expressly provided under
390 | this License. Any attempt otherwise to propagate or modify it is void, and will
391 | automatically terminate your rights under this License (including any patent licenses
392 | granted under the third paragraph of section 11).
393 |
394 | However, if you cease all violation of this License, then your license from a
395 | particular copyright holder is reinstated **(a)** provisionally, unless and until the
396 | copyright holder explicitly and finally terminates your license, and **(b)** permanently,
397 | if the copyright holder fails to notify you of the violation by some reasonable means
398 | prior to 60 days after the cessation.
399 |
400 | Moreover, your license from a particular copyright holder is reinstated permanently
401 | if the copyright holder notifies you of the violation by some reasonable means, this
402 | is the first time you have received notice of violation of this License (for any
403 | work) from that copyright holder, and you cure the violation prior to 30 days after
404 | your receipt of the notice.
405 |
406 | Termination of your rights under this section does not terminate the licenses of
407 | parties who have received copies or rights from you under this License. If your
408 | rights have been terminated and not permanently reinstated, you do not qualify to
409 | receive new licenses for the same material under section 10.
410 |
411 | ### 9. Acceptance Not Required for Having Copies
412 |
413 | You are not required to accept this License in order to receive or run a copy of the
414 | Program. Ancillary propagation of a covered work occurring solely as a consequence of
415 | using peer-to-peer transmission to receive a copy likewise does not require
416 | acceptance. However, nothing other than this License grants you permission to
417 | propagate or modify any covered work. These actions infringe copyright if you do not
418 | accept this License. Therefore, by modifying or propagating a covered work, you
419 | indicate your acceptance of this License to do so.
420 |
421 | ### 10. Automatic Licensing of Downstream Recipients
422 |
423 | Each time you convey a covered work, the recipient automatically receives a license
424 | from the original licensors, to run, modify and propagate that work, subject to this
425 | License. You are not responsible for enforcing compliance by third parties with this
426 | License.
427 |
428 | An “entity transaction” is a transaction transferring control of an
429 | organization, or substantially all assets of one, or subdividing an organization, or
430 | merging organizations. If propagation of a covered work results from an entity
431 | transaction, each party to that transaction who receives a copy of the work also
432 | receives whatever licenses to the work the party's predecessor in interest had or
433 | could give under the previous paragraph, plus a right to possession of the
434 | Corresponding Source of the work from the predecessor in interest, if the predecessor
435 | has it or can get it with reasonable efforts.
436 |
437 | You may not impose any further restrictions on the exercise of the rights granted or
438 | affirmed under this License. For example, you may not impose a license fee, royalty,
439 | or other charge for exercise of rights granted under this License, and you may not
440 | initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging
441 | that any patent claim is infringed by making, using, selling, offering for sale, or
442 | importing the Program or any portion of it.
443 |
444 | ### 11. Patents
445 |
446 | A “contributor” is a copyright holder who authorizes use under this
447 | License of the Program or a work on which the Program is based. The work thus
448 | licensed is called the contributor's “contributor version”.
449 |
450 | A contributor's “essential patent claims” are all patent claims owned or
451 | controlled by the contributor, whether already acquired or hereafter acquired, that
452 | would be infringed by some manner, permitted by this License, of making, using, or
453 | selling its contributor version, but do not include claims that would be infringed
454 | only as a consequence of further modification of the contributor version. For
455 | purposes of this definition, “control” includes the right to grant patent
456 | sublicenses in a manner consistent with the requirements of this License.
457 |
458 | Each contributor grants you a non-exclusive, worldwide, royalty-free patent license
459 | under the contributor's essential patent claims, to make, use, sell, offer for sale,
460 | import and otherwise run, modify and propagate the contents of its contributor
461 | version.
462 |
463 | In the following three paragraphs, a “patent license” is any express
464 | agreement or commitment, however denominated, not to enforce a patent (such as an
465 | express permission to practice a patent or covenant not to sue for patent
466 | infringement). To “grant” such a patent license to a party means to make
467 | such an agreement or commitment not to enforce a patent against the party.
468 |
469 | If you convey a covered work, knowingly relying on a patent license, and the
470 | Corresponding Source of the work is not available for anyone to copy, free of charge
471 | and under the terms of this License, through a publicly available network server or
472 | other readily accessible means, then you must either **(1)** cause the Corresponding
473 | Source to be so available, or **(2)** arrange to deprive yourself of the benefit of the
474 | patent license for this particular work, or **(3)** arrange, in a manner consistent with
475 | the requirements of this License, to extend the patent license to downstream
476 | recipients. “Knowingly relying” means you have actual knowledge that, but
477 | for the patent license, your conveying the covered work in a country, or your
478 | recipient's use of the covered work in a country, would infringe one or more
479 | identifiable patents in that country that you have reason to believe are valid.
480 |
481 | If, pursuant to or in connection with a single transaction or arrangement, you
482 | convey, or propagate by procuring conveyance of, a covered work, and grant a patent
483 | license to some of the parties receiving the covered work authorizing them to use,
484 | propagate, modify or convey a specific copy of the covered work, then the patent
485 | license you grant is automatically extended to all recipients of the covered work and
486 | works based on it.
487 |
488 | A patent license is “discriminatory” if it does not include within the
489 | scope of its coverage, prohibits the exercise of, or is conditioned on the
490 | non-exercise of one or more of the rights that are specifically granted under this
491 | License. You may not convey a covered work if you are a party to an arrangement with
492 | a third party that is in the business of distributing software, under which you make
493 | payment to the third party based on the extent of your activity of conveying the
494 | work, and under which the third party grants, to any of the parties who would receive
495 | the covered work from you, a discriminatory patent license **(a)** in connection with
496 | copies of the covered work conveyed by you (or copies made from those copies), or **(b)**
497 | primarily for and in connection with specific products or compilations that contain
498 | the covered work, unless you entered into that arrangement, or that patent license
499 | was granted, prior to 28 March 2007.
500 |
501 | Nothing in this License shall be construed as excluding or limiting any implied
502 | license or other defenses to infringement that may otherwise be available to you
503 | under applicable patent law.
504 |
505 | ### 12. No Surrender of Others' Freedom
506 |
507 | If conditions are imposed on you (whether by court order, agreement or otherwise)
508 | that contradict the conditions of this License, they do not excuse you from the
509 | conditions of this License. If you cannot convey a covered work so as to satisfy
510 | simultaneously your obligations under this License and any other pertinent
511 | obligations, then as a consequence you may not convey it at all. For example, if you
512 | agree to terms that obligate you to collect a royalty for further conveying from
513 | those to whom you convey the Program, the only way you could satisfy both those terms
514 | and this License would be to refrain entirely from conveying the Program.
515 |
516 | ### 13. Use with the GNU Affero General Public License
517 |
518 | Notwithstanding any other provision of this License, you have permission to link or
519 | combine any covered work with a work licensed under version 3 of the GNU Affero
520 | General Public License into a single combined work, and to convey the resulting work.
521 | The terms of this License will continue to apply to the part which is the covered
522 | work, but the special requirements of the GNU Affero General Public License, section
523 | 13, concerning interaction through a network will apply to the combination as such.
524 |
525 | ### 14. Revised Versions of this License
526 |
527 | The Free Software Foundation may publish revised and/or new versions of the GNU
528 | General Public License from time to time. Such new versions will be similar in spirit
529 | to the present version, but may differ in detail to address new problems or concerns.
530 |
531 | Each version is given a distinguishing version number. If the Program specifies that
532 | a certain numbered version of the GNU General Public License “or any later
533 | version” applies to it, you have the option of following the terms and
534 | conditions either of that numbered version or of any later version published by the
535 | Free Software Foundation. If the Program does not specify a version number of the GNU
536 | General Public License, you may choose any version ever published by the Free
537 | Software Foundation.
538 |
539 | If the Program specifies that a proxy can decide which future versions of the GNU
540 | General Public License can be used, that proxy's public statement of acceptance of a
541 | version permanently authorizes you to choose that version for the Program.
542 |
543 | Later license versions may give you additional or different permissions. However, no
544 | additional obligations are imposed on any author or copyright holder as a result of
545 | your choosing to follow a later version.
546 |
547 | ### 15. Disclaimer of Warranty
548 |
549 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
550 | EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
551 | PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER
552 | EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
553 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE
554 | QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE
555 | DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
556 |
557 | ### 16. Limitation of Liability
558 |
559 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY
560 | COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS
561 | PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL,
562 | INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
563 | PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE
564 | OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE
565 | WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
566 | POSSIBILITY OF SUCH DAMAGES.
567 |
568 | ### 17. Interpretation of Sections 15 and 16
569 |
570 | If the disclaimer of warranty and limitation of liability provided above cannot be
571 | given local legal effect according to their terms, reviewing courts shall apply local
572 | law that most closely approximates an absolute waiver of all civil liability in
573 | connection with the Program, unless a warranty or assumption of liability accompanies
574 | a copy of the Program in return for a fee.
575 |
576 | _END OF TERMS AND CONDITIONS_
577 |
578 | ## How to Apply These Terms to Your New Programs
579 |
580 | If you develop a new program, and you want it to be of the greatest possible use to
581 | the public, the best way to achieve this is to make it free software which everyone
582 | can redistribute and change under these terms.
583 |
584 | To do so, attach the following notices to the program. It is safest to attach them
585 | to the start of each source file to most effectively state the exclusion of warranty;
586 | and each file should have at least the “copyright” line and a pointer to
587 | where the full notice is found.
588 |
589 |
590 | Copyright (C)
591 |
592 | This program is free software: you can redistribute it and/or modify
593 | it under the terms of the GNU General Public License as published by
594 | the Free Software Foundation, either version 3 of the License, or
595 | (at your option) any later version.
596 |
597 | This program is distributed in the hope that it will be useful,
598 | but WITHOUT ANY WARRANTY; without even the implied warranty of
599 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
600 | GNU General Public License for more details.
601 |
602 | You should have received a copy of the GNU General Public License
603 | along with this program. If not, see .
604 |
605 | Also add information on how to contact you by electronic and paper mail.
606 |
607 | If the program does terminal interaction, make it output a short notice like this
608 | when it starts in an interactive mode:
609 |
610 | Copyright (C)
611 | This program comes with ABSOLUTELY NO WARRANTY; for details type 'show w'.
612 | This is free software, and you are welcome to redistribute it
613 | under certain conditions; type 'show c' for details.
614 |
615 | The hypothetical commands `show w` and `show c` should show the appropriate parts of
616 | the General Public License. Of course, your program's commands might be different;
617 | for a GUI interface, you would use an “about box”.
618 |
619 | You should also get your employer (if you work as a programmer) or school, if any, to
620 | sign a “copyright disclaimer” for the program, if necessary. For more
621 | information on this, and how to apply and follow the GNU GPL, see
622 | <>.
623 |
624 | The GNU General Public License does not permit incorporating your program into
625 | proprietary programs. If your program is a subroutine library, you may consider it
626 | more useful to permit linking proprietary applications with the library. If this is
627 | what you want to do, use the GNU Lesser General Public License instead of this
628 | License. But first, please read
629 | <>.
--------------------------------------------------------------------------------
/LICENSE_ru.md:
--------------------------------------------------------------------------------
1 | # Лицензионное соглашение VPNclient (Российская Федерация)
2 |
3 | ## 1. Общие положения
4 | Настоящая лицензия регулируется нормами Гражданского кодекса Российской Федерации (часть IV, статьи 1225-1301) и иных применимых законодательных актов РФ.
5 |
6 | Правообладатель: ООО «НейтивМайнд» (NativeMind Inc.)
7 |
8 | Товарный знак «VPNclient» зарегистрирован и принадлежит правообладателю.
9 |
10 | © 2010-2025 ООО «НейтивМайнд». Все права защищены.
11 |
12 | ## 2. Условия использования
13 |
14 | Используя программный продукт VPNclient («Продукт»), вы подтверждаете согласие с условиями настоящей лицензии. В случае несогласия вы обязаны немедленно прекратить использование и распространение Продукта.
15 |
16 | ### 2.1. Доступность исходного кода
17 |
18 | При использовании исходного кода Продукта вы обязаны:
19 |
20 | - Опубликовать производный код исключительно в виде публичного репозитория на платформе GitHub в виде форка официального репозитория VPNclient (https://github.com/VPNclient).
21 | - Своевременно обновлять свой репозиторий, отражая изменения в официальных релизах.
22 | - Указывать в репозитории, что он является форком официального репозитория VPNclient.
23 |
24 | ### 2.2. Автоматизация релизов
25 |
26 | Все релизы Продукта должны осуществляться исключительно через GitHub Actions.
27 |
28 | ### 2.3. Обязательная атрибуция
29 |
30 | При распространении производного Продукта вы обязаны:
31 |
32 | - Указывать автора и давать соответствующую ссылку на официальный репозиторий VPNclient: https://github.com/VPNclient.
33 | - Размещать ссылку на оригинальную лицензию.
34 | - Документировать изменения, сделанные вами в README вашего репозитория.
35 |
36 | ### 2.4. Запрет вредоносного ПО
37 |
38 | Категорически запрещается встраивать любое вредоносное программное обеспечение (вирусы, трояны и т.п.).
39 |
40 | ### 2.5. Ограничения на использование имени и интерфейса
41 |
42 | Запрещается публикация производных продуктов под названием или с пользовательским интерфейсом, сходным до степени смешения с оригинальным продуктом VPNclient, на любых площадках распространения программного обеспечения (например, Google Play, App Store, RuStore, NashStore, AppGallery, VK Play и других площадках).
43 |
44 | ### 2.6. Некоммерческое использование
45 |
46 | Использование Продукта в коммерческих целях (продажа, реклама, иные коммерческие операции) допускается исключительно после письменного согласия правообладателя.
47 |
48 | ### 2.7. Условие аналогичного распространения (ShareAlike)
49 |
50 | Любое изменение, адаптация или создание производных работ на основе Продукта должно распространяться исключительно на условиях настоящей лицензии и с открытым исходным кодом через форк официального репозитория VPNclient.
51 |
52 | ## 3. Использование компонентов с открытым исходным кодом
53 |
54 | VPNclient содержит компоненты с открытым исходным кодом, лицензируемые отдельно. Пользуясь VPNclient, вы принимаете условия лицензий каждого компонента. Подробности указаны в файле LICENSE_ru.md, входящем в комплект поставки.
55 |
56 | ## 4. Ответственность сторон
57 |
58 | Продукт предоставляется «как есть», без каких-либо гарантий, явных или подразумеваемых, в том числе гарантий пригодности для определённых целей и отсутствия нарушений прав третьих лиц. Правообладатель не несёт ответственности за убытки, возникающие вследствие использования или невозможности использования Продукта.
59 |
60 | ## 5. Нарушение условий лицензии
61 |
62 | При нарушении условий настоящей лицензии правообладатель вправе требовать прекращения распространения Продукта, а также обратиться в суд или обратиться с жалобой в соответствующие площадки распространения программного обеспечения для удаления или ограничения доступа к нарушающим продуктам.
63 |
64 | Споры разрешаются в порядке, установленном законодательством Российской Федерации.
65 |
66 | ---
67 |
68 | Используя VPNclient, вы подтверждаете, что прочитали, поняли и полностью принимаете условия настоящей лицензии.
69 |
70 |
--------------------------------------------------------------------------------
/LICENSE_th.md:
--------------------------------------------------------------------------------
1 | # ข้อตกลงสิทธิการใช้งาน VPNclient (ประเทศไทย)
2 |
3 | ## 1. ข้อกำหนดทั่วไป
4 |
5 | ข้อตกลงนี้อยู่ภายใต้บังคับของพระราชบัญญัติลิขสิทธิ์ พ.ศ. 2537 และแก้ไขเพิ่มเติม รวมถึงประมวลกฎหมายแพ่งและพาณิชย์แห่งราชอาณาจักรไทย
6 |
7 | ผู้ถือลิขสิทธิ์: บริษัท เนทีฟมายด์ จำกัด (NativeMind Inc.)
8 |
9 | เครื่องหมายการค้า "VPNclient" ได้รับการจดทะเบียนและถือครองโดยผู้ถือลิขสิทธิ์
10 |
11 | ลิขสิทธิ์ © 2010-2025 NativeMind Inc. สงวนลิขสิทธิ์
12 |
13 | ## 2. เงื่อนไขการใช้งาน
14 |
15 | การใช้งานโปรแกรม VPNclient ("ผลิตภัณฑ์") ถือว่าท่านยอมรับข้อกำหนดและเงื่อนไขตามข้อตกลงฉบับนี้ หากท่านไม่ยอมรับ โปรดหยุดใช้งานผลิตภัณฑ์โดยทันที
16 |
17 | ### 2.1. การเผยแพร่ซอร์สโค้ด
18 |
19 | เมื่อท่านใช้งานซอร์สโค้ดของผลิตภัณฑ์ ท่านมีหน้าที่:
20 |
21 | - เผยแพร่ซอร์สโค้ดของท่านผ่าน GitHub โดยทำเป็น Fork ของ Repository อย่างเป็นทางการที่ https://github.com/VPNclient
22 | - ปรับปรุงให้เป็นปัจจุบันอยู่เสมอเพื่อสะท้อนการเปลี่ยนแปลงจากต้นฉบับ
23 | - ระบุให้ชัดเจนว่าซอร์สโค้ดของท่านเป็น Fork ของ Repository ดั้งเดิม
24 |
25 | ### 2.2. การเผยแพร่อัตโนมัติ
26 |
27 | การเผยแพร่ทุกครั้งต้องดำเนินการผ่าน GitHub Actions เท่านั้น
28 |
29 | ### 2.3. การให้เครดิต (Attribution)
30 |
31 | เมื่อเผยแพร่ผลิตภัณฑ์ที่ดัดแปลงจาก VPNclient ท่านต้อง:
32 |
33 | - ระบุเครดิตของผู้ถือลิขสิทธิ์พร้อมลิงก์ไปที่ https://github.com/VPNclient
34 | - แสดงลิงก์ไปยังข้อตกลงสิทธิ์ดั้งเดิม
35 | - บันทึกการเปลี่ยนแปลงใน README ของ Repository ของท่าน
36 |
37 | ### 2.4. ห้ามการใส่มัลแวร์
38 |
39 | ห้ามอย่างเด็ดขาดที่จะเพิ่มมัลแวร์หรือรหัสอันตรายใด ๆ ลงในผลิตภัณฑ์
40 |
41 | ### 2.5. ข้อจำกัดการใช้ชื่อและอินเทอร์เฟซ
42 |
43 | ห้ามเผยแพร่แอปพลิเคชันในร้านค้าแอปใดๆ เช่น Google Play, App Store, F-Droid, Microsoft Store, Huawei AppGallery หรือแพลตฟอร์มอื่นใดด้วยชื่อหรือหน้าตาที่คล้ายกับ VPNclient จนอาจทำให้เกิดความเข้าใจผิด
44 |
45 | ### 2.6. การใช้งานเชิงพาณิชย์
46 |
47 | ห้ามนำผลิตภัณฑ์นี้ไปใช้งานเพื่อวัตถุประสงค์ทางการค้า (ขายหรือโฆษณา) โดยไม่ได้รับอนุญาตเป็นลายลักษณ์อักษรจากผู้ถือลิขสิทธิ์ก่อน
48 |
49 | ### 2.7. การเผยแพร่ภายใต้เงื่อนไขเดียวกัน (ShareAlike)
50 |
51 | ผลงานที่สร้างจากผลิตภัณฑ์นี้ต้องถูกเผยแพร่ภายใต้ข้อตกลงสิทธิ์เดียวกันและในรูปแบบ Open Source ผ่านการ Fork จาก Repository ดั้งเดิมของ VPNclient
52 |
53 | ## 3. การใช้งานส่วนประกอบ Open Source
54 |
55 | VPNclient ประกอบด้วยส่วนประกอบ Open Source ที่ได้รับอนุญาตตามเงื่อนไขอื่นๆ การใช้งาน VPNclient หมายถึงท่านยอมรับเงื่อนไขของแต่ละส่วนประกอบด้วย รายละเอียดระบุไว้ในไฟล์ LICENSE.md ที่แนบมาพร้อมผลิตภัณฑ์
56 |
57 | ## 4. การปฏิเสธความรับผิด
58 |
59 | ผลิตภัณฑ์นี้ให้บริการ "ตามสภาพ" โดยไม่มีการรับประกันใดๆ ทั้งสิ้น ไม่ว่าจะแจ้งชัดหรือโดยนัย รวมถึงการรับประกันด้านความเหมาะสมกับวัตถุประสงค์เฉพาะใดๆ และผู้ถือลิขสิทธิ์จะไม่รับผิดชอบต่อความเสียหายใดๆ อันเกิดจากการใช้งานผลิตภัณฑ์นี้
60 |
61 | ## 5. การละเมิดข้อตกลง
62 |
63 | ในกรณีที่มีการละเมิดข้อตกลงนี้ ผู้ถือลิขสิทธิ์มีสิทธิ์ขอให้หยุดเผยแพร่ผลิตภัณฑ์ และอาจดำเนินการทางกฎหมายหรือแจ้งไปยังร้านค้าแอปพลิเคชันเพื่อให้มีการลบหรือระงับการเผยแพร่ผลิตภัณฑ์ที่ละเมิด
64 |
65 | ข้อพิพาทใดๆ จะต้องได้รับการตัดสินตามกฎหมายแห่งราชอาณาจักรไทย
66 |
67 | ---
68 |
69 | การใช้งาน VPNclient หมายถึงท่านได้อ่าน เข้าใจ และยอมรับข้อกำหนดและเงื่อนไขทั้งหมดตามข้อตกลงนี้แล้ว
70 |
71 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # VPNclient Engine
2 |
3 | **VPNclient Engine** is a powerful, cross-platform VPN client core library that provides the low-level functionality to create VPN connections and tunnels. It’s designed for ultimate flexibility, supporting multiple VPN protocols (Xray:VMess,VLESS,Reality;OpenVPN;WireGuard) and network drivers in a single unified engine. The engine can be embedded into apps on various platforms (iOS, Android, Windows, macOS, Unix) to enable advanced VPN features without reinventing the wheel for each platform.
4 |
5 |
6 |
7 | ## 🚀 Key Features
8 | - **Cross-platform:** Runs on mobile, desktop, and server environments. Tested on iOS 15+, Android 6.0+, Windows 10/11, macOS (Catalina+), and Ubuntu Linux.
9 | - **Multi-Protocol Support:** Out-of-the-box integration with **Xray** core (supporting VMess, VLESS, Reality, and other protocols from the V2Ray ecosystem), **WireGuard**, and **OpenVPN**. This means the engine can handle anything from secure proxies to full VPN protocols, allowing easy migration from or combination of different VPN technologies.
10 | - **Multiple VPN Cores:** Integrates different VPN/proxy core implementations:
11 | - **VPNclient Xray Wrapper** – a wrapper for the Xray core, enabling protocols like VMess, VLESS, Reality, Shadowsocks, etc. (Xray is a fork of V2Ray, known for its flexibility in configuring inbound/outbound proxy rules).
12 | - **LibXray** – possibly a library form of Xray for direct linking.
13 | - **Sing-Box** – integration with Sing-Box (another modern proxy/VPN core that can run V2Ray protocols). This provides redundancy and choice; if one implementation has issues or a new feature, you can switch.
14 | - **WireGuard** – built-in support for WireGuard VPN protocol (via `libwg`).
15 | - **OpenVPN** – support for OpenVPN protocol, likely using an OpenVPN3 library or similar, to allow traditional VPN connections.
16 | - `No core` – you could run the engine in a mode where it doesn't internally handle any protocol (not common, but for testing or if using engine just as a packet forwarder).
17 | - **Multiple Network Drivers:** Supports several methods of capturing and forwarding traffic:
18 | - `vpnclient-driver` – a built-in driver for creating and managing a virtual network interface (TUN) on supported platforms (acts as a VPN tunnel interface).
19 | - `tun2socks` – uses the tun2socks technique to forward TUN interface traffic to a SOCKS proxy internally.
20 | - `hev-socks5` – a high-performance SOCKS5 driver (likely utilizing the **Hev** Socks5 library) to capture traffic via a local proxy.
21 | - `WinTun` – integration with the **WinTun** driver (from WireGuard) on Windows for efficient kernel-level tunneling.
22 | - `No driver` – an option to run the engine without attaching a driver (for example, operating purely as a protocol client that provides a local endpoint like a SOCKS proxy which the user can configure manually).
23 | - **Modular Architecture:** The engine is built with a plugin-like architecture, separating “drivers” (network I/O mechanisms) from “cores” (VPN protocol implementations). This modular design means you can tailor it to your needs—for example, using a TUN interface driver for full-device VPN, or a SOCKS5 driver for proxy mode; using Xray for advanced protocols or falling back to OpenVPN, etc.
24 | - **Native Platform-Specific Implementations (Swift/Kotlin):** Platform-specific VPN functionalities, such as network interfaces or background service management, are written natively in Swift for iOS and Kotlin for Android. These implementations ensure proper integration with OS-specific networking features and provide better control over system resources, such as network extension APIs on iOS and VPN service management on Android.
25 | - **High Performance GoLang Core for Xray**:Xray, the core VPN protocol handler, is implemented in GoLang for efficient and concurrent networking performance, enabling high throughput and scalability, particularly in handling various tunneling protocols.
26 | - **High Performance C++ Core:** Implemented in C++ for efficiency and speed, with careful consideration for memory and battery usage (important on mobile). It strives to achieve native-level performance comparable to dedicated clients.
27 | - **Cross-Platform Compatibility:** The same engine code runs on **iOS, Android, macOS, Windows, and Linux**. Platform-specific adaptations (like using Network Extension on iOS, or WinTun on Windows) are built-in. This ensures consistent behavior and capability across devices, making it ideal for applications that target multiple environments.
28 | - **Ease of Integration:** For developers, VPNclient Engine exposes a clear API (in multiple languages: Swift, Kotlin/Java, C++) to start/stop the VPN and configure options. It can be included as a library (.aar for Android, CocoaPod/Framework for iOS, static or dynamic libs for desktop). This makes it straightforward to integrate into your own app or system.
29 | - **Use Cases:** VPNclient Engine can power a typical VPN client app (like the VPNclient App above), but it’s flexible enough for other uses: building a secure proxy service into an app, creating a custom enterprise VPN solution, or academic/research projects experimenting with network tunneling.
30 |
31 |
32 | ## 🏗️ Architecture Overview
33 |
34 | ```mermaid
35 | graph TD
36 | C[VPNclient Engine] --> D{{Drivers}}
37 | C --> E{{Cores}}
38 | subgraph Driver Modules
39 | D --> D1[VPNclient Driver]
40 | D --> D2[tun2socks]
41 | D --> D3[hev-socks5]
42 | D --> D4[WinTun]
43 | D --> D5[No Driver]
44 | end
45 | subgraph Core Modules
46 | E --> E1[VPNclient Xray Wrapper]
47 | E --> E2[LibXray]
48 | E --> E3[Sing-Box]
49 | E --> E4[WireGuard]
50 | E --> E5[OpenVPN]
51 | E --> E6[No Core]
52 | end
53 | ```
54 |
55 | ## Quick Start
56 |
57 | ### Prerequisites
58 | - For Android: Android SDK, NDK
59 | - For iOS: Xcode with Swift support
60 | - For Desktop: CMake, platform-specific build tools
61 |
62 | ### Installation
63 |
64 | #### Android (Kotlin)
65 | Add to your `build.gradle`:
66 | ```kotlin
67 | dependencies {
68 | implementation("click.vpnclient:engine:1.0.0")
69 | }
70 | ```
71 |
72 | #### iOS (Swift)
73 | Add to your `Podfile`:
74 | ```ruby
75 | pod 'VPNclientEngine', '~> 1.0.0'
76 | ```
77 |
78 | #### C++ (Cross-platform)
79 | Add as a subproject or include the prebuilt libraries.
80 |
81 | ## API Usage
82 |
83 | ### Common Engine Initialization
84 |
85 | #### Swift (iOS/macOS)
86 | ```swift
87 | import VPNclientEngine
88 |
89 | let engine = VPNClientEngine()
90 | engine.setDriver(type: .vpnclient_driver)
91 | engine.setCore(type: .vpnclient_xray_wrapper)
92 |
93 | let config = """
94 | {
95 | "inbounds": [...],
96 | "outbounds": [...]
97 | }
98 | """
99 |
100 | engine.start(config: config) { success, error in
101 | if success {
102 | print("VPN started successfully")
103 | } else {
104 | print("Error starting VPN: \(error?.localizedDescription ?? "Unknown error")")
105 | }
106 | }
107 | ```
108 |
109 | #### Kotlin (Android)
110 | ```kotlin
111 | import com.vpnclient.engine.VPNClientEngine
112 |
113 | val engine = VPNClientEngine()
114 | engine.setDriver(DriverType.VPNCLIENT_DRIVER)
115 | engine.setCore(CoreType.VPNCLIENT_XRAY_WRAPPER)
116 |
117 | val config = """
118 | {
119 | "inbounds": [...],
120 | "outbounds": [...]
121 | }
122 | """.trimIndent()
123 |
124 | engine.start(config) { success, error ->
125 | if (success) {
126 | println("VPN started successfully")
127 | } else {
128 | println("Error starting VPN: ${error ?: "Unknown error"}")
129 | }
130 | }
131 | ```
132 |
133 | #### C++ (Windows/Linux)
134 | ```cpp
135 | #include
136 |
137 | int main() {
138 | VPNClientEngine engine;
139 | engine.setDriver(DriverType::VPNCLIENT_DRIVER);
140 | engine.setCore(CoreType::VPNCLIENT_XRAY_WRAPPER);
141 |
142 | const std::string config = R"({
143 | "inbounds": [...],
144 | "outbounds": [...]
145 | })";
146 |
147 | engine.start(config, [](bool success, const std::string& error) {
148 | if (success) {
149 | std::cout << "VPN started successfully" << std::endl;
150 | } else {
151 | std::cerr << "Error starting VPN: " << error << std::endl;
152 | }
153 | });
154 |
155 | return 0;
156 | }
157 | ```
158 |
159 | ## API Reference
160 |
161 | ### Core Methods
162 |
163 | 1. **setDriver**
164 | ```swift
165 | func setDriver(type: DriverType)
166 | ```
167 | ```kotlin
168 | fun setDriver(type: DriverType)
169 | ```
170 | ```cpp
171 | void setDriver(DriverType type);
172 | ```
173 |
174 | Available drivers:
175 | - VPNCLIENT_DRIVER
176 | - TUN2SOCKS
177 | - HEV_SOCKS5
178 | - WINTUN
179 | - NONE
180 |
181 | 2. **setCore**
182 | ```swift
183 | func setCore(type: CoreType)
184 | ```
185 | ```kotlin
186 | fun setCore(type: CoreType)
187 | ```
188 | ```cpp
189 | void setCore(CoreType type);
190 | ```
191 |
192 | Available cores:
193 | - VPNCLIENT_XRAY_WRAPPER
194 | - LIBXRAY
195 | - SING_BOX
196 | - WIREGUARD
197 | - OPENVPN
198 | - NONE
199 |
200 | 3. **start**
201 | ```swift
202 | func start(config: String, completion: @escaping (Bool, Error?) -> Void)
203 | ```
204 | ```kotlin
205 | fun start(config: String, callback: (Boolean, String?) -> Unit)
206 | ```
207 | ```cpp
208 | void start(const std::string& config, std::function callback);
209 | ```
210 |
211 | 4. **stop**
212 | ```swift
213 | func stop(completion: @escaping (Bool, Error?) -> Void)
214 | ```
215 | ```kotlin
216 | fun stop(callback: (Boolean, String?) -> Unit)
217 | ```
218 | ```cpp
219 | void stop(std::function callback);
220 | ```
221 |
222 | 5. **getStatus**
223 | ```swift
224 | func getStatus() -> VPNStatus
225 | ```
226 | ```kotlin
227 | fun getStatus(): VPNStatus
228 | ```
229 | ```cpp
230 | VPNStatus getStatus();
231 | ```
232 |
233 | ## Platform-Specific Notes
234 |
235 | ### Android
236 | - Requires VPN permission:
237 | ```xml
238 |
239 |
240 | ```
241 |
242 | ### iOS
243 | - Add VPN entitlements in your project settings
244 | - Include the following in your Info.plist:
245 | ```xml
246 | click.vpnclient.engine
247 |
248 | allow-vpn
249 |
250 | ```
251 |
252 | ### Windows
253 | - Requires TUN/TAP drivers installed for some configurations
254 | - Admin privileges may be needed for certain drivers
255 |
256 | ## Example Configurations
257 |
258 | ### Xray Core Configuration
259 | ```json
260 | {
261 | "inbounds": [
262 | {
263 | "port": 1080,
264 | "protocol": "socks",
265 | "settings": {
266 | "auth": "noauth"
267 | }
268 | }
269 | ],
270 | "outbounds": [
271 | {
272 | "protocol": "vmess",
273 | "settings": {
274 | "vnext": [
275 | {
276 | "address": "your.server.com",
277 | "port": 443,
278 | "users": [
279 | {
280 | "id": "your-uuid",
281 | "alterId": 0
282 | }
283 | ]
284 | }
285 | ]
286 | }
287 | }
288 | ]
289 | }
290 | ```
291 |
292 | ### WireGuard Configuration
293 | ```json
294 | {
295 | "interface": {
296 | "privateKey": "your_private_key",
297 | "addresses": ["10.0.0.2/32"],
298 | "dns": ["1.1.1.1"]
299 | },
300 | "peer": {
301 | "publicKey": "server_public_key",
302 | "endpoint": "your.server.com:51820",
303 | "allowedIPs": ["0.0.0.0/0"]
304 | }
305 | }
306 | ```
307 |
308 | ## 🤝 Contributing
309 | We welcome contributions! Please fork the repository and submit pull requests.
310 |
311 | ## 📜 License
312 |
313 | This project is licensed under the **VPNclient Extended GNU General Public License v3 (GPL v3)**. See [LICENSE.md](LICENSE.md) for details.
314 |
315 | ⚠️ **Note:** By using this software, you agree to comply with additional conditions outlined in the [VPNсlient Extended GNU General Public License v3 (GPL v3)](LICENSE.md)
316 |
317 | ## 💬 Support
318 | For issues or questions, please open an issue on our GitHub repository.
319 |
--------------------------------------------------------------------------------
/android/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 | .cxx
15 | local.properties
16 |
--------------------------------------------------------------------------------
/android/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 |
--------------------------------------------------------------------------------
/android/.idea/.name:
--------------------------------------------------------------------------------
1 | VPNclient Engine Android
--------------------------------------------------------------------------------
/android/.idea/AndroidProjectSystem.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/android/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | xmlns:android
18 |
19 | ^$
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 | xmlns:.*
29 |
30 | ^$
31 |
32 |
33 | BY_NAME
34 |
35 |
36 |
37 |
38 |
39 |
40 | .*:id
41 |
42 | http://schemas.android.com/apk/res/android
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 | .*:name
52 |
53 | http://schemas.android.com/apk/res/android
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 | name
63 |
64 | ^$
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 | style
74 |
75 | ^$
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 | .*
85 |
86 | ^$
87 |
88 |
89 | BY_NAME
90 |
91 |
92 |
93 |
94 |
95 |
96 | .*
97 |
98 | http://schemas.android.com/apk/res/android
99 |
100 |
101 | ANDROID_ATTRIBUTE_ORDER
102 |
103 |
104 |
105 |
106 |
107 |
108 | .*
109 |
110 | .*
111 |
112 |
113 | BY_NAME
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
--------------------------------------------------------------------------------
/android/.idea/codeStyles/codeStyleConfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/android/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/android/.idea/deploymentTargetSelector.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/android/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
18 |
19 |
--------------------------------------------------------------------------------
/android/.idea/kotlinc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/android/.idea/migrations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/android/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/android/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/android/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/android/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/android/app/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.library'
3 | //alias(libs.plugins.android.application)
4 | alias(libs.plugins.kotlin.android)
5 | alias(libs.plugins.kotlin.compose)
6 | }
7 |
8 | android {
9 | namespace 'click.vpnclient.engine'
10 | compileSdk 35
11 |
12 | defaultConfig {
13 | //applicationId "click.vpnclient.engine"
14 | minSdk 21
15 | targetSdk 35
16 | versionCode 1
17 | versionName "1.0"
18 |
19 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
20 | }
21 |
22 | buildTypes {
23 | release {
24 | minifyEnabled false
25 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
26 | }
27 | }
28 | compileOptions {
29 | sourceCompatibility JavaVersion.VERSION_11
30 | targetCompatibility JavaVersion.VERSION_11
31 | }
32 | kotlinOptions {
33 | jvmTarget = '11'
34 | }
35 | buildFeatures {
36 | compose true
37 | }
38 |
39 | sourceSets {
40 | main {
41 | jniLibs.srcDirs = ['jniLibs']
42 | }
43 | }
44 | }
45 |
46 | dependencies {
47 |
48 | implementation libs.androidx.core.ktx
49 | implementation libs.androidx.lifecycle.runtime.ktx
50 | implementation libs.androidx.activity.compose
51 | implementation platform(libs.androidx.compose.bom)
52 | implementation libs.androidx.ui
53 | implementation libs.androidx.ui.graphics
54 | implementation libs.androidx.ui.tooling.preview
55 | implementation libs.androidx.material3
56 | testImplementation libs.junit
57 | androidTestImplementation libs.androidx.junit
58 | androidTestImplementation libs.androidx.espresso.core
59 | androidTestImplementation platform(libs.androidx.compose.bom)
60 | androidTestImplementation libs.androidx.ui.test.junit4
61 | debugImplementation libs.androidx.ui.tooling
62 | debugImplementation libs.androidx.ui.test.manifest
63 | }
--------------------------------------------------------------------------------
/android/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/android/app/src/androidTest/java/click/vpnclient/engine/android/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package click.vpnclient.engine.android
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("click.vpnclient.engine.android", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/android/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
19 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/android/app/src/main/java/click/vpnclient/engine/VPNManager.kt:
--------------------------------------------------------------------------------
1 | package click.vpnclient.engine;
2 |
3 | import android.content.ComponentName;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.content.ServiceConnection;
7 | import android.os.IBinder;
8 | import android.util.Log;
9 | import click.vpnclient.engine.service.VPNService;
10 |
11 | public class VPNManager {
12 | private static final String TAG = "VPNManager";
13 | private static VPNService vpnService;
14 | private static boolean isBound = false;
15 |
16 | private static ServiceConnection serviceConnection = new ServiceConnection() {
17 | @Override
18 | public void onServiceConnected(ComponentName className, IBinder service) {
19 | // We've bound to VPNService, cast the IBinder and get VPNService instance
20 | VPNService.LocalBinder binder = (VPNService.LocalBinder) service;
21 | vpnService = binder.getService();
22 | isBound = true;
23 | Log.d(TAG, "onServiceConnected: VPN service connected");
24 | }
25 |
26 | @Override
27 | public void onServiceDisconnected(ComponentName arg0) {
28 | isBound = false;
29 | Log.d(TAG, "onServiceDisconnected: VPN service disconnected");
30 | }
31 | };
32 |
33 | // Binds the VPN service to the manager
34 | public static void bindService(Context context) {
35 | Intent intent = new Intent(context, VPNService.class);
36 | context.bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE);
37 | }
38 |
39 | public static boolean start(String config) {
40 | return vpnService != null && vpnService.startVPN(config);
41 | }
42 |
43 | public static void stop() {
44 | if (vpnService != null) vpnService.stopVPN();
45 | }
46 |
47 | public static String status() {
48 | return vpnService != null && vpnService.isRunning() ? "Running" : "Stopped";
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/android/app/src/main/java/click/vpnclient/engine/service/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package click.vpnclient.engine.android
2 |
3 | import android.content.Intent
4 | import android.os.Bundle
5 | import android.util.Log
6 | import androidx.activity.ComponentActivity
7 | import androidx.activity.compose.setContent
8 | import androidx.activity.enableEdgeToEdge
9 | import androidx.compose.foundation.layout.fillMaxSize
10 | import androidx.compose.foundation.layout.padding
11 | import androidx.compose.material3.Text
12 | import androidx.compose.runtime.Composable
13 | import androidx.compose.ui.Modifier
14 | import androidx.compose.ui.tooling.preview.Preview
15 | import click.vpnclient.engine.android.ui.theme.VPNclientEngineAndroidTheme
16 | import click.vpnclient.engine.service.VPNService
17 | import android.net.VpnService
18 |
19 |
20 | private const val TAG = "MainActivity"
21 |
22 | class MainActivity : ComponentActivity() {
23 |
24 |
25 | override fun onCreate(savedInstanceState: Bundle?) {
26 | super.onCreate(savedInstanceState)
27 | enableEdgeToEdge()
28 | setContent {
29 | VPNclientEngineAndroidTheme {
30 | Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
31 | Greeting(
32 | name = "Hello Android!",
33 | modifier = Modifier.padding(innerPadding)
34 | )
35 | }
36 |
37 | // Request VPN permission
38 | requestVPNAccess()
39 |
40 | }
41 | }
42 | }
43 |
44 | private fun requestVPNAccess() {
45 | val prepareIntent: Intent? = VpnService.prepare(this)
46 | if (prepareIntent != null) {
47 | Log.d(TAG, "Request VPN permission")
48 | startActivityForResult(prepareIntent, 0)
49 | } else {
50 | Log.d(TAG, "VPN permission already granted")
51 | startVPNService()
52 | }
53 | }
54 |
55 | private fun startVPNService() {
56 | val vpnIntent = Intent(this, VPNService::class.java)
57 | if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
58 | startForegroundService(vpnIntent)
59 | }
60 | }
61 | }
62 |
63 | @Composable
64 | fun Greeting(name: String, modifier: Modifier = Modifier) {
65 | Text(
66 | text = "Hello $name!",
67 | modifier = modifier
68 | )
69 | }
70 |
71 | @Preview(showBackground = true)
72 | @Composable
73 | fun GreetingPreview() {
74 | VPNclientEngineAndroidTheme {
75 | Greeting("Android")
76 | }
77 | }
--------------------------------------------------------------------------------
/android/app/src/main/java/click/vpnclient/engine/service/VPNService.kt:
--------------------------------------------------------------------------------
1 | package click.vpnclient.engine
2 |
3 | import android.app.PendingIntent
4 | import android.content.Intent
5 | import android.net.VpnService
6 | import android.os.ParcelFileDescriptor
7 | import android.util.Log
8 | import java.io.FileInputStream
9 | import java.io.FileOutputStream
10 | import java.net.InetSocketAddress
11 | import java.nio.channels.DatagramChannel
12 |
13 | class VPNService : VpnService() {
14 | companion object {
15 | private const val TAG = "VPNService"
16 | }
17 |
18 | private var vpnInterface: ParcelFileDescriptor? = null
19 |
20 | /**
21 | * Indicates whether the VPN service is currently running.
22 | */
23 | var isRunning = false; private set
24 |
25 | /**
26 | * Called when the service is first created.
27 | */
28 | override fun onCreate() {
29 | super.onCreate()
30 | Log.d(TAG, "VPNService created")
31 | }
32 |
33 | /**
34 | * Called when the service is started.
35 | *
36 | * @param intent The Intent supplied to [startService], as given.
37 | * @param flags Additional data about this start request.
38 | * @param startId A unique integer representing this specific request to start.
39 | * @return The return value indicates what semantics the system should use for the service's
40 | * current started state.
41 | */
42 | override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
43 | Log.d(TAG, "onStartCommand: Starting VPN service")
44 | try {
45 | setupVPN()
46 | isRunning = true
47 | // Notify that vpn started
48 | } catch (e: Exception) {
49 | Log.e(TAG, "Error starting VPN service", e)
50 | // Notify about start vpn error
51 | }
52 | return START_NOT_STICKY
53 | }
54 |
55 | /**
56 | * Called when the service is no longer used and is being destroyed.
57 | */
58 | override fun onDestroy() {
59 | Log.d(TAG, "onDestroy: Stopping VPN service")
60 | vpnInterface?.close()
61 | vpnInterface = null
62 | isRunning = false
63 | super.onDestroy()
64 |
65 | }
66 |
67 | private fun setupVPN() {
68 | // Here you can add other configures, for example:
69 | // addAddress addRoute addDnsServer
70 | vpnInterface = Builder()
71 | .setSession("VPNClient")
72 | .establish()
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/android/app/src/main/java/click/vpnclient/engine/service/ui/theme/Color.kt:
--------------------------------------------------------------------------------
1 | package click.vpnclient.engine.android.ui.theme
2 |
3 | import androidx.compose.ui.graphics.Color
4 |
5 | val Purple80 = Color(0xFFD0BCFF)
6 | val PurpleGrey80 = Color(0xFFCCC2DC)
7 | val Pink80 = Color(0xFFEFB8C8)
8 |
9 | val Purple40 = Color(0xFF6650a4)
10 | val PurpleGrey40 = Color(0xFF625b71)
11 | val Pink40 = Color(0xFF7D5260)
--------------------------------------------------------------------------------
/android/app/src/main/java/click/vpnclient/engine/service/ui/theme/Theme.kt:
--------------------------------------------------------------------------------
1 | package click.vpnclient.engine.android.ui.theme
2 |
3 | import android.app.Activity
4 | import android.os.Build
5 | import androidx.compose.foundation.isSystemInDarkTheme
6 | import androidx.compose.material3.MaterialTheme
7 | import androidx.compose.material3.darkColorScheme
8 | import androidx.compose.material3.dynamicDarkColorScheme
9 | import androidx.compose.material3.dynamicLightColorScheme
10 | import androidx.compose.material3.lightColorScheme
11 | import androidx.compose.runtime.Composable
12 | import androidx.compose.ui.platform.LocalContext
13 |
14 | private val DarkColorScheme = darkColorScheme(
15 | primary = Purple80,
16 | secondary = PurpleGrey80,
17 | tertiary = Pink80
18 | )
19 |
20 | private val LightColorScheme = lightColorScheme(
21 | primary = Purple40,
22 | secondary = PurpleGrey40,
23 | tertiary = Pink40
24 |
25 | /* Other default colors to override
26 | background = Color(0xFFFFFBFE),
27 | surface = Color(0xFFFFFBFE),
28 | onPrimary = Color.White,
29 | onSecondary = Color.White,
30 | onTertiary = Color.White,
31 | onBackground = Color(0xFF1C1B1F),
32 | onSurface = Color(0xFF1C1B1F),
33 | */
34 | )
35 |
36 | @Composable
37 | fun VPNclientEngineAndroidTheme(
38 | darkTheme: Boolean = isSystemInDarkTheme(),
39 | // Dynamic color is available on Android 12+
40 | dynamicColor: Boolean = true,
41 | content: @Composable () -> Unit
42 | ) {
43 | val colorScheme = when {
44 | dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
45 | val context = LocalContext.current
46 | if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
47 | }
48 |
49 | darkTheme -> DarkColorScheme
50 | else -> LightColorScheme
51 | }
52 |
53 | MaterialTheme(
54 | colorScheme = colorScheme,
55 | typography = Typography,
56 | content = content
57 | )
58 | }
--------------------------------------------------------------------------------
/android/app/src/main/java/click/vpnclient/engine/service/ui/theme/Type.kt:
--------------------------------------------------------------------------------
1 | package click.vpnclient.engine.android.ui.theme
2 |
3 | import androidx.compose.material3.Typography
4 | import androidx.compose.ui.text.TextStyle
5 | import androidx.compose.ui.text.font.FontFamily
6 | import androidx.compose.ui.text.font.FontWeight
7 | import androidx.compose.ui.unit.sp
8 |
9 | // Set of Material typography styles to start with
10 | val Typography = Typography(
11 | bodyLarge = TextStyle(
12 | fontFamily = FontFamily.Default,
13 | fontWeight = FontWeight.Normal,
14 | fontSize = 16.sp,
15 | lineHeight = 24.sp,
16 | letterSpacing = 0.5.sp
17 | )
18 | /* Other default text styles to override
19 | titleLarge = TextStyle(
20 | fontFamily = FontFamily.Default,
21 | fontWeight = FontWeight.Normal,
22 | fontSize = 22.sp,
23 | lineHeight = 28.sp,
24 | letterSpacing = 0.sp
25 | ),
26 | labelSmall = TextStyle(
27 | fontFamily = FontFamily.Default,
28 | fontWeight = FontWeight.Medium,
29 | fontSize = 11.sp,
30 | lineHeight = 16.sp,
31 | letterSpacing = 0.5.sp
32 | )
33 | */
34 | )
--------------------------------------------------------------------------------
/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/android/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-hdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VPNclient/VPNclient-engine/d0e5480dfb9ff4395da74af024e60d4c3265a313/android/app/src/main/res/mipmap-hdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VPNclient/VPNclient-engine/d0e5480dfb9ff4395da74af024e60d4c3265a313/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-mdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VPNclient/VPNclient-engine/d0e5480dfb9ff4395da74af024e60d4c3265a313/android/app/src/main/res/mipmap-mdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VPNclient/VPNclient-engine/d0e5480dfb9ff4395da74af024e60d4c3265a313/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VPNclient/VPNclient-engine/d0e5480dfb9ff4395da74af024e60d4c3265a313/android/app/src/main/res/mipmap-xhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VPNclient/VPNclient-engine/d0e5480dfb9ff4395da74af024e60d4c3265a313/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VPNclient/VPNclient-engine/d0e5480dfb9ff4395da74af024e60d4c3265a313/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VPNclient/VPNclient-engine/d0e5480dfb9ff4395da74af024e60d4c3265a313/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VPNclient/VPNclient-engine/d0e5480dfb9ff4395da74af024e60d4c3265a313/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VPNclient/VPNclient-engine/d0e5480dfb9ff4395da74af024e60d4c3265a313/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/android/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFBB86FC
4 | #FF6200EE
5 | #FF3700B3
6 | #FF03DAC5
7 | #FF018786
8 | #FF000000
9 | #FFFFFFFF
10 |
--------------------------------------------------------------------------------
/android/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | VPNclient Engine Android
3 |
--------------------------------------------------------------------------------
/android/app/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/android/app/src/main/res/xml/backup_rules.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
13 |
--------------------------------------------------------------------------------
/android/app/src/main/res/xml/data_extraction_rules.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
12 |
13 |
19 |
--------------------------------------------------------------------------------
/android/app/src/test/java/click/vpnclient/engine/android/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package click.vpnclient.engine.android
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
--------------------------------------------------------------------------------
/android/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 | //plugins {
3 | // id 'com.android.library'
4 | //alias(libs.plugins.android.application) apply false
5 | //alias(libs.plugins.kotlin.android) apply false
6 | //alias(libs.plugins.kotlin.compose) apply false
7 | //}
8 |
9 | plugins {
10 | id("com.android.library")
11 | id("org.jetbrains.kotlin.android")
12 | }
13 |
14 | android {
15 | namespace = "click.vpnclient.engine"
16 | compileSdk = 34
17 |
18 | defaultConfig {
19 | minSdk = 21
20 | targetSdk = 34
21 | versionCode = 1
22 | versionName = "1.0"
23 | }
24 |
25 | //buildTypes {
26 | // release {
27 | // isMinifyEnabled = false
28 | // }
29 | //}
30 |
31 | compileOptions {
32 | sourceCompatibility = JavaVersion.VERSION_11
33 | targetCompatibility = JavaVersion.VERSION_11
34 | }
35 | }
36 |
37 | tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
38 | kotlinOptions {
39 | jvmTarget = "11"
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/android/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. For more details, visit
12 | # https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app's APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Kotlin code style for this project: "official" or "obsolete":
19 | kotlin.code.style=official
20 | # Enables namespacing of each library's R class so that its R class includes only the
21 | # resources declared in the library itself and none from the library's dependencies,
22 | # thereby reducing the size of the R class for that library
23 | android.nonTransitiveRClass=true
--------------------------------------------------------------------------------
/android/gradle/libs.versions.toml:
--------------------------------------------------------------------------------
1 | [versions]
2 | agp = "8.9.1"
3 | kotlin = "2.0.21"
4 | coreKtx = "1.10.1"
5 | junit = "4.13.2"
6 | junitVersion = "1.1.5"
7 | espressoCore = "3.5.1"
8 | lifecycleRuntimeKtx = "2.6.1"
9 | activityCompose = "1.8.0"
10 | composeBom = "2024.09.00"
11 |
12 | [libraries]
13 | androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
14 | junit = { group = "junit", name = "junit", version.ref = "junit" }
15 | androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
16 | androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
17 | androidx-lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycleRuntimeKtx" }
18 | androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activityCompose" }
19 | androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "composeBom" }
20 | androidx-ui = { group = "androidx.compose.ui", name = "ui" }
21 | androidx-ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" }
22 | androidx-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" }
23 | androidx-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" }
24 | androidx-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }
25 | androidx-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" }
26 | androidx-material3 = { group = "androidx.compose.material3", name = "material3" }
27 |
28 | [plugins]
29 | android-application = { id = "com.android.application", version.ref = "agp" }
30 | kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
31 | kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
32 |
33 |
--------------------------------------------------------------------------------
/android/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VPNclient/VPNclient-engine/d0e5480dfb9ff4395da74af024e60d4c3265a313/android/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Mar 28 09:51:22 ICT 2025
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
5 | zipStoreBase=GRADLE_USER_HOME
6 | zipStorePath=wrapper/dists
7 |
--------------------------------------------------------------------------------
/android/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | #
4 | # Copyright 2015 the original author or authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | ##
21 | ## Gradle start up script for UN*X
22 | ##
23 | ##############################################################################
24 |
25 | # Attempt to set APP_HOME
26 | # Resolve links: $0 may be a link
27 | PRG="$0"
28 | # Need this for relative symlinks.
29 | while [ -h "$PRG" ] ; do
30 | ls=`ls -ld "$PRG"`
31 | link=`expr "$ls" : '.*-> \(.*\)$'`
32 | if expr "$link" : '/.*' > /dev/null; then
33 | PRG="$link"
34 | else
35 | PRG=`dirname "$PRG"`"/$link"
36 | fi
37 | done
38 | SAVED="`pwd`"
39 | cd "`dirname \"$PRG\"`/" >/dev/null
40 | APP_HOME="`pwd -P`"
41 | cd "$SAVED" >/dev/null
42 |
43 | APP_NAME="Gradle"
44 | APP_BASE_NAME=`basename "$0"`
45 |
46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
48 |
49 | # Use the maximum available, or set MAX_FD != -1 to use that value.
50 | MAX_FD="maximum"
51 |
52 | warn () {
53 | echo "$*"
54 | }
55 |
56 | die () {
57 | echo
58 | echo "$*"
59 | echo
60 | exit 1
61 | }
62 |
63 | # OS specific support (must be 'true' or 'false').
64 | cygwin=false
65 | msys=false
66 | darwin=false
67 | nonstop=false
68 | case "`uname`" in
69 | CYGWIN* )
70 | cygwin=true
71 | ;;
72 | Darwin* )
73 | darwin=true
74 | ;;
75 | MINGW* )
76 | msys=true
77 | ;;
78 | NONSTOP* )
79 | nonstop=true
80 | ;;
81 | esac
82 |
83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
84 |
85 |
86 | # Determine the Java command to use to start the JVM.
87 | if [ -n "$JAVA_HOME" ] ; then
88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
89 | # IBM's JDK on AIX uses strange locations for the executables
90 | JAVACMD="$JAVA_HOME/jre/sh/java"
91 | else
92 | JAVACMD="$JAVA_HOME/bin/java"
93 | fi
94 | if [ ! -x "$JAVACMD" ] ; then
95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
96 |
97 | Please set the JAVA_HOME variable in your environment to match the
98 | location of your Java installation."
99 | fi
100 | else
101 | JAVACMD="java"
102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
103 |
104 | Please set the JAVA_HOME variable in your environment to match the
105 | location of your Java installation."
106 | fi
107 |
108 | # Increase the maximum file descriptors if we can.
109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
110 | MAX_FD_LIMIT=`ulimit -H -n`
111 | if [ $? -eq 0 ] ; then
112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
113 | MAX_FD="$MAX_FD_LIMIT"
114 | fi
115 | ulimit -n $MAX_FD
116 | if [ $? -ne 0 ] ; then
117 | warn "Could not set maximum file descriptor limit: $MAX_FD"
118 | fi
119 | else
120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
121 | fi
122 | fi
123 |
124 | # For Darwin, add options to specify how the application appears in the dock
125 | if $darwin; then
126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
127 | fi
128 |
129 | # For Cygwin or MSYS, switch paths to Windows format before running java
130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
133 |
134 | JAVACMD=`cygpath --unix "$JAVACMD"`
135 |
136 | # We build the pattern for arguments to be converted via cygpath
137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
138 | SEP=""
139 | for dir in $ROOTDIRSRAW ; do
140 | ROOTDIRS="$ROOTDIRS$SEP$dir"
141 | SEP="|"
142 | done
143 | OURCYGPATTERN="(^($ROOTDIRS))"
144 | # Add a user-defined pattern to the cygpath arguments
145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
147 | fi
148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
149 | i=0
150 | for arg in "$@" ; do
151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
153 |
154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
156 | else
157 | eval `echo args$i`="\"$arg\""
158 | fi
159 | i=`expr $i + 1`
160 | done
161 | case $i in
162 | 0) set -- ;;
163 | 1) set -- "$args0" ;;
164 | 2) set -- "$args0" "$args1" ;;
165 | 3) set -- "$args0" "$args1" "$args2" ;;
166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
172 | esac
173 | fi
174 |
175 | # Escape application args
176 | save () {
177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
178 | echo " "
179 | }
180 | APP_ARGS=`save "$@"`
181 |
182 | # Collect all arguments for the java command, following the shell quoting and substitution rules
183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
184 |
185 | exec "$JAVACMD" "$@"
186 |
--------------------------------------------------------------------------------
/android/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/android/settings.gradle:
--------------------------------------------------------------------------------
1 | pluginManagement {
2 | repositories {
3 | google {
4 | content {
5 | includeGroupByRegex("com\\.android.*")
6 | includeGroupByRegex("com\\.google.*")
7 | includeGroupByRegex("androidx.*")
8 | }
9 | }
10 | mavenCentral()
11 | gradlePluginPortal()
12 | }
13 | }
14 | dependencyResolutionManagement {
15 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
16 | repositories {
17 | google()
18 | mavenCentral()
19 | }
20 | }
21 |
22 | rootProject.name = "VPNclient Engine Android"
23 | include ':app'
24 |
--------------------------------------------------------------------------------
/include/vpnclient_engine.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 | #include
6 |
7 | namespace vpnclient_engine {
8 |
9 | enum class EngineType {
10 | VPNCLIENTXRAY, //VPNclient-xray-wrapper
11 | LIBXRAY // libxray
12 | SINGBOX, // sing-box
13 | WIREGUARD, // libwg
14 | OPENVPN,
15 |
16 | };
17 |
18 | enum class ProxyMode {
19 | NONE, // Прямое подключение
20 | VPNCLIENTDRIVER, // VPNclient-driver
21 | TUN2SOCKS, // tun2socks
22 | HEV_SOCKS5, // hev-socks5
23 | APPROXY // approxy
24 | };
25 |
26 | struct Config {
27 | EngineType engine = EngineType::VPNCLIENTXRAY;
28 | ProxyMode proxy = ProxyMode::VPNCLIENTDRIVER;
29 |
30 | // Пути к конфигурационным файлам
31 | std::string engine_config;
32 | std::string proxy_config;
33 |
34 | bool enable_logging = true;
35 | };
36 |
37 | class VPNClientEngine {
38 | public:
39 | using LogCallback = std::function;
40 |
41 | static std::unique_ptr create(const Config& config);
42 |
43 | virtual bool start() = 0;
44 | virtual void stop() = 0;
45 | virtual ~VPNClientEngine() = default;
46 |
47 | void set_log_callback(LogCallback callback);
48 | };
49 |
50 | } // namespace vpnclient_engine
--------------------------------------------------------------------------------
/ios/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NSExtension
6 |
7 | NSExtensionPointIdentifier
8 | com.apple.networkextension.packet-tunnel
9 | NSExtensionPrincipalClass
10 | $(PRODUCT_MODULE_NAME).PacketTunnelProvider
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/ios/PackageTunnelProvider.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | com.apple.developer.networking.networkextension
6 |
7 | app-proxy-provider
8 | content-filter-provider
9 | packet-tunnel-provider
10 |
11 | com.apple.security.application-groups
12 |
13 | group.nativemind.cntrlr
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/ios/PacketTunnelProvider.swift:
--------------------------------------------------------------------------------
1 | import NetworkExtension
2 |
3 | import os.log
4 |
5 |
6 | class PacketTunnelProvider: NEPacketTunnelProvider {
7 | private var isTunnelRunning = false
8 | private var hevTunnel: HevSocks5Tunnel?
9 |
10 | override func startTunnel(options: [String: NSObject]?, completionHandler: @escaping (Error?) -> Void) {
11 | os_log(.debug, "PacketTunnelProvider: Starting tunnel with options: %@", String(describing: options))
12 |
13 | // Check if the tunnel is already running
14 | if isTunnelRunning {
15 | os_log(.error, "PacketTunnelProvider: Tunnel is already running")
16 | completionHandler(NSError(domain: "PacketTunnelProvider", code: -1, userInfo: [NSLocalizedDescriptionKey: "Tunnel is already running"]))
17 | return
18 | }
19 | guard let protocolConfiguration = protocolConfiguration as? NETunnelProviderProtocol,
20 | let providerConfig = protocolConfiguration.providerConfiguration,
21 | let tunAddr = providerConfig["tunAddr"] as? String,
22 | let tunMask = providerConfig["tunMask"] as? String,
23 | let tunDns = providerConfig["tunDns"] as? String,
24 | let socks5Proxy = providerConfig["socks5Proxy"] as? String else {
25 | os_log(.error, "PacketTunnelProvider: Failed to load provider configuration")
26 | completionHandler(NSError(domain: "PacketTunnelProvider", code: -1, userInfo: [NSLocalizedDescriptionKey: "Missing provider configuration"]))
27 | return
28 |
29 | }
30 |
31 | os_log(.debug, "PacketTunnelProvider: Config - tunAddr: %@, tunMask: %@, tunDns: %@, socks5Proxy: %@", tunAddr, tunMask, tunDns, socks5Proxy)
32 |
33 | let proxyComponents = socks5Proxy.components(separatedBy: ":")
34 | guard proxyComponents.count == 2,
35 | let socks5Address = proxyComponents.first,
36 | let socks5Port = UInt16(proxyComponents.last ?? "1080") else {
37 | os_log(.error, "PacketTunnelProvider: Invalid SOCKS5 proxy format: %@", socks5Proxy)
38 | completionHandler(NSError(domain: "PacketTunnelProvider", code: -1, userInfo: [NSLocalizedDescriptionKey: "Invalid SOCKS5 proxy format"]))
39 | return
40 | }
41 |
42 | let settings = NEPacketTunnelNetworkSettings(tunnelRemoteAddress: socks5Address)
43 | settings.mtu = 1500
44 |
45 | let ipv4Settings = NEIPv4Settings(addresses: [tunAddr], subnetMasks: [tunMask])
46 | ipv4Settings.includedRoutes = [NEIPv4Route.default()]
47 | settings.ipv4Settings = ipv4Settings
48 |
49 | let dnsSettings = NEDNSSettings(servers: [tunDns])
50 | settings.dnsSettings = dnsSettings
51 |
52 | os_log(.debug, "PacketTunnelProvider: Applying tunnel network settings...")
53 | setTunnelNetworkSettings(settings) { error in
54 | if let error = error {
55 | os_log(.error, "PacketTunnelProvider: Failed to set tunnel network settings: %@", error.localizedDescription)
56 | completionHandler(error)
57 | return
58 | }
59 |
60 | os_log(.info, "PacketTunnelProvider: Tunnel network settings applied successfully")
61 |
62 | let config = """
63 | tunnel:
64 | name: tun0
65 | mtu: 1500
66 | log_level: 2
67 | dns:
68 | address: "\(tunDns)"
69 | port: 53
70 | socks5:
71 | address: "\(socks5Address)"
72 | port: \(socks5Port)
73 | """
74 |
75 | os_log(.debug, "PacketTunnelProvider: Starting hev-socks5-tunnel with config: %@", config)
76 | DispatchQueue.global().async {
77 | self.startHevSocks5Tunnel(withConfig: config)
78 | }
79 |
80 | // Set tunnel running flag
81 | self.isTunnelRunning = true
82 |
83 |
84 | self.monitorTunnelActivity()
85 | os_log(.debug, "PacketTunnelProvider: Calling completion handler with success")
86 | completionHandler(nil)
87 | }
88 | }
89 |
90 | func startHevSocks5Tunnel(withConfig config: String) {
91 | os_log(.debug, "PacketTunnelProvider: Starting hev-socks5-tunnel...")
92 |
93 | guard let configData = config.data(using: .utf8) else {
94 | os_log(.error, "PacketTunnelProvider: Failed to convert config to UTF-8 data")
95 | return
96 | }
97 | let configLen = UInt32(configData.count)
98 |
99 | self.hevTunnel = HevSocks5Tunnel(packetTunnel: self)
100 | guard let hevTunnel = self.hevTunnel else {
101 | os_log(.error, "Failed to initialize HevSocks5Tunnel")
102 | return
103 | }
104 |
105 | // Start the HevSocks5Tunnel
106 | let result = configData.withUnsafeBytes { configPtr in
107 | return hevTunnel.start(configPtr.baseAddress!, configLen)
108 | }
109 |
110 | if result != 0 {
111 | os_log(.error, "PacketTunnelProvider: Failed to start HevSocks5Tunnel. Result code: %d", result)
112 | return
113 | }
114 |
115 | os_log(.info, "PacketTunnelProvider: HevSocks5Tunnel started successfully")
116 |
117 | // Start handling packets
118 | self.handlePackets()
119 | }
120 |
121 |
122 |
123 | func handlePackets() {
124 | guard isTunnelRunning else {
125 | os_log(.error, "PacketTunnelProvider: Tunnel is not running, cannot handle packets")
126 | return
127 | }
128 |
129 | // Check if the packet flow is available
130 | guard let flow = self.packetFlow else {
131 | os_log(.error, "PacketTunnelProvider: Packet flow is nil")
132 | return
133 | }
134 |
135 | // Read packets from the packet flow
136 | flow.readPackets { [weak self] packets, protocols in
137 | guard let self = self else { return }
138 | // Check if the tunnel is still running before processing packets
139 | guard self.isTunnelRunning else {
140 | os_log(.info, "PacketTunnelProvider: Tunnel is stopping, ceasing packet handling")
141 | return
142 | }
143 |
144 | // Process each packet
145 | for (packet, protocol) in zip(packets, protocols) {
146 | os_log(.debug, "PacketTunnelProvider: Received packet of size %d, protocol: %@", packet.count, protocol.description)
147 | // Handle the packet using HevSocks5Tunnel (if needed)
148 | if let hevTunnel = self.hevTunnel {
149 | let result = packet.withUnsafeBytes { packetPtr in
150 | return hevTunnel.inputPacket(packetPtr.baseAddress!, UInt32(packet.count))
151 | }
152 | os_log(.debug, "PacketTunnelProvider:inputPacket result = %d", result)
153 | }
154 | }
155 |
156 | // Continue handling packets
157 | self.handlePackets()
158 | }
159 | }
160 |
161 | // Method for monitoring tunnel activity
162 | func monitorTunnelActivity() {
163 | // Create a global asynchronous queue
164 | DispatchQueue.global().async {
165 | // Continue monitoring as long as the tunnel is running
166 | while self.isTunnelRunning {
167 | // Pause for 1 second
168 | usleep(1000000)
169 | os_log(.debug, "PacketTunnelProvider: Tunnel still active, checking packets...")
170 | }
171 | }
172 | }
173 |
174 | // Method to stop the tunnel
175 | override func stopTunnel(with reason: NEProviderStopReason, completionHandler: @escaping () -> Void) {
176 | os_log(.debug, "PacketTunnelProvider: Stopping tunnel with reason: %@", reason.rawValue.description)
177 |
178 | // Stop the tunnel and close the flow
179 | isTunnelRunning = false
180 | hevTunnel?.stop()
181 | hevTunnel = nil
182 |
183 |
184 |
185 | // Call the completion handler to indicate that the tunnel has stopped
186 | completionHandler()
187 | }
188 | }
189 |
--------------------------------------------------------------------------------
/src/core/vpnclient_engine.cpp:
--------------------------------------------------------------------------------
1 | #include "vpnclient_engine.h"
2 | #include "engines/wireguard_engine.h"
3 | #include "engines/singbox_engine.h"
4 | #include "engines/xray_engine.h"
5 | #include "proxies/tun2socks.h"
6 | #include "proxies/hev_socks5.h"
7 | #include "proxies/approxy.h"
8 |
9 | namespace vpnclient_engine {
10 |
11 | std::unique_ptr VPNClientEngine::create(const Config& config) {
12 | std::unique_ptr client;
13 |
14 | // Создаем выбранный движок
15 | switch(config.engine) {
16 | case EngineType::VPNCLIENTXRAY:
17 | client = std::make_unique(config.engine_config);
18 | break;
19 | case EngineType::SINGBOX:
20 | client = std::make_unique(config.engine_config);
21 | break;
22 | case EngineType::LIBXRAY:
23 | client = std::make_unique(config.engine_config);
24 | break;
25 | case EngineType::WIREGUARD:
26 | client = std::make_unique(config.engine_config);
27 | break;
28 | case EngineType::OPENVPN:
29 | client = std::make_unique(config.engine_config);
30 | break;
31 | }
32 |
33 | // Настраиваем прокси (если нужно)
34 | if(config.proxy != ProxyMode::NONE) {
35 | switch(config.proxy) {
36 | case ProxyMode::VPNCLIENTDRIVER:
37 | client->set_proxy(std::make_unique(config.proxy_config));
38 | break;
39 | case ProxyMode::TUN2SOCKS:
40 | client->set_proxy(std::make_unique(config.proxy_config));
41 | break;
42 | case ProxyMode::HEV_SOCKS5:
43 | client->set_proxy(std::make_unique(config.proxy_config));
44 | break;
45 | case ProxyMode::APPROXY:
46 | client->set_proxy(std::make_unique(config.proxy_config));
47 | break;
48 | default: break;
49 | }
50 | }
51 |
52 | return client;
53 | }
54 |
55 | } // namespace
56 |
--------------------------------------------------------------------------------
/src/engines/singbox.cpp:
--------------------------------------------------------------------------------
1 | #include "engines/singbox_engine.h"
2 | #include
3 |
4 | namespace vpnclient_engine {
5 |
6 | class SingBox : public VPNClientEngine {
7 | singbox_instance* sb;
8 | LogCallback log_cb;
9 |
10 | public:
11 | SingBox(const std::string& config) {
12 | sb = singbox_new(config.c_str());
13 | }
14 |
15 | bool start() override {
16 | if(singbox_start(sb) {
17 | log("sing-box started successfully");
18 | return true;
19 | }
20 | return false;
21 | }
22 |
23 | void stop() override {
24 | singbox_stop(sb);
25 | log("sing-box stopped");
26 | }
27 |
28 | ~SingBox() {
29 | singbox_free(sb);
30 | }
31 |
32 | private:
33 | void log(const std::string& msg) {
34 | if(log_cb) log_cb("[sing-box] " + msg);
35 | }
36 | };
37 |
38 | } // namespace
--------------------------------------------------------------------------------
/src/engines/wireguard.cpp:
--------------------------------------------------------------------------------
1 | #include "engines/wireguard.h"
2 | #include
3 |
4 | namespace vpnclient_engine {
5 |
6 | class WireGuard : public VPNClientEngine {
7 | wg_handle h;
8 | LogCallback log_cb;
9 |
10 | public:
11 | WireGuard(const std::string& config) {
12 | h = wg_create(config.c_str());
13 | }
14 |
15 | bool start() override {
16 | if(wg_start(h) {
17 | log("WireGuard started successfully");
18 | return true;
19 | }
20 | return false;
21 | }
22 |
23 | void stop() override {
24 | wg_stop(h);
25 | log("WireGuard stopped");
26 | }
27 |
28 | ~WireGuard() {
29 | wg_destroy(h);
30 | }
31 |
32 | private:
33 | void log(const std::string& msg) {
34 | if(log_cb) log_cb("[WireGuard] " + msg);
35 | }
36 | };
37 |
38 | } // namespace
39 |
--------------------------------------------------------------------------------
/src/proxies/tun2socks.cpp:
--------------------------------------------------------------------------------
1 | #include "proxies/tun2socks.h"
2 | #include
3 |
4 | namespace vpnclient_engine {
5 |
6 | class Tun2SocksProxy {
7 | t2s_handle h;
8 | LogCallback log_cb;
9 |
10 | public:
11 | Tun2SocksProxy(const std::string& config) {
12 | h = t2s_create(config.c_str());
13 | }
14 |
15 | bool start() {
16 | if(t2s_start(h)) {
17 | log("tun2socks started");
18 | return true;
19 | }
20 | return false;
21 | }
22 |
23 | void stop() {
24 | t2s_stop(h);
25 | log("tun2socks stopped");
26 | }
27 |
28 | private:
29 | void log(const std::string& msg) {
30 | if(log_cb) log_cb("[tun2socks] " + msg);
31 | }
32 | };
33 |
34 | } // namespace
--------------------------------------------------------------------------------
/tests/test_vpnclient_engine.cpp:
--------------------------------------------------------------------------------
1 | #include "vpnclient_engine.h"
2 |
3 | int main() {
4 | using namespace vpnclient_engine;
5 |
6 | Config config;
7 | config.engine = EngineType::VPNCLIENTXRAY;
8 | config.engine_config = "xray.conf";
9 | config.proxy = ProxyMode::VPNCLIENTDRIVER;
10 | config.proxy_config = "driver.json";
11 |
12 | auto client = VPNClient::create(config);
13 |
14 | client->set_log_callback([](const std::string& msg) {
15 | std::cout << msg << std::endl;
16 | });
17 |
18 | if(client->start()) {
19 | std::cout << "VPN is running. Press Enter to stop..." << std::endl;
20 | std::cin.get();
21 | client->stop();
22 | }
23 |
24 | return 0;
25 | }1
26 |
--------------------------------------------------------------------------------
/vpnclient_engine.mmd:
--------------------------------------------------------------------------------
1 | graph TD
2 | A[VPNclient App] --> B[VPNclient Engine Flutter Plugin]
3 | B --> C[VPNclient Engine]
4 | C --> D[Drivers]
5 | C --> E[Cores]
6 |
7 | D --> F[VPNclient Driver]
8 | D --> G[tun2socks]
9 | D --> H[hev5-socks]
10 | D --> I[WinTun]
11 | D --> J[No driver]
12 |
13 | E --> K[VPNclient Xray Wrapper]
14 | E --> L[libXray]
15 | E --> M[sing-box]
16 | E --> N[WireGuard]
17 | E --> O[OpenVPN]
18 | E --> P[No core]
--------------------------------------------------------------------------------