├── .gitignore
├── CMakeLists.txt
├── Changelog
├── DNSCryptClient.desktop
├── DNSCryptClient@.service
├── DNSCryptClient_test@.service
├── DNSCryptClient_test_v2.service
├── LICENSE
├── README.md
├── dnscrypt-proxy-gui.spec
└── src
├── CMakeLists.txt
├── DNSCryptClient.notifyrc
├── app_settings.cpp
├── app_settings.h
├── button_panel.cpp
├── button_panel.h
├── click_label.cpp
├── click_label.h
├── dnscrypt_proxy_icons.qrc
├── enums.h
├── help_thread.cpp
├── help_thread.h
├── helpers
├── CMakeLists.txt
├── dns_utility
│ ├── dns.c
│ └── dns.h
├── job_helper
│ ├── CMakeLists.txt
│ ├── actions.actions
│ ├── dnscrypt_client_helper.cpp
│ └── dnscrypt_client_helper.h
├── reload_helper
│ ├── CMakeLists.txt
│ ├── actions.actions
│ ├── dnscrypt_client_reload_helper.cpp
│ └── dnscrypt_client_reload_helper.h
└── test_helper
│ ├── CMakeLists.txt
│ ├── actions.actions
│ ├── dnscrypt_client_test_helper.cpp
│ └── dnscrypt_client_test_helper.h
├── icons
├── 128x128
│ └── actions
│ │ ├── DNSCryptClient_close.png
│ │ ├── DNSCryptClient_open.png
│ │ └── DNSCryptClient_restore.png
├── 32x32
│ └── status
│ │ ├── fast.png
│ │ ├── middle.png
│ │ ├── none.png
│ │ └── slow.png
├── 64x64
│ ├── actions
│ │ ├── DNSCryptClient_add.png
│ │ ├── DNSCryptClient_close.png
│ │ ├── DNSCryptClient_help.png
│ │ ├── DNSCryptClient_info.png
│ │ ├── DNSCryptClient_open.png
│ │ ├── DNSCryptClient_settings.png
│ │ ├── DNSCryptClient_start.png
│ │ ├── DNSCryptClient_test.png
│ │ └── DNSCryptClient_write.png
│ └── status
│ │ ├── DNSCryptClient.png
│ │ ├── DNSCryptClient_closed.png
│ │ ├── DNSCryptClient_opened.png
│ │ ├── DNSCryptClient_reload.png
│ │ └── exit.png
├── License
└── index.theme
├── info_panel.cpp
├── info_panel.h
├── main.cpp
├── mainwindow.cpp
├── mainwindow.h
├── port_settings.cpp
├── port_settings.h
├── resolver_entries.cpp
├── resolver_entries.h
├── server_info.cpp
├── server_info.h
├── server_panel.cpp
├── server_panel.h
├── test_respond.cpp
├── test_respond.h
├── test_widget.cpp
├── test_widget.h
└── tray
├── traywidget.cpp
└── traywidget.h
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | CMakeLists.txt.user
3 | CMakeCache.txt
4 | CMakeFiles
5 | Makefile
6 | cmake_install.cmake
7 | install_manifest.txt
8 | *build*
9 | make-source-archive
10 |
--------------------------------------------------------------------------------
/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.0)
2 | set (CMAKE_INSTALL_PREFIX /usr)
3 |
4 |
5 | project (dnscrypt-proxy-gui)
6 | set (APP_NAME DNSCryptClient)
7 |
8 | include(CheckFunctionExists)
9 | include(CheckCXXCompilerFlag)
10 | CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
11 | if (COMPILER_SUPPORTS_CXX11)
12 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
13 | endif()
14 |
15 | add_subdirectory(src)
16 |
17 | install ( FILES ${APP_NAME}.desktop
18 | DESTINATION ${SHARE_INSTALL_PREFIX}/applications )
19 | install ( FILES ${APP_NAME}@.service
20 | DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/systemd/system )
21 | install ( FILES ${APP_NAME}_test@.service
22 | DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/systemd/system )
23 | install ( FILES ${APP_NAME}_test_v2.service
24 | DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/systemd/system )
25 | install ( FILES src/icons/64x64/status/${APP_NAME}.png
26 | DESTINATION ${SHARE_INSTALL_PREFIX}/icons/hicolor/64x64/apps
27 | RENAME ${APP_NAME}.png )
28 |
--------------------------------------------------------------------------------
/Changelog:
--------------------------------------------------------------------------------
1 | v.1.0.0 :
2 | implemented DNSCrypt proxy client;
3 |
4 | v.1.2.2 :
5 | simplified start/stop implementation;
6 | enhanced restoring control;
7 | simplified notification;
8 | enhanced Server Info;
9 |
10 | v.1.2.3 :
11 | removed useless socket unit;
12 |
13 | v.1.3.4 :
14 | added test of the servers validity;
15 | enhanced GUI;
16 |
17 | v.1.3.7 :
18 | fixed restore settings;
19 | fixed start proxing in simple mode;
20 | added 'use fast only' property;
21 |
22 | v.1.5.7 :
23 | implemented test for respond speed;
24 | implemented exclusion from proxy servers list;
25 |
26 | v.1.6.8 :
27 | reimplemented dns respond test as free action;
28 | changed dns respond timeout to 3 sec.;
29 |
30 | v.1.9.8 :
31 | implemented changing the job\test ports;
32 | implemented test_helper
33 | for avoid deadlock
34 | between job and test actions;
35 | implemented check and change job\test ports
36 | to according with settings
37 | if application was updated or reinstalled;
38 |
39 | v.1.10.8 :
40 | implemented 'asUser' parameter
41 | for DNSCryptClient systemd unit;
42 | implemented reload_helper
43 | for avoid deadlock
44 | between job, test, reload actions;
45 |
46 | v.1.10.9 :
47 | fixed activation the Start button
48 | after cancel the restore dialog;
49 |
50 | v.1.10.10 :
51 | fixed the uncontrol expanding mainwindow
52 | at first start;
53 |
54 | v.1.11.10 :
55 | enhanceded icon set and some fixes
56 | for resizing;
57 |
58 | v.1.11.11 :
59 | added UnhideAtStart settings;
60 |
61 | v.1.11.14 :
62 | some enhancements
63 | ( fixed issues #10, #11, #12);
64 |
65 | v.1.11.15 :
66 | some enhancements
67 | ( fixed issues #14);
68 |
69 | v.1.20.15 :
70 | adopted for using dnscrypt-proxy v2
71 | ( fixed issues #9);
72 |
73 | v.1.21.16 :
74 | added restoring resolv.conf
75 | at active service;
76 | added show messages settings;
77 |
78 | v.1.23.17 :
79 | implemented automated initialization
80 | of dnscrypt-proxy service;
81 | fixed respond test for ver.2;
82 | some fixes;
83 |
84 | v.1.24.17 :
85 | implemented re-initialization action
86 | for in tray menu for ver.2;
87 |
88 | v.1.24.20 :
89 | fixed deprecated headers;
90 | some fixes for building with old Kauth releases;
91 |
--------------------------------------------------------------------------------
/DNSCryptClient.desktop:
--------------------------------------------------------------------------------
1 | [Desktop Entry]
2 | Name=DNSCryptClient
3 | GenericName=Qt DNSCrypt proxy client
4 | Type=Application
5 | Categories=Network;
6 | Icon=DNSCryptClient
7 | Exec=DNSCryptClient
8 | Terminal=false
9 | StartupNotify=true
10 |
--------------------------------------------------------------------------------
/DNSCryptClient@.service:
--------------------------------------------------------------------------------
1 | [Unit]
2 | Description=DNSCrypt client proxy
3 | Documentation=man:dnscrypt-proxy(8)
4 | After=network.target
5 | Before=nss-lookup.target
6 |
7 | [Install]
8 | #WantedBy=multi-user.target
9 |
10 | [Service]
11 | Type=simple
12 | NonBlocking=true
13 |
14 | # Fill in the resolver name with one from dnscrypt-resolvers.csv file
15 | # with default 127.0.0.1:53 local-address
16 | ExecStart=/usr/sbin/dnscrypt-proxy -a 127.0.0.1:53 -R %i
17 |
--------------------------------------------------------------------------------
/DNSCryptClient_test@.service:
--------------------------------------------------------------------------------
1 | [Unit]
2 | Description=DNSCrypt client proxy test service
3 | Documentation=man:dnscrypt-proxy(8)
4 | After=network.target
5 | Before=nss-lookup.target
6 |
7 | [Install]
8 | #WantedBy=multi-user.target
9 |
10 | [Service]
11 | Type=simple
12 | NonBlocking=true
13 |
14 | # Fill in the resolver name with one from dnscrypt-resolvers.csv file
15 | ExecStart=/usr/sbin/dnscrypt-proxy -a 127.0.0.1:53535 -R %i
16 |
--------------------------------------------------------------------------------
/DNSCryptClient_test_v2.service:
--------------------------------------------------------------------------------
1 | [Unit]
2 | Description=DNSCrypt-proxy v2 client
3 | Documentation=https://github.com/jedisct1/dnscrypt-proxy/wiki
4 |
5 | After=network-online.target
6 | Wants=network-online.target
7 |
8 | Before=nss-lookup.target
9 | Wants=nss-lookup.target
10 |
11 | [Service]
12 | NonBlocking=true
13 | ExecStart=/usr/bin/dnscrypt-proxy --config /tmp/DNSCryptClientV2.toml
14 |
15 | [Install]
16 |
17 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 2, June 1991
3 |
4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 | Preamble
10 |
11 | The licenses for most software are designed to take away your
12 | freedom to share and change it. By contrast, the GNU General Public
13 | License is intended to guarantee your freedom to share and change free
14 | software--to make sure the software is free for all its users. This
15 | General Public License applies to most of the Free Software
16 | Foundation's software and to any other program whose authors commit to
17 | using it. (Some other Free Software Foundation software is covered by
18 | the GNU Lesser General Public License instead.) You can apply it to
19 | your programs, too.
20 |
21 | When we speak of free software, we are referring to freedom, not
22 | price. Our General Public Licenses are designed to make sure that you
23 | have the freedom to distribute copies of free software (and charge for
24 | this service if you wish), that you receive source code or can get it
25 | if you want it, that you can change the software or use pieces of it
26 | in new free programs; and that you know you can do these things.
27 |
28 | To protect your rights, we need to make restrictions that forbid
29 | anyone to deny you these rights or to ask you to surrender the rights.
30 | These restrictions translate to certain responsibilities for you if you
31 | distribute copies of the software, or if you modify it.
32 |
33 | For example, if you distribute copies of such a program, whether
34 | gratis or for a fee, you must give the recipients all the rights that
35 | you have. You must make sure that they, too, receive or can get the
36 | source code. And you must show them these terms so they know their
37 | rights.
38 |
39 | We protect your rights with two steps: (1) copyright the software, and
40 | (2) offer you this license which gives you legal permission to copy,
41 | distribute and/or modify the software.
42 |
43 | Also, for each author's protection and ours, we want to make certain
44 | that everyone understands that there is no warranty for this free
45 | software. If the software is modified by someone else and passed on, we
46 | want its recipients to know that what they have is not the original, so
47 | that any problems introduced by others will not reflect on the original
48 | authors' reputations.
49 |
50 | Finally, any free program is threatened constantly by software
51 | patents. We wish to avoid the danger that redistributors of a free
52 | program will individually obtain patent licenses, in effect making the
53 | program proprietary. To prevent this, we have made it clear that any
54 | patent must be licensed for everyone's free use or not licensed at all.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | GNU GENERAL PUBLIC LICENSE
60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61 |
62 | 0. This License applies to any program or other work which contains
63 | a notice placed by the copyright holder saying it may be distributed
64 | under the terms of this General Public License. The "Program", below,
65 | refers to any such program or work, and a "work based on the Program"
66 | means either the Program or any derivative work under copyright law:
67 | that is to say, a work containing the Program or a portion of it,
68 | either verbatim or with modifications and/or translated into another
69 | language. (Hereinafter, translation is included without limitation in
70 | the term "modification".) Each licensee is addressed as "you".
71 |
72 | Activities other than copying, distribution and modification are not
73 | covered by this License; they are outside its scope. The act of
74 | running the Program is not restricted, and the output from the Program
75 | is covered only if its contents constitute a work based on the
76 | Program (independent of having been made by running the Program).
77 | Whether that is true depends on what the Program does.
78 |
79 | 1. You may copy and distribute verbatim copies of the Program's
80 | source code as you receive it, in any medium, provided that you
81 | conspicuously and appropriately publish on each copy an appropriate
82 | copyright notice and disclaimer of warranty; keep intact all the
83 | notices that refer to this License and to the absence of any warranty;
84 | and give any other recipients of the Program a copy of this License
85 | along with the Program.
86 |
87 | You may charge a fee for the physical act of transferring a copy, and
88 | you may at your option offer warranty protection in exchange for a fee.
89 |
90 | 2. You may modify your copy or copies of the Program or any portion
91 | of it, thus forming a work based on the Program, and copy and
92 | distribute such modifications or work under the terms of Section 1
93 | above, provided that you also meet all of these conditions:
94 |
95 | a) You must cause the modified files to carry prominent notices
96 | stating that you changed the files and the date of any change.
97 |
98 | b) You must cause any work that you distribute or publish, that in
99 | whole or in part contains or is derived from the Program or any
100 | part thereof, to be licensed as a whole at no charge to all third
101 | parties under the terms of this License.
102 |
103 | c) If the modified program normally reads commands interactively
104 | when run, you must cause it, when started running for such
105 | interactive use in the most ordinary way, to print or display an
106 | announcement including an appropriate copyright notice and a
107 | notice that there is no warranty (or else, saying that you provide
108 | a warranty) and that users may redistribute the program under
109 | these conditions, and telling the user how to view a copy of this
110 | License. (Exception: if the Program itself is interactive but
111 | does not normally print such an announcement, your work based on
112 | the Program is not required to print an announcement.)
113 |
114 | These requirements apply to the modified work as a whole. If
115 | identifiable sections of that work are not derived from the Program,
116 | and can be reasonably considered independent and separate works in
117 | themselves, then this License, and its terms, do not apply to those
118 | sections when you distribute them as separate works. But when you
119 | distribute the same sections as part of a whole which is a work based
120 | on the Program, the distribution of the whole must be on the terms of
121 | this License, whose permissions for other licensees extend to the
122 | entire whole, and thus to each and every part regardless of who wrote it.
123 |
124 | Thus, it is not the intent of this section to claim rights or contest
125 | your rights to work written entirely by you; rather, the intent is to
126 | exercise the right to control the distribution of derivative or
127 | collective works based on the Program.
128 |
129 | In addition, mere aggregation of another work not based on the Program
130 | with the Program (or with a work based on the Program) on a volume of
131 | a storage or distribution medium does not bring the other work under
132 | the scope of this License.
133 |
134 | 3. You may copy and distribute the Program (or a work based on it,
135 | under Section 2) in object code or executable form under the terms of
136 | Sections 1 and 2 above provided that you also do one of the following:
137 |
138 | a) Accompany it with the complete corresponding machine-readable
139 | source code, which must be distributed under the terms of Sections
140 | 1 and 2 above on a medium customarily used for software interchange; or,
141 |
142 | b) Accompany it with a written offer, valid for at least three
143 | years, to give any third party, for a charge no more than your
144 | cost of physically performing source distribution, a complete
145 | machine-readable copy of the corresponding source code, to be
146 | distributed under the terms of Sections 1 and 2 above on a medium
147 | customarily used for software interchange; or,
148 |
149 | c) Accompany it with the information you received as to the offer
150 | to distribute corresponding source code. (This alternative is
151 | allowed only for noncommercial distribution and only if you
152 | received the program in object code or executable form with such
153 | an offer, in accord with Subsection b above.)
154 |
155 | The source code for a work means the preferred form of the work for
156 | making modifications to it. For an executable work, complete source
157 | code means all the source code for all modules it contains, plus any
158 | associated interface definition files, plus the scripts used to
159 | control compilation and installation of the executable. However, as a
160 | special exception, the source code distributed need not include
161 | anything that is normally distributed (in either source or binary
162 | form) with the major components (compiler, kernel, and so on) of the
163 | operating system on which the executable runs, unless that component
164 | itself accompanies the executable.
165 |
166 | If distribution of executable or object code is made by offering
167 | access to copy from a designated place, then offering equivalent
168 | access to copy the source code from the same place counts as
169 | distribution of the source code, even though third parties are not
170 | compelled to copy the source along with the object code.
171 |
172 | 4. You may not copy, modify, sublicense, or distribute the Program
173 | except as expressly provided under this License. Any attempt
174 | otherwise to copy, modify, sublicense or distribute the Program is
175 | void, and will automatically terminate your rights under this License.
176 | However, parties who have received copies, or rights, from you under
177 | this License will not have their licenses terminated so long as such
178 | parties remain in full compliance.
179 |
180 | 5. You are not required to accept this License, since you have not
181 | signed it. However, nothing else grants you permission to modify or
182 | distribute the Program or its derivative works. These actions are
183 | prohibited by law if you do not accept this License. Therefore, by
184 | modifying or distributing the Program (or any work based on the
185 | Program), you indicate your acceptance of this License to do so, and
186 | all its terms and conditions for copying, distributing or modifying
187 | the Program or works based on it.
188 |
189 | 6. Each time you redistribute the Program (or any work based on the
190 | Program), the recipient automatically receives a license from the
191 | original licensor to copy, distribute or modify the Program subject to
192 | these terms and conditions. You may not impose any further
193 | restrictions on the recipients' exercise of the rights granted herein.
194 | You are not responsible for enforcing compliance by third parties to
195 | this License.
196 |
197 | 7. If, as a consequence of a court judgment or allegation of patent
198 | infringement or for any other reason (not limited to patent issues),
199 | conditions are imposed on you (whether by court order, agreement or
200 | otherwise) that contradict the conditions of this License, they do not
201 | excuse you from the conditions of this License. If you cannot
202 | distribute so as to satisfy simultaneously your obligations under this
203 | License and any other pertinent obligations, then as a consequence you
204 | may not distribute the Program at all. For example, if a patent
205 | license would not permit royalty-free redistribution of the Program by
206 | all those who receive copies directly or indirectly through you, then
207 | the only way you could satisfy both it and this License would be to
208 | refrain entirely from distribution of the Program.
209 |
210 | If any portion of this section is held invalid or unenforceable under
211 | any particular circumstance, the balance of the section is intended to
212 | apply and the section as a whole is intended to apply in other
213 | circumstances.
214 |
215 | It is not the purpose of this section to induce you to infringe any
216 | patents or other property right claims or to contest validity of any
217 | such claims; this section has the sole purpose of protecting the
218 | integrity of the free software distribution system, which is
219 | implemented by public license practices. Many people have made
220 | generous contributions to the wide range of software distributed
221 | through that system in reliance on consistent application of that
222 | system; it is up to the author/donor to decide if he or she is willing
223 | to distribute software through any other system and a licensee cannot
224 | impose that choice.
225 |
226 | This section is intended to make thoroughly clear what is believed to
227 | be a consequence of the rest of this License.
228 |
229 | 8. If the distribution and/or use of the Program is restricted in
230 | certain countries either by patents or by copyrighted interfaces, the
231 | original copyright holder who places the Program under this License
232 | may add an explicit geographical distribution limitation excluding
233 | those countries, so that distribution is permitted only in or among
234 | countries not thus excluded. In such case, this License incorporates
235 | the limitation as if written in the body of this License.
236 |
237 | 9. The Free Software Foundation may publish revised and/or new versions
238 | of the General Public License from time to time. Such new versions will
239 | be similar in spirit to the present version, but may differ in detail to
240 | address new problems or concerns.
241 |
242 | Each version is given a distinguishing version number. If the Program
243 | specifies a version number of this License which applies to it and "any
244 | later version", you have the option of following the terms and conditions
245 | either of that version or of any later version published by the Free
246 | Software Foundation. If the Program does not specify a version number of
247 | this License, you may choose any version ever published by the Free Software
248 | Foundation.
249 |
250 | 10. If you wish to incorporate parts of the Program into other free
251 | programs whose distribution conditions are different, write to the author
252 | to ask for permission. For software which is copyrighted by the Free
253 | Software Foundation, write to the Free Software Foundation; we sometimes
254 | make exceptions for this. Our decision will be guided by the two goals
255 | of preserving the free status of all derivatives of our free software and
256 | of promoting the sharing and reuse of software generally.
257 |
258 | NO WARRANTY
259 |
260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268 | REPAIR OR CORRECTION.
269 |
270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278 | POSSIBILITY OF SUCH DAMAGES.
279 |
280 | END OF TERMS AND CONDITIONS
281 |
282 | How to Apply These Terms to Your New Programs
283 |
284 | If you develop a new program, and you want it to be of the greatest
285 | possible use to the public, the best way to achieve this is to make it
286 | free software which everyone can redistribute and change under these terms.
287 |
288 | To do so, attach the following notices to the program. It is safest
289 | to attach them to the start of each source file to most effectively
290 | convey the exclusion of warranty; and each file should have at least
291 | the "copyright" line and a pointer to where the full notice is found.
292 |
293 | {description}
294 | Copyright (C) {year} {fullname}
295 |
296 | This program is free software; you can redistribute it and/or modify
297 | it under the terms of the GNU General Public License as published by
298 | the Free Software Foundation; either version 2 of the License, or
299 | (at your option) any later version.
300 |
301 | This program is distributed in the hope that it will be useful,
302 | but WITHOUT ANY WARRANTY; without even the implied warranty of
303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304 | GNU General Public License for more details.
305 |
306 | You should have received a copy of the GNU General Public License along
307 | with this program; if not, write to the Free Software Foundation, Inc.,
308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309 |
310 | Also add information on how to contact you by electronic and paper mail.
311 |
312 | If the program is interactive, make it output a short notice like this
313 | when it starts in an interactive mode:
314 |
315 | Gnomovision version 69, Copyright (C) year name of author
316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317 | This is free software, and you are welcome to redistribute it
318 | under certain conditions; type `show c' for details.
319 |
320 | The hypothetical commands `show w' and `show c' should show the appropriate
321 | parts of the General Public License. Of course, the commands you use may
322 | be called something other than `show w' and `show c'; they could even be
323 | mouse-clicks or menu items--whatever suits your program.
324 |
325 | You should also get your employer (if you work as a programmer) or your
326 | school, if any, to sign a "copyright disclaimer" for the program, if
327 | necessary. Here is a sample; alter the names:
328 |
329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330 | `Gnomovision' (which makes passes at compilers) written by James Hacker.
331 |
332 | {signature of Ty Coon}, 1 April 1989
333 | Ty Coon, President of Vice
334 |
335 | This General Public License does not permit incorporating your program into
336 | proprietary programs. If your program is a subroutine library, you may
337 | consider it more useful to permit linking proprietary applications with the
338 | library. If this is what you want to do, use the GNU Lesser General
339 | Public License instead of this License.
340 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # DNSCryptClient
2 | Qt/KF5 GUI wrapper over dnscrypt-proxy (v.1 & v.2)
3 |
4 | Contains systemd instantiated unit for control proxying service.
5 | Works with local (127.0.0.1 by default) address and service list from
6 | dnscrypt-proxy package.
7 | Implemented restore DNS resolver system settings.
8 |
--------------------------------------------------------------------------------
/dnscrypt-proxy-gui.spec:
--------------------------------------------------------------------------------
1 | %global cmake_build_dir build-cmake
2 | %global app_name DNSCryptClient
3 |
4 | Name: dnscrypt-proxy-gui
5 | Version: 1.24.20
6 | Release: 1%{?dist}
7 | Summary: GUI wrapper for dnscrypt-proxy
8 | License: GPLv2+
9 | Source0: https://github.com/F1ash/%{name}/archive/%{version}.tar.gz
10 | URL: https://github.com/F1ash/%{name}
11 |
12 | Requires: systemd
13 | Requires: polkit
14 | Requires: dnscrypt-proxy
15 | Requires: hicolor-icon-theme
16 | Requires: kf5-kauth
17 | Requires: kf5-knotifications
18 |
19 | BuildRequires: gcc-c++
20 | BuildRequires: cmake
21 | BuildRequires: glibc-headers
22 | BuildRequires: desktop-file-utils
23 | BuildRequires: qt5-qtbase-devel
24 | BuildRequires: qt5-qtbase-private-devel
25 | %{?_qt5:Requires: %{_qt5}%{?_isa} = %{_qt5_version}}
26 | BuildRequires: kf5-kauth-devel
27 | BuildRequires: kf5-knotifications-devel
28 | BuildRequires: extra-cmake-modules
29 | %{?systemd_requires}
30 | BuildRequires: systemd
31 |
32 | %description
33 | The Qt/KF5 GUI wrapper over dnscrypt-proxy (version 1, 2)
34 | for encrypting all DNS traffic between the user and DNS resolvers,
35 | preventing any spying, spoofing or man-in-the-middle attacks.
36 |
37 | %prep
38 | %setup -q
39 |
40 | %build
41 | mkdir %{cmake_build_dir}
42 | pushd %{cmake_build_dir}
43 | %cmake ..
44 | %{make_build}
45 | popd
46 |
47 | %install
48 | pushd %{cmake_build_dir}
49 | %{make_install}
50 | popd
51 |
52 | %check
53 | desktop-file-validate %{buildroot}/%{_datadir}/applications/%{app_name}.desktop
54 |
55 | %post
56 | /bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null || :
57 | %systemd_post %{app_name}@.service
58 | %systemd_post %{app_name}_test@.service
59 | %systemd_post %{app_name}_test_v2.service
60 |
61 | %preun
62 | %systemd_preun %{app_name}@.service
63 | %systemd_preun %{app_name}_test@.service
64 | %systemd_post %{app_name}_test_v2.service
65 |
66 | %postun
67 | %systemd_postun %{app_name}@.service
68 | %systemd_postun %{app_name}_test@.service
69 | %systemd_post %{app_name}_test_v2.service
70 |
71 | %files
72 | %license LICENSE
73 | %doc README.md
74 | %{_bindir}/%{app_name}
75 | %{_datadir}/applications/%{app_name}.desktop
76 | %{_libexecdir}/kf5/kauth/dnscrypt_client_helper
77 | %{_datadir}/dbus-1/system-services/pro.russianfedora.dnscryptclient.service
78 | %{_datadir}/polkit-1/actions/pro.russianfedora.dnscryptclient.policy
79 | %{_sysconfdir}/dbus-1/system.d/pro.russianfedora.dnscryptclient.conf
80 | %{_libexecdir}/kf5/kauth/dnscrypt_client_test_helper
81 | %{_datadir}/dbus-1/system-services/pro.russianfedora.dnscryptclienttest.service
82 | %{_datadir}/polkit-1/actions/pro.russianfedora.dnscryptclienttest.policy
83 | %{_sysconfdir}/dbus-1/system.d/pro.russianfedora.dnscryptclienttest.conf
84 | %{_libexecdir}/kf5/kauth/dnscrypt_client_reload_helper
85 | %{_datadir}/dbus-1/system-services/pro.russianfedora.dnscryptclientreload.service
86 | %{_datadir}/polkit-1/actions/pro.russianfedora.dnscryptclientreload.policy
87 | %{_sysconfdir}/dbus-1/system.d/pro.russianfedora.dnscryptclientreload.conf
88 | %{_datadir}/knotifications5/%{app_name}.notifyrc
89 | %{_unitdir}/%{app_name}@.service
90 | %{_unitdir}/%{app_name}_test@.service
91 | %{_unitdir}/%{app_name}_test_v2.service
92 | %{_datadir}/icons/hicolor/64x64/apps/%{app_name}.png
93 |
94 | %changelog
95 | * Tue Jun 14 2022 Fl@sh - 1.24.20-1
96 | - version updated;
97 |
98 | * Mon Jun 6 2022 Fl@sh - 1.24.18-1
99 | - version updated;
100 |
101 | * Fri Jan 1 2021 Fl@sh - 1.24.17-1
102 | - version updated;
103 |
104 | * Mon Dec 28 2020 Fl@sh - 1.23.17-1
105 | - enhanced R;
106 | - version updated;
107 |
108 | * Mon Dec 26 2018 Fl@sh - 1.21.16-1
109 | - enhanced R, BR, %%postun, delete %%posttrans;
110 | - version updated;
111 |
112 | * Mon Dec 24 2018 Fl@sh - 1.20.15-1
113 | - enhanced %%description;
114 | - added new unit file to %%files, %%post, %%preun, %%postun;
115 | - version updated;
116 |
117 | * Mon Mar 5 2018 Fl@sh - 1.11.15-1
118 | - version updated;
119 |
120 | * Wed Feb 21 2018 Fl@sh - 1.11.14-1
121 | - version updated;
122 |
123 | * Mon Jan 15 2018 Fl@sh - 1.11.11-1
124 | - version updated;
125 |
126 | * Wed Jun 28 2017 Fl@sh - 1.11.10-1
127 | - version updated;
128 |
129 | * Tue Jun 27 2017 Fl@sh - 1.10.10-1
130 | - version updated;
131 |
132 | * Thu Jun 22 2017 Fl@sh - 1.10.9-1
133 | - version updated;
134 |
135 | * Sat Jun 3 2017 Fl@sh - 1.10.8-1
136 | - changed %%files for reload_helper;
137 | - version updated;
138 |
139 | * Mon May 22 2017 Fl@sh - 1.9.8-1
140 | - changed %%files for test_helper;
141 | - version updated;
142 |
143 | * Mon Mar 27 2017 Fl@sh - 1.6.8-2
144 | - release updated;
145 |
146 | * Mon Mar 27 2017 Fl@sh - 1.6.8-1
147 | - version updated;
148 | - changed %%post, %%preun, %%postun, %%files for new systemd unit;
149 |
150 | * Sun Jan 29 2017 Fl@sh - 1.5.7-1
151 | - version updated;
152 |
153 | * Tue Jan 10 2017 Fl@sh - 1.3.7-1
154 | - version updated;
155 |
156 | * Fri Dec 16 2016 Fl@sh - 1.2.3-4
157 | - removed dbus-1 R;
158 | - release updated;
159 |
160 | * Wed Dec 7 2016 Fl@sh - 1.2.3-3
161 | - returned gcc-c++ BR;
162 | - release updated;
163 |
164 | * Wed Dec 7 2016 Fl@sh - 1.2.3-2
165 | - removed gcc-c++ BR, fixed dbus-1 R;
166 | - added scriptlets for update Icon_Cache;
167 | - added %%license in %%files;
168 | - release updated;
169 |
170 | * Wed Dec 7 2016 Fl@sh - 1.2.3-1
171 | - enhanced Summary and %%description;
172 | - removed useless socket unit from scriplets and %%files;
173 | - version updated;
174 |
175 | * Mon Nov 28 2016 Fl@sh - 1.2.2-4
176 | - added cmake, gcc-c++ BR;
177 | - added systemd scriptlets;
178 | - release updated;
179 |
180 | * Sun Nov 27 2016 Fl@sh - 1.2.2-3
181 | - changed package name to comply with the NamingGuidelines;
182 | - release updated;
183 |
184 | * Fri Nov 25 2016 Fl@sh - 1.2.2-2
185 | - changed package name to comply with the NamingGuidelines;
186 | - release updated;
187 |
188 | * Fri Nov 25 2016 Fl@sh - 1.2.2-1
189 | - version updated;
190 |
191 | * Tue Nov 22 2016 Fl@sh - 1.0.0-2
192 | - enhanced Summary and %%description;
193 | - release updated;
194 |
195 | * Mon Nov 21 2016 Fl@sh - 1.0.0-1
196 | - Initial build
197 |
--------------------------------------------------------------------------------
/src/CMakeLists.txt:
--------------------------------------------------------------------------------
1 |
2 | find_package(ECM REQUIRED NO_MODULE)
3 | set(CMAKE_MODULE_PATH ${ECM_MODULE_DIR} ${ECM_KDE_MODULE_DIR})
4 | include(KDEInstallDirs)
5 |
6 | set(HEADERS
7 | enums.h
8 | mainwindow.h
9 | server_panel.h
10 | button_panel.h
11 | info_panel.h
12 | app_settings.h
13 | test_respond.h
14 | test_widget.h
15 | help_thread.h
16 | server_info.h
17 | resolver_entries.h
18 | click_label.h
19 | port_settings.h
20 | tray/traywidget.h)
21 | set(SOURCES
22 | main.cpp
23 | mainwindow.cpp
24 | server_panel.cpp
25 | button_panel.cpp
26 | info_panel.cpp
27 | app_settings.cpp
28 | test_respond.cpp
29 | test_widget.cpp
30 | help_thread.cpp
31 | server_info.cpp
32 | resolver_entries.cpp
33 | click_label.cpp
34 | port_settings.cpp
35 | tray/traywidget.cpp)
36 |
37 | find_package(Qt5Core REQUIRED)
38 | find_package(Qt5Widgets REQUIRED)
39 | find_package(Qt5DBus REQUIRED)
40 | find_package(KF5Auth REQUIRED)
41 | find_package(KF5Notifications REQUIRED)
42 | include_directories(
43 | ${Qt5Core_INCLUDE_DIRS}
44 | ${Qt5Widgets_INCLUDE_DIRS}
45 | ${Qt5DBus_INCLUDE_DIRS}
46 | ${Qt5DBus_PRIVATE_INCLUDE_DIRS})
47 | #message("DBusPrivDirs: ${Qt5DBus_PRIVATE_INCLUDE_DIRS}")
48 | qt5_wrap_cpp(MOC_SOURCES ${HEADERS})
49 | qt5_add_resources(RCCs dnscrypt_proxy_icons.qrc)
50 | set (
51 | BUILD_PROJECT_LIBRARIES
52 | ${Qt5Core_LIBRARIES}
53 | ${Qt5Widgets_LIBRARIES}
54 | ${Qt5DBus_LIBRARIES}
55 | KF5::Auth
56 | KF5::Notifications)
57 | add_definitions(
58 | ${Qt5Core_DEFINITIONS}
59 | ${Qt5Widgets_DEFINITIONS}
60 | ${Qt5DBus_DEFINITIONS})
61 |
62 | add_executable(
63 | ${APP_NAME}
64 | ${HEADERS}
65 | ${SOURCES}
66 | ${MOC_SOURCES}
67 | ${RCCs})
68 | target_link_libraries(${APP_NAME} ${BUILD_PROJECT_LIBRARIES})
69 |
70 | install ( TARGETS ${APP_NAME}
71 | DESTINATION ${CMAKE_INSTALL_PREFIX}/bin )
72 | #message("KNOTIFYRC_INSTALL_DIR: ${KNOTIFYRC_INSTALL_DIR}")
73 | install( FILES ${APP_NAME}.notifyrc
74 | DESTINATION ${KNOTIFYRC_INSTALL_DIR})
75 |
76 | add_subdirectory(helpers)
77 |
--------------------------------------------------------------------------------
/src/DNSCryptClient.notifyrc:
--------------------------------------------------------------------------------
1 | [Global]
2 | IconName=WvDialer
3 | Comment=Qt wrapper for wvdial
4 | Name=WvDialer
5 |
--------------------------------------------------------------------------------
/src/app_settings.cpp:
--------------------------------------------------------------------------------
1 | #include "app_settings.h"
2 | //#include
3 |
4 | AppSettings::AppSettings(QWidget *parent, QString ver) :
5 | QWidget(parent), serviceVersion(ver)
6 | {
7 | setLabel = new QLabel(this);
8 | setLabel->setPixmap(QIcon::fromTheme(
9 | "DNSCryptClient_settings",
10 | QIcon(":/settings.png"))
11 | .pixmap(32));
12 | setLabel->setSizePolicy(
13 | QSizePolicy(
14 | QSizePolicy::Ignored,
15 | QSizePolicy::Ignored));
16 | setLabel->setContentsMargins(0, 0, 0, 0);
17 | nameLabel = new QLabel(this);
18 | nameLabel->setText("Application Settings");
19 | nameLabel->setSizePolicy(
20 | QSizePolicy(
21 | QSizePolicy::Ignored,
22 | QSizePolicy::Ignored));
23 | nameLabel->setContentsMargins(0, 0, 0, 0);
24 | baseButton = new QPushButton(
25 | QIcon::fromTheme("DNSCryptClient_start",
26 | QIcon(":/start.png")),
27 | "", this);
28 | baseButton->setFlat(false);
29 | baseButton->setToolTip("to Control Panel");
30 | baseButton->setSizePolicy(
31 | QSizePolicy(
32 | QSizePolicy::Ignored,
33 | QSizePolicy::Ignored));
34 | baseButton->setContentsMargins(0, 0, 0, 0);
35 | headLayout = new QHBoxLayout(this);
36 | headLayout->addWidget(setLabel, 1);
37 | headLayout->addWidget(nameLabel, 10, Qt::AlignCenter);
38 | headLayout->addWidget(baseButton, 1);
39 | headWdg = new QWidget(this);
40 | headWdg->setContentsMargins(0, 0, 0, 0);
41 | headWdg->setLayout(headLayout);
42 |
43 | advancedLabel = new QLabel(this);
44 | advancedLabel->setText("Advanced settings");
45 |
46 | runAtStart = new QCheckBox(
47 | "run service at start",
48 | this);
49 | unhideAtStart = new QCheckBox(
50 | "unhide at start",
51 | this);
52 | useActiveService = new QCheckBox(
53 | "use an active service automatically",
54 | this);
55 | useFastOnly = new QCheckBox(
56 | "use fast servers only",
57 | this);
58 | useFastOnly->setEnabled(false);
59 | restoreAtClose = new QCheckBox(
60 | "restore DNS system resolver settings at close",
61 | this);
62 | showMessages = new QCheckBox(
63 | "show messages",
64 | this);
65 | showBasicMsgOnly = new QCheckBox(
66 | "show basic messages only",
67 | this);
68 |
69 | asUser = new QCheckBox("Use as user", this);
70 | asUserLine = new QLineEdit(this);
71 | asUserLine->setEnabled(false);
72 | asUserLine->setPlaceholderText("dnscrypt");
73 | asUserLayout = new QHBoxLayout(this);
74 | asUserLayout->addWidget(asUser);
75 | asUserLayout->addWidget(asUserLine);
76 | asUserWdg = new QWidget(this);
77 | asUserWdg->setLayout(asUserLayout);
78 |
79 | jobPort = new PortSettings(this, JOB_PORT);
80 | jobPort->setName("port for receive DNS");
81 | testPort = new PortSettings(this, TEST_PORT);
82 | testPort->setName("port for testing server's responds");
83 | if ( serviceVersion.compare("2")>0 ) {
84 | asUserWdg->hide();
85 | jobPort->hide();
86 | };
87 |
88 | restoreDefaultBtn = new QPushButton(
89 | "Restore default",
90 | this);
91 | applyNewPortsBtn = new QPushButton(
92 | "Apply new ports",
93 | this);
94 | applyNewPortsBtn->setEnabled(false);
95 | advancedButtonsLayout = new QHBoxLayout(this);
96 | advancedButtonsLayout->addWidget(restoreDefaultBtn);
97 | advancedButtonsLayout->addWidget(applyNewPortsBtn);
98 | advancedButtons = new QWidget(this);
99 | advancedButtons->setLayout(advancedButtonsLayout);
100 |
101 | appSettingsLayout = new QVBoxLayout(this);
102 | appSettingsLayout->addWidget(runAtStart);
103 | appSettingsLayout->addWidget(unhideAtStart);
104 | appSettingsLayout->addWidget(useActiveService);
105 | appSettingsLayout->addWidget(useFastOnly);
106 | appSettingsLayout->addWidget(restoreAtClose);
107 | appSettingsLayout->addWidget(showMessages);
108 | appSettingsLayout->addWidget(showBasicMsgOnly);
109 | appSettingsLayout->addWidget(advancedLabel, 0, Qt::AlignCenter);
110 | appSettingsLayout->addWidget(asUserWdg, 0, Qt::AlignLeft);
111 | appSettingsLayout->addWidget(jobPort, 0, Qt::AlignLeft);
112 | appSettingsLayout->addWidget(testPort, 0, Qt::AlignLeft);
113 | appSettingsLayout->addWidget(advancedButtons, 0, Qt::AlignCenter);
114 | appSettingsLayout->addStretch(-1);
115 |
116 | appSettings = new QWidget(this);
117 | appSettings->setContentsMargins(0, 0, 0, 0);
118 | appSettings->setLayout(appSettingsLayout);
119 |
120 | scrolled = new QScrollArea(this);
121 | scrolled->setWidget(appSettings);
122 |
123 | commonLayout = new QVBoxLayout(this);
124 | commonLayout->addWidget(headWdg, 1);
125 | commonLayout->addWidget(scrolled, 5);
126 | commonLayout->addStretch(-1);
127 | setLayout(commonLayout);
128 |
129 | connect(baseButton, SIGNAL(released()),
130 | this, SIGNAL(toBase()));
131 | connect(useActiveService, SIGNAL(toggled(bool)),
132 | this, SIGNAL(findActiveServiceStateChanged(bool)));
133 | connect(useActiveService, SIGNAL(toggled(bool)),
134 | this, SLOT(enableUseFastOnly(bool)));
135 | connect(useFastOnly, SIGNAL(toggled(bool)),
136 | this, SIGNAL(useFastOnlyStateChanged(bool)));
137 | connect(restoreAtClose, SIGNAL(toggled(bool)),
138 | this, SIGNAL(restoreAtCloseChanged(bool)));
139 | connect(showMessages, SIGNAL(toggled(bool)),
140 | showBasicMsgOnly, SLOT(setEnabled(bool)));
141 | connect(showMessages, SIGNAL(toggled(bool)),
142 | this, SIGNAL(showMsgStateChanged(bool)));
143 | connect(showBasicMsgOnly, SIGNAL(toggled(bool)),
144 | this, SIGNAL(showBasicMsgOnlyStateChanged(bool)));
145 | connect(jobPort, SIGNAL(valueChanged(int)),
146 | this, SLOT(unitChanged()));
147 | connect(testPort, SIGNAL(valueChanged(int)),
148 | this, SLOT(unitChanged()));
149 | connect(restoreDefaultBtn, SIGNAL(clicked(bool)),
150 | this, SLOT(setUnits()));
151 | connect(applyNewPortsBtn, SIGNAL(clicked(bool)),
152 | this, SLOT(setUnits()));
153 | connect(asUser, SIGNAL(toggled(bool)),
154 | asUserLine, SLOT(setEnabled(bool)));
155 | connect(asUser, SIGNAL(toggled(bool)),
156 | asUserLine, SLOT(clear()));
157 | connect(asUser, SIGNAL(toggled(bool)),
158 | this, SLOT(unitChanged()));
159 | connect(asUserLine, SIGNAL(textChanged(QString)),
160 | this, SLOT(unitChanged()));
161 | }
162 |
163 | void AppSettings::setUserName(QString _user)
164 | {
165 | if ( !_user.isEmpty() ) {
166 | asUser->setChecked(true);
167 | asUserLine->setText(_user);
168 | };
169 | }
170 | bool AppSettings::getRunAtStartState() const
171 | {
172 | return runAtStart->isChecked();
173 | }
174 | void AppSettings::setRunAtStartState(bool state)
175 | {
176 | runAtStart->setChecked(state);
177 | }
178 | bool AppSettings::getUnhideAtStartState() const
179 | {
180 | return unhideAtStart->isChecked();
181 | }
182 | void AppSettings::setUnhideAtStartState(bool state)
183 | {
184 | unhideAtStart->setChecked(state);
185 | }
186 | void AppSettings::setUseActiveServiceState(bool state)
187 | {
188 | useActiveService->setChecked(state);
189 | }
190 | void AppSettings::setUseFastOnlyState(bool state)
191 | {
192 | if ( useActiveService->isChecked() ) {
193 | useFastOnly->setChecked(state);
194 | };
195 | }
196 | void AppSettings::setRestoreAtClose(bool state)
197 | {
198 | restoreAtClose->setChecked(state);
199 | }
200 | void AppSettings::setShowMessagesState(bool state)
201 | {
202 | showMessages->setChecked(state);
203 | }
204 | void AppSettings::setShowBasicMsgOnlyState(bool state)
205 | {
206 | showBasicMsgOnly->setChecked(state);
207 | showBasicMsgOnly->setEnabled(showMessages->isChecked());
208 | }
209 | void AppSettings::runChangeUnits()
210 | {
211 | //QTextStream s(stdout);
212 | //s << "runChangeUnits; ver."<< serviceVersion << Qt::endl;
213 | //s << "JobPort >>" << jobPort->getPort() << Qt::endl;
214 | //s << "TestPort >>" << testPort->getPort() << Qt::endl;
215 | QVariantMap args;
216 | args["action"] = "setUnits";
217 | args["version"] = serviceVersion;
218 | args["JobPort"] = jobPort->getPort();
219 | args["TestPort"] = testPort->getPort();
220 | if ( asUser->isChecked() ) {
221 | args["User"] = asUserLine->text();
222 | };
223 | Action act("pro.russianfedora.dnscryptclientreload.setunits");
224 | act.setHelperId("pro.russianfedora.dnscryptclientreload");
225 | act.setArguments(args);
226 | ExecuteJob *job = act.execute();
227 | job->setParent(this);
228 | job->setAutoDelete(true);
229 | connect(job, SIGNAL(result(KJob*)),
230 | this, SLOT(resultChangeUnits(KJob*)));
231 | job->start();
232 | }
233 |
234 | /* private slots */
235 | void AppSettings::enableUseFastOnly(bool state)
236 | {
237 | useFastOnly->setChecked(false);
238 | useFastOnly->setEnabled(state);
239 | }
240 | void AppSettings::unitChanged()
241 | {
242 | applyNewPortsBtn->setEnabled(true);
243 | }
244 | void AppSettings::setUnits()
245 | {
246 | if ( asUser->isChecked() && (
247 | asUserLine->text().isEmpty() ||
248 | asUserLine->text().contains(" ")) ) {
249 | asUserLine->clear();
250 | asUser->setChecked(false);
251 | if ( showMessages->isChecked() ) {
252 | // is basic message
253 | KNotification::event(
254 | KNotification::Notification,
255 | "DNSCryptClient",
256 | QString("Username contains blanks or empty."));
257 | };
258 | return;
259 | };
260 | scrolled->setEnabled(false);
261 | if ( sender()==restoreDefaultBtn ) {
262 | jobPort->setPort(JOB_PORT);
263 | testPort->setPort(TEST_PORT);
264 | asUser->setChecked(false);
265 | };
266 | emit stopSystemdAppUnits();
267 | }
268 |
269 | void AppSettings::resultChangeUnits(KJob *_job)
270 | {
271 | ExecuteJob *job = static_cast(_job);
272 | if ( job!=Q_NULLPTR ) {
273 | //QTextStream s(stdout);
274 | if ( job->data().value("jobUnit").toInt() == jobPort->getPort() ) {
275 | emit jobPortChanged(jobPort->getPort());
276 | emit userChanged(asUserLine->text());
277 | if ( showMessages->isChecked() && !showBasicMsgOnly->isChecked() ) {
278 | // is not basic message
279 | KNotification::event(
280 | KNotification::Notification,
281 | "DNSCryptClient",
282 | QString("Job systemd unit changed."));
283 | };
284 | } else {
285 | if ( job->data().value("code").toInt()<0 ) {
286 | if ( showMessages->isChecked() && !showBasicMsgOnly->isChecked() ) {
287 | // is not basic message
288 | KNotification::event(
289 | KNotification::Notification,
290 | "DNSCryptClient",
291 | QString("Job systemd unit not changed.\nERR: %1")
292 | .arg(job->data().value("err").toString()));
293 | };
294 | };
295 | };
296 | if ( job->data().value("testUnit").toInt() == testPort->getPort() ) {
297 | emit testPortChanged(testPort->getPort());
298 | if ( showMessages->isChecked() && !showBasicMsgOnly->isChecked() ) {
299 | // is not basic message
300 | KNotification::event(
301 | KNotification::Notification,
302 | "DNSCryptClient",
303 | QString("Test systemd unit changed."));
304 | };
305 | } else {
306 | if ( job->data().value("code").toInt()<0 ) {
307 | if ( showMessages->isChecked() && !showBasicMsgOnly->isChecked() ) {
308 | // is not basic message
309 | KNotification::event(
310 | KNotification::Notification,
311 | "DNSCryptClient",
312 | QString("Test systemd unit not changed.\nERR: %1")
313 | .arg(job->data().value("err").toString()));
314 | };
315 | };
316 | };
317 | //s << "jobUnit "<< job->data().value("jobUnit").toString() << Qt::endl;
318 | //s << "testUnit "<< job->data().value("testUnit").toString() << Qt::endl;
319 | //s << "jobUnitText: " << job->data().value("jobUnitText").toString() << Qt::endl;
320 | //s << "testUnitText: " << job->data().value("testUnitText").toString() << Qt::endl;
321 | } else {
322 | if ( showMessages->isChecked() && !showBasicMsgOnly->isChecked() ) {
323 | // is not basic message
324 | KNotification::event(
325 | KNotification::Notification,
326 | "DNSCryptClient",
327 | QString("Units not changed."));
328 | };
329 | };
330 | scrolled->setEnabled(true);
331 | emit changeUnitsFinished();
332 | }
333 |
--------------------------------------------------------------------------------
/src/app_settings.h:
--------------------------------------------------------------------------------
1 | #ifndef APP_SETTINGS_H
2 | #define APP_SETTINGS_H
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include "port_settings.h"
12 | #include
13 | #if KAUTH_VERSION < ((5<<16)|(92<<8)|(0))
14 | #include
15 | #else
16 | #include
17 | #endif
18 | #include
19 | using namespace KAuth;
20 |
21 | #define JOB_PORT 53
22 | #define TEST_PORT 53535
23 |
24 | class AppSettings : public QWidget
25 | {
26 | Q_OBJECT
27 | public:
28 | explicit AppSettings(QWidget *parent = Q_NULLPTR, QString ver = "");
29 | PortSettings *jobPort, *testPort;
30 | QPushButton *applyNewPortsBtn;
31 | void setUserName(QString);
32 | bool getRunAtStartState() const;
33 | void setRunAtStartState(bool);
34 | bool getUnhideAtStartState() const;
35 | void setUnhideAtStartState(bool);
36 | void setUseActiveServiceState(bool);
37 | void setUseFastOnlyState(bool);
38 | void setRestoreAtClose(bool);
39 | void setShowMessagesState(bool);
40 | void setShowBasicMsgOnlyState(bool);
41 | void runChangeUnits();
42 |
43 | signals:
44 | void toBase();
45 | void findActiveServiceStateChanged(bool);
46 | void useFastOnlyStateChanged(bool);
47 | void restoreAtCloseChanged(bool);
48 | void showMsgStateChanged(bool);
49 | void showBasicMsgOnlyStateChanged(bool);
50 | void jobPortChanged(int);
51 | void testPortChanged(int);
52 | void userChanged(QString);
53 | void stopSystemdAppUnits();
54 | void changeUnitsFinished();
55 |
56 | private:
57 | const QString serviceVersion;
58 | QLabel *setLabel, *nameLabel, *advancedLabel;
59 | QLineEdit *asUserLine;
60 | QPushButton *baseButton, *restoreDefaultBtn;
61 | QHBoxLayout *headLayout, *asUserLayout;
62 | QVBoxLayout *appSettingsLayout;
63 | QHBoxLayout *advancedButtonsLayout;
64 | QCheckBox *runAtStart, *useActiveService,
65 | *useFastOnly, *restoreAtClose,
66 | *asUser, *unhideAtStart,
67 | *showMessages, *showBasicMsgOnly;
68 | QWidget *headWdg, *appSettings,
69 | *asUserWdg, *advancedButtons;
70 | QScrollArea *scrolled;
71 |
72 | QVBoxLayout *commonLayout;
73 |
74 | public slots:
75 |
76 | private slots:
77 | void enableUseFastOnly(bool);
78 | void unitChanged();
79 | void setUnits();
80 | void resultChangeUnits(KJob*);
81 | };
82 |
83 | #endif // APP_SETTINGS_H
84 |
--------------------------------------------------------------------------------
/src/button_panel.cpp:
--------------------------------------------------------------------------------
1 | #include "button_panel.h"
2 | //#include
3 |
4 | ButtonPanel::ButtonPanel(QWidget *parent) :
5 | QWidget(parent)
6 | {
7 | start = new QPushButton(
8 | QIcon::fromTheme("DNSCryptClient_open",
9 | QIcon(":/open.png")),
10 | "", this);
11 | start->setFlat(false);
12 | start->setToolTip("Start proxying");
13 | start->setSizePolicy(
14 | QSizePolicy(
15 | QSizePolicy::Ignored,
16 | QSizePolicy::Ignored));
17 | start->setContentsMargins(0, 0, 0, 0);
18 | stop = new QPushButton(
19 | QIcon::fromTheme("DNSCryptClient_close",
20 | QIcon(":/close.png")),
21 | "", this);
22 | stop->setFlat(false);
23 | stop->setToolTip("Stop proxying");
24 | stop->setSizePolicy(
25 | QSizePolicy(
26 | QSizePolicy::Ignored,
27 | QSizePolicy::Ignored));
28 | stop->setContentsMargins(0, 0, 0, 0);
29 | stop->setEnabled(false);
30 | restore = new QPushButton(
31 | QIcon::fromTheme("DNSCryptClient_restore",
32 | QIcon(":/restore.png")),
33 | "", this);
34 | restore->setFlat(false);
35 | restore->setToolTip("Stop proxying\nRestore system DNS resolver settings");
36 | restore->setSizePolicy(
37 | QSizePolicy(
38 | QSizePolicy::Ignored,
39 | QSizePolicy::Ignored));
40 | restore->setContentsMargins(0, 0, 0, 0);
41 | restore->setEnabled(false);
42 |
43 | baseLayout = new QHBoxLayout(this);
44 | baseLayout->addWidget(start);
45 | baseLayout->addWidget(stop);
46 | baseLayout->addWidget(restore);
47 |
48 | setContentsMargins(0, 0, 0, 0);
49 | setLayout(baseLayout);
50 |
51 | connect(start, SIGNAL(released()),
52 | this, SIGNAL(startProxing()));
53 | connect(stop, SIGNAL(released()),
54 | this, SIGNAL(stopProxing()));
55 | connect(restore, SIGNAL(released()),
56 | this, SIGNAL(restoreSettings()));
57 | }
58 |
59 | /* public slots */
60 | void ButtonPanel::changeAppState(SRV_STATUS state)
61 | {
62 | //QTextStream s(stdout);
63 | switch (state) {
64 | case READY:
65 | //s<< 0 <setDisabled(true);
73 | stop->setEnabled(true);
74 | restore->setEnabled(true);
75 | //s<< 1 <setEnabled(true);
79 | stop->setDisabled(true);
80 | restore->setDisabled(true);
81 | //s<< 2 <setDisabled(true);
85 | stop->setDisabled(true);
86 | restore->setDisabled(true);
87 | //s<< 3 <setEnabled(true);
93 | stop->setDisabled(true);
94 | restore->setEnabled(true);
95 | //s<< 4 <accept();
104 | int h = ev->size().height();
105 | int w = ev->size().width()/3;
106 | //int m = (hsetIconSize(s);
109 | start->setMaximumSize(s);
110 | stop->setIconSize(s);
111 | stop->setMaximumSize(s);
112 | restore->setIconSize(s);
113 | restore->setMaximumSize(s);
114 | }
115 |
--------------------------------------------------------------------------------
/src/button_panel.h:
--------------------------------------------------------------------------------
1 | #ifndef BUTTON_PANEL_H
2 | #define BUTTON_PANEL_H
3 |
4 | #include
5 | #include
6 | #include
7 | #include "enums.h"
8 |
9 | class ButtonPanel : public QWidget
10 | {
11 | Q_OBJECT
12 | public:
13 | explicit ButtonPanel(QWidget *parent = Q_NULLPTR);
14 |
15 | signals:
16 | void startProxing();
17 | void stopProxing();
18 | void restoreSettings();
19 |
20 | private:
21 | QPushButton *start, *stop, *restore;
22 | QHBoxLayout *baseLayout;
23 |
24 | public slots:
25 | void changeAppState(SRV_STATUS);
26 |
27 | private slots:
28 | void resizeEvent(QResizeEvent*);
29 | };
30 |
31 | #endif // BUTTON_PANEL_H
32 |
--------------------------------------------------------------------------------
/src/click_label.cpp:
--------------------------------------------------------------------------------
1 | #include "click_label.h"
2 | #include
3 | #include
4 |
5 | Click_Label::Click_Label(QWidget *parent) :
6 | QLabel(parent)
7 | {
8 |
9 | }
10 |
11 | void Click_Label::mouseReleaseEvent(QMouseEvent *ev)
12 | {
13 | if ( ev->type()==QEvent::MouseButtonRelease ) {
14 | //setStyleSheet("QLabel {background-color: gold;}");
15 | QMenu *menu = new QMenu(this);
16 | QAction *copy = menu->addAction("Copy to Clipboard");
17 | //menu->setStyleSheet("QMenu {background-color: blue;}");
18 | QAction *act = menu->exec(mapToGlobal(ev->pos()+QPoint(3,0)));
19 | if ( act==copy ) {
20 | QClipboard *c = QApplication::clipboard();
21 | c->setText(this->text());
22 | };
23 | //setStyleSheet("QLabel {background-color: white;}");
24 | };
25 | }
26 |
--------------------------------------------------------------------------------
/src/click_label.h:
--------------------------------------------------------------------------------
1 | #ifndef CLICK_LABEL_H
2 | #define CLICK_LABEL_H
3 |
4 | #include
5 | #include
6 | #include
7 |
8 | class Click_Label : public QLabel
9 | {
10 | Q_OBJECT
11 | public:
12 | explicit Click_Label(QWidget *parent = Q_NULLPTR);
13 |
14 | private slots:
15 | void mouseReleaseEvent(QMouseEvent*);
16 | };
17 |
18 | #endif // CLICK_LABEL_H
19 |
--------------------------------------------------------------------------------
/src/dnscrypt_proxy_icons.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 | icons/index.theme
4 | icons/64x64/status/DNSCryptClient.png
5 | icons/64x64/status/DNSCryptClient_reload.png
6 | icons/64x64/status/exit.png
7 | icons/64x64/status/DNSCryptClient_opened.png
8 | icons/64x64/status/DNSCryptClient_closed.png
9 | icons/64x64/actions/DNSCryptClient_info.png
10 | icons/64x64/actions/DNSCryptClient_add.png
11 | icons/64x64/actions/DNSCryptClient_help.png
12 | icons/64x64/actions/DNSCryptClient_settings.png
13 | icons/64x64/actions/DNSCryptClient_start.png
14 | icons/64x64/actions/DNSCryptClient_write.png
15 | icons/128x128/actions/DNSCryptClient_close.png
16 | icons/128x128/actions/DNSCryptClient_open.png
17 | icons/128x128/actions/DNSCryptClient_restore.png
18 | icons/32x32/status/fast.png
19 | icons/32x32/status/middle.png
20 | icons/32x32/status/slow.png
21 | icons/32x32/status/none.png
22 | icons/64x64/actions/DNSCryptClient_test.png
23 |
24 |
25 |
--------------------------------------------------------------------------------
/src/enums.h:
--------------------------------------------------------------------------------
1 | #ifndef ENUMS_H
2 | #define ENUMS_H
3 |
4 | // ActiveState contains a state value
5 | // that reflects whether the unit is currently active or not.
6 | enum SRV_STATUS {
7 | INACTIVE = -1,
8 | ACTIVE,
9 | FAILED,
10 | ACTIVATING,
11 | DEACTIVATING,
12 | RELOADING,
13 | RESTORED,
14 | STOP_SLICE,
15 | PROCESSING,
16 | READY
17 | };
18 |
19 | #endif // ENUMS_H
20 |
--------------------------------------------------------------------------------
/src/help_thread.cpp:
--------------------------------------------------------------------------------
1 | #include "help_thread.h"
2 | #include
3 |
4 | HelpThread::HelpThread(QObject *parent) :
5 | QThread(parent)
6 | {
7 |
8 | }
9 |
10 | void HelpThread::setServerDataMap(const QVariantMap _map)
11 | {
12 | listOfServers = _map;
13 | }
14 | QString HelpThread::readToNextComma(QString *_str)
15 | {
16 | QString item;
17 | if ( _str->startsWith(',') ) {
18 | // empty item;
19 | } else if ( !_str->isEmpty() ) {
20 | item.append( _str->at(0) );
21 | _str->remove(0, 1);
22 | item.append(readToNextComma(_str));
23 | };
24 | return item;
25 | }
26 | QString HelpThread::readToNextQuotes(QString *_str)
27 | {
28 | QString item;
29 | if ( _str->startsWith('"') ) {
30 | _str->remove(0, 1);
31 | } else if ( !_str->isEmpty() ) {
32 | item.append( _str->at(0) );
33 | _str->remove(0, 1);
34 | item.append(readToNextQuotes(_str));
35 | };
36 | return item;
37 | }
38 | QString HelpThread::readNextItem(QString *_str)
39 | {
40 | QString item;
41 | if ( _str->startsWith(',') ) {
42 | _str->remove(0, 1);
43 | };
44 | if ( _str->startsWith('"') ) {
45 | _str->remove(0, 1);
46 | item.append(readToNextQuotes(_str));
47 | } else {
48 | item.append(readToNextComma(_str));
49 | };
50 | if ( item.isEmpty() || item.startsWith("\r") ) {
51 | item.clear();
52 | item.append("---");
53 | };
54 | return item;
55 | }
56 | void HelpThread::readServerData(QString servData)
57 | {
58 | // Name,Full name,Description,Location,Coordinates,URL,Version,
59 | // DNSSEC validation,No logs,Namecoin,Resolver address,
60 | // Provider name,Provider public key,Provider public key TXT record
61 | QVariantMap _data;
62 | {
63 | _data.insert("Name", readNextItem(&servData));
64 | _data.insert("FullName", readNextItem(&servData));
65 | _data.insert("Description", readNextItem(&servData));
66 | _data.insert("Location", readNextItem(&servData));
67 | _data.insert("Coordinates", readNextItem(&servData));
68 | _data.insert("URL", readNextItem(&servData));
69 | _data.insert("Version", readNextItem(&servData));
70 | _data.insert("DNSSECvalidation", readNextItem(&servData));
71 | _data.insert("NoLogs", readNextItem(&servData));
72 | _data.insert("Namecoin", readNextItem(&servData));
73 | _data.insert("ResolverAddress", readNextItem(&servData));
74 | _data.insert("ProviderName", readNextItem(&servData));
75 | _data.insert("ProviderPublicKey", readNextItem(&servData));
76 | _data.insert("ProviderPublicKeyTXTrecord", readNextItem(&servData));
77 | };
78 | QString _key = _data.value("Name").toString();
79 | settings.beginGroup("Responds");
80 | QString respondIconName = settings.value(_key).toString();
81 | if ( respondIconName.isEmpty() ) respondIconName.append("none");
82 | settings.endGroup();
83 | settings.beginGroup("Enables");
84 | bool state = settings.value(_key, true).toBool();
85 | settings.endGroup();
86 | _data.insert("Respond", respondIconName);
87 | _data.insert("Enable", state);
88 | emit newDNSCryptSever(_data);
89 | }
90 |
91 | void HelpThread::run()
92 | {
93 | if ( listOfServers.isEmpty() ) {
94 | QFile f("/usr/share/dnscrypt-proxy/dnscrypt-resolvers.csv");
95 | bool opened = f.open(QIODevice::ReadOnly);
96 | if ( opened ) {
97 | QString _data = QString::fromUtf8(f.readAll());
98 | QStringList _dataList = _data.split("\n");
99 | _dataList.removeFirst();
100 | foreach (QString s, _dataList) {
101 | if ( s.isEmpty() ) continue;
102 | readServerData(s);
103 | };
104 | f.close();
105 | };
106 | } else {
107 | foreach (QString _key, listOfServers.keys()) {
108 | QStringList _srvData = listOfServers.value(_key).toStringList();
109 | QVariantMap _data;
110 | _data.insert("Name", _key);
111 | _srvData.removeLast();
112 | _data.insert("Description", _srvData.join("\n"));
113 | settings.beginGroup("Responds");
114 | QString respondIconName = settings.value(_key).toString();
115 | if ( respondIconName.isEmpty() ) respondIconName.append("none");
116 | settings.endGroup();
117 | settings.beginGroup("Enables");
118 | bool state = settings.value(_key, true).toBool();
119 | settings.endGroup();
120 | _data.insert("Respond", respondIconName);
121 | _data.insert("Enable", state);
122 | emit newDNSCryptSever(_data);
123 | };
124 | }
125 | }
126 |
--------------------------------------------------------------------------------
/src/help_thread.h:
--------------------------------------------------------------------------------
1 | #ifndef HELP_THREAD_H
2 | #define HELP_THREAD_H
3 |
4 | #include
5 | #include
6 | #include
7 |
8 | class HelpThread : public QThread
9 | {
10 | Q_OBJECT
11 | public:
12 | explicit HelpThread(QObject *parent = Q_NULLPTR);
13 | void setServerDataMap(const QVariantMap);
14 |
15 | signals:
16 | void newDNSCryptSever(const QVariantMap&);
17 |
18 | private:
19 | QSettings settings;
20 | QString readToNextComma(QString*);
21 | QString readToNextQuotes(QString*);
22 | QString readNextItem(QString*);
23 | void readServerData(QString);
24 | QVariantMap listOfServers;
25 |
26 | private slots:
27 | void run();
28 | };
29 |
30 | #endif // HELP_THREAD_H
31 |
--------------------------------------------------------------------------------
/src/helpers/CMakeLists.txt:
--------------------------------------------------------------------------------
1 |
2 | add_subdirectory(job_helper)
3 | add_subdirectory(test_helper)
4 | add_subdirectory(reload_helper)
5 |
--------------------------------------------------------------------------------
/src/helpers/dns_utility/dns.c:
--------------------------------------------------------------------------------
1 | //DNS Query Program on Linux
2 | //Author : Silver Moon ([email protected])
3 | //Dated : 29/4/2009
4 |
5 | // remaked for application usage
6 |
7 | //Header Files
8 | //#include //printf
9 | #include "dns.h"
10 | #include //strlen
11 | #include //malloc
12 | #include //you know what this is for
13 | //#include //inet_addr , inet_ntoa , ntohs etc
14 | //#include
15 | #include //getpid
16 | #include //time
17 |
18 | #define T_A 1 //Ipv4 address
19 | #define T_AAAA 28 //Ipv6 address
20 | #define T_NS 2 //Nameserver
21 | #define T_CNAME 5 // canonical name
22 | #define T_SOA 6 /* start of authority zone */
23 | #define T_PTR 12 /* domain name pointer */
24 | #define T_MX 15 //Mail server
25 |
26 | //Function Prototypes
27 | void ChangetoDnsNameFormat (unsigned char*,unsigned char*);
28 |
29 | //DNS header structure
30 | struct DNS_HEADER
31 | {
32 | unsigned short id; // identification number
33 |
34 | unsigned char rd :1; // recursion desired
35 | unsigned char tc :1; // truncated message
36 | unsigned char aa :1; // authoritive answer
37 | unsigned char opcode :4; // purpose of message
38 | unsigned char qr :1; // query/response flag
39 |
40 | unsigned char rcode :4; // response code
41 | unsigned char cd :1; // checking disabled
42 | unsigned char ad :1; // authenticated data
43 | unsigned char z :1; // its z! reserved
44 | unsigned char ra :1; // recursion available
45 |
46 | unsigned short q_count; // number of question entries
47 | unsigned short ans_count; // number of answer entries
48 | unsigned short auth_count; // number of authority entries
49 | unsigned short add_count; // number of resource entries
50 | };
51 |
52 | //Constant sized fields of query structure
53 | struct QUESTION
54 | {
55 | unsigned short qtype;
56 | unsigned short qclass;
57 | };
58 |
59 | //Constant sized fields of the resource record structure
60 | #pragma pack(push, 1)
61 | struct R_DATA
62 | {
63 | unsigned short type;
64 | unsigned short _class;
65 | unsigned int ttl;
66 | unsigned short data_len;
67 | };
68 | #pragma pack(pop)
69 |
70 | //Pointers to resource record contents
71 | struct RES_RECORD
72 | {
73 | unsigned char *name;
74 | struct R_DATA *resource;
75 | unsigned char *rdata;
76 | };
77 |
78 | //Structure of a Query
79 | typedef struct
80 | {
81 | unsigned char *name;
82 | struct QUESTION *ques;
83 | } QUERY;
84 |
85 | /*
86 | * Perform a DNS query by sending a packet
87 | * */
88 | uint16_t is_responsible(unsigned long *t, int _port, int _family)
89 | {
90 | sleep(1); // dirty action to wait when the dnscrypt-proxy will runned
91 | unsigned char host[100] = "google.com";
92 | unsigned char buf[65536],*qname;
93 |
94 | struct DNS_HEADER *dns = NULL;
95 | struct QUESTION *qinfo = NULL;
96 |
97 | //printf("Resolving %s" , host);
98 |
99 | int s = socket((_family==6)? AF_INET6:AF_INET, SOCK_DGRAM, IPPROTO_UDP); //UDP packet for DNS queries
100 | struct timeval tv;
101 | tv.tv_sec = 3;
102 | tv.tv_usec = 0;
103 | if (setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) < 0) {
104 | //perror(" setsocketopt Error");
105 | }
106 |
107 | struct sockaddr_in dest;
108 | struct sockaddr_in6 dest6;
109 | if (_family==4) {
110 | dest.sin_family = AF_INET;
111 | dest.sin_port = htons(_port);
112 | //dns servers resolver
113 | dest.sin_addr.s_addr = inet_addr("127.0.0.1");
114 | } else {
115 | dest6.sin6_family = AF_INET6;
116 | dest6.sin6_port = htons(_port);
117 | //dns servers resolver
118 | inet_pton(AF_INET6, "::1", &(dest6.sin6_addr));
119 | }
120 |
121 | //Set the DNS structure to standard queries
122 | dns = (struct DNS_HEADER *)&buf;
123 |
124 | dns->id = (unsigned short) htons(getpid());
125 | dns->qr = 0; //This is a query
126 | dns->opcode = 0; //This is a standard query
127 | dns->aa = 0; //Not Authoritative
128 | dns->tc = 0; //This message is not truncated
129 | dns->rd = 1; //Recursion Desired
130 | dns->ra = 0; //Recursion not available! hey we dont have it (lol)
131 | dns->z = 0;
132 | dns->ad = 0;
133 | dns->cd = 0;
134 | dns->rcode = 0;
135 | dns->q_count = htons(1); //we have only 1 question
136 | dns->ans_count = 0;
137 | dns->auth_count = 0;
138 | dns->add_count = 0;
139 |
140 | //point to the query portion
141 | qname =(unsigned char*)&buf[sizeof(struct DNS_HEADER)];
142 |
143 | ChangetoDnsNameFormat(qname , host);
144 | qinfo =(struct QUESTION*)&buf[sizeof(struct DNS_HEADER) + (strlen((const char*)qname) + 1)]; //fill it
145 |
146 | //qinfo->qtype = htons( query_type ); //type of the query , A , MX , CNAME , NS etc
147 | //type of the query , A , MX , CNAME , NS etc
148 | qinfo->qtype = htons( (_family==4)? T_A : T_AAAA );
149 | qinfo->qclass = htons(1); //its internet (lol)
150 |
151 | //printf("\nSending Packet...");
152 | sendto(
153 | s,
154 | (char*)buf,
155 | sizeof(struct DNS_HEADER)
156 | + (strlen((const char*)qname)+1)
157 | + sizeof(struct QUESTION),
158 | 0,
159 | (_family==6)? (struct sockaddr*)&dest6:(struct sockaddr*)&dest,
160 | (_family==6)? sizeof(dest6):sizeof(dest));
161 |
162 | struct timespec start, end;
163 | clock_gettime(CLOCK_MONOTONIC_RAW, &start);
164 | //Receive the answer
165 | recvfrom(
166 | s,
167 | (void*)buf,
168 | 65536,
169 | 0,
170 | (_family==6)? (struct sockaddr*)&dest6:(struct sockaddr*)&dest,
171 | (_family==6)? (socklen_t*)sizeof(dest6):(socklen_t*)sizeof(dest));
172 | clock_gettime(CLOCK_MONOTONIC_RAW, &end);
173 | close(s);
174 |
175 | *t = (end.tv_sec - start.tv_sec)*1000000
176 | + (end.tv_nsec - start.tv_nsec)/1000;
177 |
178 | return ntohs(dns->ans_count);
179 | }
180 |
181 | /*
182 | * This will convert www.google.com to 3www6google3com
183 | * got it :)
184 | * */
185 | void ChangetoDnsNameFormat(unsigned char* dns,unsigned char* host)
186 | {
187 | int lock = 0 , i;
188 | strcat((char*)host,".");
189 |
190 | for(i = 0 ; i < strlen((char*)host) ; i++)
191 | {
192 | if(host[i]=='.')
193 | {
194 | *dns++ = i-lock;
195 | for(;lock //inet_addr , inet_ntoa , ntohs etc
5 |
6 | uint16_t is_responsible(unsigned long int*, int, int);
7 |
8 | #endif // DNS_H
9 |
--------------------------------------------------------------------------------
/src/helpers/job_helper/CMakeLists.txt:
--------------------------------------------------------------------------------
1 |
2 | set (DNS_UTILITY "../dns_utility")
3 | include_directories(${DNS_UTILITY})
4 |
5 | set (dnscrypt_client_helper_SRCS
6 | ${DNS_UTILITY}/dns.c
7 | dnscrypt_client_helper.cpp)
8 |
9 | find_package (Qt5Core REQUIRED)
10 | find_package (Qt5DBus REQUIRED)
11 | find_package (KF5Auth REQUIRED)
12 | qt5_wrap_cpp (HELPER_MOC_SOURCES
13 | dnscrypt_client_helper.h
14 | ${DNS_UTILITY}/dns.h)
15 |
16 |
17 | set (
18 | HELPER_BUILD_PROJECT_LIBRARIES
19 | ${Qt5Core_LIBRARIES}
20 | ${Qt5DBus_LIBRARIES}
21 | KF5::Auth)
22 | add_definitions(
23 | ${Qt5Core_DEFINITIONS}
24 | ${Qt5DBus_DEFINITIONS})
25 |
26 | # FYI: helper names don't like a CAPs letters !!!
27 | add_executable(
28 | dnscrypt_client_helper
29 | ${dnscrypt_client_helper_SRCS}
30 | ${HELPER_MOC_SOURCES})
31 | target_link_libraries(
32 | dnscrypt_client_helper
33 | ${HELPER_BUILD_PROJECT_LIBRARIES})
34 | install(
35 | TARGETS dnscrypt_client_helper
36 | DESTINATION ${KAUTH_HELPER_INSTALL_DIR})
37 | #message("KAUTH_HELPER_INSTALL_DIR: ${KAUTH_HELPER_INSTALL_DIR}")
38 | #message("KAUTH_POLICY_FILES_INSTALL_DIR: ${KAUTH_POLICY_FILES_INSTALL_DIR}")
39 | #message("DBUS_SYSTEM_SERVICES_INSTALL_DIR: ${DBUS_SYSTEM_SERVICES_INSTALL_DIR}")
40 |
41 | kauth_install_helper_files(
42 | dnscrypt_client_helper
43 | pro.russianfedora.dnscryptclient
44 | root)
45 | kauth_install_actions(
46 | pro.russianfedora.dnscryptclient
47 | actions.actions)
48 |
--------------------------------------------------------------------------------
/src/helpers/job_helper/actions.actions:
--------------------------------------------------------------------------------
1 | [pro.russianfedora.dnscryptclient.create]
2 | Name=Create DNSCrypt proxy service
3 | Description=User DNSCrypt
4 | Policy=yes
5 | Persistence=session
6 |
7 | [pro.russianfedora.dnscryptclient.start]
8 | Name=Start DNSCrypt proxy service
9 | Description=User DNSCrypt
10 | Policy=yes
11 | Persistence=session
12 |
13 | [pro.russianfedora.dnscryptclient.stop]
14 | Name=Stop DNSCrypt proxy service
15 | Description=User DNSCrypt
16 | Policy=yes
17 | Persistence=session
18 |
19 | [pro.russianfedora.dnscryptclient.restore]
20 | Name=Restore DNSCrypt proxy service
21 | Description=User DNSCrypt
22 | Policy=yes
23 | Persistence=session
24 |
25 | [pro.russianfedora.dnscryptclient.stopslice]
26 | Name=Stop DNSCrypt proxy service by stop slice
27 | Description=User DNSCrypt
28 | Policy=yes
29 | Persistence=session
30 |
31 | [pro.russianfedora.dnscryptclient.startv2]
32 | Name=Start DNSCrypt proxy ver.2.x.x service
33 | Description=User DNSCrypt
34 | Policy=yes
35 | Persistence=session
36 |
37 | [pro.russianfedora.dnscryptclient.stopv2]
38 | Name=Stop DNSCrypt proxy ver.2.x.x service
39 | Description=User DNSCrypt
40 | Policy=yes
41 | Persistence=session
42 |
--------------------------------------------------------------------------------
/src/helpers/job_helper/dnscrypt_client_helper.cpp:
--------------------------------------------------------------------------------
1 | extern "C" {
2 | #include "dns.h"
3 | }
4 | #include "dnscrypt_client_helper.h"
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | //#include
11 |
12 | #define UnitName QString("DNSCryptClient")
13 |
14 | struct PrimitivePair
15 | {
16 | QString name;
17 | QVariant value;
18 | };
19 | Q_DECLARE_METATYPE(PrimitivePair)
20 | typedef QList SrvParameters;
21 | Q_DECLARE_METATYPE(SrvParameters)
22 |
23 | struct ComplexPair
24 | {
25 | QString name;
26 | SrvParameters value;
27 | };
28 | Q_DECLARE_METATYPE(ComplexPair)
29 | typedef QList AuxParameters;
30 | Q_DECLARE_METATYPE(AuxParameters)
31 |
32 | /* unused
33 | QString getRandomHex(const int &length)
34 | {
35 | QString randomHex;
36 | for(int i = 0; i < length; i++) {
37 | int n = qrand() % 16;
38 | randomHex.append(QString::number(n,16));
39 | };
40 | return randomHex;
41 | }
42 | */
43 | QString getRespondIconName(qreal r)
44 | {
45 | if ( 0();
91 | qDBusRegisterMetaType();
92 | qDBusRegisterMetaType();
93 | qDBusRegisterMetaType();
94 | }
95 |
96 | QDBusArgument &operator<<(QDBusArgument &argument, const PrimitivePair &pair)
97 | {
98 | argument.beginStructure();
99 | argument << pair.name << QDBusVariant(pair.value);
100 | argument.endStructure();
101 | return argument;
102 | }
103 | const QDBusArgument &operator>>(const QDBusArgument &argument, PrimitivePair &pair)
104 | {
105 | argument.beginStructure();
106 | argument >> pair.name >> pair.value;
107 | argument.endStructure();
108 | return argument;
109 | }
110 | QDBusArgument &operator<<(QDBusArgument &argument, const SrvParameters &list)
111 | {
112 | int id = qMetaTypeId();
113 | argument.beginArray(id);
114 | //foreach (PrimitivePair item, list) {
115 | // argument << item;
116 | //};
117 | SrvParameters::ConstIterator it = list.constBegin();
118 | SrvParameters::ConstIterator end = list.constEnd();
119 | for ( ; it != end; ++it)
120 | argument << *it;
121 | argument.endArray();
122 | return argument;
123 | }
124 | const QDBusArgument &operator>>(const QDBusArgument &argument, SrvParameters &list)
125 | {
126 | argument.beginArray();
127 | while (!argument.atEnd()) {
128 | PrimitivePair item;
129 | argument >> item;
130 | list.append(item);
131 | };
132 | argument.endArray();
133 | return argument;
134 | }
135 |
136 | QDBusArgument &operator<<(QDBusArgument &argument, const ComplexPair &pair)
137 | {
138 | argument.beginStructure();
139 | argument << pair.name << pair.value;
140 | argument.endStructure();
141 | return argument;
142 | }
143 | const QDBusArgument &operator>>(const QDBusArgument &argument, ComplexPair &pair)
144 | {
145 | argument.beginStructure();
146 | argument >> pair.name >> pair.value;
147 | argument.endStructure();
148 | return argument;
149 | }
150 | QDBusArgument &operator<<(QDBusArgument &argument, const AuxParameters &list)
151 | {
152 | int id = qMetaTypeId();
153 | argument.beginArray(id);
154 | //foreach (ComplexPair item, list) {
155 | // argument << item;
156 | //};
157 | AuxParameters::ConstIterator it = list.constBegin();
158 | AuxParameters::ConstIterator end = list.constEnd();
159 | for ( ; it != end; ++it)
160 | argument << *it;
161 | argument.endArray();
162 | return argument;
163 | }
164 | const QDBusArgument &operator>>(const QDBusArgument &argument, AuxParameters &list)
165 | {
166 | argument.beginArray();
167 | while (!argument.atEnd()) {
168 | ComplexPair item;
169 | argument >> item;
170 | list.append(item);
171 | };
172 | argument.endArray();
173 | return argument;
174 | }
175 |
176 | // not implemented; transient unit not started in system
177 | // create transient DNSCryptClient.service systemd unit
178 | /*
179 | ActionReply DNSCryptClientHelper::create(const QVariantMap args) const
180 | {
181 | ActionReply reply;
182 |
183 | const QString act = get_key_varmap(args, "action");
184 | if ( act!="create" ) {
185 | QVariantMap err;
186 | err["result"] = QString::number(-1);
187 | reply.setData(err);
188 | return reply;
189 | };
190 | QString servName = get_key_varmap(args, "server");
191 |
192 | QDBusMessage msg = QDBusMessage::createMethodCall(
193 | "org.freedesktop.systemd1",
194 | "/org/freedesktop/systemd1",
195 | "org.freedesktop.systemd1.Manager",
196 | "StartTransientUnit");
197 |
198 | // Expecting 'ssa(sv)a(sa(sv))'
199 | // StartTransientUnit(in s name,
200 | // in s mode,
201 | // in a(sv) properties,
202 | // in a(sa(sv)) aux,
203 | // out o job);
204 |
205 | QString suffix = getRandomHex(8);
206 | QString name = QString("%1-%2.service")
207 | .arg(UnitName)
208 | .arg(suffix); // service name + unique suffix
209 | QLatin1String mode("replace"); // If "replace" the call will start the unit
210 | // and its dependencies, possibly replacing
211 | // already queued jobs that conflict with this.
212 |
213 | SrvParameters _props;
214 | PrimitivePair srvType, execStart, execStop, user;
215 | srvType.name = QLatin1String("Type");
216 | srvType.value = QLatin1String("forking");
217 | execStart.name = QLatin1String("ExecStart");
218 | execStart.value = QString("/sbin/dnscrypt-proxy -d -R %1").arg(servName);
219 | execStop.name = QLatin1String("ExecStop");
220 | execStop.value = QLatin1String("/bin/kill -INT ${MAINPID}");
221 | user.name = QLatin1String("User");
222 | user.value = QLatin1String("root");
223 | _props.append(srvType);
224 | _props.append(execStart);
225 | _props.append(execStop);
226 | _props.append(user);
227 |
228 | AuxParameters _aux;
229 | // aux is currently unused and should be passed as empty array.
230 | // ComplexPair srvAuxData;
231 | //_aux.append(srvAuxData);
232 |
233 | QDBusArgument PROPS, AUX;
234 | PROPS << _props;
235 | AUX << _aux;
236 |
237 | QVariantList _args;
238 | _args << name
239 | << mode
240 | << qVariantFromValue(PROPS)
241 | << qVariantFromValue(AUX);
242 | msg.setArguments(_args);
243 | QDBusMessage res = QDBusConnection::systemBus()
244 | .call(msg, QDBus::Block);
245 | QString str;
246 | foreach (QVariant arg, res.arguments()) {
247 | str.append(QDBusUtil::argumentToString(arg));
248 | str.append("\n");
249 | };
250 |
251 | QVariantMap retdata;
252 | retdata["msg"] = str;
253 | retdata["name"] = name;
254 | switch (res.type()) {
255 | case QDBusMessage::ReplyMessage:
256 | retdata["code"] = QString::number(0);
257 | break;
258 | case QDBusMessage::ErrorMessage:
259 | retdata["code"] = QString::number(1);
260 | retdata["err"] = res.errorMessage();
261 | break;
262 | default:
263 | retdata["code"] = QString::number(1);
264 | break;
265 | };
266 |
267 | reply.setData(retdata);
268 | return reply;
269 | }
270 | */
271 |
272 | ActionReply DNSCryptClientHelper::start(const QVariantMap args) const
273 | {
274 | ActionReply reply;
275 |
276 | const QString act = get_key_varmap(args, "action");
277 | if ( act!="start" ) {
278 | QVariantMap err;
279 | err["result"] = QString::number(-1);
280 | reply.setData(err);
281 | return reply;
282 | };
283 |
284 | QString servName = get_key_varmap(args, "server");
285 | int jobPort = get_key_varmap(args, "port").toInt();
286 |
287 | qint64 code = 0;
288 | QString entry = readFile("/etc/resolv.conf");
289 | if ( entry.startsWith("nameserver 127.0.0.1\nnameserver ::1\n") ) {
290 | entry.clear();
291 | } else {
292 | code = writeFile("/etc/resolv.conf", "nameserver 127.0.0.1\nnameserver ::1\n");
293 | };
294 | QVariantMap retdata;
295 | if ( code != -1 ) {
296 | QDBusMessage msg = QDBusMessage::createMethodCall(
297 | "org.freedesktop.systemd1",
298 | "/org/freedesktop/systemd1",
299 | "org.freedesktop.systemd1.Manager",
300 | "StartUnit");
301 | QList _args;
302 | _args< _args;
363 | _args< _args;
439 | _args< _args;
485 | _args<<"dnscrypt-proxy.service"<<"fail";
486 | msg.setArguments(_args);
487 | QDBusMessage res = QDBusConnection::systemBus()
488 | .call(msg, QDBus::Block);
489 |
490 | const QString servName = get_key_varmap(args, "server");
491 | qint64 code = 0;
492 | QString entry = readFile("/etc/dnscrypt-proxy/dnscrypt-proxy.toml");
493 | QStringList _data, _new_data;
494 | _data = entry.split("\n");
495 | foreach(QString _s, _data) {
496 | if ( _s.startsWith("server_names") ) {
497 | QStringList _parts = _s.split(" = ");
498 | _s.clear();
499 | _s.append(_parts.first());
500 | _s.append(" = ");
501 | _s.append(QString("['%1']").arg(servName));
502 | };
503 | _new_data.append(_s);
504 | };
505 | code = writeFile("/etc/dnscrypt-proxy/dnscrypt-proxy.toml", _new_data.join("\n"));
506 | entry = readFile("/etc/resolv.conf");
507 | code = 0;
508 | if ( entry.startsWith("nameserver 127.0.0.1\nnameserver ::1\n") ) {
509 | entry.clear();
510 | } else {
511 | code = writeFile("/etc/resolv.conf", "nameserver 127.0.0.1\nnameserver ::1\n");
512 | };
513 |
514 | QVariantMap retdata;
515 | msg = QDBusMessage::createMethodCall(
516 | "org.freedesktop.systemd1",
517 | "/org/freedesktop/systemd1",
518 | "org.freedesktop.systemd1.Manager",
519 | "StartUnit");
520 | //QList _args;
521 | _args.clear();
522 | _args<<"dnscrypt-proxy.service"<<"fail";
523 | msg.setArguments(_args);
524 | res = QDBusConnection::systemBus()
525 | .call(msg, QDBus::Block);
526 | QString str;
527 | foreach (QVariant arg, res.arguments()) {
528 | str.append(QDBusUtil::argumentToString(arg));
529 | str.append("\n");
530 | };
531 |
532 | retdata["msg"] = str;
533 | long unsigned int t = 0;
534 | int domain = (servName.endsWith("ipv6") || servName.contains("ip6")) ? 6 : 4;
535 | switch (res.type()) {
536 | case QDBusMessage::ReplyMessage:
537 | retdata["entry"] = entry;
538 | retdata["code"] = QString::number(0);
539 | retdata["answ"] = QString::number(
540 | is_responsible(&t, 53, domain)); // used default DNS port
541 | retdata["resp"] = getRespondIconName(qreal(t)/1000000);
542 | break;
543 | case QDBusMessage::ErrorMessage:
544 | default:
545 | retdata["entry"] = entry;
546 | retdata["code"] = QString::number(-1);
547 | retdata["err"] = res.errorMessage();
548 | break;
549 | };
550 |
551 | reply.setData(retdata);
552 | return reply;
553 | }
554 |
555 | ActionReply DNSCryptClientHelper::stopv2(const QVariantMap args) const
556 | {
557 | ActionReply reply;
558 |
559 | const QString act = get_key_varmap(args, "action");
560 | if ( act!="stop" ) {
561 | QVariantMap err;
562 | err["result"] = QString::number(-1);
563 | reply.setData(err);
564 | return reply;
565 | };
566 |
567 | QVariantMap retdata;
568 | QDBusMessage msg = QDBusMessage::createMethodCall(
569 | "org.freedesktop.systemd1",
570 | "/org/freedesktop/systemd1",
571 | "org.freedesktop.systemd1.Manager",
572 | "StopUnit");
573 | QList _args;
574 | _args<<"dnscrypt-proxy.service"<<"fail";
575 | msg.setArguments(_args);
576 | QDBusMessage res = QDBusConnection::systemBus()
577 | .call(msg, QDBus::Block);
578 | QString str;
579 | foreach (QVariant arg, res.arguments()) {
580 | str.append(QDBusUtil::argumentToString(arg));
581 | str.append("\n");
582 | };
583 | retdata["msg"] = str;
584 | switch (res.type()) {
585 | case QDBusMessage::ReplyMessage:
586 | retdata["code"] = QString::number(0);
587 | break;
588 | case QDBusMessage::ErrorMessage:
589 | retdata["code"] = QString::number(-1);
590 | retdata["err"] = res.errorMessage();
591 | break;
592 | default:
593 | retdata["msg"] = "Stop failed";
594 | retdata["code"] = QString::number(-1);
595 | break;
596 | };
597 |
598 | reply.setData(retdata);
599 | return reply;
600 | }
601 |
602 | KAUTH_HELPER_MAIN("pro.russianfedora.dnscryptclient", DNSCryptClientHelper)
603 |
--------------------------------------------------------------------------------
/src/helpers/job_helper/dnscrypt_client_helper.h:
--------------------------------------------------------------------------------
1 | #include
2 | #if KAUTH_VERSION < ((5<<16)|(92<<8)|(0))
3 | #include
4 | #else
5 | #include
6 | #include
7 | #endif
8 | using namespace KAuth;
9 |
10 | class DNSCryptClientHelper : public QObject
11 | {
12 | Q_OBJECT
13 | public:
14 | explicit DNSCryptClientHelper(QObject *parent = Q_NULLPTR);
15 |
16 | public slots:
17 | //ActionReply create(const QVariantMap args) const;
18 | ActionReply start(const QVariantMap args) const;
19 | ActionReply stop(const QVariantMap args) const;
20 | ActionReply restore(const QVariantMap args) const;
21 | ActionReply stopslice(const QVariantMap args) const;
22 | ActionReply startv2(const QVariantMap args) const;
23 | ActionReply stopv2(const QVariantMap args) const;
24 | };
25 |
--------------------------------------------------------------------------------
/src/helpers/reload_helper/CMakeLists.txt:
--------------------------------------------------------------------------------
1 |
2 | set (DNS_UTILITY "../dns_utility")
3 | include_directories(${DNS_UTILITY})
4 |
5 | set (dnscrypt_client_reload_helper_SRCS
6 | ${DNS_UTILITY}/dns.c
7 | dnscrypt_client_reload_helper.cpp)
8 |
9 | find_package (Qt5Core REQUIRED)
10 | find_package (Qt5DBus REQUIRED)
11 | find_package (KF5Auth REQUIRED)
12 | qt5_wrap_cpp (RELOAD_HELPER_MOC_SOURCES
13 | dnscrypt_client_reload_helper.h
14 | ${DNS_UTILITY}/dns.h)
15 |
16 | set (
17 | RELOAD_HELPER_BUILD_PROJECT_LIBRARIES
18 | ${Qt5Core_LIBRARIES}
19 | ${Qt5DBus_LIBRARIES}
20 | KF5::Auth)
21 | add_definitions(
22 | ${Qt5Core_DEFINITIONS}
23 | ${Qt5DBus_DEFINITIONS})
24 |
25 | # FYI: helper names don't like a CAPs letters !!!
26 | add_executable(
27 | dnscrypt_client_reload_helper
28 | ${dnscrypt_client_reload_helper_SRCS}
29 | ${RELOAD_HELPER_MOC_SOURCES})
30 | target_link_libraries(
31 | dnscrypt_client_reload_helper
32 | ${RELOAD_HELPER_BUILD_PROJECT_LIBRARIES})
33 | install(
34 | TARGETS dnscrypt_client_reload_helper
35 | DESTINATION ${KAUTH_HELPER_INSTALL_DIR})
36 | #message("KAUTH_HELPER_INSTALL_DIR: ${KAUTH_HELPER_INSTALL_DIR}")
37 | #message("KAUTH_POLICY_FILES_INSTALL_DIR: ${KAUTH_POLICY_FILES_INSTALL_DIR}")
38 | #message("DBUS_SYSTEM_SERVICES_INSTALL_DIR: ${DBUS_SYSTEM_SERVICES_INSTALL_DIR}")
39 |
40 | kauth_install_helper_files(
41 | dnscrypt_client_reload_helper
42 | pro.russianfedora.dnscryptclientreload
43 | root)
44 | kauth_install_actions(
45 | pro.russianfedora.dnscryptclientreload
46 | actions.actions)
47 |
--------------------------------------------------------------------------------
/src/helpers/reload_helper/actions.actions:
--------------------------------------------------------------------------------
1 | [pro.russianfedora.dnscryptclientreload.setunits]
2 | Name=Set parameters to systemd DNSCrypt units
3 | Description=User DNSCrypt
4 | Policy=yes
5 | Persistence=session
6 |
--------------------------------------------------------------------------------
/src/helpers/reload_helper/dnscrypt_client_reload_helper.cpp:
--------------------------------------------------------------------------------
1 | extern "C" {
2 | #include "dns.h"
3 | }
4 | #include "dnscrypt_client_reload_helper.h"
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | //#include
11 |
12 | #define UnitName QString("DNSCryptClient")
13 |
14 | struct PrimitivePair
15 | {
16 | QString name;
17 | QVariant value;
18 | };
19 | Q_DECLARE_METATYPE(PrimitivePair)
20 | typedef QList SrvParameters;
21 | Q_DECLARE_METATYPE(SrvParameters)
22 |
23 | struct ComplexPair
24 | {
25 | QString name;
26 | SrvParameters value;
27 | };
28 | Q_DECLARE_METATYPE(ComplexPair)
29 | typedef QList AuxParameters;
30 | Q_DECLARE_METATYPE(AuxParameters)
31 |
32 | QString get_key_varmap(const QVariantMap &args, const QString& key)
33 | {
34 | QString value;
35 | if (args.keys().contains(key)) {
36 | value = args[key].toString();
37 | };
38 | return value;
39 | }
40 | QString readFile(const QString &_path)
41 | {
42 | QString ret;
43 | QFile f(_path);
44 | bool opened = f.open(QIODevice::ReadOnly);
45 | if ( opened ) {
46 | ret = QString::fromUtf8( f.readAll() );
47 | f.close();
48 | };
49 | return ret;
50 | }
51 | qint64 writeFile(const QString &_path, const QString &entry)
52 | {
53 | qint64 ret = 0;
54 | QFile f(_path);
55 | bool opened = f.open(QIODevice::WriteOnly);
56 | if ( opened ) {
57 | ret = f.write(entry.toUtf8().data(), entry.size());
58 | f.close();
59 | } else {
60 | ret = -1;
61 | };
62 | return ret;
63 | }
64 | QString changeUnit(const QString &entry, const QString &_port,
65 | bool asUser = false, const QString &_User = "")
66 | {
67 | //ExecStart=/usr/sbin/dnscrypt-proxy -a 127.0.0.1:53 [-u username] -R %i
68 | //QTextStream s(stdout);
69 | bool entryChanged = false;
70 | QStringList _strings = entry.split("\n");
71 | QStringList changedEntry;
72 | foreach (QString _str, _strings) {
73 | QString changedString;
74 | if ( _str.startsWith("ExecStart") ) {
75 | QStringList _parts = _str.split(" ");
76 | QStringList _changedParts;
77 | if ( _parts.count()>1 ) {
78 | QString _comm("ExecStart=/usr/sbin/dnscrypt-proxy");
79 | QString _addrKey("-a");
80 | QString _addr;
81 | QString _userKey("-u");
82 | QString _suff("-R %i");
83 | _changedParts.append(_comm);
84 | _changedParts.append(_addrKey);
85 | QStringList _addrParts = _parts.at(2).split(":");
86 | if ( _addrParts.count()>1 && !_addrParts.at(1).isEmpty() ) {
87 | if ( _addrParts.at(1)!=_port ) {
88 | _addr.append("127.0.0.1");
89 | _addr.append(":");
90 | _addr.append(_port);
91 | entryChanged = true;
92 | } else {
93 | _addr.append(_parts.at(2));
94 | };
95 | } else {
96 | _addr.append("127.0.0.1:53");
97 | entryChanged = true;
98 | };
99 | _changedParts.append(_addr);
100 | if ( asUser ) {
101 | if ( _parts.contains(_userKey) ) {
102 | _changedParts.append(_userKey);
103 | if ( _parts.at(4)!=_User ) {
104 | entryChanged = true;
105 | };
106 | _changedParts.append(_User);
107 | } else {
108 | _changedParts.append(_userKey);
109 | _changedParts.append(_User);
110 | entryChanged = true;
111 | };
112 | } else {
113 | if ( _parts.contains("-u") ) {
114 | entryChanged = true;
115 | };
116 | };
117 | _changedParts.append(_suff);
118 | changedString.append(_changedParts.join(" "));
119 | } else {
120 | changedString.append(_str);
121 | };
122 | } else {
123 | changedString.append(_str);
124 | };
125 | changedEntry.append(changedString);
126 | };
127 | return ( entryChanged ) ? changedEntry.join("\n") : QString();
128 | }
129 |
130 | DNSCryptClientReloadHelper::DNSCryptClientReloadHelper(QObject *parent) :
131 | QObject(parent)
132 | {
133 | qDBusRegisterMetaType();
134 | qDBusRegisterMetaType();
135 | qDBusRegisterMetaType();
136 | qDBusRegisterMetaType();
137 | }
138 |
139 | QDBusArgument &operator<<(QDBusArgument &argument, const PrimitivePair &pair)
140 | {
141 | argument.beginStructure();
142 | argument << pair.name << QDBusVariant(pair.value);
143 | argument.endStructure();
144 | return argument;
145 | }
146 | const QDBusArgument &operator>>(const QDBusArgument &argument, PrimitivePair &pair)
147 | {
148 | argument.beginStructure();
149 | argument >> pair.name >> pair.value;
150 | argument.endStructure();
151 | return argument;
152 | }
153 | QDBusArgument &operator<<(QDBusArgument &argument, const SrvParameters &list)
154 | {
155 | int id = qMetaTypeId();
156 | argument.beginArray(id);
157 | //foreach (PrimitivePair item, list) {
158 | // argument << item;
159 | //};
160 | SrvParameters::ConstIterator it = list.constBegin();
161 | SrvParameters::ConstIterator end = list.constEnd();
162 | for ( ; it != end; ++it)
163 | argument << *it;
164 | argument.endArray();
165 | return argument;
166 | }
167 | const QDBusArgument &operator>>(const QDBusArgument &argument, SrvParameters &list)
168 | {
169 | argument.beginArray();
170 | while (!argument.atEnd()) {
171 | PrimitivePair item;
172 | argument >> item;
173 | list.append(item);
174 | };
175 | argument.endArray();
176 | return argument;
177 | }
178 |
179 | QDBusArgument &operator<<(QDBusArgument &argument, const ComplexPair &pair)
180 | {
181 | argument.beginStructure();
182 | argument << pair.name << pair.value;
183 | argument.endStructure();
184 | return argument;
185 | }
186 | const QDBusArgument &operator>>(const QDBusArgument &argument, ComplexPair &pair)
187 | {
188 | argument.beginStructure();
189 | argument >> pair.name >> pair.value;
190 | argument.endStructure();
191 | return argument;
192 | }
193 | QDBusArgument &operator<<(QDBusArgument &argument, const AuxParameters &list)
194 | {
195 | int id = qMetaTypeId();
196 | argument.beginArray(id);
197 | //foreach (ComplexPair item, list) {
198 | // argument << item;
199 | //};
200 | AuxParameters::ConstIterator it = list.constBegin();
201 | AuxParameters::ConstIterator end = list.constEnd();
202 | for ( ; it != end; ++it)
203 | argument << *it;
204 | argument.endArray();
205 | return argument;
206 | }
207 | const QDBusArgument &operator>>(const QDBusArgument &argument, AuxParameters &list)
208 | {
209 | argument.beginArray();
210 | while (!argument.atEnd()) {
211 | ComplexPair item;
212 | argument >> item;
213 | list.append(item);
214 | };
215 | argument.endArray();
216 | return argument;
217 | }
218 |
219 | ActionReply DNSCryptClientReloadHelper::setunits(const QVariantMap args) const
220 | {
221 | ActionReply reply;
222 |
223 | const QString act = get_key_varmap(args, "action");
224 | if ( act!="setUnits" ) {
225 | QVariantMap err;
226 | err["result"] = QString::number(-1);
227 | reply.setData(err);
228 | return reply;
229 | };
230 |
231 | QString unitPath("/usr/lib/systemd/system/");
232 | QString jobUnitPath = QString("%1%2@.service")
233 | .arg(unitPath).arg(UnitName);
234 | QString testUnitPath = QString("%1%2_test@.service")
235 | .arg(unitPath).arg(UnitName);
236 |
237 | QString serviceVersion = get_key_varmap(args, "version");
238 |
239 | QString _User = get_key_varmap(args, "User");
240 | bool asUser = !_User.isEmpty();
241 |
242 | QString jobPort = get_key_varmap(args, "JobPort");
243 | QString jobUnitText = changeUnit(
244 | readFile(jobUnitPath), jobPort,
245 | asUser, _User);
246 |
247 | QString testPort = get_key_varmap(args, "TestPort");
248 | QString testUnitText = changeUnit(
249 | readFile(testUnitPath), testPort);
250 |
251 | QVariantMap retdata;
252 | if ( serviceVersion.compare("2")<0 && !jobUnitText.isEmpty() ) {
253 | retdata["jobUnit"] = QString::number(
254 | writeFile(jobUnitPath, jobUnitText));
255 | // reload unit
256 | QDBusMessage msg = QDBusMessage::createMethodCall(
257 | "org.freedesktop.systemd1",
258 | "/org/freedesktop/systemd1",
259 | "org.freedesktop.systemd1.Manager",
260 | "ReloadUnit");
261 | QList _args;
262 | _args<=2 nothing to change in service unit file,
285 | // because it has new changes at each job iteraton
286 | retdata["code"] = QString::number(1);
287 | retdata["jobUnit"] = jobPort;
288 | };
289 | if ( serviceVersion.compare("2")<0 && !testUnitText.isEmpty() ) {
290 | retdata["testUnit"] = QString::number(
291 | writeFile(testUnitPath, testUnitText));
292 | // reload unit
293 | QDBusMessage msg = QDBusMessage::createMethodCall(
294 | "org.freedesktop.systemd1",
295 | "/org/freedesktop/systemd1",
296 | "org.freedesktop.systemd1.Manager",
297 | "ReloadUnit");
298 | QList _args;
299 | _args<=2 nothing to change in test unit file,
322 | // because it created new at each test iteration
323 | retdata["code"] = QString::number(1);
324 | retdata["testUnit"] = testPort;
325 | };
326 | //retdata["jobUnitText"] = jobUnitText;
327 | //retdata["testUnitText"] = testUnitText;
328 |
329 | reply.setData(retdata);
330 | return reply;
331 | }
332 |
333 | KAUTH_HELPER_MAIN("pro.russianfedora.dnscryptclientreload", DNSCryptClientReloadHelper)
334 |
--------------------------------------------------------------------------------
/src/helpers/reload_helper/dnscrypt_client_reload_helper.h:
--------------------------------------------------------------------------------
1 | #include
2 | #if KAUTH_VERSION < ((5<<16)|(92<<8)|(0))
3 | #include
4 | #else
5 | #include
6 | #include
7 | #endif
8 | using namespace KAuth;
9 |
10 | class DNSCryptClientReloadHelper : public QObject
11 | {
12 | Q_OBJECT
13 | public:
14 | explicit DNSCryptClientReloadHelper(QObject *parent = Q_NULLPTR);
15 |
16 | public slots:
17 | ActionReply setunits(const QVariantMap args) const;
18 | };
19 |
--------------------------------------------------------------------------------
/src/helpers/test_helper/CMakeLists.txt:
--------------------------------------------------------------------------------
1 |
2 | set (DNS_UTILITY "../dns_utility")
3 | include_directories(${DNS_UTILITY})
4 |
5 | set (dnscrypt_client_test_helper_SRCS
6 | ${DNS_UTILITY}/dns.c
7 | dnscrypt_client_test_helper.cpp)
8 |
9 | find_package (Qt5Core REQUIRED)
10 | find_package (Qt5DBus REQUIRED)
11 | find_package (KF5Auth REQUIRED)
12 | qt5_wrap_cpp (TEST_HELPER_MOC_SOURCES
13 | dnscrypt_client_test_helper.h
14 | ${DNS_UTILITY}/dns.h)
15 |
16 | set (
17 | TEST_HELPER_BUILD_PROJECT_LIBRARIES
18 | ${Qt5Core_LIBRARIES}
19 | ${Qt5DBus_LIBRARIES}
20 | KF5::Auth)
21 | add_definitions(
22 | ${Qt5Core_DEFINITIONS}
23 | ${Qt5DBus_DEFINITIONS})
24 |
25 | # FYI: helper names don't like a CAPs letters !!!
26 | add_executable(
27 | dnscrypt_client_test_helper
28 | ${dnscrypt_client_test_helper_SRCS}
29 | ${TEST_HELPER_MOC_SOURCES})
30 | target_link_libraries(
31 | dnscrypt_client_test_helper
32 | ${TEST_HELPER_BUILD_PROJECT_LIBRARIES})
33 | install(
34 | TARGETS dnscrypt_client_test_helper
35 | DESTINATION ${KAUTH_HELPER_INSTALL_DIR})
36 | #message("KAUTH_HELPER_INSTALL_DIR: ${KAUTH_HELPER_INSTALL_DIR}")
37 | #message("KAUTH_POLICY_FILES_INSTALL_DIR: ${KAUTH_POLICY_FILES_INSTALL_DIR}")
38 | #message("DBUS_SYSTEM_SERVICES_INSTALL_DIR: ${DBUS_SYSTEM_SERVICES_INSTALL_DIR}")
39 |
40 | kauth_install_helper_files(
41 | dnscrypt_client_test_helper
42 | pro.russianfedora.dnscryptclienttest
43 | root)
44 | kauth_install_actions(
45 | pro.russianfedora.dnscryptclienttest
46 | actions.actions)
47 |
--------------------------------------------------------------------------------
/src/helpers/test_helper/actions.actions:
--------------------------------------------------------------------------------
1 | [pro.russianfedora.dnscryptclienttest.starttest]
2 | Name=Start DNSCrypt proxy test service
3 | Description=User DNSCrypt test
4 | Policy=yes
5 | Persistence=session
6 |
7 | [pro.russianfedora.dnscryptclienttest.stoptestslice]
8 | Name=Stop DNSCrypt proxy test service by stop slice
9 | Description=User DNSCrypt test
10 | Policy=yes
11 | Persistence=session
12 |
13 | [pro.russianfedora.dnscryptclienttest.initialization]
14 | Name=Initialize DNSCrypt v2 proxy service
15 | Description=User DNSCrypt test
16 | Policy=yes
17 | Persistence=session
18 |
19 | [pro.russianfedora.dnscryptclienttest.getversion]
20 | Name=Get DNSCrypt proxy service version
21 | Description=User DNSCrypt test
22 | Policy=yes
23 | Persistence=session
24 |
25 | [pro.russianfedora.dnscryptclienttest.getlistofservers]
26 | Name=Get DNSCrypt proxy servers list and data
27 | Description=User DNSCrypt test
28 | Policy=yes
29 | Persistence=session
30 |
31 | [pro.russianfedora.dnscryptclienttest.starttestv2]
32 | Name=Start DNSCrypt v2 proxy test service
33 | Description=User DNSCrypt test
34 | Policy=yes
35 | Persistence=session
36 |
--------------------------------------------------------------------------------
/src/helpers/test_helper/dnscrypt_client_test_helper.cpp:
--------------------------------------------------------------------------------
1 | extern "C" {
2 | #include "dns.h"
3 | }
4 | #include "dnscrypt_client_test_helper.h"
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 | //#include
13 |
14 | struct PrimitivePair
15 | {
16 | QString name;
17 | QVariant value;
18 | };
19 | Q_DECLARE_METATYPE(PrimitivePair)
20 | typedef QList SrvParameters;
21 | Q_DECLARE_METATYPE(SrvParameters)
22 |
23 | struct ComplexPair
24 | {
25 | QString name;
26 | SrvParameters value;
27 | };
28 | Q_DECLARE_METATYPE(ComplexPair)
29 | typedef QList AuxParameters;
30 | Q_DECLARE_METATYPE(AuxParameters)
31 |
32 | QString getRespondIconName(qreal r)
33 | {
34 | if ( 0 0);
155 |
156 | return ret;
157 | }
158 | bool preparedServiceUnit()
159 | {
160 | bool ret = false;
161 | QString entry = readFile("/etc/systemd/system/dnscrypt-proxy.service");
162 | QStringList _data, _new_data;
163 | _data = entry.split("\n");
164 | foreach(QString _s, _data) {
165 | QString _new_str;
166 | if ( _s.startsWith("WorkingDirectory")
167 | && !_s.endsWith("/etc/dnscrypt-proxy") ) {
168 | QStringList _parts = _s.split("=", Qt::KeepEmptyParts);
169 | _parts.removeLast();
170 | _parts.append("/etc/dnscrypt-proxy");
171 | ret = true;
172 | _new_str.append(_parts.join("="));
173 | } else if ( _s.startsWith("WorkingDirectory")
174 | && _s.endsWith("/etc/dnscrypt-proxy") ) {
175 | _new_str.append(_s);
176 | ret = true;
177 | } else {
178 | _new_str.append(_s);
179 | };
180 | _new_data.append(_new_str);
181 | };
182 | qint64 code = writeFile("/etc/systemd/system/dnscrypt-proxy.service",
183 | _new_data.join("\n"));
184 | ret &= (code > 0);
185 |
186 | return ret;
187 | }
188 |
189 | DNSCryptClientTestHelper::DNSCryptClientTestHelper(QObject *parent) :
190 | QObject(parent)
191 | {
192 | qDBusRegisterMetaType();
193 | qDBusRegisterMetaType();
194 | qDBusRegisterMetaType();
195 | qDBusRegisterMetaType();
196 | }
197 |
198 | QDBusArgument &operator<<(QDBusArgument &argument, const PrimitivePair &pair)
199 | {
200 | argument.beginStructure();
201 | argument << pair.name << QDBusVariant(pair.value);
202 | argument.endStructure();
203 | return argument;
204 | }
205 | const QDBusArgument &operator>>(const QDBusArgument &argument, PrimitivePair &pair)
206 | {
207 | argument.beginStructure();
208 | argument >> pair.name >> pair.value;
209 | argument.endStructure();
210 | return argument;
211 | }
212 | QDBusArgument &operator<<(QDBusArgument &argument, const SrvParameters &list)
213 | {
214 | int id = qMetaTypeId();
215 | argument.beginArray(id);
216 | //foreach (PrimitivePair item, list) {
217 | // argument << item;
218 | //};
219 | SrvParameters::ConstIterator it = list.constBegin();
220 | SrvParameters::ConstIterator end = list.constEnd();
221 | for ( ; it != end; ++it)
222 | argument << *it;
223 | argument.endArray();
224 | return argument;
225 | }
226 | const QDBusArgument &operator>>(const QDBusArgument &argument, SrvParameters &list)
227 | {
228 | argument.beginArray();
229 | while (!argument.atEnd()) {
230 | PrimitivePair item;
231 | argument >> item;
232 | list.append(item);
233 | };
234 | argument.endArray();
235 | return argument;
236 | }
237 |
238 | QDBusArgument &operator<<(QDBusArgument &argument, const ComplexPair &pair)
239 | {
240 | argument.beginStructure();
241 | argument << pair.name << pair.value;
242 | argument.endStructure();
243 | return argument;
244 | }
245 | const QDBusArgument &operator>>(const QDBusArgument &argument, ComplexPair &pair)
246 | {
247 | argument.beginStructure();
248 | argument >> pair.name >> pair.value;
249 | argument.endStructure();
250 | return argument;
251 | }
252 | QDBusArgument &operator<<(QDBusArgument &argument, const AuxParameters &list)
253 | {
254 | int id = qMetaTypeId();
255 | argument.beginArray(id);
256 | //foreach (ComplexPair item, list) {
257 | // argument << item;
258 | //};
259 | AuxParameters::ConstIterator it = list.constBegin();
260 | AuxParameters::ConstIterator end = list.constEnd();
261 | for ( ; it != end; ++it)
262 | argument << *it;
263 | argument.endArray();
264 | return argument;
265 | }
266 | const QDBusArgument &operator>>(const QDBusArgument &argument, AuxParameters &list)
267 | {
268 | argument.beginArray();
269 | while (!argument.atEnd()) {
270 | ComplexPair item;
271 | argument >> item;
272 | list.append(item);
273 | };
274 | argument.endArray();
275 | return argument;
276 | }
277 |
278 |
279 | ActionReply DNSCryptClientTestHelper::starttest(const QVariantMap args) const
280 | {
281 | ActionReply reply;
282 |
283 | const QString act = get_key_varmap(args, "action");
284 | if ( act!="startTest" ) {
285 | QVariantMap err;
286 | err["result"] = QString::number(-1);
287 | reply.setData(err);
288 | return reply;
289 | };
290 |
291 | QString servName = get_key_varmap(args, "server");
292 | int testPort = get_key_varmap(args, "port").toInt();
293 |
294 | qint64 code = 0;
295 | QString entry = readFile("/etc/resolv.conf");
296 | if ( !entry.startsWith("nameserver 127.0.0.1\nnameserver ::1\n") ) {
297 | entry.clear();
298 | entry.append("nameserver 127.0.0.1\nnameserver ::1\n");
299 | code = writeFile("/etc/resolv.conf", entry);
300 | };
301 | QVariantMap retdata;
302 | if ( code != -1 ) {
303 | QDBusMessage msg = QDBusMessage::createMethodCall(
304 | "org.freedesktop.systemd1",
305 | "/org/freedesktop/systemd1",
306 | "org.freedesktop.systemd1.Manager",
307 | "StartUnit");
308 | QList _args;
309 | _args< _args;
367 | if ( serviceVersion.compare("2")>0 ) {
368 | _args< _args;
598 | _args<
2 | #if KAUTH_VERSION < ((5<<16)|(92<<8)|(0))
3 | #include
4 | #else
5 | #include
6 | #include
7 | #endif
8 | using namespace KAuth;
9 |
10 | class DNSCryptClientTestHelper : public QObject
11 | {
12 | Q_OBJECT
13 | public:
14 | explicit DNSCryptClientTestHelper(QObject *parent = Q_NULLPTR);
15 |
16 | public slots:
17 | ActionReply starttest(const QVariantMap args) const;
18 | ActionReply stoptestslice(const QVariantMap args) const;
19 | ActionReply initialization(const QVariantMap args) const;
20 | ActionReply getversion(const QVariantMap args) const;
21 | ActionReply getlistofservers(const QVariantMap args) const;
22 | ActionReply starttestv2(const QVariantMap args) const;
23 | };
24 |
--------------------------------------------------------------------------------
/src/icons/128x128/actions/DNSCryptClient_close.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/F1ash/dnscrypt-proxy-gui/99c67072fe8eca7f6363f578b05d5054b1bdbd2d/src/icons/128x128/actions/DNSCryptClient_close.png
--------------------------------------------------------------------------------
/src/icons/128x128/actions/DNSCryptClient_open.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/F1ash/dnscrypt-proxy-gui/99c67072fe8eca7f6363f578b05d5054b1bdbd2d/src/icons/128x128/actions/DNSCryptClient_open.png
--------------------------------------------------------------------------------
/src/icons/128x128/actions/DNSCryptClient_restore.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/F1ash/dnscrypt-proxy-gui/99c67072fe8eca7f6363f578b05d5054b1bdbd2d/src/icons/128x128/actions/DNSCryptClient_restore.png
--------------------------------------------------------------------------------
/src/icons/32x32/status/fast.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/F1ash/dnscrypt-proxy-gui/99c67072fe8eca7f6363f578b05d5054b1bdbd2d/src/icons/32x32/status/fast.png
--------------------------------------------------------------------------------
/src/icons/32x32/status/middle.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/F1ash/dnscrypt-proxy-gui/99c67072fe8eca7f6363f578b05d5054b1bdbd2d/src/icons/32x32/status/middle.png
--------------------------------------------------------------------------------
/src/icons/32x32/status/none.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/F1ash/dnscrypt-proxy-gui/99c67072fe8eca7f6363f578b05d5054b1bdbd2d/src/icons/32x32/status/none.png
--------------------------------------------------------------------------------
/src/icons/32x32/status/slow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/F1ash/dnscrypt-proxy-gui/99c67072fe8eca7f6363f578b05d5054b1bdbd2d/src/icons/32x32/status/slow.png
--------------------------------------------------------------------------------
/src/icons/64x64/actions/DNSCryptClient_add.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/F1ash/dnscrypt-proxy-gui/99c67072fe8eca7f6363f578b05d5054b1bdbd2d/src/icons/64x64/actions/DNSCryptClient_add.png
--------------------------------------------------------------------------------
/src/icons/64x64/actions/DNSCryptClient_close.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/F1ash/dnscrypt-proxy-gui/99c67072fe8eca7f6363f578b05d5054b1bdbd2d/src/icons/64x64/actions/DNSCryptClient_close.png
--------------------------------------------------------------------------------
/src/icons/64x64/actions/DNSCryptClient_help.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/F1ash/dnscrypt-proxy-gui/99c67072fe8eca7f6363f578b05d5054b1bdbd2d/src/icons/64x64/actions/DNSCryptClient_help.png
--------------------------------------------------------------------------------
/src/icons/64x64/actions/DNSCryptClient_info.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/F1ash/dnscrypt-proxy-gui/99c67072fe8eca7f6363f578b05d5054b1bdbd2d/src/icons/64x64/actions/DNSCryptClient_info.png
--------------------------------------------------------------------------------
/src/icons/64x64/actions/DNSCryptClient_open.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/F1ash/dnscrypt-proxy-gui/99c67072fe8eca7f6363f578b05d5054b1bdbd2d/src/icons/64x64/actions/DNSCryptClient_open.png
--------------------------------------------------------------------------------
/src/icons/64x64/actions/DNSCryptClient_settings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/F1ash/dnscrypt-proxy-gui/99c67072fe8eca7f6363f578b05d5054b1bdbd2d/src/icons/64x64/actions/DNSCryptClient_settings.png
--------------------------------------------------------------------------------
/src/icons/64x64/actions/DNSCryptClient_start.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/F1ash/dnscrypt-proxy-gui/99c67072fe8eca7f6363f578b05d5054b1bdbd2d/src/icons/64x64/actions/DNSCryptClient_start.png
--------------------------------------------------------------------------------
/src/icons/64x64/actions/DNSCryptClient_test.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/F1ash/dnscrypt-proxy-gui/99c67072fe8eca7f6363f578b05d5054b1bdbd2d/src/icons/64x64/actions/DNSCryptClient_test.png
--------------------------------------------------------------------------------
/src/icons/64x64/actions/DNSCryptClient_write.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/F1ash/dnscrypt-proxy-gui/99c67072fe8eca7f6363f578b05d5054b1bdbd2d/src/icons/64x64/actions/DNSCryptClient_write.png
--------------------------------------------------------------------------------
/src/icons/64x64/status/DNSCryptClient.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/F1ash/dnscrypt-proxy-gui/99c67072fe8eca7f6363f578b05d5054b1bdbd2d/src/icons/64x64/status/DNSCryptClient.png
--------------------------------------------------------------------------------
/src/icons/64x64/status/DNSCryptClient_closed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/F1ash/dnscrypt-proxy-gui/99c67072fe8eca7f6363f578b05d5054b1bdbd2d/src/icons/64x64/status/DNSCryptClient_closed.png
--------------------------------------------------------------------------------
/src/icons/64x64/status/DNSCryptClient_opened.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/F1ash/dnscrypt-proxy-gui/99c67072fe8eca7f6363f578b05d5054b1bdbd2d/src/icons/64x64/status/DNSCryptClient_opened.png
--------------------------------------------------------------------------------
/src/icons/64x64/status/DNSCryptClient_reload.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/F1ash/dnscrypt-proxy-gui/99c67072fe8eca7f6363f578b05d5054b1bdbd2d/src/icons/64x64/status/DNSCryptClient_reload.png
--------------------------------------------------------------------------------
/src/icons/64x64/status/exit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/F1ash/dnscrypt-proxy-gui/99c67072fe8eca7f6363f578b05d5054b1bdbd2d/src/icons/64x64/status/exit.png
--------------------------------------------------------------------------------
/src/icons/License:
--------------------------------------------------------------------------------
1 | URL: http://findicons.com/search/network-proxy
2 | IconPack: Android Icons
3 | Designer: IconShock
4 | License: Creative Commons Attribution (by)
5 | Commercial: +, Link Free: +
6 |
--------------------------------------------------------------------------------
/src/icons/index.theme:
--------------------------------------------------------------------------------
1 | [Icon Theme]
2 | Name=DNSCryptClient
3 | Comment=DNSCryptClient Icon Set
4 | Inherits=hicolor,default
5 | Directories=32x32/status,64x64/status,64x64/actions,128x128/actions
6 |
7 | [32x32/status]
8 | Size=72
9 | Context=Status
10 |
11 | [64x64/status]
12 | Size=72
13 | Context=Status
14 |
15 | [64x64/actions]
16 | Size=72
17 | Context=Actions
18 |
19 | [128x128/actions]
20 | Size=128
21 | Context=Actions
22 |
--------------------------------------------------------------------------------
/src/info_panel.cpp:
--------------------------------------------------------------------------------
1 | #include "info_panel.h"
2 | //#include
3 |
4 | InfoPanel::InfoPanel(QWidget *parent) :
5 | QStackedWidget(parent)
6 | {
7 | setSizePolicy(
8 | QSizePolicy(
9 | QSizePolicy::Ignored,
10 | QSizePolicy::Ignored));
11 | st = this->styleSheet();
12 | fullName = new QLabel(this);
13 | description = new QLabel(this);
14 | location = new QLabel(this);
15 | respond = new QLabel(this);
16 | srvState = new QLabel(this);
17 | servLayout = new QVBoxLayout();
18 | servLayout->addWidget(fullName);
19 | servLayout->addWidget(description);
20 | servLayout->addWidget(location);
21 | servLayout->addWidget(respond);
22 | servLayout->addWidget(srvState);
23 | servInfo = new QWidget(this);
24 | servInfo->setSizePolicy(
25 | QSizePolicy(
26 | QSizePolicy::Ignored,
27 | QSizePolicy::Ignored));
28 | servInfo->setContentsMargins(0, 0, 0, 0);
29 | servInfo->setLayout(servLayout);
30 |
31 | attention = new QLabel(this);
32 | attentLayout = new QVBoxLayout();
33 | attentLayout->addWidget(attention);
34 | attentions = new QWidget(this);
35 | attentions->setSizePolicy(
36 | QSizePolicy(
37 | QSizePolicy::Ignored,
38 | QSizePolicy::Ignored));
39 | attentions->setContentsMargins(0, 0, 0, 0);
40 | attentions->setLayout(attentLayout);
41 |
42 | addWidget(servInfo);
43 | addWidget(attentions);
44 | setContentsMargins(0, 0, 0, 0);
45 | }
46 |
47 | /* public slots */
48 | void InfoPanel::changeAppState(SRV_STATUS state)
49 | {
50 | //QTextStream s(stdout);
51 | int idx = 0;
52 | switch (state) {
53 | case PROCESSING:
54 | //s<< "PROCESSING" <setStyleSheet("QLabel {background-color: gold;}");
57 | attention->setText("Processing...");
58 | break;
59 | case READY:
60 | //s<< "READY" <setText("You may need to restart the network\nand web applications");
66 | break;
67 | case RESTORED:
68 | //s<< "RESTORED" <setText("System DNS resolver settings restored.\
71 | \nYou may need to restart the network\nand web applications");
72 | break;
73 | case ACTIVATING:
74 | //s<< "ACTIVATING" <0 ) killTimer(timerId);
95 | timerId = startTimer(10000);
96 | attention->setStyleSheet("QLabel {background-color: gold;}");
97 | };
98 | //s << "idx=" << idx << " state="<< state<setText(_data.value("FullName").toString());
103 | fullName->setToolTip(_data.value("FullName").toString());
104 | description->setText(_data.value("Description").toString());
105 | description->setToolTip(_data.value("Description").toString());
106 | location->setText(_data.value("Location").toString());
107 | location->setToolTip(_data.value("Location").toString());
108 | respond->setText(QString("Current respond from server: %1")
109 | .arg(_data.value("Respond").toString()));
110 | respond->setToolTip(_data.value("Respond").toString());
111 | srvState->setText(QString("Server is used: %1")
112 | .arg(_data.value("Enable").toBool()? "yes":"no"));
113 | srvState->setToolTip(_data.value("Enable").toBool()? "yes":"no");
114 | setCurrentIndex(0);
115 | }
116 |
117 | /* private slots */
118 | void InfoPanel::timerEvent(QTimerEvent *ev)
119 | {
120 | if ( timerId && ev->timerId()==timerId ) {
121 | killTimer(timerId);
122 | timerId = 0;
123 | attention->setStyleSheet(st);
124 | setCurrentIndex(0);
125 | };
126 | ev->accept();
127 | }
128 |
--------------------------------------------------------------------------------
/src/info_panel.h:
--------------------------------------------------------------------------------
1 | #ifndef INFO_PANEL_H
2 | #define INFO_PANEL_H
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include "enums.h"
10 |
11 | class InfoPanel : public QStackedWidget
12 | {
13 | Q_OBJECT
14 | public:
15 | explicit InfoPanel(QWidget *parent = Q_NULLPTR);
16 |
17 | signals:
18 |
19 | private:
20 | int timerId = 0;
21 | QString st;
22 | QLabel *location, *fullName, *description,
23 | *respond, *srvState, *attention;
24 | QVBoxLayout *servLayout, *attentLayout;
25 | QWidget *servInfo, *attentions;
26 |
27 | public slots:
28 | void changeAppState(SRV_STATUS);
29 | void setServerDescription(const QVariantMap&);
30 |
31 | private slots:
32 | void timerEvent(QTimerEvent*);
33 | };
34 |
35 | #endif // INFO_PANEL_H
36 |
--------------------------------------------------------------------------------
/src/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include "mainwindow.h"
3 |
4 | int main(int argc, char *argv[])
5 | {
6 | Q_INIT_RESOURCE(dnscrypt_proxy_icons);
7 | QApplication a(argc, argv);
8 | QString name("DNSCryptClient");
9 | a.setOrganizationName(name);
10 | a.setApplicationName(name);
11 | MainWindow w;
12 | w.hide();
13 |
14 | return a.exec();
15 | }
16 |
--------------------------------------------------------------------------------
/src/mainwindow.h:
--------------------------------------------------------------------------------
1 | #ifndef MAINWINDOW_H
2 | #define MAINWINDOW_H
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include "server_panel.h"
12 | #include "button_panel.h"
13 | #include "info_panel.h"
14 | #include "test_respond.h"
15 | #include "app_settings.h"
16 | #include "tray/traywidget.h"
17 |
18 | class MainWindow : public QMainWindow
19 | {
20 | Q_OBJECT
21 | public:
22 | explicit MainWindow(QWidget *parent = Q_NULLPTR);
23 |
24 | signals:
25 | void serviceStateChanged(SRV_STATUS);
26 | void nextServer();
27 |
28 | private:
29 | bool runAtStart, useActiveService,
30 | useFastOnly, stopManually,
31 | restoreFlag, restoreAtClose,
32 | stopForChangeUnits, unhideAtStart,
33 | restoreResolvFileFlag,reinitFlag,
34 | showMessages, showBasicMsgOnly;
35 | int probeCount, jobPort, testPort;
36 | SRV_STATUS srvStatus;
37 | ServerPanel *serverWdg;
38 | ButtonPanel *buttonsWdg;
39 | InfoPanel *infoWdg;
40 | TrayIcon *trayIcon;
41 | QVBoxLayout *baseLayout;
42 | QWidget *baseWdg;
43 | AppSettings *appSettings;
44 | TestRespond *testRespond;
45 | QStackedWidget *commonWdg;
46 | QSettings settings;
47 | QDBusConnection connection;
48 | QStringList resolverEntries;
49 | QString currentUnitTranscription,
50 | asUser, serviceVersion, cfg_data;
51 | QVariantMap listOfServers;
52 | QFileSystemWatcher *watcher;
53 |
54 | void initWidgets();
55 | void readSettings();
56 | void setSettings();
57 | void initTrayIcon();
58 | void changeVisibility();
59 | void connectToClientService();
60 | void disconnectFromClientService();
61 | void checkServiceStatus();
62 | int checkSliceStatus();
63 | void startServiceProcess();
64 | void stopServiceProcess();
65 | void stopSliceProcess();
66 | void restoreSettingsProcess();
67 | void restoreResolvFileProcess();
68 | void passToNextServer();
69 | void addServerEnrty(const QString&);
70 | QString showResolverEntries();
71 |
72 | private slots:
73 | void toSettings();
74 | void toTest();
75 | void toBase();
76 | void testStarted();
77 | void testFinished();
78 | void checkRespondSettings(const QString, const QString);
79 | void firstServiceStart();
80 | void startServiceJobFinished(KJob*);
81 | void stopServiceJobFinished(KJob*);
82 | void restoreSettingsProcessFinished(KJob*);
83 | void stopsliceJobFinished(KJob*);
84 | void changeFindActiveServiceState(bool);
85 | void changeUseFastOnlyState(bool);
86 | void changeRestoreAtCloseState(bool);
87 | void changeShowMessagesState(bool);
88 | void changeShowBasicMsgOnlyState(bool);
89 | void changeJobPort(int);
90 | void changeTestPort(int);
91 | void changeUserName(QString);
92 | void startService();
93 | void stopService();
94 | void restoreSystemSettings();
95 | void trayIconActivated(QSystemTrayIcon::ActivationReason);
96 | void servicePropertyChanged(QDBusMessage);
97 | void closeEvent(QCloseEvent*);
98 | void receiveServiceStatus(QDBusMessage);
99 | void changeAppState(SRV_STATUS);
100 | void probeNextServer();
101 | void stopSystemdAppUnits();
102 | void changeUnitsFinished();
103 | void getServiceVersion();
104 | void getServiceVersionFinished(KJob*);
105 | void watchedFileChanged(const QString&);
106 |
107 | // for DNSCrypt-proxy service version 2.x.x
108 | void getListOfServersV2();
109 | void getListOfServersV2Finished(KJob*);
110 | void initServiceV2();
111 | void initServiceV2Finished(KJob*);
112 | void reinitServiceV2();
113 | };
114 |
115 | #endif // MAINWINDOW_H
116 |
--------------------------------------------------------------------------------
/src/port_settings.cpp:
--------------------------------------------------------------------------------
1 | #include "port_settings.h"
2 |
3 | PortSettings::PortSettings(QWidget *parent, int _port) :
4 | QWidget(parent)
5 | {
6 | name = new QLabel(this);
7 | name->setContentsMargins(0, 0, 0, 0);
8 | port = new QSpinBox(this);
9 | port->setRange(0, 65535);
10 | port->setValue(_port);
11 | port->setContentsMargins(0, 0, 0, 0);
12 | commonLayout = new QHBoxLayout(this);
13 | commonLayout->addWidget(port, 0, Qt::AlignLeft);
14 | commonLayout->addWidget(name, 0, Qt::AlignLeft);
15 | setContentsMargins(0, 0, 0, 0);
16 | setLayout(commonLayout);
17 | connect(port, SIGNAL(valueChanged(int)),
18 | this, SIGNAL(valueChanged(int)));
19 | }
20 |
21 | void PortSettings::setPort(const int i)
22 | {
23 | port->setValue(i);
24 | }
25 | void PortSettings::setName(const QString &_name)
26 | {
27 | name->setText(_name);
28 | }
29 | int PortSettings::getPort() const
30 | {
31 | return port->value();
32 | }
33 |
--------------------------------------------------------------------------------
/src/port_settings.h:
--------------------------------------------------------------------------------
1 | #ifndef PORT_SETTINGS_H
2 | #define PORT_SETTINGS_H
3 |
4 | #include
5 | #include
6 | #include
7 |
8 | class PortSettings : public QWidget
9 | {
10 | Q_OBJECT
11 | public:
12 | explicit PortSettings(QWidget *parent = Q_NULLPTR,
13 | int _port = 0);
14 | void setPort(const int);
15 | void setName(const QString&);
16 | int getPort() const;
17 |
18 | signals:
19 | void valueChanged(int);
20 |
21 | private:
22 | QLabel *name;
23 | QSpinBox *port;
24 | QHBoxLayout *commonLayout;
25 | };
26 |
27 | #endif // PORT_SETTINGS_H
28 |
--------------------------------------------------------------------------------
/src/resolver_entries.cpp:
--------------------------------------------------------------------------------
1 | #include "resolver_entries.h"
2 |
3 | ResolverEntries::ResolverEntries(QWidget *parent) :
4 | QDialog(parent)
5 | {
6 | setWindowTitle("Resolver Entries");
7 |
8 | entries = new QListWidget(this);
9 | ok = new QPushButton("Ok", this);
10 |
11 | dnsEntry = new QLineEdit(this);
12 | dnsEntry->setPlaceholderText("123.45.67.89");
13 | addDNS = new QPushButton("Add", this);
14 | addDNS->setToolTip("Add to list");
15 | delDNS = new QPushButton("Delete", this);
16 | delDNS->setToolTip("Delete from list");
17 | entryLayout = new QHBoxLayout(this);
18 | entryLayout->addWidget(delDNS);
19 | entryLayout->addWidget(dnsEntry);
20 | entryLayout->addWidget(addDNS);
21 | entryWdg = new QWidget(this);
22 | entryWdg->setLayout(entryLayout);
23 |
24 | commonLayout = new QVBoxLayout(this);
25 | commonLayout->addWidget(entries);
26 | commonLayout->addWidget(entryWdg);
27 | commonLayout->addWidget(ok, 0, Qt::AlignCenter);
28 | setLayout(commonLayout);
29 |
30 | connect(entries, SIGNAL(entered(QModelIndex)),
31 | this, SLOT(_close()));
32 | connect(ok, SIGNAL(released()),
33 | this, SLOT(_close()));
34 | connect(dnsEntry, SIGNAL(returnPressed()),
35 | this, SLOT(addEntry()));
36 | connect(addDNS, SIGNAL(released()),
37 | this, SLOT(addEntry()));
38 | connect(delDNS, SIGNAL(released()),
39 | this, SLOT(delEntry()));
40 | }
41 |
42 | QString ResolverEntries::getEntry() const
43 | {
44 | return selectedEntry;
45 | }
46 | void ResolverEntries::setEntries(const QStringList &_entries)
47 | {
48 | entries->addItems(_entries);
49 | entries->setCurrentRow(0, QItemSelectionModel::SelectCurrent);
50 | }
51 | QStringList ResolverEntries::getEntries() const
52 | {
53 | QStringList ret;
54 | for (int i = 0; icount(); i++ ) {
55 | QListWidgetItem *item = entries->item(i);
56 | if ( item!=Q_NULLPTR && !item->text().isEmpty() ) {
57 | ret.append(item->text());
58 | };
59 | };
60 | return ret;
61 | }
62 |
63 | /* private slots */
64 | void ResolverEntries::_close()
65 | {
66 | QList items = entries->selectedItems();
67 | if ( items.count()==0 ) {
68 | return;
69 | };
70 | if ( items.first()!=Q_NULLPTR ) {
71 | selectedEntry = items.first()->text();
72 | };
73 | done(0);
74 | }
75 | void ResolverEntries::addEntry()
76 | {
77 | if ( dnsEntry->text().isEmpty() ) return;
78 | QString _entry = QString("nameserver %1\n").arg(dnsEntry->text());
79 | entries->addItem(_entry);
80 | dnsEntry->clear();
81 | }
82 | void ResolverEntries::delEntry()
83 | {
84 | QList items = entries->selectedItems();
85 | if ( items.count()==0 ) return;
86 | foreach (QListWidgetItem *item, items) {
87 | if ( item!=Q_NULLPTR ) {
88 | int idx = entries->row(item);
89 | entries->takeItem(idx);
90 | delete item;
91 | item = Q_NULLPTR;
92 | };
93 | };
94 | }
95 |
--------------------------------------------------------------------------------
/src/resolver_entries.h:
--------------------------------------------------------------------------------
1 | #ifndef RESOLVER_ENTRIES_H
2 | #define RESOLVER_ENTRIES_H
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 |
10 | class ResolverEntries : public QDialog
11 | {
12 | Q_OBJECT
13 | public:
14 | explicit ResolverEntries(QWidget *parent = Q_NULLPTR);
15 | QString getEntry() const;
16 | void setEntries(const QStringList&);
17 | QStringList getEntries() const;
18 |
19 | private:
20 | QListWidget *entries;
21 | QPushButton *ok;
22 | QLineEdit *dnsEntry;
23 | QPushButton *addDNS, *delDNS;
24 | QHBoxLayout *entryLayout;
25 | QWidget *entryWdg;
26 | QVBoxLayout *commonLayout;
27 | QString selectedEntry;
28 |
29 | private slots:
30 | void _close();
31 | void addEntry();
32 | void delEntry();
33 | };
34 |
35 | #endif // RESOLVER_ENTRIES_H
36 |
--------------------------------------------------------------------------------
/src/server_info.cpp:
--------------------------------------------------------------------------------
1 | #include "server_info.h"
2 |
3 | ServerInfo::ServerInfo(QWidget *parent) :
4 | QDialog(parent)
5 | {
6 | setWindowTitle("Server Info");
7 |
8 | name = new Click_Label(this);
9 | name->setToolTip("Name");
10 | fullName = new Click_Label(this);
11 | fullName->setToolTip("Full name");
12 | description = new Click_Label(this);
13 | description->setToolTip("Description");
14 | location = new Click_Label(this);
15 | location->setToolTip("Location");
16 | coordinates = new Click_Label(this);
17 | coordinates->setToolTip("Coordinates");
18 | URL = new Click_Label(this);
19 | URL->setToolTip("URL");
20 | version = new Click_Label(this);
21 | version->setToolTip("Version");
22 | DNSSECvalidation = new Click_Label(this);
23 | DNSSECvalidation->setToolTip("DNSSEC validation");
24 | NoLogs = new Click_Label(this);
25 | NoLogs->setToolTip("No Logs");
26 | Namecoin = new Click_Label(this);
27 | Namecoin->setToolTip("Namecoin");
28 | ResolverAddress = new Click_Label(this);
29 | ResolverAddress->setToolTip("Resolver Address");
30 | ProviderName = new Click_Label(this);
31 | ProviderName->setToolTip("Provider Name");
32 | ProviderPublicKey = new Click_Label(this);
33 | ProviderPublicKey->setToolTip("Provider Public Key");
34 | ProviderPublicKeyTXTrecord = new Click_Label(this);
35 | ProviderPublicKeyTXTrecord->setToolTip("Provider Public Key TXT record");
36 |
37 | commonLayout = new QVBoxLayout(this);
38 | commonLayout->addWidget(name);
39 | commonLayout->addWidget(fullName);
40 | commonLayout->addWidget(description);
41 | commonLayout->addWidget(location);
42 | commonLayout->addWidget(coordinates);
43 | commonLayout->addWidget(URL);
44 | commonLayout->addWidget(version);
45 | commonLayout->addWidget(DNSSECvalidation);
46 | commonLayout->addWidget(NoLogs);
47 | commonLayout->addWidget(Namecoin);
48 | commonLayout->addWidget(ResolverAddress);
49 | commonLayout->addWidget(ProviderName);
50 | commonLayout->addWidget(ProviderPublicKey);
51 | commonLayout->addWidget(ProviderPublicKeyTXTrecord);
52 | setLayout(commonLayout);
53 | }
54 |
55 | void ServerInfo::setServerData(const QVariantMap &map)
56 | {
57 | name->setText(map.value("Name").toString());
58 | fullName->setText(map.value("FullName").toString());
59 | description->setText(map.value("Description").toString());
60 | location->setText(map.value("Location").toString());
61 | coordinates->setText(map.value("Coordinates").toString());
62 | URL->setText(map.value("URL").toString());
63 | version->setText(map.value("Version").toString());
64 | DNSSECvalidation->setText(map.value("DNSSECvalidation").toString());
65 | NoLogs->setText(map.value("NoLogs").toString());
66 | Namecoin->setText(map.value("Namecoin").toString());
67 | ResolverAddress->setText(map.value("ResolverAddress").toString());
68 | ProviderName->setText(map.value("ProviderName").toString());
69 | ProviderPublicKey->setText(map.value("ProviderPublicKey").toString());
70 | ProviderPublicKeyTXTrecord->setText(map.value("ProviderPublicKeyTXTrecord").toString());
71 | }
72 |
--------------------------------------------------------------------------------
/src/server_info.h:
--------------------------------------------------------------------------------
1 | #ifndef SERVER_INFO_H
2 | #define SERVER_INFO_H
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include "click_label.h"
9 |
10 | class ServerInfo : public QDialog
11 | {
12 | Q_OBJECT
13 | public:
14 | explicit ServerInfo(QWidget *parent = Q_NULLPTR);
15 | void setServerData(const QVariantMap&);
16 |
17 | private:
18 | QVBoxLayout *commonLayout;
19 | Click_Label *name, *fullName, *description,
20 | *location, *coordinates, *URL,
21 | *version, *DNSSECvalidation, *NoLogs,
22 | *Namecoin, *ResolverAddress, *ProviderName,
23 | *ProviderPublicKey, *ProviderPublicKeyTXTrecord;
24 | };
25 |
26 | #endif // SERVER_INFO_H
27 |
--------------------------------------------------------------------------------
/src/server_panel.cpp:
--------------------------------------------------------------------------------
1 | #include "server_panel.h"
2 | #include "help_thread.h"
3 | #include "server_info.h"
4 | //#include
5 |
6 | ServerPanel::ServerPanel(QWidget *parent, QString ver) :
7 | QWidget(parent), serviceVersion(ver)
8 | {
9 | servLabel = new QLabel(this);
10 | servLabel->setPixmap(
11 | QIcon::fromTheme("DNSCryptClient_start",
12 | QIcon(":/start.png"))
13 | .pixmap(32));
14 | servLabel->setSizePolicy(
15 | QSizePolicy(
16 | QSizePolicy::Ignored,
17 | QSizePolicy::Ignored));
18 | servLabel->setContentsMargins(0, 0, 0, 0);
19 | servItems = QList();
20 | servList = new QComboBox(this);
21 | servList->setDuplicatesEnabled(false);
22 | servList->setContextMenuPolicy(Qt::NoContextMenu);
23 | servList->setSizeAdjustPolicy(QComboBox::AdjustToContents);
24 | servItemModel = new QStandardItemModel(this);
25 | servList->setModel(servItemModel);
26 | servList->setContentsMargins(0, 0, 0, 0);
27 | servInfo = new QPushButton(
28 | QIcon::fromTheme("DNSCryptClient_info",
29 | QIcon(":/info.png")),
30 | "", this);
31 | servInfo->setFlat(false);
32 | servInfo->setToolTip("DNSCrypt Server Info");
33 | servInfo->setSizePolicy(
34 | QSizePolicy(
35 | QSizePolicy::Ignored,
36 | QSizePolicy::Ignored));
37 | servInfo->setContentsMargins(0, 0, 0, 0);
38 | appSettings = new QPushButton(
39 | QIcon::fromTheme("DNSCryptClient_settings",
40 | QIcon(":/settings.png")),
41 | "", this);
42 | appSettings->setFlat(false);
43 | appSettings->setToolTip("to Application Settings");
44 | appSettings->setSizePolicy(
45 | QSizePolicy(
46 | QSizePolicy::Ignored,
47 | QSizePolicy::Ignored));
48 | appSettings->setContentsMargins(0, 0, 0, 0);
49 | testRespond = new QPushButton(
50 | QIcon::fromTheme("DNSCryptClient_test",
51 | QIcon(":/test.png")),
52 | "", this);
53 | testRespond->setFlat(false);
54 | testRespond->setToolTip("to Respond test");
55 | testRespond->setSizePolicy(
56 | QSizePolicy(
57 | QSizePolicy::Ignored,
58 | QSizePolicy::Ignored));
59 | testRespond->setContentsMargins(0, 0, 0, 0);
60 |
61 | baseLayout = new QHBoxLayout(this);
62 | baseLayout->addWidget(servLabel, 1);
63 | baseLayout->addWidget(servList, 6);
64 | baseLayout->addWidget(servInfo, 1);
65 | baseLayout->addWidget(appSettings, 1);
66 | baseLayout->addWidget(testRespond, 1);
67 |
68 | setContentsMargins(0, 0, 0, 0);
69 | setLayout(baseLayout);
70 |
71 | connect(appSettings, SIGNAL(released()),
72 | this, SIGNAL(toSettings()));
73 | connect(testRespond, SIGNAL(released()),
74 | this, SIGNAL(toTest()));
75 | connect(servList, SIGNAL(currentIndexChanged(int)),
76 | this, SLOT(serverDataChanged(int)));
77 | connect(servList, SIGNAL(activated(int)),
78 | this, SIGNAL(serverActivated()));
79 | connect(servList->model(), SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector)),
80 | this, SLOT(changeItemState(QModelIndex, QModelIndex)));
81 | connect(servInfo, SIGNAL(released()),
82 | this, SLOT(showServerInfo()));
83 | }
84 |
85 | void ServerPanel::setServerDataMap(const QVariantMap _map)
86 | {
87 | listOfServers = _map;
88 | }
89 | void ServerPanel::setLastServer(const QString &_server)
90 | {
91 | lastServer = _server;
92 | HelpThread *hlpThread = new HelpThread(this);
93 | if ( serviceVersion.compare("2")>0 ) {
94 | hlpThread->setServerDataMap(listOfServers);
95 | };
96 | connect(hlpThread, SIGNAL(newDNSCryptSever(const QVariantMap&)),
97 | this, SLOT(addServer(const QVariantMap&)));
98 | connect(hlpThread, SIGNAL(finished()),
99 | this, SLOT(findLastServer()));
100 | hlpThread->start();
101 | }
102 | QString ServerPanel::getCurrentServer() const
103 | {
104 | return servList->currentText();
105 | }
106 | QString ServerPanel::getCurrentRespondIconName() const
107 | {
108 | return servList->currentData().toMap()
109 | .value("Respond").toString();
110 | }
111 | int ServerPanel::getServerListCount() const
112 | {
113 | return servList->count();
114 | }
115 | void ServerPanel::setNextServer()
116 | {
117 | int idx = servList->currentIndex() + 1;
118 | if ( idx==servList->count() ) idx = 0;
119 | servList->setCurrentIndex(idx);
120 | }
121 | QString ServerPanel::getItemName(int idx) const
122 | {
123 | return servList->itemText(idx);
124 | }
125 | QString ServerPanel::getRespondIconName(int idx) const
126 | {
127 | return servList->itemData(idx).toMap()
128 | .value("Respond", "none").toString();
129 | }
130 | bool ServerPanel::getItemState(int idx) const
131 | {
132 | return servList->itemData(idx).toMap()
133 | .value("Enable", true).toBool();
134 | }
135 | bool ServerPanel::serverIsEnabled() const
136 | {
137 | return getItemState(servList->currentIndex());
138 | }
139 | void ServerPanel::changeServerInfo()
140 | {
141 | QVariantMap servData = servList->currentData().toMap();
142 | emit serverData(servData);
143 | }
144 |
145 | /* public slots */
146 | void ServerPanel::changeAppState(SRV_STATUS state)
147 | {
148 | switch (state) {
149 | case READY:
150 | break;
151 | case INACTIVE:
152 | case RESTORED:
153 | servList->setEnabled(true);
154 | break;
155 | case ACTIVE:
156 | case ACTIVATING:
157 | case FAILED:
158 | case DEACTIVATING:
159 | case RELOADING:
160 | case PROCESSING:
161 | default:
162 | servList->setEnabled(false);
163 | break;
164 | }
165 | }
166 | void ServerPanel::setItemIcon(QString name, QString icon_name)
167 | {
168 | int idx = servList->findText(name, Qt::MatchExactly);
169 | if ( idx>-1 ) {
170 | servList->setItemIcon(
171 | idx,
172 | QIcon::fromTheme(icon_name,
173 | QIcon(QString(":/%1.png").arg(icon_name))));
174 | QVariantMap _map = servList->itemData(idx).toMap();
175 | _map.insert("Respond", icon_name);
176 | servList->setItemData(idx, _map);
177 | };
178 | }
179 |
180 | /* private slots */
181 | void ServerPanel::resizeEvent(QResizeEvent *ev)
182 | {
183 | ev->accept();
184 | // (widget+combobox+shadow+itemborder\buttonborder)*2
185 | // (1+1+1+3)*2 = 12
186 | int h = ev->size().height();
187 | QSize s = QSize(h-12, h-12);
188 | servLabel->setMaximumHeight(h);
189 | //servList->setIconSize(s1);
190 | servList->setMaximumHeight(h);
191 | servInfo->setIconSize(s);
192 | servInfo->setMaximumHeight(h);
193 | appSettings->setIconSize(s);
194 | appSettings->setMaximumHeight(h);
195 | testRespond->setIconSize(s);
196 | testRespond->setMaximumHeight(h);
197 | }
198 | void ServerPanel::serverDataChanged(int idx)
199 | {
200 | Q_UNUSED(idx)
201 | //QVariantMap servData = servList->currentData().toMap();
202 | //emit serverData(servData);
203 | changeServerInfo();
204 | }
205 | void ServerPanel::addServer(const QVariantMap &_data)
206 | {
207 | QStandardItem *_item = new QStandardItem;
208 | _item->setData(_data.value("Name").toString(), Qt::DisplayRole);
209 | bool state = _data.value("Enable").toBool();
210 | if ( state ) {
211 | _item->setFlags(Qt::ItemIsUserCheckable |
212 | Qt::ItemIsEnabled |
213 | Qt::ItemIsSelectable);
214 | } else {
215 | _item->setFlags(Qt::ItemIsUserCheckable |
216 | Qt::ItemIsEnabled);
217 | };
218 | _item->setData(
219 | (state)? Qt::Checked : Qt::Unchecked,
220 | Qt::CheckStateRole);
221 | QString respondIconName = _data.value("Respond", "none").toString();
222 | _item->setData(
223 | QIcon::fromTheme(respondIconName,
224 | QIcon(QString(":/%1.png").arg(respondIconName))),
225 | Qt::DecorationRole);
226 | _item->setData("Press 'Blank' key to change state", Qt::ToolTipRole);
227 | _item->setData(_data, Qt::UserRole);
228 | servItemModel->insertRow(servItems.count(), _item);
229 | servItems.append(_item);
230 | emit checkItem(_data.value("Name").toString(), respondIconName);
231 | }
232 | void ServerPanel::findLastServer()
233 | {
234 | servList->setCurrentText(lastServer);
235 | QVariantMap _data = servList->currentData().toMap();
236 | emit serverData(_data);
237 | emit readyForStart();
238 | }
239 | void ServerPanel::showServerInfo()
240 | {
241 | QVariantMap _map = servList->currentData().toMap();
242 | ServerInfo *d = new ServerInfo(this);
243 | d->setServerData(_map);
244 | d->exec();
245 | d->deleteLater();
246 | }
247 | void ServerPanel::changeItemState(QModelIndex topLeft, QModelIndex bottomRight)
248 | {
249 | Q_UNUSED(bottomRight);
250 | QStandardItem* _item = servItems.at(topLeft.row());
251 | QVariantMap _map = _item->data(Qt::UserRole).toMap();
252 | bool state = (_item->checkState() == Qt::Checked);
253 | _map.insert("Enable", state);
254 | if ( state ) {
255 | _item->setFlags(Qt::ItemIsUserCheckable |
256 | Qt::ItemIsEnabled |
257 | Qt::ItemIsSelectable);
258 | } else {
259 | _item->setFlags(Qt::ItemIsUserCheckable |
260 | Qt::ItemIsEnabled);
261 | };
262 | _item->setData(_map, Qt::UserRole);
263 | //QTextStream s(stdout);
264 | //s<< _item->text()<<" " << _item->checkState() << endl;
265 | }
266 |
--------------------------------------------------------------------------------
/src/server_panel.h:
--------------------------------------------------------------------------------
1 | #ifndef SERVER_PANEL_H
2 | #define SERVER_PANEL_H
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include "enums.h"
10 | #include
11 |
12 | class ServerPanel : public QWidget
13 | {
14 | Q_OBJECT
15 | public:
16 | explicit ServerPanel(QWidget *parent = Q_NULLPTR, QString ver = "");
17 | void setServerDataMap(const QVariantMap);
18 | void setLastServer(const QString&);
19 | QString getCurrentServer() const;
20 | QString getCurrentRespondIconName() const;
21 | int getServerListCount() const;
22 | void setNextServer();
23 | QString getItemName(int) const;
24 | QString getRespondIconName(int) const;
25 | bool getItemState(int) const;
26 | bool serverIsEnabled() const;
27 | void changeServerInfo();
28 |
29 | signals:
30 | void toSettings();
31 | void toTest();
32 | void serverData(const QVariantMap&);
33 | void readyForStart();
34 | void checkItem(const QString, const QString);
35 | void serverActivated();
36 |
37 | private:
38 | const QString serviceVersion;
39 | QString lastServer;
40 | QLabel *servLabel;
41 | QComboBox *servList;
42 | QPushButton *servInfo, *appSettings, *testRespond;
43 | QHBoxLayout *baseLayout;
44 |
45 | QStandardItemModel
46 | *servItemModel;
47 | QList
48 | servItems;
49 | QVariantMap listOfServers;
50 |
51 | public slots:
52 | void changeAppState(SRV_STATUS);
53 | void setItemIcon(QString, QString);
54 |
55 | private slots:
56 | void resizeEvent(QResizeEvent*);
57 | void serverDataChanged(int);
58 | void addServer(const QVariantMap&);
59 | void findLastServer();
60 | void showServerInfo();
61 | void changeItemState(QModelIndex, QModelIndex);
62 | };
63 |
64 | #endif // SERVER_PANEL_H
65 |
--------------------------------------------------------------------------------
/src/test_respond.cpp:
--------------------------------------------------------------------------------
1 | #include "test_respond.h"
2 |
3 | TestRespond::TestRespond(QWidget *parent, QString ver, QString cfg) :
4 | QWidget(parent), serviceVersion(ver)
5 | {
6 | setContentsMargins(0, 0, 0, 0);
7 | testLabel = new QLabel(this);
8 | testLabel->setPixmap(QIcon::fromTheme(
9 | "DNSCryptClient_test",
10 | QIcon(":/test.png"))
11 | .pixmap(32));
12 | testLabel->setSizePolicy(
13 | QSizePolicy(
14 | QSizePolicy::Ignored,
15 | QSizePolicy::Ignored));
16 | testLabel->setContentsMargins(0, 0, 0, 0);
17 | nameLabel = new QLabel(this);
18 | nameLabel->setText("Test servers respond");
19 | nameLabel->setSizePolicy(
20 | QSizePolicy(
21 | QSizePolicy::Ignored,
22 | QSizePolicy::Ignored));
23 | nameLabel->setContentsMargins(0, 0, 0, 0);
24 | baseButton = new QPushButton(
25 | QIcon::fromTheme("DNSCryptClient_start",
26 | QIcon(":/start.png")),
27 | "", this);
28 | baseButton->setFlat(false);
29 | baseButton->setToolTip("to Control Panel");
30 | baseButton->setSizePolicy(
31 | QSizePolicy(
32 | QSizePolicy::Ignored,
33 | QSizePolicy::Ignored));
34 | baseButton->setContentsMargins(0, 0, 0, 0);
35 | headLayout = new QHBoxLayout(this);
36 | headLayout->addWidget(testLabel, 1);
37 | headLayout->addWidget(nameLabel, 10, Qt::AlignCenter);
38 | headLayout->addWidget(baseButton, 1);
39 | headWdg = new QWidget(this);
40 | headWdg->setContentsMargins(0, 0, 0, 0);
41 | headWdg->setLayout(headLayout);
42 |
43 | testWdg = new TestWidget(this, serviceVersion, cfg);
44 |
45 | commonLayout = new QVBoxLayout(this);
46 | commonLayout->addWidget(headWdg, 1);
47 | commonLayout->addWidget(testWdg, 5);
48 | commonLayout->addStretch(-1);
49 | setLayout(commonLayout);
50 |
51 | connect(baseButton, SIGNAL(released()),
52 | this, SIGNAL(toBase()));
53 | }
54 |
--------------------------------------------------------------------------------
/src/test_respond.h:
--------------------------------------------------------------------------------
1 | #ifndef TEST_RESPOND_H
2 | #define TEST_RESPOND_H
3 |
4 | #include
5 | #include
6 | #include
7 | #include "test_widget.h"
8 |
9 | class TestRespond : public QWidget
10 | {
11 | Q_OBJECT
12 | public:
13 | explicit TestRespond(QWidget *parent = Q_NULLPTR,
14 | QString ver = "",
15 | QString cfg = "");
16 | TestWidget *testWdg;
17 |
18 | signals:
19 | void toBase();
20 | void findActiveServiceStateChanged(bool);
21 | void restoreAtCloseChanged(bool);
22 |
23 | private:
24 | const QString serviceVersion;
25 | QLabel *testLabel, *nameLabel;
26 | QPushButton *baseButton;
27 | QHBoxLayout *headLayout;
28 | QWidget *headWdg;
29 |
30 | QVBoxLayout *commonLayout;
31 |
32 | public slots:
33 | };
34 |
35 | #endif // TEST_RESPOND_H
36 |
--------------------------------------------------------------------------------
/src/test_widget.cpp:
--------------------------------------------------------------------------------
1 | #include "test_widget.h"
2 | //#include
3 |
4 | TestWidget::TestWidget(QWidget *parent, QString ver, QString cfg) :
5 | QWidget(parent), serviceVersion(ver), cfg_data(cfg)
6 | {
7 | processing = false;
8 | active = false;
9 | info = new QLabel(this);
10 | progress = new QProgressBar(this);
11 | progress->setEnabled(false);
12 | start = new QPushButton("Start", this);
13 | stop = new QPushButton("Stop", this);
14 | //stop->setEnabled(false);
15 | buttonLayout = new QHBoxLayout(this);
16 | buttonLayout->addWidget(start, 0, Qt::AlignRight);
17 | buttonLayout->addWidget(stop, 0, Qt::AlignRight);
18 | buttons = new QWidget(this);
19 | buttons->setLayout(buttonLayout);
20 |
21 | commonLayout = new QVBoxLayout(this);
22 | commonLayout->addWidget(info);
23 | commonLayout->addWidget(progress);
24 | commonLayout->addWidget(buttons);
25 | setLayout(commonLayout);
26 |
27 | connect(start, SIGNAL(released()),
28 | this, SLOT(startTest()));
29 | connect(stop, SIGNAL(released()),
30 | this, SLOT(stopTest()));
31 |
32 | connect(this, SIGNAL(nextItem()),
33 | this, SLOT(checkServerRespond()));
34 | }
35 |
36 | void TestWidget::setServerList(QStringList _list)
37 | {
38 | list = _list;
39 | progress->setRange(0, _list.count());
40 | }
41 | void TestWidget::setTestPort(int port)
42 | {
43 | testPort = port;
44 | }
45 | bool TestWidget::isActive() const
46 | {
47 | return active;
48 | }
49 |
50 | /* private slots */
51 | void TestWidget::startTest()
52 | {
53 | progress->setEnabled(true);
54 | start->setEnabled(false);
55 | stop->setEnabled(true);
56 | processing = true;
57 | active = true;
58 | //emit started();
59 | progress->setValue(0);
60 | counter = 0;
61 | emit nextItem();
62 | }
63 | void TestWidget::stopTest()
64 | {
65 | stop->setEnabled(false);
66 | processing = false;
67 | }
68 | void TestWidget::finishTest()
69 | {
70 | active = false;
71 | progress->setEnabled(false);
72 | stop->setEnabled(false);
73 | start->setEnabled(true);
74 | emit finished();
75 | info->clear();
76 | }
77 | void TestWidget::checkServerRespond()
78 | {
79 | //QTextStream s(stdout);
80 | if ( !processing || counter>=list.count() ) {
81 | finishTest();
82 | return;
83 | };
84 | QVariantMap args;
85 | args["action"] = "startTest";
86 | args["port"] = testPort;
87 | args["server"] = list.at(counter);
88 | Action act;
89 | if ( serviceVersion.compare("2")>0 ) {
90 | args["cfg_data"] = cfg_data;
91 | act.setName("pro.russianfedora.dnscryptclienttest.starttestv2");
92 | } else {
93 | act.setName("pro.russianfedora.dnscryptclienttest.starttest");
94 | };
95 | act.setHelperId("pro.russianfedora.dnscryptclienttest");
96 | act.setArguments(args);
97 | ExecuteJob *job = act.execute();
98 | job->setParent(this);
99 | job->setAutoDelete(true);
100 | connect(job, SIGNAL(result(KJob*)),
101 | this, SLOT(resultCheckServerRespond(KJob*)));
102 | job->start();
103 | //s<< counter <<"\t"<< "startTest"<< endl;
104 | }
105 | void TestWidget::stopServiceSlice()
106 | {
107 | //QTextStream s(stdout);
108 | QVariantMap args;
109 | args["action"] = "stopTestSlice";
110 | args["version"] = serviceVersion;
111 | Action act("pro.russianfedora.dnscryptclienttest.stoptestslice");
112 | act.setHelperId("pro.russianfedora.dnscryptclienttest");
113 | act.setArguments(args);
114 | ExecuteJob *job = act.execute();
115 | job->setParent(this);
116 | job->setAutoDelete(true);
117 | connect(job, SIGNAL(result(KJob*)),
118 | this, SLOT(resultStopServiceSlice(KJob*)));
119 | job->start();
120 | //s<< counter <<"\t"<< "stopTestSlice"<< endl;
121 | }
122 | void TestWidget::resultCheckServerRespond(KJob *_job)
123 | {
124 | //QTextStream s(stdout);
125 | QString i = QString("\nIt left about %1 sec...")
126 | .arg(list.count()-counter-1);
127 | ExecuteJob *job = static_cast(_job);
128 | if ( job!=Q_NULLPTR ) {
129 | QString code = job->data().value("code").toString();
130 | //QString msg = job->data().value("msg").toString();
131 | //QString err = job->data().value("err").toString();
132 | //QString entry = job->data().value("entry").toString();
133 | QString answ = job->data().value("answ").toString();
134 | QString resp_icon = job->data().value("resp").toString();
135 | if ( code.toInt()==0 && answ.toInt()>0 ) {
136 | emit serverRespondIcon(list.at(counter), resp_icon);
137 | i.prepend(QString("%1\tis %2.")
138 | .arg(list.at(counter)).arg(resp_icon));
139 | } else {
140 | emit serverRespondIcon(list.at(counter), "none");
141 | i.prepend(QString("%1\tis none.").arg(list.at(counter)));
142 | };
143 | } else {
144 | emit serverRespondIcon(list.at(counter), "none");
145 | i.prepend(QString("%1\tis none.").arg(list.at(counter)));
146 | };
147 | //s<< counter <<"\t"<< "start1"<< endl;
148 | info->setText(i);
149 | stopServiceSlice();
150 | }
151 | void TestWidget::resultStopServiceSlice(KJob *_job)
152 | {
153 | //QTextStream s(stdout);
154 | ExecuteJob *job = static_cast(_job);
155 | if ( job!=Q_NULLPTR ) {
156 | QString code = job->data().value("code").toString();
157 | if ( code.toInt()!=0 ) {
158 | stopServiceSlice();
159 | };
160 | } else {
161 | //stopServiceSlice();
162 | };
163 | //s<< counter <<"\t"<< "stopslice1"<< endl;
164 | ++counter;
165 | progress->setValue(counter);
166 | emit nextItem();
167 | }
168 |
169 | /* public slots */
170 | void TestWidget::changeAppState(SRV_STATUS state)
171 | {
172 | switch (state) {
173 | case READY:
174 | //start->setEnabled(true);
175 | break;
176 | case PROCESSING:
177 | //start->setEnabled(false);
178 | break;
179 | case ACTIVE:
180 | //buttons->setDisabled(true);
181 | //info->setText("To use necessary to stop service.");
182 | break;
183 | case INACTIVE:
184 | case FAILED:
185 | //buttons->setEnabled(true);
186 | break;
187 | case ACTIVATING:
188 | case DEACTIVATING:
189 | case RELOADING:
190 | case RESTORED:
191 | case STOP_SLICE:
192 | default:
193 | break;
194 | };
195 | }
196 |
--------------------------------------------------------------------------------
/src/test_widget.h:
--------------------------------------------------------------------------------
1 | #ifndef TEST_WIDGET_H
2 | #define TEST_WIDGET_H
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include "enums.h"
9 | #include
10 | #if KAUTH_VERSION < ((5<<16)|(92<<8)|(0))
11 | #include
12 | #else
13 | #include
14 | #endif
15 | using namespace KAuth;
16 |
17 | class TestWidget : public QWidget
18 | {
19 | Q_OBJECT
20 | public:
21 | explicit TestWidget(QWidget *parent = Q_NULLPTR,
22 | QString ver = "",
23 | QString cfg = "");
24 | void setServerList(QStringList);
25 | void setTestPort(int);
26 | bool isActive() const;
27 |
28 | signals:
29 | void started();
30 | void finished();
31 | void serverRespondIcon(const QString, const QString);
32 | void nextItem();
33 |
34 | private:
35 | int counter, testPort;
36 | bool processing, active;
37 | QLabel *info;
38 | QProgressBar *progress;
39 | QPushButton *start, *stop;
40 | QHBoxLayout *buttonLayout;
41 | QWidget *buttons;
42 | QVBoxLayout *commonLayout;
43 |
44 | QStringList list;
45 | QString serviceVersion, cfg_data;
46 |
47 | private slots:
48 | void startTest();
49 | void finishTest();
50 | void checkServerRespond();
51 | void stopServiceSlice();
52 | void resultCheckServerRespond(KJob*);
53 | void resultStopServiceSlice(KJob*);
54 |
55 | public slots:
56 | void changeAppState(SRV_STATUS);
57 | void stopTest();
58 | };
59 |
60 | #endif // TEST_WIDGET_H
61 |
--------------------------------------------------------------------------------
/src/tray/traywidget.cpp:
--------------------------------------------------------------------------------
1 | #include "traywidget.h"
2 |
3 | TrayIcon::TrayIcon(
4 | QWidget *parent,
5 | QString ver)
6 | : QSystemTrayIcon(parent)
7 | {
8 | setIcon(QIcon::fromTheme("DNSCryptClient",
9 | QIcon(":/DNSCryptClient.png")));
10 | setToolTip("DNSCryptClient");
11 |
12 | reinitAction = new QAction(QString("Re-initializate"), this);
13 | reinitAction->setIcon (
14 | QIcon::fromTheme("reload", QIcon(":/reload.png")));
15 |
16 | closeAction = new QAction(QString("Exit"), this);
17 | closeAction->setIcon (
18 | QIcon::fromTheme("exit", QIcon(":/exit.png")));
19 |
20 | trayIconMenu = new QMenu(parent);
21 | trayIconMenu->addAction(reinitAction);
22 | reinitAction->setVisible(false);
23 | if ( ver.compare("2")>0 ) {
24 | trayIconMenu->addSeparator();
25 | reinitAction->setVisible(true);
26 | };
27 | trayIconMenu->addAction(closeAction);
28 |
29 | setContextMenu(trayIconMenu);
30 | setVisible(true);
31 | }
32 |
--------------------------------------------------------------------------------
/src/tray/traywidget.h:
--------------------------------------------------------------------------------
1 | #ifndef TRAYWIDGET_H
2 | #define TRAYWIDGET_H
3 |
4 | #include
5 | #include
6 | #include
7 |
8 | class TrayIcon : public QSystemTrayIcon
9 | {
10 | Q_OBJECT
11 | public :
12 | explicit TrayIcon(
13 | QWidget *parent = Q_NULLPTR,
14 | QString ver = "1.x.x");
15 | QAction *reinitAction;
16 | QAction *closeAction;
17 |
18 | private :
19 | QMenu *trayIconMenu;
20 | };
21 |
22 | #endif
23 |
--------------------------------------------------------------------------------