├── .gitignore
├── LICENSE
├── README.md
├── build.gradle
├── config.gradle
├── dsl
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ └── kotlin
│ └── com
│ └── v2ray
│ └── android
│ └── protobuf
│ ├── dsl
│ ├── _Config.kt
│ ├── _Inbound.kt
│ ├── _Outbound.kt
│ ├── _Transport.kt
│ ├── app
│ │ ├── _Dns.kt
│ │ ├── _Log.kt
│ │ ├── _Proxyman.kt
│ │ └── _Router.kt
│ ├── common
│ │ ├── net
│ │ │ ├── _Destination.kt
│ │ │ ├── _IPOrDomain.kt
│ │ │ ├── _Network.kt
│ │ │ └── _Port.kt
│ │ └── protocol
│ │ │ ├── _ServerSpec.kt
│ │ │ └── _User.kt
│ ├── proxy
│ │ ├── _Blackhole.kt
│ │ ├── _Dokodemo.kt
│ │ ├── _Freedom.kt
│ │ ├── _Http.kt
│ │ ├── _Shadowsocks.kt
│ │ ├── _Socks.kt
│ │ └── vmess
│ │ │ ├── _Account.kt
│ │ │ ├── _Inbound.kt
│ │ │ └── _Outbound.kt
│ └── transport
│ │ ├── _Internet.kt
│ │ └── internet
│ │ ├── _Kcp.kt
│ │ ├── _Tcp.kt
│ │ ├── _Tls.kt
│ │ ├── _Websocket.kt
│ │ └── headers
│ │ ├── _Http.kt
│ │ ├── _Srtp.kt
│ │ ├── _Utp.kt
│ │ └── _Wechat.kt
│ └── extention
│ └── _TypedMessage.kt
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── model
├── .gitignore
├── build.gradle
└── src
│ └── main
│ ├── AndroidManifest.xml
│ └── proto
│ ├── LibV2Ray.proto
│ ├── LibV2RayConfigure.proto
│ ├── config.proto
│ └── v2ray.com
│ └── core
│ ├── app
│ ├── dispatcher
│ │ └── config.proto
│ ├── dns
│ │ └── config.proto
│ ├── log
│ │ └── config.proto
│ ├── policy
│ │ └── config.proto
│ ├── proxyman
│ │ └── config.proto
│ └── router
│ │ └── config.proto
│ ├── common
│ ├── log
│ │ └── log.proto
│ ├── net
│ │ ├── address.proto
│ │ ├── destination.proto
│ │ ├── network.proto
│ │ └── port.proto
│ ├── protocol
│ │ ├── command.proto
│ │ ├── headers.proto
│ │ ├── server_spec.proto
│ │ └── user.proto
│ └── serial
│ │ └── typed_message.proto
│ ├── proxy
│ ├── blackhole
│ │ └── config.proto
│ ├── dokodemo
│ │ └── config.proto
│ ├── freedom
│ │ └── config.proto
│ ├── http
│ │ └── config.proto
│ ├── shadowsocks
│ │ └── config.proto
│ ├── socks
│ │ └── config.proto
│ └── vmess
│ │ ├── account.proto
│ │ ├── inbound
│ │ └── config.proto
│ │ └── outbound
│ │ └── config.proto
│ └── transport
│ ├── config.proto
│ └── internet
│ ├── config.proto
│ ├── headers
│ ├── http
│ │ └── config.proto
│ ├── noop
│ │ └── config.proto
│ ├── srtp
│ │ └── config.proto
│ ├── utp
│ │ └── config.proto
│ └── wechat
│ │ └── config.proto
│ ├── kcp
│ └── config.proto
│ ├── tcp
│ └── config.proto
│ ├── tls
│ └── config.proto
│ └── websocket
│ └── config.proto
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea
5 | .DS_Store
6 | /build
7 | /captures
8 | *.apk
9 | signing.properties
10 | /gradle.properties
11 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 | V2Ray-Protobuf-Android: V2Ray Protobuf-lite models and DSL builder for them
635 | Copyright (C) 2018 Liberal Boy
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # V2Ray-Protobuf-Android
2 | V2Ray Protobuf-lite models and DSL builder for them
3 |
4 | ## Import
5 | Models only
6 | ```Groovy
7 | implementation 'com.v2ray.android.protobuf:model:x.y.z'
8 | ```
9 | Models and DSL builder
10 | ```Groovy
11 | implementation 'com.v2ray.android.protobuf:dsl:x.y.z'
12 | ```
13 |
14 | ## Example
15 | ```Kotlin
16 | fun main(args: Array) {
17 | val config = config {
18 | addInbound {
19 | receiver {
20 | portRange(10800)
21 | listen = ip("127.0.0.1")
22 | }
23 | http {}
24 | }
25 | addInbound {
26 | receiver {
27 | portRange(10808)
28 | listen = ip("127.0.0.1")
29 | }
30 | socks {
31 | udpEnabled = true
32 | address = ip("127.0.0.1")
33 | }
34 | }
35 | addOutbound {
36 | vmess {
37 | addReceiver {
38 | address = domain("example.com")
39 | port = 443
40 | addUser {
41 | level = 1
42 | accountVmess {
43 | id = "490f75d7-0063-485a-a1bd-4f264f04a3e5"
44 | alterId = 32
45 | securityType = SecurityType.NONE
46 | }
47 | }
48 | }
49 | }
50 | sender {
51 | streamSettings {
52 | protocol = TransportProtocol.WebSocket
53 | addTransportSettings {
54 | protocol = TransportProtocol.WebSocket
55 | websocketSettings {
56 | path = "v2ray"
57 | }
58 | }
59 | securityType = com.v2ray.core.transport.internet.tls.Config.getDefaultInstance().messageName
60 | addTlsSettings { }
61 | }
62 | multiplexSettings {
63 | enabled = true
64 | concurrency = 8
65 | }
66 | }
67 | }
68 | addOutbound {
69 | tag = "direct"
70 | freedom {}
71 | }
72 | dns {
73 | addNameServers(ip("8.8.8.8"))
74 | }
75 | router {
76 | domainStrategy = Config.DomainStrategy.IpIfNonMatch
77 | addRule {
78 | addDomain("www.ipip.net")
79 | tag = "direct"
80 | }
81 | }
82 | log {
83 | errorLogLevel = Severity.Debug
84 | }
85 | addApp(InboundConfig.getDefaultInstance().toTypedMessage())
86 | addApp(OutboundConfig.getDefaultInstance().toTypedMessage())
87 | addApp(com.v2ray.core.app.dispatcher.Config.getDefaultInstance().toTypedMessage())
88 | }
89 |
90 | config.writeTo(File("config.pb").outputStream())
91 | }
92 | ```
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | apply from: 'config.gradle'
5 |
6 | repositories {
7 | google()
8 | jcenter()
9 | }
10 | dependencies {
11 | classpath 'com.android.tools.build:gradle:3.0.1'
12 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$rootProject.ext.dependencies.kotlinVersion"
13 |
14 | classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.0"
15 | classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
16 |
17 | // NOTE: Do not place your application dependencies here; they belong
18 | // in the individual module build.gradle files
19 | }
20 | }
21 |
22 | allprojects {
23 | repositories {
24 | google()
25 | jcenter()
26 | }
27 | }
28 |
29 | task clean(type: Delete) {
30 | delete rootProject.buildDir
31 | }
32 | subprojects { subProject ->
33 | afterEvaluate {
34 | if (subProject.plugins.hasPlugin("kotlin") && subProject.plugins.hasPlugin("java-library")) {
35 | subProject.kotlin.copyClassesToJavaOutput = true
36 | subProject.jar.duplicatesStrategy = DuplicatesStrategy.EXCLUDE
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/config.gradle:
--------------------------------------------------------------------------------
1 | ext {
2 | android = [
3 | buildToolsVer: '27.0.3',
4 | compileSdkVer: '27',
5 | targetSdkVer : '27',
6 | versionCode : '2',
7 | versionName : '0.1.1'
8 | ]
9 | dependencies = [
10 | ankoVersion : '0.10.3',
11 | kotlinVersion : '1.2.21',
12 | supportLibVersion: '27.0.2',
13 | firebaseVersion : '11.8.0',
14 | protobuf_version : '3.0.0'
15 | ]
16 | }
--------------------------------------------------------------------------------
/dsl/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/dsl/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'com.github.dcendents.android-maven'
4 | apply plugin: 'com.jfrog.bintray'
5 |
6 | def libraries = rootProject.ext.dependencies
7 |
8 | android {
9 | compileSdkVersion Integer.parseInt("$rootProject.android.compileSdkVer")
10 |
11 | defaultConfig {
12 | minSdkVersion 15
13 | targetSdkVersion Integer.parseInt("$rootProject.android.targetSdkVer")
14 | versionCode Integer.parseInt("$rootProject.android.versionCode")
15 | versionName "$rootProject.android.versionName"
16 |
17 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
18 |
19 | }
20 |
21 | buildTypes {
22 | release {
23 | minifyEnabled false
24 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
25 | }
26 | }
27 |
28 | sourceSets {
29 | main.java.srcDirs += 'src/main/kotlin'
30 | }
31 | }
32 |
33 | dependencies {
34 | implementation fileTree(dir: 'libs', include: ['*.jar'])
35 | implementation project(':model')
36 |
37 | implementation "org.jetbrains.kotlin:kotlin-stdlib:$libraries.kotlinVersion"
38 | }
39 |
40 | buildscript {
41 | repositories {
42 | jcenter()
43 | }
44 | dependencies {
45 | classpath "org.jetbrains.kotlin:kotlin-android-extensions:$rootProject.ext.dependencies.kotlinVersion"
46 | }
47 | }
48 |
49 | version = "$rootProject.android.versionName"
50 | def siteUrl = 'https://github.com/V2Ray-Android/V2Ray-Protobuf-Android'
51 | def gitUrl = 'https://github.com/V2Ray-Android/V2Ray-Protobuf-Android.git'
52 | group = "com.v2ray.android.protobuf"
53 | install {
54 | repositories.mavenInstaller {
55 | // This generates POM.xml with proper parameters
56 | pom.project {
57 | artifactId "dsl"
58 | packaging 'aar'
59 | // Add your description here
60 | name 'DSL builder for V2Ray Protobuf-lite models'
61 | url siteUrl
62 | // Set your license
63 | licenses {
64 | license {
65 | name 'GNU GENERAL PUBLIC LICENSE, Version 3'
66 | url 'https://www.gnu.org/licenses/gpl-3.0.txt'
67 | }
68 | }
69 | developers {
70 | developer {
71 | id 'liberal-boy'
72 | name 'Liberal Boy'
73 | email 'liberal-boy@protonmail.com'
74 | }
75 | }
76 | scm {
77 | connection gitUrl
78 | developerConnection gitUrl
79 | url siteUrl
80 | }
81 | }
82 | }
83 | }
84 | task sourcesJar(type: Jar) {
85 | from android.sourceSets.main.java.srcDirs
86 | classifier = 'sources'
87 | }
88 | task javadoc(type: Javadoc) {
89 | source = android.sourceSets.main.java.srcDirs
90 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
91 | }
92 | task javadocJar(type: Jar, dependsOn: javadoc) {
93 | classifier = 'javadoc'
94 | from javadoc.destinationDir
95 | }
96 | artifacts {
97 | // archives javadocJar
98 | archives sourcesJar
99 | }
100 | Properties properties = new Properties()
101 | properties.load(project.rootProject.file('local.properties').newDataInputStream())
102 | bintray {
103 | user = properties.getProperty("bintray.user")
104 | key = properties.getProperty("bintray.apikey")
105 | configurations = ['archives']
106 | pkg {
107 | repo = "maven"
108 | name = "V2Ray-Protobuf-Android"
109 | websiteUrl = siteUrl
110 | vcsUrl = gitUrl
111 | licenses = ["GPL-3.0"]
112 | publish = true
113 | }
114 | }
115 |
--------------------------------------------------------------------------------
/dsl/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
22 |
--------------------------------------------------------------------------------
/dsl/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/dsl/src/main/kotlin/com/v2ray/android/protobuf/dsl/_Config.kt:
--------------------------------------------------------------------------------
1 | package com.v2ray.android.protobuf.dsl
2 |
3 | import com.v2ray.android.protobuf.dsl.app.dnsConfig
4 | import com.v2ray.android.protobuf.dsl.app.logConfig
5 | import com.v2ray.android.protobuf.dsl.app.routerConfig
6 | import com.v2ray.android.protobuf.extention.toTypedMessage
7 | import com.v2ray.core.Config
8 | import com.v2ray.core.InboundHandlerConfig
9 | import com.v2ray.core.OutboundHandlerConfig
10 |
11 | fun config(init: Config.Builder.() -> Unit): Config = Config.newBuilder().apply(init).build()
12 |
13 | fun inboundHandlerConfig(init: InboundHandlerConfig.Builder.() -> Unit): InboundHandlerConfig = InboundHandlerConfig.newBuilder().apply(init).build()
14 |
15 | fun Config.Builder.addInbound(init: InboundHandlerConfig.Builder.() -> Unit) {
16 | addInbound(inboundHandlerConfig(init))
17 | }
18 |
19 | fun outboundHandlerConfig(init: OutboundHandlerConfig.Builder.() -> Unit): OutboundHandlerConfig = OutboundHandlerConfig.newBuilder().apply(init).build()
20 |
21 | fun Config.Builder.addOutbound(init: OutboundHandlerConfig.Builder.() -> Unit) {
22 | addOutbound(outboundHandlerConfig(init))
23 | }
24 |
25 | fun Config.Builder.log(init: com.v2ray.core.app.log.Config.Builder.() -> Unit) {
26 | addApp(logConfig(init).toTypedMessage())
27 | }
28 |
29 | fun Config.Builder.dns(init: com.v2ray.core.app.dns.Config.Builder.() -> Unit) {
30 | addApp(dnsConfig(init).toTypedMessage())
31 | }
32 |
33 | fun Config.Builder.router(init: com.v2ray.core.app.router.Config.Builder.() -> Unit) {
34 | addApp(routerConfig(init).toTypedMessage())
35 | }
36 |
37 | fun Config.Builder.transport(init: com.v2ray.core.transport.Config.Builder.() -> Unit) {
38 | transport = transportConfig(init)
39 | }
40 |
--------------------------------------------------------------------------------
/dsl/src/main/kotlin/com/v2ray/android/protobuf/dsl/_Inbound.kt:
--------------------------------------------------------------------------------
1 | package com.v2ray.android.protobuf.dsl
2 |
3 | import com.v2ray.android.protobuf.dsl.app.receiverConfig
4 | import com.v2ray.android.protobuf.dsl.proxy.dokodemoConfig
5 | import com.v2ray.android.protobuf.dsl.proxy.httpServerConfig
6 | import com.v2ray.android.protobuf.dsl.proxy.shadowsocksServerConfig
7 | import com.v2ray.android.protobuf.dsl.proxy.socksServerConfig
8 | import com.v2ray.android.protobuf.dsl.proxy.vmess.vmessServerConfig
9 | import com.v2ray.android.protobuf.extention.toTypedMessage
10 | import com.v2ray.core.InboundHandlerConfig
11 | import com.v2ray.core.app.proxyman.ReceiverConfig
12 |
13 | fun InboundHandlerConfig.Builder.receiver(init: ReceiverConfig.Builder.() -> Unit) {
14 | receiverSettings = receiverConfig(init).toTypedMessage()
15 | }
16 |
17 | fun InboundHandlerConfig.Builder.http(init: com.v2ray.core.proxy.http.ServerConfig.Builder.() -> Unit) {
18 | proxySettings = httpServerConfig(init).toTypedMessage()
19 | }
20 |
21 | fun InboundHandlerConfig.Builder.socks(init: com.v2ray.core.proxy.socks.ServerConfig.Builder.() -> Unit) {
22 | proxySettings = socksServerConfig(init).toTypedMessage()
23 | }
24 |
25 | fun InboundHandlerConfig.Builder.vmess(init: com.v2ray.core.proxy.vmess.inbound.Config.Builder.() -> Unit) {
26 | proxySettings = vmessServerConfig(init).toTypedMessage()
27 | }
28 |
29 | fun InboundHandlerConfig.Builder.shadowsocks(init: com.v2ray.core.proxy.shadowsocks.ServerConfig.Builder.() -> Unit) {
30 | proxySettings = shadowsocksServerConfig(init).toTypedMessage()
31 | }
32 |
33 | fun InboundHandlerConfig.Builder.dokodemo(init: com.v2ray.core.proxy.dokodemo.Config.Builder.() -> Unit) {
34 | proxySettings = dokodemoConfig(init).toTypedMessage()
35 | }
--------------------------------------------------------------------------------
/dsl/src/main/kotlin/com/v2ray/android/protobuf/dsl/_Outbound.kt:
--------------------------------------------------------------------------------
1 | package com.v2ray.android.protobuf.dsl
2 |
3 | import com.v2ray.android.protobuf.dsl.app.senderConfig
4 | import com.v2ray.android.protobuf.dsl.proxy.blackholeConfig
5 | import com.v2ray.android.protobuf.dsl.proxy.freedomConfig
6 | import com.v2ray.android.protobuf.dsl.proxy.shadowsocksClientConfig
7 | import com.v2ray.android.protobuf.dsl.proxy.socksClientConfig
8 | import com.v2ray.android.protobuf.dsl.proxy.vmess.vmessClientConfig
9 | import com.v2ray.android.protobuf.extention.toTypedMessage
10 | import com.v2ray.core.OutboundHandlerConfig
11 | import com.v2ray.core.app.proxyman.SenderConfig
12 |
13 | fun OutboundHandlerConfig.Builder.sender(init: SenderConfig.Builder.() -> Unit) {
14 | senderSettings = senderConfig(init).toTypedMessage()
15 | }
16 |
17 | fun OutboundHandlerConfig.Builder.blackhole(init: com.v2ray.core.proxy.blackhole.Config.Builder.() -> Unit) {
18 | proxySettings = blackholeConfig(init).toTypedMessage()
19 | }
20 |
21 | fun OutboundHandlerConfig.Builder.freedom(init: com.v2ray.core.proxy.freedom.Config.Builder.() -> Unit) {
22 | proxySettings = freedomConfig(init).toTypedMessage()
23 | }
24 |
25 | fun OutboundHandlerConfig.Builder.shadowsocks(init: com.v2ray.core.proxy.shadowsocks.ClientConfig.Builder.() -> Unit) {
26 | proxySettings = shadowsocksClientConfig(init).toTypedMessage()
27 | }
28 |
29 | fun OutboundHandlerConfig.Builder.socks(init: com.v2ray.core.proxy.socks.ClientConfig.Builder.() -> Unit) {
30 | proxySettings = socksClientConfig(init).toTypedMessage()
31 | }
32 |
33 | fun OutboundHandlerConfig.Builder.vmess(init: com.v2ray.core.proxy.vmess.outbound.Config.Builder.() -> Unit) {
34 | proxySettings = vmessClientConfig(init).toTypedMessage()
35 | }
36 |
--------------------------------------------------------------------------------
/dsl/src/main/kotlin/com/v2ray/android/protobuf/dsl/_Transport.kt:
--------------------------------------------------------------------------------
1 | package com.v2ray.android.protobuf.dsl
2 |
3 | import com.v2ray.core.transport.Config
4 | import com.v2ray.core.transport.internet.TransportConfig
5 |
6 | fun transportConfig(init: Config.Builder.() -> Unit): Config = Config.newBuilder().apply(init).build()
7 |
8 | fun Config.Builder.addTransportSettings(init: TransportConfig.Builder.() -> Unit) {
9 | addTransportSettings(com.v2ray.android.protobuf.dsl.transport.transportConfig(init))
10 | }
11 |
--------------------------------------------------------------------------------
/dsl/src/main/kotlin/com/v2ray/android/protobuf/dsl/app/_Dns.kt:
--------------------------------------------------------------------------------
1 | package com.v2ray.android.protobuf.dsl.app
2 |
3 | import com.v2ray.android.protobuf.dsl.common.net.endpoint
4 | import com.v2ray.core.app.dns.Config
5 | import com.v2ray.core.common.net.IPOrDomain
6 | import com.v2ray.core.common.net.Network
7 |
8 | fun dnsConfig(init: Config.Builder.() -> Unit): Config = Config.newBuilder().apply(init).build()
9 |
10 | fun Config.Builder.addNameServers(address: IPOrDomain, port: Int = 53, network: Network = Network.UDP) {
11 | addNameServers(endpoint(network, address, port))
12 | }
13 |
--------------------------------------------------------------------------------
/dsl/src/main/kotlin/com/v2ray/android/protobuf/dsl/app/_Log.kt:
--------------------------------------------------------------------------------
1 | package com.v2ray.android.protobuf.dsl.app
2 |
3 | import com.v2ray.core.app.log.Config
4 |
5 | fun logConfig(init: Config.Builder.() -> Unit): Config = Config.newBuilder().apply(init).build()
6 |
--------------------------------------------------------------------------------
/dsl/src/main/kotlin/com/v2ray/android/protobuf/dsl/app/_Proxyman.kt:
--------------------------------------------------------------------------------
1 | package com.v2ray.android.protobuf.dsl.app
2 |
3 | import com.v2ray.android.protobuf.dsl.common.net.iPOrDomain
4 | import com.v2ray.android.protobuf.dsl.transport.proxyConfig
5 | import com.v2ray.android.protobuf.dsl.transport.streamConfig
6 | import com.v2ray.core.app.proxyman.AllocationStrategy
7 | import com.v2ray.core.app.proxyman.MultiplexingConfig
8 | import com.v2ray.core.app.proxyman.ReceiverConfig
9 | import com.v2ray.core.app.proxyman.SenderConfig
10 | import com.v2ray.core.common.net.IPOrDomain
11 | import com.v2ray.core.common.net.PortRange
12 | import com.v2ray.core.transport.internet.ProxyConfig
13 | import com.v2ray.core.transport.internet.StreamConfig
14 |
15 | fun receiverConfig(init: ReceiverConfig.Builder.() -> Unit): ReceiverConfig = ReceiverConfig.newBuilder().apply(init).build()
16 |
17 | fun ReceiverConfig.Builder.portRange(init: PortRange.Builder.() -> Unit) {
18 | portRange = com.v2ray.android.protobuf.dsl.common.net.portRange(init)
19 | }
20 |
21 | fun ReceiverConfig.Builder.portRange(from: Int, to: Int = from) {
22 | portRange = com.v2ray.android.protobuf.dsl.common.net.portRange(from, to)
23 | }
24 |
25 | fun ReceiverConfig.Builder.listen(init: IPOrDomain.Builder.() -> Unit) {
26 | listen = iPOrDomain(init)
27 | }
28 |
29 | fun allocationStrategy(init: AllocationStrategy.Builder.() -> Unit): AllocationStrategy = AllocationStrategy.newBuilder().apply(init).build()
30 |
31 | fun ReceiverConfig.Builder.allocationStrategy(init: AllocationStrategy.Builder.() -> Unit) {
32 | allocationStrategy = com.v2ray.android.protobuf.dsl.app.allocationStrategy(init)
33 | }
34 |
35 | fun ReceiverConfig.Builder.streamSettings(init: StreamConfig.Builder.() -> Unit) {
36 | streamSettings = streamConfig(init)
37 | }
38 |
39 | fun senderConfig(init: SenderConfig.Builder.() -> Unit): SenderConfig = SenderConfig.newBuilder().apply(init).build()
40 |
41 | fun SenderConfig.Builder.via(init: IPOrDomain.Builder.() -> Unit) {
42 | via = iPOrDomain(init)
43 | }
44 |
45 | fun SenderConfig.Builder.streamSettings(init: StreamConfig.Builder.() -> Unit) {
46 | streamSettings = streamConfig(init)
47 | }
48 |
49 | fun SenderConfig.Builder.proxySettings(init: ProxyConfig.Builder.() -> Unit) {
50 | proxySettings = proxyConfig(init)
51 | }
52 |
53 | fun multiplexingConfig(init: MultiplexingConfig.Builder.() -> Unit): MultiplexingConfig = MultiplexingConfig.newBuilder().apply(init).build()
54 |
55 | fun SenderConfig.Builder.multiplexSettings(init: MultiplexingConfig.Builder.() -> Unit) {
56 | multiplexSettings = multiplexingConfig(init)
57 | }
58 |
--------------------------------------------------------------------------------
/dsl/src/main/kotlin/com/v2ray/android/protobuf/dsl/app/_Router.kt:
--------------------------------------------------------------------------------
1 | package com.v2ray.android.protobuf.dsl.app
2 |
3 | import com.google.protobuf.ByteString
4 | import com.v2ray.core.app.router.CIDR
5 | import com.v2ray.core.app.router.Config
6 | import com.v2ray.core.app.router.Domain
7 | import com.v2ray.core.app.router.RoutingRule
8 | import com.v2ray.core.common.net.Network
9 | import com.v2ray.core.common.net.NetworkList
10 |
11 | fun routerConfig(init: Config.Builder.() -> Unit): Config = Config.newBuilder().apply(init).build()
12 |
13 | fun routingRule(init: RoutingRule.Builder.() -> Unit): RoutingRule = RoutingRule.newBuilder().apply(init).build()
14 |
15 | fun Config.Builder.addRule(init: RoutingRule.Builder.() -> Unit) {
16 | addRule(routingRule(init))
17 | }
18 |
19 |
20 | fun domain(init: Domain.Builder.() -> Unit): Domain = Domain.newBuilder().apply(init).build()
21 |
22 | fun domain(domain: String, type: Domain.Type) = domain {
23 | setType(type)
24 | value = domain
25 | }
26 |
27 | fun RoutingRule.Builder.addDomain(init: Domain.Builder.() -> Unit) {
28 | addDomain(domain(init))
29 | }
30 |
31 | fun RoutingRule.Builder.addDomain(domain: String, type: Domain.Type = Domain.Type.Plain) {
32 | addDomain(domain(domain, type))
33 | }
34 |
35 |
36 | fun cidr(init: CIDR.Builder.() -> Unit): CIDR = CIDR.newBuilder().apply(init).build()
37 |
38 | fun cidr(ip: ByteArray, prefix: Int) = cidr {
39 | setIp(ByteString.copyFrom(ip))
40 | setPrefix(prefix)
41 | }
42 |
43 | fun RoutingRule.Builder.addCidr(init: CIDR.Builder.() -> Unit) {
44 | addCidr(cidr(init))
45 | }
46 |
47 | fun RoutingRule.Builder.addCidr(ip: ByteArray, prefix: Int) {
48 | addCidr(cidr(ip, prefix))
49 | }
50 |
51 | fun RoutingRule.Builder.addSourceCidr(init: CIDR.Builder.() -> Unit) {
52 | addSourceCidr(cidr(init))
53 | }
54 |
55 | fun RoutingRule.Builder.addSourceCidr(ip: ByteArray, prefix: Int) {
56 | addSourceCidr(cidr(ip, prefix))
57 | }
58 |
59 | fun RoutingRule.Builder.networkList(init: NetworkList.Builder.() -> Unit) {
60 | networkList = com.v2ray.android.protobuf.dsl.common.net.networkList(init)
61 | }
62 |
63 | fun RoutingRule.Builder.networkList(vararg network: Network) {
64 | networkList = com.v2ray.android.protobuf.dsl.common.net.networkList(*network)
65 | }
66 |
67 | fun RoutingRule.Builder.portRange(from: Int, to: Int = from) {
68 | portRange = com.v2ray.android.protobuf.dsl.common.net.portRange(from, to)
69 | }
70 |
--------------------------------------------------------------------------------
/dsl/src/main/kotlin/com/v2ray/android/protobuf/dsl/common/net/_Destination.kt:
--------------------------------------------------------------------------------
1 | package com.v2ray.android.protobuf.dsl.common.net
2 |
3 | import com.v2ray.core.common.net.Endpoint
4 | import com.v2ray.core.common.net.IPOrDomain
5 | import com.v2ray.core.common.net.Network
6 |
7 | fun endpoint(init: Endpoint.Builder.() -> Unit): Endpoint = Endpoint.newBuilder().apply(init).build()
8 |
9 | fun endpoint(network: Network, address: IPOrDomain, port: Int): Endpoint = endpoint {
10 | setNetwork(network)
11 | setAddress(address)
12 | setPort(port)
13 | }
14 |
--------------------------------------------------------------------------------
/dsl/src/main/kotlin/com/v2ray/android/protobuf/dsl/common/net/_IPOrDomain.kt:
--------------------------------------------------------------------------------
1 | package com.v2ray.android.protobuf.dsl.common.net
2 |
3 | import com.google.protobuf.ByteString
4 | import com.v2ray.core.common.net.IPOrDomain
5 | import java.net.InetAddress
6 |
7 | fun iPOrDomain(init: IPOrDomain.Builder.() -> Unit): IPOrDomain = IPOrDomain.newBuilder().apply(init).build()
8 |
9 | fun ip(ip: ByteArray): IPOrDomain = iPOrDomain { setIp(ByteString.copyFrom(ip)) }
10 |
11 | fun ip(ip: String): IPOrDomain = ip(InetAddress.getByName(ip).address)
12 |
13 | fun domain(domain: String): IPOrDomain = iPOrDomain { setDomain(domain) }
--------------------------------------------------------------------------------
/dsl/src/main/kotlin/com/v2ray/android/protobuf/dsl/common/net/_Network.kt:
--------------------------------------------------------------------------------
1 | package com.v2ray.android.protobuf.dsl.common.net
2 |
3 | import com.v2ray.core.common.net.Network
4 | import com.v2ray.core.common.net.NetworkList
5 |
6 | fun networkList(init: NetworkList.Builder.() -> Unit): NetworkList = NetworkList.newBuilder().apply(init).build()
7 |
8 | fun networkList(vararg network: Network): NetworkList = networkList { network.forEach { addNetwork(it) } }
9 |
--------------------------------------------------------------------------------
/dsl/src/main/kotlin/com/v2ray/android/protobuf/dsl/common/net/_Port.kt:
--------------------------------------------------------------------------------
1 | package com.v2ray.android.protobuf.dsl.common.net
2 |
3 | import com.v2ray.core.common.net.PortRange
4 |
5 | fun portRange(init: PortRange.Builder.() -> Unit): PortRange = PortRange.newBuilder().apply(init).build()
6 |
7 | fun portRange(from: Int, to: Int = from): PortRange = portRange {
8 | setFrom(from)
9 | setTo(to)
10 | }
--------------------------------------------------------------------------------
/dsl/src/main/kotlin/com/v2ray/android/protobuf/dsl/common/protocol/_ServerSpec.kt:
--------------------------------------------------------------------------------
1 | package com.v2ray.android.protobuf.dsl.common.protocol
2 |
3 | import com.v2ray.android.protobuf.dsl.common.net.iPOrDomain
4 | import com.v2ray.core.common.net.IPOrDomain
5 | import com.v2ray.core.common.protocol.ServerEndpoint
6 | import com.v2ray.core.common.protocol.User
7 |
8 | fun serverEndpoint(init: ServerEndpoint.Builder.() -> Unit): ServerEndpoint = ServerEndpoint.newBuilder().apply(init).build()
9 |
10 | fun serverEndpoint(address: IPOrDomain, port: Int, init: (User.Builder.() -> Unit)? = null): ServerEndpoint = serverEndpoint {
11 | setAddress(address)
12 | setPort(port)
13 | if (init != null) addUser(init)
14 | }
15 |
16 | fun ServerEndpoint.Builder.address(init: IPOrDomain.Builder.() -> Unit) {
17 | address = iPOrDomain(init)
18 | }
19 |
20 | fun ServerEndpoint.Builder.addUser(init: User.Builder.() -> Unit) {
21 | addUser(user(init))
22 | }
23 |
--------------------------------------------------------------------------------
/dsl/src/main/kotlin/com/v2ray/android/protobuf/dsl/common/protocol/_User.kt:
--------------------------------------------------------------------------------
1 | package com.v2ray.android.protobuf.dsl.common.protocol
2 |
3 | import com.v2ray.android.protobuf.dsl.proxy.shadowsocksAccount
4 | import com.v2ray.android.protobuf.dsl.proxy.socksAccount
5 | import com.v2ray.android.protobuf.dsl.proxy.vmess.vmesssAccount
6 | import com.v2ray.android.protobuf.extention.toTypedMessage
7 | import com.v2ray.core.common.protocol.User
8 |
9 | fun user(init: User.Builder.() -> Unit): User = User.newBuilder().apply(init).build()
10 |
11 | fun User.Builder.accountVmess(init: com.v2ray.core.proxy.vmess.Account.Builder.() -> Unit) {
12 | account = vmesssAccount(init).toTypedMessage()
13 | }
14 |
15 | fun User.Builder.accountShadowsocks(init: com.v2ray.core.proxy.shadowsocks.Account.Builder.() -> Unit) {
16 | account = shadowsocksAccount(init).toTypedMessage()
17 | }
18 |
19 | fun User.Builder.accountSocks(init: com.v2ray.core.proxy.socks.Account.Builder.() -> Unit) {
20 | account = socksAccount(init).toTypedMessage()
21 | }
22 |
23 | fun User.Builder.accountSocks(user: String, pass: String) {
24 | account = socksAccount(user, pass).toTypedMessage()
25 | }
--------------------------------------------------------------------------------
/dsl/src/main/kotlin/com/v2ray/android/protobuf/dsl/proxy/_Blackhole.kt:
--------------------------------------------------------------------------------
1 | package com.v2ray.android.protobuf.dsl.proxy
2 |
3 | import com.v2ray.android.protobuf.extention.messageName
4 | import com.v2ray.android.protobuf.extention.toTypedMessage
5 | import com.v2ray.core.proxy.blackhole.Config
6 | import com.v2ray.core.proxy.blackhole.HTTPResponse
7 | import com.v2ray.core.proxy.blackhole.NoneResponse
8 |
9 | fun blackholeConfig(init: Config.Builder.() -> Unit): Config = Config.newBuilder().apply(init).build()
10 |
11 | enum class ResponseType {
12 | NONE,
13 | HTTP
14 | }
15 |
16 | var Config.Builder.responseType: ResponseType
17 | get() = if (response.messageName == HTTPResponse.getDefaultInstance().messageName) ResponseType.HTTP
18 | else ResponseType.NONE
19 | set(value) = when (value) {
20 | ResponseType.HTTP -> response = HTTPResponse.getDefaultInstance().toTypedMessage()
21 | ResponseType.NONE -> response = NoneResponse.getDefaultInstance().toTypedMessage()
22 | }
23 |
--------------------------------------------------------------------------------
/dsl/src/main/kotlin/com/v2ray/android/protobuf/dsl/proxy/_Dokodemo.kt:
--------------------------------------------------------------------------------
1 | package com.v2ray.android.protobuf.dsl.proxy
2 |
3 | import com.v2ray.android.protobuf.dsl.common.net.iPOrDomain
4 | import com.v2ray.core.common.net.IPOrDomain
5 | import com.v2ray.core.common.net.Network
6 | import com.v2ray.core.proxy.dokodemo.Config
7 |
8 | fun dokodemoConfig(init: Config.Builder.() -> Unit): Config = Config.newBuilder().apply(init).build()
9 |
10 | fun Config.Builder.address(init: IPOrDomain.Builder.() -> Unit) {
11 | address = iPOrDomain(init)
12 | }
13 |
14 | fun Config.Builder.networkList(vararg network: Network) {
15 | networkList = com.v2ray.android.protobuf.dsl.common.net.networkList(*network)
16 | }
17 |
--------------------------------------------------------------------------------
/dsl/src/main/kotlin/com/v2ray/android/protobuf/dsl/proxy/_Freedom.kt:
--------------------------------------------------------------------------------
1 | package com.v2ray.android.protobuf.dsl.proxy
2 |
3 | import com.v2ray.core.common.protocol.ServerEndpoint
4 | import com.v2ray.core.proxy.freedom.Config
5 | import com.v2ray.core.proxy.freedom.DestinationOverride
6 |
7 | fun freedomConfig(init: Config.Builder.() -> Unit): Config = Config.newBuilder().apply(init).build()
8 |
9 | fun destinationOverride(init: DestinationOverride.Builder.() -> Unit): DestinationOverride = DestinationOverride.newBuilder().apply(init).build()
10 |
11 | fun Config.Builder.destinationOverride(init: DestinationOverride.Builder.() -> Unit) {
12 | destinationOverride = com.v2ray.android.protobuf.dsl.proxy.destinationOverride(init)
13 | }
14 |
15 | var Config.Builder.destinationOverrideServer: ServerEndpoint
16 | get() = destinationOverride.server
17 | set(value) = destinationOverride { server = value }
18 |
--------------------------------------------------------------------------------
/dsl/src/main/kotlin/com/v2ray/android/protobuf/dsl/proxy/_Http.kt:
--------------------------------------------------------------------------------
1 | package com.v2ray.android.protobuf.dsl.proxy
2 |
3 | import com.v2ray.core.proxy.http.ServerConfig
4 |
5 | fun httpServerConfig(init: ServerConfig.Builder.() -> Unit): ServerConfig = ServerConfig.newBuilder().apply(init).build()
6 |
--------------------------------------------------------------------------------
/dsl/src/main/kotlin/com/v2ray/android/protobuf/dsl/proxy/_Shadowsocks.kt:
--------------------------------------------------------------------------------
1 | package com.v2ray.android.protobuf.dsl.proxy
2 |
3 | import com.v2ray.android.protobuf.dsl.common.protocol.serverEndpoint
4 | import com.v2ray.core.common.protocol.ServerEndpoint
5 | import com.v2ray.core.common.protocol.User
6 | import com.v2ray.core.proxy.shadowsocks.Account
7 | import com.v2ray.core.proxy.shadowsocks.ClientConfig
8 | import com.v2ray.core.proxy.shadowsocks.ServerConfig
9 |
10 | fun shadowsocksServerConfig(init: ServerConfig.Builder.() -> Unit): ServerConfig = ServerConfig.newBuilder().apply(init).build()
11 |
12 | fun shadowsocksClientConfig(init: ClientConfig.Builder.() -> Unit): ClientConfig = ClientConfig.newBuilder().apply(init).build()
13 |
14 | fun shadowsocksAccount(init: Account.Builder.() -> Unit): Account = Account.newBuilder().apply(init).build()
15 |
16 | fun ServerConfig.Builder.user(init: User.Builder.() -> Unit) {
17 | user = com.v2ray.android.protobuf.dsl.common.protocol.user(init)
18 | }
19 |
20 | fun ClientConfig.Builder.addServer(init: ServerEndpoint.Builder.() -> Unit) {
21 | addServer(serverEndpoint(init))
22 | }
23 |
--------------------------------------------------------------------------------
/dsl/src/main/kotlin/com/v2ray/android/protobuf/dsl/proxy/_Socks.kt:
--------------------------------------------------------------------------------
1 | package com.v2ray.android.protobuf.dsl.proxy
2 |
3 | import com.v2ray.android.protobuf.dsl.common.net.iPOrDomain
4 | import com.v2ray.android.protobuf.dsl.common.protocol.serverEndpoint
5 | import com.v2ray.core.common.net.IPOrDomain
6 | import com.v2ray.core.common.protocol.ServerEndpoint
7 | import com.v2ray.core.proxy.socks.Account
8 | import com.v2ray.core.proxy.socks.ClientConfig
9 | import com.v2ray.core.proxy.socks.ServerConfig
10 |
11 | fun socksServerConfig(init: ServerConfig.Builder.() -> Unit): ServerConfig = ServerConfig.newBuilder().apply(init).build()
12 |
13 | fun socksClientConfig(init: ClientConfig.Builder.() -> Unit): ClientConfig = ClientConfig.newBuilder().apply(init).build()
14 |
15 | fun ServerConfig.Builder.address(init: IPOrDomain.Builder.() -> Unit) {
16 | address = iPOrDomain(init)
17 | }
18 |
19 | fun ClientConfig.Builder.addServer(init: ServerEndpoint.Builder.() -> Unit) {
20 | addServer(serverEndpoint(init))
21 | }
22 |
23 | fun socksAccount(init: Account.Builder.() -> Unit): Account = Account.newBuilder().apply(init).build()
24 |
25 | fun socksAccount(user: String, pass: String): Account = socksAccount {
26 | username = user
27 | password = pass
28 | }
29 |
--------------------------------------------------------------------------------
/dsl/src/main/kotlin/com/v2ray/android/protobuf/dsl/proxy/vmess/_Account.kt:
--------------------------------------------------------------------------------
1 | package com.v2ray.android.protobuf.dsl.proxy.vmess
2 |
3 | import com.v2ray.core.common.protocol.SecurityConfig
4 | import com.v2ray.core.common.protocol.SecurityType
5 | import com.v2ray.core.proxy.vmess.Account
6 |
7 | fun vmesssAccount(init: Account.Builder.() -> Unit) = Account.newBuilder().apply(init).build()
8 |
9 | fun security(init: SecurityConfig.Builder.() -> Unit): SecurityConfig = SecurityConfig.newBuilder().apply(init).build()
10 |
11 | fun Account.Builder.security(init: SecurityConfig.Builder.() -> Unit) {
12 | securitySettings = com.v2ray.android.protobuf.dsl.proxy.vmess.security(init)
13 | }
14 |
15 | fun security(type: SecurityType): SecurityConfig = security { setType(type) }
16 |
17 | var Account.Builder.securityType: SecurityType
18 | get() = securitySettings.type
19 | set(value) = security { type = value }
--------------------------------------------------------------------------------
/dsl/src/main/kotlin/com/v2ray/android/protobuf/dsl/proxy/vmess/_Inbound.kt:
--------------------------------------------------------------------------------
1 | package com.v2ray.android.protobuf.dsl.proxy.vmess
2 |
3 | import com.v2ray.android.protobuf.dsl.common.protocol.user
4 | import com.v2ray.core.common.protocol.User
5 | import com.v2ray.core.proxy.vmess.inbound.Config
6 | import com.v2ray.core.proxy.vmess.inbound.DefaultConfig
7 | import com.v2ray.core.proxy.vmess.inbound.DetourConfig
8 |
9 | fun vmessServerConfig(init: Config.Builder.() -> Unit): Config = Config.newBuilder().apply(init).build()
10 |
11 | fun Config.Builder.addUser(init: User.Builder.() -> Unit) {
12 | addUser(user(init))
13 | }
14 |
15 | fun detour(init: DetourConfig.Builder.() -> Unit) = DetourConfig.newBuilder().apply(init).build()
16 |
17 | fun Config.Builder.detour(init: DetourConfig.Builder.() -> Unit) {
18 | detour = com.v2ray.android.protobuf.dsl.proxy.vmess.detour(init)
19 | }
20 |
21 | fun default(init: DefaultConfig.Builder.() -> Unit) = DefaultConfig.newBuilder().apply(init).build()
22 |
23 | fun Config.Builder.default(init: DefaultConfig.Builder.() -> Unit) {
24 | default = com.v2ray.android.protobuf.dsl.proxy.vmess.default(init)
25 | }
26 |
--------------------------------------------------------------------------------
/dsl/src/main/kotlin/com/v2ray/android/protobuf/dsl/proxy/vmess/_Outbound.kt:
--------------------------------------------------------------------------------
1 | package com.v2ray.android.protobuf.dsl.proxy.vmess
2 |
3 | import com.v2ray.android.protobuf.dsl.common.protocol.serverEndpoint
4 | import com.v2ray.core.common.protocol.ServerEndpoint
5 | import com.v2ray.core.proxy.vmess.outbound.Config
6 |
7 | fun vmessClientConfig(init: Config.Builder.() -> Unit): Config = Config.newBuilder().apply(init).build()
8 |
9 | fun Config.Builder.addReceiver(init: ServerEndpoint.Builder.() -> Unit) {
10 | addReceiver(serverEndpoint(init))
11 | }
--------------------------------------------------------------------------------
/dsl/src/main/kotlin/com/v2ray/android/protobuf/dsl/transport/_Internet.kt:
--------------------------------------------------------------------------------
1 | package com.v2ray.android.protobuf.dsl.transport
2 |
3 | import com.v2ray.android.protobuf.dsl.transport.internet.kcpConfig
4 | import com.v2ray.android.protobuf.dsl.transport.internet.tcpConfig
5 | import com.v2ray.android.protobuf.dsl.transport.internet.tlsConfig
6 | import com.v2ray.android.protobuf.dsl.transport.internet.websocketConfig
7 | import com.v2ray.android.protobuf.extention.toTypedMessage
8 | import com.v2ray.core.transport.internet.ProxyConfig
9 | import com.v2ray.core.transport.internet.StreamConfig
10 | import com.v2ray.core.transport.internet.TransportConfig
11 |
12 | fun streamConfig(init: StreamConfig.Builder.() -> Unit): StreamConfig = StreamConfig.newBuilder().apply(init).build()
13 |
14 | fun transportConfig(init: TransportConfig.Builder.() -> Unit): TransportConfig = TransportConfig.newBuilder().apply(init).build()
15 |
16 | fun StreamConfig.Builder.addTransportSettings(init: TransportConfig.Builder.() -> Unit) {
17 | addTransportSettings(transportConfig(init))
18 | }
19 |
20 | fun StreamConfig.Builder.addTlsSettings(init: com.v2ray.core.transport.internet.tls.Config.Builder.() -> Unit) {
21 | addSecuritySettings(tlsConfig(init).toTypedMessage())
22 | }
23 |
24 | fun TransportConfig.Builder.tcpSettings(init: com.v2ray.core.transport.internet.tcp.Config.Builder.() -> Unit) {
25 | settings = tcpConfig(init).toTypedMessage()
26 | }
27 |
28 | fun TransportConfig.Builder.kcpSettings(init: com.v2ray.core.transport.internet.kcp.Config.Builder.() -> Unit) {
29 | settings = kcpConfig(init).toTypedMessage()
30 | }
31 |
32 | fun TransportConfig.Builder.websocketSettings(init: com.v2ray.core.transport.internet.websocket.Config.Builder.() -> Unit) {
33 | settings = websocketConfig(init).toTypedMessage()
34 | }
35 |
36 | fun proxyConfig(init: ProxyConfig.Builder.() -> Unit): ProxyConfig = ProxyConfig.newBuilder().apply(init).build()
37 |
--------------------------------------------------------------------------------
/dsl/src/main/kotlin/com/v2ray/android/protobuf/dsl/transport/internet/_Kcp.kt:
--------------------------------------------------------------------------------
1 | package com.v2ray.android.protobuf.dsl.transport.internet
2 |
3 | import com.v2ray.android.protobuf.dsl.transport.internet.headers.srtpConfig
4 | import com.v2ray.android.protobuf.dsl.transport.internet.headers.utpConfig
5 | import com.v2ray.android.protobuf.dsl.transport.internet.headers.wechatVideoConfig
6 | import com.v2ray.android.protobuf.extention.toTypedMessage
7 | import com.v2ray.core.transport.internet.kcp.*
8 |
9 | fun kcpConfig(init: Config.Builder.() -> Unit): Config = Config.newBuilder().apply(init).build()
10 |
11 |
12 | fun mtu(init: MTU.Builder.() -> Unit): MTU = MTU.newBuilder().apply(init).build()
13 |
14 | fun Config.Builder.mtu(init: MTU.Builder.() -> Unit) {
15 | mtu = com.v2ray.android.protobuf.dsl.transport.internet.mtu(init)
16 | }
17 |
18 | var Config.Builder.mtuValue: Int
19 | get() = mtu.value
20 | set(value) = mtu { setValue(value) }
21 |
22 |
23 | fun tti(init: TTI.Builder.() -> Unit): TTI = TTI.newBuilder().apply(init).build()
24 |
25 | fun Config.Builder.tti(init: TTI.Builder.() -> Unit) {
26 | tti = com.v2ray.android.protobuf.dsl.transport.internet.tti(init)
27 | }
28 |
29 | var Config.Builder.ttiValue: Int
30 | get() = tti.value
31 | set(value) = tti { setValue(value) }
32 |
33 |
34 | fun uplinkCapacity(init: UplinkCapacity.Builder.() -> Unit): UplinkCapacity = UplinkCapacity.newBuilder().apply(init).build()
35 |
36 | fun Config.Builder.uplinkCapacity(init: UplinkCapacity.Builder.() -> Unit) {
37 | uplinkCapacity = com.v2ray.android.protobuf.dsl.transport.internet.uplinkCapacity(init)
38 | }
39 |
40 | var Config.Builder.uplinkCapacityValue: Int
41 | get() = uplinkCapacity.value
42 | set(value) = uplinkCapacity { setValue(value) }
43 |
44 |
45 | fun downlinkCapacity(init: DownlinkCapacity.Builder.() -> Unit): DownlinkCapacity = DownlinkCapacity.newBuilder().apply(init).build()
46 |
47 | fun Config.Builder.downlinkCapacity(init: DownlinkCapacity.Builder.() -> Unit) {
48 | downlinkCapacity = com.v2ray.android.protobuf.dsl.transport.internet.downlinkCapacity(init)
49 | }
50 |
51 | var Config.Builder.downlinkCapacityValue: Int
52 | get() = downlinkCapacity.value
53 | set(value) = downlinkCapacity { setValue(value) }
54 |
55 |
56 | fun writeBuffer(init: WriteBuffer.Builder.() -> Unit): WriteBuffer = WriteBuffer.newBuilder().apply(init).build()
57 |
58 | fun Config.Builder.writeBuffer(init: WriteBuffer.Builder.() -> Unit) {
59 | writeBuffer = com.v2ray.android.protobuf.dsl.transport.internet.writeBuffer(init)
60 | }
61 |
62 |
63 | fun readBuffer(init: ReadBuffer.Builder.() -> Unit): ReadBuffer = ReadBuffer.newBuilder().apply(init).build()
64 |
65 | fun Config.Builder.readBuffer(init: ReadBuffer.Builder.() -> Unit) {
66 | readBuffer = com.v2ray.android.protobuf.dsl.transport.internet.readBuffer(init)
67 | }
68 |
69 |
70 | fun Config.Builder.utpHeader(init: com.v2ray.core.transport.internet.headers.utp.Config.Builder.() -> Unit) {
71 | headerConfig = utpConfig(init).toTypedMessage()
72 | }
73 |
74 |
75 | fun Config.Builder.wechatVideoHeader(init: com.v2ray.core.transport.internet.headers.wechat.VideoConfig.Builder.() -> Unit) {
76 | headerConfig = wechatVideoConfig(init).toTypedMessage()
77 | }
78 |
79 |
80 | fun Config.Builder.srtpHeader(init: com.v2ray.core.transport.internet.headers.srtp.Config.Builder.() -> Unit) {
81 | headerConfig = srtpConfig(init).toTypedMessage()
82 | }
83 |
--------------------------------------------------------------------------------
/dsl/src/main/kotlin/com/v2ray/android/protobuf/dsl/transport/internet/_Tcp.kt:
--------------------------------------------------------------------------------
1 | package com.v2ray.android.protobuf.dsl.transport.internet
2 |
3 | import com.v2ray.android.protobuf.dsl.transport.internet.headers.httpConfig
4 | import com.v2ray.android.protobuf.extention.toTypedMessage
5 | import com.v2ray.core.transport.internet.tcp.Config
6 |
7 | fun tcpConfig(init: Config.Builder.() -> Unit): Config = Config.newBuilder().apply(init).build()
8 |
9 | fun Config.Builder.httpHeader(init: com.v2ray.core.transport.internet.headers.http.Config.Builder.() -> Unit) {
10 | headerSettings = httpConfig(init).toTypedMessage()
11 | }
12 |
--------------------------------------------------------------------------------
/dsl/src/main/kotlin/com/v2ray/android/protobuf/dsl/transport/internet/_Tls.kt:
--------------------------------------------------------------------------------
1 | package com.v2ray.android.protobuf.dsl.transport.internet
2 |
3 | import com.v2ray.core.transport.internet.tls.Certificate
4 | import com.v2ray.core.transport.internet.tls.Config
5 |
6 | fun tlsConfig(init: Config.Builder.() -> Unit): Config = Config.newBuilder().apply(init).build()
7 |
8 |
9 | fun certificateConfig(init: Certificate.Builder.() -> Unit): Certificate = Certificate.newBuilder().apply(init).build()
10 |
11 | fun Config.Builder.addCertificate(init: Certificate.Builder.() -> Unit) {
12 | addCertificate(certificateConfig(init))
13 | }
14 |
--------------------------------------------------------------------------------
/dsl/src/main/kotlin/com/v2ray/android/protobuf/dsl/transport/internet/_Websocket.kt:
--------------------------------------------------------------------------------
1 | package com.v2ray.android.protobuf.dsl.transport.internet
2 |
3 | import com.v2ray.core.transport.internet.websocket.Config
4 | import com.v2ray.core.transport.internet.websocket.Header
5 |
6 | fun websocketConfig(init: Config.Builder.() -> Unit): Config = Config.newBuilder().apply(init).build()
7 |
8 | fun header(init: Header.Builder.() -> Unit): Header = Header.newBuilder().apply(init).build()
9 |
10 | fun header(key: String, value: String) = header {
11 | setKey(key)
12 | setValue(value)
13 | }
14 |
15 | fun Config.Builder.addheader(key: String, value: String) {
16 | addHeader(header(key, value))
17 | }
18 |
--------------------------------------------------------------------------------
/dsl/src/main/kotlin/com/v2ray/android/protobuf/dsl/transport/internet/headers/_Http.kt:
--------------------------------------------------------------------------------
1 | package com.v2ray.android.protobuf.dsl.transport.internet.headers
2 |
3 | import com.v2ray.core.transport.internet.headers.http.*
4 |
5 | fun httpConfig(init: Config.Builder.() -> Unit): Config = Config.newBuilder().apply(init).build()
6 |
7 | fun requestConfig(init: RequestConfig.Builder.() -> Unit): RequestConfig = RequestConfig.newBuilder().apply(init).build()
8 |
9 | fun Config.Builder.request(init: RequestConfig.Builder.() -> Unit) {
10 | request = requestConfig(init)
11 | }
12 |
13 | fun responseConfig(init: ResponseConfig.Builder.() -> Unit): ResponseConfig = ResponseConfig.newBuilder().apply(init).build()
14 |
15 | fun Config.Builder.response(init: ResponseConfig.Builder.() -> Unit) {
16 | response = responseConfig(init)
17 | }
18 |
19 | fun version(init: Version.Builder.() -> Unit): Version = Version.newBuilder().apply(init).build()
20 |
21 | fun RequestConfig.Builder.version(init: Version.Builder.() -> Unit) {
22 | version = com.v2ray.android.protobuf.dsl.transport.internet.headers.version(init)
23 | }
24 |
25 | fun ResponseConfig.Builder.version(init: Version.Builder.() -> Unit) {
26 | version = com.v2ray.android.protobuf.dsl.transport.internet.headers.version(init)
27 | }
28 |
29 | var RequestConfig.Builder.versionValue: String
30 | get() = version.value
31 | set(value) = version { setValue(value) }
32 |
33 | var ResponseConfig.Builder.versionValue: String
34 | get() = version.value
35 | set(value) = version { setValue(value) }
36 |
37 | fun method(init: Method.Builder.() -> Unit): Method = Method.newBuilder().apply(init).build()
38 |
39 | fun RequestConfig.Builder.method(init: Method.Builder.() -> Unit) {
40 | method = com.v2ray.android.protobuf.dsl.transport.internet.headers.method(init)
41 | }
42 |
43 | var RequestConfig.Builder.methodValue: String
44 | get() = method.value
45 | set(value) = method { setValue(value) }
46 |
47 | fun header(init: Header.Builder.() -> Unit): Header = Header.newBuilder().apply(init).build()
48 |
49 | fun RequestConfig.Builder.addHeader(init: Header.Builder.() -> Unit) {
50 | addHeader(header(init))
51 | }
52 |
53 | fun ResponseConfig.Builder.addHeader(init: Header.Builder.() -> Unit) {
54 | addHeader(header(init))
55 | }
56 |
57 | fun header(name: String, vararg value: String): Header = header {
58 | this.name = name
59 | value.forEach { addValue(it) }
60 | }
61 |
62 | fun RequestConfig.Builder.addHeader(name: String, vararg value: String) {
63 | addHeader(header(name, *value))
64 | }
65 |
66 | fun ResponseConfig.Builder.addHeader(name: String, vararg value: String) {
67 | addHeader(header(name, *value))
68 | }
69 |
70 | fun status(init: Status.Builder.() -> Unit): Status = Status.newBuilder().apply(init).build()
71 |
72 | fun ResponseConfig.Builder.status(init: Status.Builder.() -> Unit) {
73 | status = com.v2ray.android.protobuf.dsl.transport.internet.headers.status(init)
74 | }
75 |
76 | fun status(code: String, reason: String): Status = status {
77 | this.code = code
78 | this.reason = reason
79 | }
80 |
81 | fun ResponseConfig.Builder.status(code: String, reason: String) {
82 | status = com.v2ray.android.protobuf.dsl.transport.internet.headers.status(code, reason)
83 | }
84 |
--------------------------------------------------------------------------------
/dsl/src/main/kotlin/com/v2ray/android/protobuf/dsl/transport/internet/headers/_Srtp.kt:
--------------------------------------------------------------------------------
1 | package com.v2ray.android.protobuf.dsl.transport.internet.headers
2 |
3 | import com.v2ray.core.transport.internet.headers.srtp.Config
4 |
5 | fun srtpConfig(init: Config.Builder.() -> Unit): Config = Config.newBuilder().apply(init).build()
6 |
--------------------------------------------------------------------------------
/dsl/src/main/kotlin/com/v2ray/android/protobuf/dsl/transport/internet/headers/_Utp.kt:
--------------------------------------------------------------------------------
1 | package com.v2ray.android.protobuf.dsl.transport.internet.headers
2 |
3 | import com.v2ray.core.transport.internet.headers.utp.Config
4 |
5 | fun utpConfig(init: Config.Builder.() -> Unit): Config = Config.newBuilder().apply(init).build()
6 |
--------------------------------------------------------------------------------
/dsl/src/main/kotlin/com/v2ray/android/protobuf/dsl/transport/internet/headers/_Wechat.kt:
--------------------------------------------------------------------------------
1 | package com.v2ray.android.protobuf.dsl.transport.internet.headers
2 |
3 | import com.v2ray.core.transport.internet.headers.wechat.VideoConfig
4 |
5 | fun wechatVideoConfig(init: VideoConfig.Builder.() -> Unit): VideoConfig = VideoConfig.newBuilder().apply(init).build()
6 |
--------------------------------------------------------------------------------
/dsl/src/main/kotlin/com/v2ray/android/protobuf/extention/_TypedMessage.kt:
--------------------------------------------------------------------------------
1 | package com.v2ray.android.protobuf.extention
2 |
3 | import com.google.protobuf.MessageLite
4 | import com.v2ray.core.common.serial.TypedMessage
5 |
6 | fun MessageLite.toTypedMessage(): TypedMessage {
7 | return TypedMessage.newBuilder().apply {
8 | type = this@toTypedMessage.messageName
9 | value = this@toTypedMessage.toByteString()
10 | }.build()
11 | }
12 |
13 | val MessageLite.messageName: String
14 | get() {
15 | val javaName = this::class.java.name
16 | return if (javaName.startsWith("com.v2ray.core"))
17 | javaName.removePrefix("com.")
18 | else
19 | javaName
20 | }
21 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/V2Ray-Android/V2Ray-Protobuf-Android/412726b65d0840d58bf59656efe628f245fb6fde/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu Jan 25 17:02:32 CST 2018
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/model/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/model/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'com.google.protobuf'
3 | apply plugin: 'com.github.dcendents.android-maven'
4 | apply plugin: 'com.jfrog.bintray'
5 |
6 | def libraries = rootProject.ext.dependencies
7 |
8 | android {
9 | compileSdkVersion Integer.parseInt("$rootProject.android.compileSdkVer")
10 |
11 | defaultConfig {
12 | minSdkVersion 15
13 | targetSdkVersion Integer.parseInt("$rootProject.android.targetSdkVer")
14 | versionCode Integer.parseInt("$rootProject.android.versionCode")
15 | versionName "$rootProject.android.versionName"
16 | }
17 | buildTypes {
18 | release {
19 | minifyEnabled false
20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
21 | }
22 | }
23 | }
24 |
25 | protobuf {
26 | protoc {
27 | artifact = "com.google.protobuf:protoc:$libraries.protobuf_version"
28 | }
29 | plugins {
30 | javalite {
31 | artifact = "com.google.protobuf:protoc-gen-javalite:$libraries.protobuf_version"
32 | }
33 | }
34 | generateProtoTasks {
35 | all().each { task ->
36 | task.builtins {
37 | remove java
38 | }
39 | task.plugins {
40 | javalite {}
41 | }
42 | }
43 | }
44 | }
45 |
46 | sourceSets {
47 | main {
48 | java {
49 | srcDirs += file("${protobuf.generatedFilesBaseDir}/main/javalite")
50 | }
51 | }
52 | }
53 |
54 | dependencies {
55 | implementation fileTree(dir: 'libs', include: ['*.jar'])
56 |
57 | api "com.google.protobuf:protobuf-lite:$libraries.protobuf_version"
58 | }
59 |
60 | buildscript {
61 | repositories {
62 | jcenter()
63 | }
64 | dependencies {
65 | classpath "com.google.protobuf:protobuf-gradle-plugin:0.8.3"
66 | }
67 | }
68 |
69 | version = "$rootProject.android.versionName"
70 | def siteUrl = 'https://github.com/V2Ray-Android/V2Ray-Protobuf-Android'
71 | def gitUrl = 'https://github.com/V2Ray-Android/V2Ray-Protobuf-Android.git'
72 | group = "com.v2ray.android.protobuf"
73 | install {
74 | repositories.mavenInstaller {
75 | // This generates POM.xml with proper parameters
76 | pom.project {
77 | artifactId "model"
78 | packaging 'aar'
79 | // Add your description here
80 | name 'V2Ray Protobuf-lite models'
81 | url siteUrl
82 | // Set your license
83 | licenses {
84 | license {
85 | name 'GNU GENERAL PUBLIC LICENSE, Version 3'
86 | url 'https://www.gnu.org/licenses/gpl-3.0.txt'
87 | }
88 | }
89 | developers {
90 | developer {
91 | id 'liberal-boy'
92 | name 'Liberal Boy'
93 | email 'liberal-boy@protonmail.com'
94 | }
95 | }
96 | scm {
97 | connection gitUrl
98 | developerConnection gitUrl
99 | url siteUrl
100 | }
101 | }
102 | }
103 | }
104 | task sourcesJar(type: Jar) {
105 | from android.sourceSets.main.java.srcDirs
106 | classifier = 'sources'
107 | }
108 | task javadoc(type: Javadoc) {
109 | source = android.sourceSets.main.java.srcDirs
110 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
111 | }
112 | task javadocJar(type: Jar, dependsOn: javadoc) {
113 | classifier = 'javadoc'
114 | from javadoc.destinationDir
115 | }
116 | artifacts {
117 | // archives javadocJar
118 | archives sourcesJar
119 | }
120 | Properties properties = new Properties()
121 | properties.load(project.rootProject.file('local.properties').newDataInputStream())
122 | bintray {
123 | user = properties.getProperty("bintray.user")
124 | key = properties.getProperty("bintray.apikey")
125 | configurations = ['archives']
126 | pkg {
127 | repo = "maven"
128 | name = "V2Ray-Protobuf-Android"
129 | websiteUrl = siteUrl
130 | vcsUrl = gitUrl
131 | licenses = ["GPL-3.0"]
132 | publish = true
133 | }
134 | }
135 |
--------------------------------------------------------------------------------
/model/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/model/src/main/proto/LibV2Ray.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package kkdev.v2ray.LibV2Ray;
4 | option go_package = "configure";
5 |
6 |
7 | message VPNServiceConfig {
8 | string Target = 1;
9 | repeated string Args = 2;
10 | string VPNSetupArg = 3;
11 | }
12 |
13 | message DNSLoopFix {
14 | string TCPVersion = 1;
15 | string UDPVersion = 2;
16 | repeated string DomainNameList = 3;
17 | }
18 |
19 | message VPNConfig {
20 | VPNServiceConfig Service = 1;
21 | DNSLoopFix PreparedDomainName = 2;
22 | }
23 |
24 | message EscortedProcess {
25 | string Target = 1;
26 | repeated string Args = 2;
27 | bool Forgiveable = 3;
28 | }
29 |
30 | message UpDownScripts {
31 | string UpScript = 1;
32 | string DownScript = 2;
33 | }
34 |
35 | message RootModeConfig {
36 | repeated EscortedProcess Escorting = 1;
37 | UpDownScripts Scripts = 2;
38 | }
39 | message EnvironmentVar {
40 | map Vars = 3;
41 | }
42 |
43 | message LibV2RayConf {
44 | //If this is false, no other options will be readed
45 | bool NoAutoConvert = 1;
46 |
47 | VPNConfig VpnConf = 1000;
48 | RootModeConfig RootModeConf = 1001;
49 | EnvironmentVar Env = 1002;
50 | }
--------------------------------------------------------------------------------
/model/src/main/proto/LibV2RayConfigure.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package kkdev.v2ray.LibV2Ray;
4 | option go_package = "configure";
5 |
6 |
7 | import "LibV2Ray.proto";
8 |
9 | message V2RaySharedConf {
10 | reserved 1 to 5;
11 | LibV2RayConf SharpLibV2Ray = 12;
12 | }
--------------------------------------------------------------------------------
/model/src/main/proto/config.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package v2ray.core;
4 | option csharp_namespace = "V2Ray.Core";
5 | option go_package = "core";
6 | option java_package = "com.v2ray.core";
7 | option java_multiple_files = true;
8 |
9 | import "v2ray.com/core/common/serial/typed_message.proto";
10 | import "v2ray.com/core/transport/config.proto";
11 |
12 | // Configuration serialization format.
13 | enum ConfigFormat {
14 | Protobuf = 0;
15 | JSON = 1;
16 | }
17 |
18 | // Master config of V2Ray. V2Ray takes this config as input and functions accordingly.
19 | message Config {
20 | // Inbound handler configurations. Must have at least one item.
21 | repeated InboundHandlerConfig inbound = 1;
22 |
23 | // Outbound handler configurations. Must have at least one item. The first item is used as default for routing.
24 | repeated OutboundHandlerConfig outbound = 2;
25 |
26 | reserved 3;
27 |
28 | // App configuration. Must be one in the app directory.
29 | repeated v2ray.core.common.serial.TypedMessage app = 4;
30 |
31 | // Transport settings.
32 | v2ray.core.transport.Config transport = 5;
33 |
34 | // Configuration for extensions. The config may not work if corresponding extension is not loaded into V2Ray.
35 | // V2Ray will ignore such config during initialization.
36 | repeated v2ray.core.common.serial.TypedMessage extension = 6;
37 | }
38 |
39 | message InboundHandlerConfig {
40 | // Tag of the inbound handler.
41 | string tag = 1;
42 | // Settings for how this inbound proxy is handled. Must be ReceiverConfig above.
43 | v2ray.core.common.serial.TypedMessage receiver_settings = 2;
44 | // Settings for inbound proxy. Must be one of the inbound proxies.
45 | v2ray.core.common.serial.TypedMessage proxy_settings = 3;
46 | }
47 |
48 | message OutboundHandlerConfig {
49 | // Tag of this outbound handler.
50 | string tag = 1;
51 | // Settings for how to dial connection for this outbound handler. Must be SenderConfig above.
52 | v2ray.core.common.serial.TypedMessage sender_settings = 2;
53 | // Settings for this outbound proxy. Must be one of the outbound proxies.
54 | v2ray.core.common.serial.TypedMessage proxy_settings = 3;
55 | // If not zero, this outbound will be expired in seconds. Not used for now.
56 | int64 expire = 4;
57 | // Comment of this outbound handler. Not used for now.
58 | string comment = 5;
59 | }
60 |
--------------------------------------------------------------------------------
/model/src/main/proto/v2ray.com/core/app/dispatcher/config.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package v2ray.core.app.dispatcher;
4 | option csharp_namespace = "V2Ray.Core.App.Dispatcher";
5 | option go_package = "dispatcher";
6 | option java_package = "com.v2ray.core.app.dispatcher";
7 | option java_multiple_files = true;
8 |
9 | message SessionConfig {
10 | reserved 1;
11 |
12 | }
13 |
14 | message Config {
15 | SessionConfig settings = 1;
16 | }
17 |
--------------------------------------------------------------------------------
/model/src/main/proto/v2ray.com/core/app/dns/config.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package v2ray.core.app.dns;
4 | option csharp_namespace = "V2Ray.Core.App.Dns";
5 | option go_package = "dns";
6 | option java_package = "com.v2ray.core.app.dns";
7 | option java_multiple_files = true;
8 |
9 | import "v2ray.com/core/common/net/address.proto";
10 | import "v2ray.com/core/common/net/destination.proto";
11 |
12 | message Config {
13 | // Nameservers used by this DNS. Only traditional UDP servers are support at the moment.
14 | // A special value 'localhost' as a domain address can be set to use DNS on local system.
15 | repeated v2ray.core.common.net.Endpoint NameServers = 1;
16 |
17 | // Static hosts. Domain to IP.
18 | map Hosts = 2;
19 | }
20 |
--------------------------------------------------------------------------------
/model/src/main/proto/v2ray.com/core/app/log/config.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package v2ray.core.app.log;
4 | option csharp_namespace = "V2Ray.Core.App.Log";
5 | option go_package = "log";
6 | option java_package = "com.v2ray.core.app.log";
7 | option java_multiple_files = true;
8 |
9 | import "v2ray.com/core/common/log/log.proto";
10 |
11 | enum LogType {
12 | None = 0;
13 | Console = 1;
14 | File = 2;
15 | Event = 3;
16 | }
17 |
18 | message Config {
19 | LogType error_log_type = 1;
20 | v2ray.core.common.log.Severity error_log_level = 2;
21 | string error_log_path = 3;
22 |
23 | LogType access_log_type = 4;
24 | string access_log_path = 5;
25 | }
--------------------------------------------------------------------------------
/model/src/main/proto/v2ray.com/core/app/policy/config.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package v2ray.core.app.policy;
4 | option csharp_namespace = "V2Ray.Core.App.Policy";
5 | option go_package = "policy";
6 | option java_package = "com.v2ray.core.app.policy";
7 | option java_multiple_files = true;
8 |
9 | message Second {
10 | uint32 value = 1;
11 | }
12 |
13 | message Policy {
14 | // Timeout is a message for timeout settings in various stages, in seconds.
15 | message Timeout {
16 | Second handshake = 1;
17 | Second connection_idle = 2;
18 | Second uplink_only = 3;
19 | Second downlink_only = 4;
20 | }
21 |
22 | Timeout timeout = 1;
23 | }
24 |
25 | message Config {
26 | map level = 1;
27 | }
28 |
--------------------------------------------------------------------------------
/model/src/main/proto/v2ray.com/core/app/proxyman/config.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package v2ray.core.app.proxyman;
4 | option csharp_namespace = "V2Ray.Core.App.Proxyman";
5 | option go_package = "proxyman";
6 | option java_package = "com.v2ray.core.app.proxyman";
7 | option java_multiple_files = true;
8 |
9 | import "v2ray.com/core/common/net/address.proto";
10 | import "v2ray.com/core/common/net/port.proto";
11 | import "v2ray.com/core/transport/internet/config.proto";
12 |
13 | message InboundConfig {
14 | }
15 |
16 | message AllocationStrategy {
17 | enum Type {
18 | // Always allocate all connection handlers.
19 | Always = 0;
20 |
21 | // Randomly allocate specific range of handlers.
22 | Random = 1;
23 |
24 | // External. Not supported yet.
25 | External = 2;
26 | }
27 |
28 | Type type = 1;
29 |
30 | message AllocationStrategyConcurrency {
31 | uint32 value = 1;
32 | }
33 |
34 | // Number of handlers (ports) running in parallel.
35 | // Default value is 3 if unset.
36 | AllocationStrategyConcurrency concurrency = 2;
37 |
38 |
39 | message AllocationStrategyRefresh {
40 | uint32 value = 1;
41 | }
42 |
43 | // Number of minutes before a handler is regenerated.
44 | // Default value is 5 if unset.
45 | AllocationStrategyRefresh refresh = 3;
46 | }
47 |
48 | enum KnownProtocols {
49 | HTTP = 0;
50 | TLS = 1;
51 | }
52 |
53 | message ReceiverConfig {
54 | v2ray.core.common.net.PortRange port_range = 1;
55 | v2ray.core.common.net.IPOrDomain listen = 2;
56 | AllocationStrategy allocation_strategy = 3;
57 | v2ray.core.transport.internet.StreamConfig stream_settings = 4;
58 | bool receive_original_destination = 5;
59 | reserved 6;
60 | repeated KnownProtocols domain_override = 7;
61 | }
62 |
63 | message OutboundConfig {
64 |
65 | }
66 |
67 | message SenderConfig {
68 | // Send traffic through the given IP. Only IP is allowed.
69 | v2ray.core.common.net.IPOrDomain via = 1;
70 | v2ray.core.transport.internet.StreamConfig stream_settings = 2;
71 | v2ray.core.transport.internet.ProxyConfig proxy_settings = 3;
72 | MultiplexingConfig multiplex_settings = 4;
73 | }
74 |
75 | message MultiplexingConfig {
76 | // Whether or not Mux is enabled.
77 | bool enabled = 1;
78 | // Max number of concurrent connections that one Mux connection can handle.
79 | uint32 concurrency = 2;
80 | }
81 |
--------------------------------------------------------------------------------
/model/src/main/proto/v2ray.com/core/app/router/config.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package v2ray.core.app.router;
4 | option csharp_namespace = "V2Ray.Core.App.Router";
5 | option go_package = "router";
6 | option java_package = "com.v2ray.core.app.router";
7 | option java_multiple_files = true;
8 |
9 | import "v2ray.com/core/common/net/port.proto";
10 | import "v2ray.com/core/common/net/network.proto";
11 |
12 | // Domain for routing decision.
13 | message Domain {
14 | // Type of domain value.
15 | enum Type {
16 | // The value is used as is.
17 | Plain = 0;
18 | // The value is used as a regular expression.
19 | Regex = 1;
20 | // The value is a domain.
21 | Domain = 2;
22 | }
23 |
24 | // Domain matching type.
25 | Type type = 1;
26 |
27 | // Domain value.
28 | string value = 2;
29 | }
30 |
31 | // IP for routing decision, in CIDR form.
32 | message CIDR {
33 | // IP address, should be either 4 or 16 bytes.
34 | bytes ip = 1;
35 |
36 | // Number of leading ones in the network mask.
37 | uint32 prefix = 2;
38 | }
39 |
40 | message GeoIP {
41 | string country_code = 1;
42 | repeated CIDR cidr = 2;
43 | }
44 |
45 | message GeoIPList {
46 | repeated GeoIP entry = 1;
47 | }
48 |
49 | message GeoSite {
50 | string country_code = 1;
51 | repeated Domain domain = 2;
52 | }
53 |
54 | message GeoSiteList {
55 | repeated GeoSite entry = 1;
56 | }
57 |
58 | message RoutingRule {
59 | string tag = 1;
60 | repeated Domain domain = 2;
61 | repeated CIDR cidr = 3;
62 | v2ray.core.common.net.PortRange port_range = 4;
63 | v2ray.core.common.net.NetworkList network_list = 5;
64 | repeated CIDR source_cidr = 6;
65 | repeated string user_email = 7;
66 | repeated string inbound_tag = 8;
67 | }
68 |
69 | message Config {
70 | enum DomainStrategy {
71 | // Use domain as is.
72 | AsIs = 0;
73 |
74 | // Always resolve IP for domains.
75 | UseIp = 1;
76 |
77 | // Resolve to IP if the domain doesn't match any rules.
78 | IpIfNonMatch = 2;
79 |
80 | // Resolve to IP if any rule requires IP matching.
81 | IpOnDemand = 3;
82 | }
83 | DomainStrategy domain_strategy = 1;
84 | repeated RoutingRule rule = 2;
85 | }
86 |
--------------------------------------------------------------------------------
/model/src/main/proto/v2ray.com/core/common/log/log.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package v2ray.core.common.log;
4 | option csharp_namespace = "V2Ray.Core.Common.Log";
5 | option go_package = "log";
6 | option java_package = "com.v2ray.core.common.log";
7 | option java_multiple_files = true;
8 |
9 | enum Severity {
10 | Unknown = 0;
11 | Error = 1;
12 | Warning = 2;
13 | Info = 3;
14 | Debug = 4;
15 | }
16 |
17 |
--------------------------------------------------------------------------------
/model/src/main/proto/v2ray.com/core/common/net/address.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package v2ray.core.common.net;
4 | option csharp_namespace = "V2Ray.Core.Common.Net";
5 | option go_package = "net";
6 | option java_package = "com.v2ray.core.common.net";
7 | option java_multiple_files = true;
8 |
9 | // Address of a network host. It may be either an IP address or a domain address.
10 | message IPOrDomain {
11 | oneof address {
12 | // IP address. Must by either 4 or 16 bytes.
13 | bytes ip = 1;
14 |
15 | // Domain address.
16 | string domain = 2;
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/model/src/main/proto/v2ray.com/core/common/net/destination.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package v2ray.core.common.net;
4 | option csharp_namespace = "V2Ray.Core.Common.Net";
5 | option go_package = "net";
6 | option java_package = "com.v2ray.core.common.net";
7 | option java_multiple_files = true;
8 |
9 | import "v2ray.com/core/common/net/network.proto";
10 | import "v2ray.com/core/common/net/address.proto";
11 |
12 | // Endpoint of a network connection.
13 | message Endpoint {
14 | Network network = 1;
15 | IPOrDomain address = 2;
16 | uint32 port = 3;
17 | }
18 |
--------------------------------------------------------------------------------
/model/src/main/proto/v2ray.com/core/common/net/network.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package v2ray.core.common.net;
4 | option csharp_namespace = "V2Ray.Core.Common.Net";
5 | option go_package = "net";
6 | option java_package = "com.v2ray.core.common.net";
7 | option java_multiple_files = true;
8 |
9 | enum Network {
10 | Unknown = 0;
11 |
12 | RawTCP = 1 [deprecated = true];
13 | TCP = 2;
14 | UDP = 3;
15 | }
16 |
17 | // NetworkList is a list of Networks.
18 | message NetworkList {
19 | repeated Network network = 1;
20 | }
21 |
--------------------------------------------------------------------------------
/model/src/main/proto/v2ray.com/core/common/net/port.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package v2ray.core.common.net;
4 | option csharp_namespace = "V2Ray.Core.Common.Net";
5 | option go_package = "net";
6 | option java_package = "com.v2ray.core.common.net";
7 | option java_multiple_files = true;
8 |
9 | // PortRange represents a range of ports.
10 | message PortRange {
11 | // The port that this range starts from.
12 | uint32 From = 1;
13 | // The port that this range ends with (inclusive).
14 | uint32 To = 2;
15 | }
16 |
--------------------------------------------------------------------------------
/model/src/main/proto/v2ray.com/core/common/protocol/command.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package v2ray.core.common.protocol;
4 | option csharp_namespace = "V2Ray.Core.Common.Protocol";
5 | option go_package = "protocol";
6 | option java_package = "com.v2ray.core.common.protocol";
7 | option java_multiple_files = true;
8 |
9 | import "v2ray.com/core/common/serial/typed_message.proto";
10 | import "v2ray.com/core/transport/internet/config.proto";
11 |
12 | message AlternativeOutboundConfig {
13 | v2ray.core.common.serial.TypedMessage settings = 1;
14 | v2ray.core.transport.internet.StreamConfig stream_settings = 3;
15 | }
16 |
--------------------------------------------------------------------------------
/model/src/main/proto/v2ray.com/core/common/protocol/headers.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package v2ray.core.common.protocol;
4 | option csharp_namespace = "V2Ray.Core.Common.Protocol";
5 | option go_package = "protocol";
6 | option java_package = "com.v2ray.core.common.protocol";
7 | option java_multiple_files = true;
8 |
9 | enum SecurityType {
10 | UNKNOWN = 0;
11 | LEGACY = 1;
12 | AUTO = 2;
13 | AES128_GCM = 3;
14 | CHACHA20_POLY1305 = 4;
15 | NONE = 5;
16 | }
17 |
18 | message SecurityConfig {
19 | SecurityType type = 1;
20 | }
21 |
--------------------------------------------------------------------------------
/model/src/main/proto/v2ray.com/core/common/protocol/server_spec.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package v2ray.core.common.protocol;
4 | option csharp_namespace = "V2Ray.Core.Common.Protocol";
5 | option go_package = "protocol";
6 | option java_package = "com.v2ray.core.common.protocol";
7 | option java_multiple_files = true;
8 |
9 | import "v2ray.com/core/common/net/address.proto";
10 | import "v2ray.com/core/common/protocol/user.proto";
11 |
12 | message ServerEndpoint {
13 | v2ray.core.common.net.IPOrDomain address = 1;
14 | uint32 port = 2;
15 | repeated v2ray.core.common.protocol.User user = 3;
16 | }
17 |
--------------------------------------------------------------------------------
/model/src/main/proto/v2ray.com/core/common/protocol/user.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package v2ray.core.common.protocol;
4 | option csharp_namespace = "V2Ray.Core.Common.Protocol";
5 | option go_package = "protocol";
6 | option java_package = "com.v2ray.core.common.protocol";
7 | option java_multiple_files = true;
8 |
9 | import "v2ray.com/core/common/serial/typed_message.proto";
10 |
11 | // User is a generic user for all procotols.
12 | message User {
13 | uint32 level = 1;
14 | string email = 2;
15 |
16 | // Protocol specific account information. Must be the account proto in one of the proxies.
17 | v2ray.core.common.serial.TypedMessage account = 3;
18 | }
--------------------------------------------------------------------------------
/model/src/main/proto/v2ray.com/core/common/serial/typed_message.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package v2ray.core.common.serial;
4 | option csharp_namespace = "V2Ray.Core.Common.Serial";
5 | option go_package = "serial";
6 | option java_package = "com.v2ray.core.common.serial";
7 | option java_multiple_files = true;
8 |
9 | // TypedMessage is a serialized proto message along with its type name.
10 | message TypedMessage {
11 | // The name of the message type, retrieved from protobuf API.
12 | string type = 1;
13 | // Serialized proto message.
14 | bytes value = 2;
15 | }
16 |
--------------------------------------------------------------------------------
/model/src/main/proto/v2ray.com/core/proxy/blackhole/config.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package v2ray.core.proxy.blackhole;
4 | option csharp_namespace = "V2Ray.Core.Proxy.Blackhole";
5 | option go_package = "blackhole";
6 | option java_package = "com.v2ray.core.proxy.blackhole";
7 | option java_multiple_files = true;
8 |
9 | import "v2ray.com/core/common/serial/typed_message.proto";
10 |
11 | message NoneResponse {
12 | }
13 |
14 | message HTTPResponse {
15 | }
16 |
17 | message Config {
18 | v2ray.core.common.serial.TypedMessage response = 1;
19 | }
20 |
--------------------------------------------------------------------------------
/model/src/main/proto/v2ray.com/core/proxy/dokodemo/config.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package v2ray.core.proxy.dokodemo;
4 | option csharp_namespace = "V2Ray.Core.Proxy.Dokodemo";
5 | option go_package = "dokodemo";
6 | option java_package = "com.v2ray.core.proxy.dokodemo";
7 | option java_multiple_files = true;
8 |
9 | import "v2ray.com/core/common/net/address.proto";
10 | import "v2ray.com/core/common/net/network.proto";
11 |
12 | message Config {
13 | v2ray.core.common.net.IPOrDomain address = 1;
14 | uint32 port = 2;
15 | v2ray.core.common.net.NetworkList network_list = 3;
16 | uint32 timeout = 4 [deprecated = true];
17 | bool follow_redirect = 5;
18 | uint32 user_level = 6;
19 | }
--------------------------------------------------------------------------------
/model/src/main/proto/v2ray.com/core/proxy/freedom/config.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package v2ray.core.proxy.freedom;
4 | option csharp_namespace = "V2Ray.Core.Proxy.Freedom";
5 | option go_package = "freedom";
6 | option java_package = "com.v2ray.core.proxy.freedom";
7 | option java_multiple_files = true;
8 |
9 | import "v2ray.com/core/common/protocol/server_spec.proto";
10 |
11 | message DestinationOverride {
12 | v2ray.core.common.protocol.ServerEndpoint server = 1;
13 | }
14 |
15 | message Config {
16 | enum DomainStrategy {
17 | AS_IS = 0;
18 | USE_IP = 1;
19 | }
20 | DomainStrategy domain_strategy = 1;
21 | uint32 timeout = 2 [deprecated = true];
22 | DestinationOverride destination_override = 3;
23 | uint32 user_level = 4;
24 | }
25 |
--------------------------------------------------------------------------------
/model/src/main/proto/v2ray.com/core/proxy/http/config.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package v2ray.core.proxy.http;
4 | option csharp_namespace = "V2Ray.Core.Proxy.Http";
5 | option go_package = "http";
6 | option java_package = "com.v2ray.core.proxy.http";
7 | option java_multiple_files = true;
8 |
9 | // Config for HTTP proxy server.
10 | message ServerConfig {
11 | uint32 timeout = 1 [deprecated = true];
12 | map accounts = 2;
13 | bool allow_transparent = 3;
14 | uint32 user_level = 4;
15 | }
16 |
17 | // ClientConfig for HTTP proxy client.
18 | message ClientConfig {
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/model/src/main/proto/v2ray.com/core/proxy/shadowsocks/config.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package v2ray.core.proxy.shadowsocks;
4 | option csharp_namespace = "V2Ray.Core.Proxy.Shadowsocks";
5 | option go_package = "shadowsocks";
6 | option java_package = "com.v2ray.core.proxy.shadowsocks";
7 | option java_multiple_files = true;
8 |
9 | import "v2ray.com/core/common/protocol/user.proto";
10 | import "v2ray.com/core/common/protocol/server_spec.proto";
11 |
12 | message Account {
13 | enum OneTimeAuth {
14 | Auto = 0;
15 | Disabled = 1;
16 | Enabled = 2;
17 | }
18 | string password = 1;
19 | CipherType cipher_type = 2;
20 | OneTimeAuth ota = 3;
21 | }
22 |
23 | enum CipherType {
24 | UNKNOWN = 0;
25 | AES_128_CFB = 1;
26 | AES_256_CFB = 2;
27 | CHACHA20 = 3;
28 | CHACHA20_IETF = 4;
29 | AES_128_GCM = 5;
30 | AES_256_GCM = 6;
31 | CHACHA20_POLY1305 = 7;
32 | NONE = 8;
33 | }
34 |
35 | message ServerConfig {
36 | bool udp_enabled = 1;
37 | v2ray.core.common.protocol.User user = 2;
38 | }
39 |
40 | message ClientConfig {
41 | repeated v2ray.core.common.protocol.ServerEndpoint server = 1;
42 | }
43 |
--------------------------------------------------------------------------------
/model/src/main/proto/v2ray.com/core/proxy/socks/config.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package v2ray.core.proxy.socks;
4 | option csharp_namespace = "V2Ray.Core.Proxy.Socks";
5 | option go_package = "socks";
6 | option java_package = "com.v2ray.core.proxy.socks";
7 | option java_multiple_files = true;
8 |
9 | import "v2ray.com/core/common/net/address.proto";
10 | import "v2ray.com/core/common/protocol/server_spec.proto";
11 |
12 | message Account {
13 | string username = 1;
14 | string password = 2;
15 | }
16 |
17 | enum AuthType {
18 | NO_AUTH = 0;
19 | PASSWORD = 1;
20 | }
21 |
22 | message ServerConfig {
23 | AuthType auth_type = 1;
24 | map accounts = 2;
25 | v2ray.core.common.net.IPOrDomain address = 3;
26 | bool udp_enabled = 4;
27 | uint32 timeout = 5 [deprecated = true];
28 | uint32 user_level = 6;
29 | }
30 |
31 | message ClientConfig {
32 | repeated v2ray.core.common.protocol.ServerEndpoint server = 1;
33 | }
34 |
--------------------------------------------------------------------------------
/model/src/main/proto/v2ray.com/core/proxy/vmess/account.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package v2ray.core.proxy.vmess;
4 | option csharp_namespace = "V2Ray.Core.Proxy.Vmess";
5 | option go_package = "vmess";
6 | option java_package = "com.v2ray.core.proxy.vmess";
7 | option java_multiple_files = true;
8 |
9 | import "v2ray.com/core/common/protocol/headers.proto";
10 |
11 | message Account {
12 | // ID of the account, in the form of an UUID, e.g., "66ad4540-b58c-4ad2-9926-ea63445a9b57".
13 | string id = 1;
14 | // Number of alternative IDs. Client and server must share the same number.
15 | uint32 alter_id = 2;
16 | // Security settings. Only applies to client side.
17 | v2ray.core.common.protocol.SecurityConfig security_settings = 3;
18 | }
19 |
--------------------------------------------------------------------------------
/model/src/main/proto/v2ray.com/core/proxy/vmess/inbound/config.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package v2ray.core.proxy.vmess.inbound;
4 | option csharp_namespace = "V2Ray.Core.Proxy.Vmess.Inbound";
5 | option go_package = "inbound";
6 | option java_package = "com.v2ray.core.proxy.vmess.inbound";
7 | option java_multiple_files = true;
8 |
9 | import "v2ray.com/core/common/protocol/user.proto";
10 |
11 | message DetourConfig {
12 | string to = 1;
13 | }
14 |
15 | message DefaultConfig {
16 | uint32 alter_id = 1;
17 | uint32 level = 2;
18 | }
19 |
20 | message Config {
21 | repeated v2ray.core.common.protocol.User user = 1;
22 | DefaultConfig default = 2;
23 | DetourConfig detour = 3;
24 | }
--------------------------------------------------------------------------------
/model/src/main/proto/v2ray.com/core/proxy/vmess/outbound/config.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package v2ray.core.proxy.vmess.outbound;
4 | option csharp_namespace = "V2Ray.Core.Proxy.Vmess.Outbound";
5 | option go_package = "outbound";
6 | option java_package = "com.v2ray.core.proxy.vmess.outbound";
7 | option java_multiple_files = true;
8 |
9 | import "v2ray.com/core/common/protocol/server_spec.proto";
10 |
11 | message Config {
12 | repeated v2ray.core.common.protocol.ServerEndpoint Receiver = 1;
13 | }
--------------------------------------------------------------------------------
/model/src/main/proto/v2ray.com/core/transport/config.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package v2ray.core.transport;
4 | option csharp_namespace = "V2Ray.Core.Transport";
5 | option go_package = "transport";
6 | option java_package = "com.v2ray.core.transport";
7 | option java_multiple_files = true;
8 |
9 | import "v2ray.com/core/transport/internet/config.proto";
10 |
11 | // Global transport settings. This affects all type of connections that go through V2Ray.
12 | message Config {
13 | repeated v2ray.core.transport.internet.TransportConfig transport_settings = 1;
14 | }
--------------------------------------------------------------------------------
/model/src/main/proto/v2ray.com/core/transport/internet/config.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package v2ray.core.transport.internet;
4 | option csharp_namespace = "V2Ray.Core.Transport.Internet";
5 | option go_package = "internet";
6 | option java_package = "com.v2ray.core.transport.internet";
7 | option java_multiple_files = true;
8 |
9 | import "v2ray.com/core/common/serial/typed_message.proto";
10 |
11 | enum TransportProtocol {
12 | TCP = 0;
13 | UDP = 1;
14 | MKCP = 2;
15 | WebSocket = 3;
16 | }
17 |
18 | message TransportConfig {
19 | // Type of network that this settings supports.
20 | TransportProtocol protocol = 1;
21 |
22 | // Specific settings. Must be of the transports.
23 | v2ray.core.common.serial.TypedMessage settings = 2;
24 | }
25 |
26 | message StreamConfig {
27 | // Effective network.
28 | TransportProtocol protocol = 1;
29 |
30 | repeated TransportConfig transport_settings = 2;
31 |
32 | // Type of security. Must be a message name of the settings proto.
33 | string security_type = 3;
34 |
35 | // Settings for transport security. For now the only choice is TLS.
36 | repeated v2ray.core.common.serial.TypedMessage security_settings = 4;
37 | }
38 |
39 | message ProxyConfig {
40 | string tag = 1;
41 | }
42 |
--------------------------------------------------------------------------------
/model/src/main/proto/v2ray.com/core/transport/internet/headers/http/config.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package v2ray.core.transport.internet.headers.http;
4 | option csharp_namespace = "V2Ray.Core.Transport.Internet.Headers.Http";
5 | option go_package = "http";
6 | option java_package = "com.v2ray.core.transport.internet.headers.http";
7 | option java_multiple_files = true;
8 |
9 | message Header {
10 | // "Accept", "Cookie", etc
11 | string name = 1;
12 |
13 | // Each entry must be valid in one piece. Random entry will be chosen if multiple entries present.
14 | repeated string value = 2;
15 | }
16 |
17 | // HTTP version. Default value "1.1".
18 | message Version {
19 | string value = 1;
20 | }
21 |
22 | // HTTP method. Default value "GET".
23 | message Method {
24 | string value = 1;
25 | }
26 |
27 | message RequestConfig {
28 | // Full HTTP version like "1.1".
29 | Version version = 1;
30 |
31 | // GET, POST, CONNECT etc
32 | Method method = 2;
33 |
34 | // URI like "/login.php"
35 | repeated string uri = 3;
36 |
37 | repeated Header header = 4;
38 | }
39 |
40 | message Status {
41 | // Status code. Default "200".
42 | string code = 1;
43 |
44 | // Statue reason. Default "OK".
45 | string reason = 2;
46 | }
47 |
48 | message ResponseConfig {
49 | Version version = 1;
50 |
51 | Status status = 2;
52 |
53 | repeated Header header = 3;
54 | }
55 |
56 | message Config {
57 | // Settings for authenticating requests. If not set, client side will not send authenication header, and server side will bypass authentication.
58 | RequestConfig request = 1;
59 |
60 | // Settings for authenticating responses. If not set, client side will bypass authentication, and server side will not send authentication header.
61 | ResponseConfig response = 2;
62 | }
--------------------------------------------------------------------------------
/model/src/main/proto/v2ray.com/core/transport/internet/headers/noop/config.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package v2ray.core.transport.internet.headers.noop;
4 | option csharp_namespace = "V2Ray.Core.Transport.Internet.Headers.Noop";
5 | option go_package = "noop";
6 | option java_package = "com.v2ray.core.transport.internet.headers.noop";
7 | option java_multiple_files = true;
8 |
9 | message Config {
10 | }
11 |
12 | message ConnectionConfig {
13 | }
--------------------------------------------------------------------------------
/model/src/main/proto/v2ray.com/core/transport/internet/headers/srtp/config.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package v2ray.core.transport.internet.headers.srtp;
4 | option csharp_namespace = "V2Ray.Core.Transport.Internet.Headers.Srtp";
5 | option go_package = "srtp";
6 | option java_package = "com.v2ray.core.transport.internet.headers.srtp";
7 | option java_multiple_files = true;
8 |
9 | message Config {
10 | uint32 version = 1;
11 | bool padding = 2;
12 | bool extension = 3;
13 | uint32 csrc_count = 4;
14 | bool marker = 5;
15 | uint32 payload_type = 6;
16 | }
--------------------------------------------------------------------------------
/model/src/main/proto/v2ray.com/core/transport/internet/headers/utp/config.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package v2ray.core.transport.internet.headers.utp;
4 | option csharp_namespace = "V2Ray.Core.Transport.Internet.Headers.Utp";
5 | option go_package = "utp";
6 | option java_package = "com.v2ray.core.transport.internet.headers.utp";
7 | option java_multiple_files = true;
8 |
9 | message Config {
10 | uint32 version = 1;
11 | }
--------------------------------------------------------------------------------
/model/src/main/proto/v2ray.com/core/transport/internet/headers/wechat/config.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package v2ray.core.transport.internet.headers.wechat;
4 | option csharp_namespace = "V2Ray.Core.Transport.Internet.Headers.Wechat";
5 | option go_package = "wechat";
6 | option java_package = "com.v2ray.core.transport.internet.headers.wechat";
7 | option java_multiple_files = true;
8 |
9 | message VideoConfig {
10 | }
--------------------------------------------------------------------------------
/model/src/main/proto/v2ray.com/core/transport/internet/kcp/config.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package v2ray.core.transport.internet.kcp;
4 | option csharp_namespace = "V2Ray.Core.Transport.Internet.Kcp";
5 | option go_package = "kcp";
6 | option java_package = "com.v2ray.core.transport.internet.kcp";
7 | option java_multiple_files = true;
8 |
9 | import "v2ray.com/core/common/serial/typed_message.proto";
10 |
11 | // Maximum Transmission Unit, in bytes.
12 | message MTU {
13 | uint32 value = 1;
14 | }
15 |
16 | // Transmission Time Interview, in milli-sec.
17 | message TTI {
18 | uint32 value = 1;
19 | }
20 |
21 | // Uplink capacity, in MB.
22 | message UplinkCapacity {
23 | uint32 value = 1;
24 | }
25 |
26 | // Downlink capacity, in MB.
27 | message DownlinkCapacity {
28 | uint32 value = 1;
29 | }
30 |
31 | message WriteBuffer {
32 | // Buffer size in bytes.
33 | uint32 size = 1;
34 | }
35 |
36 | message ReadBuffer {
37 | // Buffer size in bytes.
38 | uint32 size = 1;
39 | }
40 |
41 | message ConnectionReuse {
42 | bool enable = 1;
43 | }
44 |
45 | message Config {
46 | MTU mtu = 1;
47 | TTI tti = 2;
48 | UplinkCapacity uplink_capacity = 3;
49 | DownlinkCapacity downlink_capacity = 4;
50 | bool congestion = 5;
51 | WriteBuffer write_buffer = 6;
52 | ReadBuffer read_buffer = 7;
53 | v2ray.core.common.serial.TypedMessage header_config = 8;
54 | reserved 9;
55 | }
--------------------------------------------------------------------------------
/model/src/main/proto/v2ray.com/core/transport/internet/tcp/config.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package v2ray.core.transport.internet.tcp;
4 | option csharp_namespace = "V2Ray.Core.Transport.Internet.Tcp";
5 | option go_package = "tcp";
6 | option java_package = "com.v2ray.core.transport.internet.tcp";
7 | option java_multiple_files = true;
8 |
9 | import "v2ray.com/core/common/serial/typed_message.proto";
10 |
11 | message Config {
12 | reserved 1;
13 | v2ray.core.common.serial.TypedMessage header_settings = 2;
14 | }
15 |
--------------------------------------------------------------------------------
/model/src/main/proto/v2ray.com/core/transport/internet/tls/config.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package v2ray.core.transport.internet.tls;
4 | option csharp_namespace = "V2Ray.Core.Transport.Internet.Tls";
5 | option go_package = "tls";
6 | option java_package = "com.v2ray.core.transport.internet.tls";
7 | option java_multiple_files = true;
8 |
9 | message Certificate {
10 | // TLS certificate in x509 format.
11 | bytes Certificate = 1;
12 |
13 | // TLS key in x509 format.
14 | bytes Key = 2;
15 | }
16 |
17 | message Config {
18 | // Whether or not to allow self-signed certificates.
19 | bool allow_insecure = 1;
20 |
21 | // List of certificates to be served on server.
22 | repeated Certificate certificate = 2;
23 |
24 | // Override server name.
25 | string server_name = 3;
26 |
27 | // Lists of string as ALPN values.
28 | repeated string next_protocol = 4;
29 | }
--------------------------------------------------------------------------------
/model/src/main/proto/v2ray.com/core/transport/internet/websocket/config.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package v2ray.core.transport.internet.websocket;
4 | option csharp_namespace = "V2Ray.Core.Transport.Internet.Websocket";
5 | option go_package = "websocket";
6 | option java_package = "com.v2ray.core.transport.internet.websocket";
7 | option java_multiple_files = true;
8 |
9 | message Header {
10 | string key = 1;
11 | string value = 2;
12 | }
13 |
14 | message Config {
15 | reserved 1;
16 |
17 | // URL path to the WebSocket service. Empty value means root(/).
18 | string path = 2;
19 |
20 | repeated Header header = 3;
21 | }
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':model', ':dsl'
2 |
--------------------------------------------------------------------------------