pax_global_header00006660000000000000000000000064124632137220014514gustar00rootroot0000000000000052 comment=0b16d400e3f36defeac840993702e0f0902d40fa guidedog-1.2.0/000077500000000000000000000000001246321372200133035ustar00rootroot00000000000000guidedog-1.2.0/AUTHORS000066400000000000000000000001511246321372200143500ustar00rootroot00000000000000Simon Edwards Converted to Qt5 by Antonio Cardoso Martins guidedog-1.2.0/COPYING000066400000000000000000000354331246321372200143460ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS guidedog-1.2.0/ChangeLog000066400000000000000000000020371246321372200150570ustar00rootroot00000000000000* Sun Dec 28 2014 Antonio Cardoso Martins - Converted version 1.0.0 to pure Qt5. * Sat Aug 23 2008 Simon Edwards - 1.1 test release - Ported to Python and KDE 4. * Tue Nov 11 2003 Simon Edwards - 1.0.0 release. - Manual finished. * Mon Sep 29 2003 Simon Edwards - 0.9.2 release. - Small compile fix, stdlib.h. (thanks Sbastien Phlep, Paul Cupis) - Generated script now returns 'true' to the caller (thanks Paul Cupis) - Only accepts numeric IP addresses or masks. No domain names. - More work on the manual. * Thu May 08 2003 Simon Edwards - 0.9.1 release. - Added "No-masquerade" address list. - Added Port Forwarding. * Thu Jul 11 2002 Simon Edwards - 0.9.0 - Script no longer uses the 'sysctl' command. - Added /usr/local/sbin/ to the command search path. - Updated the admin dir, and made sure it compiles on KDE 2 and 3. * Fri Nov 09 2001 Simon Edwards - 0.1.0 - Initial release guidedog-1.2.0/INSTALL000066400000000000000000000007261246321372200143410ustar00rootroot00000000000000 This software uses qmake for building and installation. Quick install instructions ~~~~~~~~~~~~~~~~~~~~~~~~~~ After unpacking the archive, set the current directory to the one containhing this INSTALL file, and run the following commands: If you want to create a Makefile, issue 'qmake -makefile', otherwise, simply type 'qmake' to build the source code. The last command "make install", will probably have to be done as the root user or using root user privileges. guidedog-1.2.0/README000066400000000000000000000030351246321372200141640ustar00rootroot00000000000000 Installation & Requirements ~~~~~~~~~~~~~~~~~~~~~~~~~~~ To install and run this software requires: * qtbase5-dev * gcc * gksudo * iproute2 * iptables - Commands for setup Linux's low level network filtering * Linux Read the file called INSTALL for generic instructions about using cmake to install software. Post-build setup ~~~~~~~~~~~~~~~~ After running 'make', a few more steps are needed to correctly install Guidedog. The Guidedog script at /etc/rc.guidedog needs to be run each time that a network interface goes up (enabled) or down (disabled). Most Linux have two directories to control this: /etc/sysconfig/network-scripts/ifup.d /etc/sysconfig/network-scripts/ifdown.d These work much like /etc/rc.d/*. Any scripts (or symbol links to scripts) get executed when a network interface goes up or down. So to have Guidedog run we can add some links. First make sure that a file exits at /etc/rc.guidedog . Run the command (as root): echo "#!/bin/sh" > /etc/rc.guidedog Now create some links in the ifup.d and ifdown.d directories: /bin/ln -s /etc/rc.guidedog /etc/sysconfig/network-scripts/ifup.d/51guidedog /bin/ln -s /etc/rc.guidedog /etc/sysconfig/network-scripts/ifdown.d/51guidedog When a network interface goes up/down the Guidedog script should run. You can check you boot message logs and look for a message from Guidedog. Needless to say, but if you can use a prepackaged Guidedog for your Linux distribution then do so. good luck, Simon Edwards Antonio Cardoso Martins guidedog-1.2.0/aboutdialog.cpp000066400000000000000000000031341246321372200163020ustar00rootroot00000000000000/*************************************************************************** aboutdialog.cpp - description ------------------- begin : Dec 2014 copyright : (C) 2001 by Simon Edwards email : simon@simonzone.com ***************************************************************************/ /*************************************************************************** Converted to a pure Qt5 application begin : December 2014 by : Antonio Martins email : digiplan.pt@gmail.com ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include "aboutdialog.h" #include "ui_aboutdialog.h" AboutDialog::AboutDialog(QWidget *parent) : QDialog(parent), ui(new Ui::AboutDialog) { ui->setupUi(this); } AboutDialog::~AboutDialog() { delete ui; } void AboutDialog::on_closeButton_clicked() { close(); } guidedog-1.2.0/aboutdialog.h000066400000000000000000000032251246321372200157500ustar00rootroot00000000000000/*************************************************************************** aboutdialog.h - description ------------------- begin : Dec 2014 copyright : (C) 2001 by Simon Edwards email : simon@simonzone.com ***************************************************************************/ /*************************************************************************** Converted to a pure Qt5 application begin : December 2014 by : Antonio Martins email : digiplan.pt@gmail.com ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef ABOUTDIALOG_H #define ABOUTDIALOG_H #include namespace Ui { class AboutDialog; } class AboutDialog : public QDialog { Q_OBJECT public: explicit AboutDialog(QWidget *parent = 0); ~AboutDialog(); private slots: void on_closeButton_clicked(); private: Ui::AboutDialog *ui; }; #endif // ABOUTDIALOG_H guidedog-1.2.0/aboutdialog.ui000066400000000000000000001304321246321372200161370ustar00rootroot00000000000000 AboutDialog 0 0 513 379 0 0 513 379 About Guidedog :/images/hi48-app-guidedog.png:/images/hi48-app-guidedog.png 0 0 :/images/hi48-app-guidedog.png Qt::Horizontal 40 20 0 0 75 true Guidedog 1.2.0 (Using Qt5) 0 0 0 &About <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } </style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;"> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Advanced networking utility</p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Utility for easily configureing advanced networking features</p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">(c) 2001-2008, Simon Edwards</p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://www.simonzone.com/software/guidedog"><span style=" text-decoration: underline; color:#0000ff;">http://www.simonzone.com/software/guidedog</span></a></p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">(C) 2014-2015, Antonio Cardoso Martins</p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://www.simonzone.com/software/guidedog"><span style=" text-decoration: underline; color:#0000ff;">https://github.com/antocm/guidedog/wiki</span></a></p></body></html> true true Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse A&uthors <html><head/><body><p>Please use <a href="https://github.com/antocm/guidedog/issues"><span style=" text-decoration: underline; color:#0000ff;">https://github.com/antocm/guidedog/issues</span></a> to report bugs</p><p><br/></p><p>Simon Edwards <a href="mailto:simon@simonzone.com"><span style=" text-decoration: underline; color:#0000ff;">simon@simonzone.com</span></a></p><p>Antonio Cardoso Martins <a href="mailto:digiplan.pt@gmail.com"><span style=" text-decoration: underline; color:#0000ff;">digiplan.pt@gmail.com</span></a></p></body></html> true true &License Agreement 0 0 Qt::ScrollBarAsNeeded Qt::ScrollBarAsNeeded <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><title>GNU General Public License v2.0 - GNU Project - Free Software Foundation (FSF)</title><style type="text/css"> p, li { white-space: pre-wrap; } </style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;"> <p style=" margin-top:14px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a name="SEC1"></a><span style=" font-size:large; font-weight:600;">G</span><span style=" font-size:large; font-weight:600;">NU GENERAL PUBLIC LICENSE</span></p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Version 2, June 1991 </p> <p style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New,courier';">Copyright (C) 1989, 1991 Free Software Foundation, Inc. </span></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New,courier';">51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA</span></p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New,courier';"><br /></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New,courier';">Everyone is permitted to copy and distribute verbatim copies</span></p> <p style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New,courier';">of this license document, but changing it is not allowed. </span></p> <p style=" margin-top:14px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a name="preamble"></a><span style=" font-size:large; font-weight:600;">P</span><span style=" font-size:large; font-weight:600;">reamble</span> </p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. </p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. </p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. </p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. </p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. </p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. </p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. </p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">The precise terms and conditions for copying, distribution and modification follow. </p> <p style=" margin-top:14px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a name="terms"></a><span style=" font-size:large; font-weight:600;">T</span><span style=" font-size:large; font-weight:600;">ERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION</span> </p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">0.</span> This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The &quot;Program&quot;, below, refers to any such program or work, and a &quot;work based on the Program&quot; means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term &quot;modification&quot;.) Each licensee is addressed as &quot;you&quot;. </p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. </p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">1.</span> You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. </p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. </p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">2.</span> You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: </p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:30px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">a)</span> You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. </p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:30px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">b)</span> You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. </p> <p style=" margin-top:0px; margin-bottom:8px; margin-left:30px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">c)</span> If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) </p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. </p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. </p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. </p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">3.</span> You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: </p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:30px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">a)</span> Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, </p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:30px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">b)</span> Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, </p> <p style=" margin-top:0px; margin-bottom:8px; margin-left:30px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">c)</span> Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) </p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. </p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. </p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">4.</span> You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. </p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">5.</span> You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. </p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">6.</span> Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. </p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">7.</span> If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. </p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. </p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. </p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. </p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">8.</span> If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. </p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">9.</span> The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. </p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and &quot;any later version&quot;, you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. </p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">10.</span> If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. </p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">NO WARRANTY</span> </p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">11.</span> BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM &quot;AS IS&quot; WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. </p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">12.</span> IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. </p> <p style=" margin-top:14px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:large; font-weight:600;">END OF TERMS AND CONDITIONS</span> </p> <p style=" margin-top:14px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a name="howto"></a><span style=" font-size:large; font-weight:600;">H</span><span style=" font-size:large; font-weight:600;">ow to Apply These Terms to Your New Programs</span> </p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. </p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the &quot;copyright&quot; line and a pointer to where the full notice is found. </p> <p style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New,courier'; font-style:italic;">one line to give the program's name and an idea of what it does.</span></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New,courier';">Copyright (C) </span><span style=" font-family:'Courier New,courier'; font-style:italic;">yyyy</span><span style=" font-family:'Courier New,courier';"> </span><span style=" font-family:'Courier New,courier'; font-style:italic;">name of author</span></p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New,courier'; font-style:italic;"><br /></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New,courier';">This program is free software; you can redistribute it and/or</span></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New,courier';">modify it under the terms of the GNU General Public License</span></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New,courier';">as published by the Free Software Foundation; either version 2</span></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New,courier';">of the License, or (at your option) any later version.</span></p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New,courier';"><br /></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New,courier';">This program is distributed in the hope that it will be useful,</span></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New,courier';">but WITHOUT ANY WARRANTY; without even the implied warranty of</span></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New,courier';">MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New,courier';">GNU General Public License for more details.</span></p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New,courier';"><br /></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New,courier';">You should have received a copy of the GNU General Public License</span></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New,courier';">along with this program; if not, write to the Free Software</span></p> <p style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New,courier';">Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. </span></p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Also add information on how to contact you by electronic and paper mail. </p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">If the program is interactive, make it output a short notice like this when it starts in an interactive mode: </p> <p style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New,courier';">Gnomovision version 69, Copyright (C) </span><span style=" font-family:'Courier New,courier'; font-style:italic;">year</span><span style=" font-family:'Courier New,courier';"> </span><span style=" font-family:'Courier New,courier'; font-style:italic;">name of author</span></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New,courier';">Gnomovision comes with ABSOLUTELY NO WARRANTY; for details</span></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New,courier';">type `show w'. This is free software, and you are welcome</span></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New,courier';">to redistribute it under certain conditions; type `show c' </span></p> <p style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New,courier';">for details. </span></p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">The hypothetical commands <span style=" font-family:'Courier New,courier';">`show w'</span> and <span style=" font-family:'Courier New,courier';">`show c'</span> should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than <span style=" font-family:'Courier New,courier';">`show w'</span> and <span style=" font-family:'Courier New,courier';">`show c'</span>; they could even be mouse-clicks or menu items--whatever suits your program. </p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">You should also get your employer (if you work as a programmer) or your school, if any, to sign a &quot;copyright disclaimer&quot; for the program, if necessary. Here is a sample; alter the names: </p> <p style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New,courier';">Yoyodyne, Inc., hereby disclaims all copyright</span></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New,courier';">interest in the program `Gnomovision'</span></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New,courier';">(which makes passes at compilers) written </span></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New,courier';">by James Hacker.</span></p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Courier New,courier';"><br /></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New,courier'; font-style:italic;">signature of Ty Coon</span><span style=" font-family:'Courier New,courier';">, 1 April 1989</span></p> <p style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Courier New,courier';">Ty Coon, President of Vice </span></p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the <a href="http://www.gnu.org/licenses/lgpl.html"><span style=" text-decoration: underline; color:#0000ff;">GNU Lesser General Public License</span></a> instead of this License. </p></body></html> true Qt::Horizontal 198 20 &Close guidedog-1.2.0/commandrunner.cpp000066400000000000000000000120371246321372200166620ustar00rootroot00000000000000/*************************************************************************** commandrunner.cpp - description ------------------- begin : Sat Jul 14 2001 copyright : (C) 2001 by Simon Edwards email : simon@simonzone.com ***************************************************************************/ /*************************************************************************** Converted to a pure Qt5 application begin : December 2014 by : Antonio Martins email : digiplan.pt@gmail.com ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include "commandrunner.h" #include #include /////////////////////////////////////////////////////////////////////////// CommandRunner::CommandRunner(QWidget *parent) : QDialog(parent) { QVBoxLayout *verticalLayoutMain; QVBoxLayout *verticalLayout; QHBoxLayout *horizontalLayout; QSpacerItem *horizontalSpacer; running = false; verticalLayoutMain = new QVBoxLayout(this); verticalLayoutMain->setSpacing(6); verticalLayoutMain->setContentsMargins(11, 11, 11, 11); verticalLayout = new QVBoxLayout(); verticalLayout->setSpacing(6); horizontalLayout = new QHBoxLayout(); horizontalLayout->setSpacing(6); labelIcon = new QLabel(this); QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); sizePolicy.setHorizontalStretch(0); sizePolicy.setVerticalStretch(0); sizePolicy.setHeightForWidth(labelIcon->sizePolicy().hasHeightForWidth()); labelIcon->setSizePolicy(sizePolicy); labelIcon->setTextFormat(Qt::AutoText); labelIcon->setPixmap(QPixmap(QString::fromUtf8(":/images/laserwarn.png"))); labelIcon->setScaledContents(false); labelIcon->setMargin(0); horizontalLayout->addWidget(labelIcon); headinglabel = new QLabel(this); horizontalLayout->addWidget(headinglabel); horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); horizontalLayout->addItem(horizontalSpacer); verticalLayout->addLayout(horizontalLayout); outputview = new QTextEdit(this); outputview->setReadOnly(true); verticalLayout->addWidget(outputview); okbutton = new QPushButton(tr("Ok"), parent); verticalLayout->addWidget(okbutton); verticalLayoutMain->addLayout(verticalLayout); connect(okbutton, SIGNAL(clicked()), this, SLOT(slotOkClicked())); kid = new QProcess(); connect(kid, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(slotKidExited(int, QProcess::ExitStatus))); connect(kid, SIGNAL(readyReadStandardOutput()), this, SLOT(slotReceivedStdout())); connect(kid, SIGNAL(readyReadStandardError()), this, SLOT(slotReceivedStderr())); } /////////////////////////////////////////////////////////////////////////// CommandRunner::~CommandRunner() { delete kid; } /////////////////////////////////////////////////////////////////////////// void CommandRunner::setHeading(const QString &heading) { headinglabel->setText(heading); } /////////////////////////////////////////////////////////////////////////// void CommandRunner::run(QString cmd) { command = cmd; output.truncate(0); outputview->setText(output); running = true; okbutton->setEnabled(false); // Start a BASH shell kid->start("/bin/sh", QStringList() << "-c" << command); exec(); } /////////////////////////////////////////////////////////////////////////// void CommandRunner::slotKidExited(int exitCode, QProcess::ExitStatus exitStatus) { if (exitStatus == QProcess::NormalExit) { qDebug("Command executed normally. Exit code is %d", exitCode); } else { qDebug("Command crashed"); } running = false; okbutton->setEnabled(true); } /////////////////////////////////////////////////////////////////////////// void CommandRunner::slotReceivedStdout() { output.append(kid->readAllStandardOutput()); outputview->setText(output); outputview->ensureCursorVisible(); } /////////////////////////////////////////////////////////////////////////// void CommandRunner::slotReceivedStderr() { output.append(kid->readAllStandardError()); outputview->setText(output); outputview->ensureCursorVisible(); } /////////////////////////////////////////////////////////////////////////// void CommandRunner::slotOkClicked() { done(0); } guidedog-1.2.0/commandrunner.h000066400000000000000000000040451246321372200163270ustar00rootroot00000000000000/*************************************************************************** commandrunner.h - description ------------------- begin : Sat Jul 14 2001 copyright : (C) 2001 by Simon Edwards email : simon@simonzone.com ***************************************************************************/ /*************************************************************************** Converted to a pure Qt5 application begin : December 2014 by : Antonio Martins email : digiplan.pt@gmail.com ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef COMMANDRUNNER_H #define COMMANDRUNNER_H #include #include #include #include /** *@author Simon Edwards */ class CommandRunner : public QDialog { Q_OBJECT public: CommandRunner(QWidget *parent = 0); ~CommandRunner(); void run(QString cmd); void setHeading(const QString &heading); private slots: void slotKidExited(int exitCode, QProcess::ExitStatus exitStatus); void slotReceivedStdout(); void slotReceivedStderr(); void slotOkClicked(); private: QPushButton *okbutton; QLabel *headinglabel; QLabel *labelIcon; QTextEdit *outputview; QProcess *kid; QString command; QString output; bool running; }; #endif guidedog-1.2.0/guidedog.8000066400000000000000000000013301246321372200151600ustar00rootroot00000000000000.\" Manpage for guidedog. .\" Contact digiplan.pt@gmail.com to correct errors or typos. .TH man 8 "27 Jan 2015" "1.2.0" "guidedog man page" .SH NAME guidedog \- NAT/masquerading/port-forwarding configuration tool .SH SYNOPSIS guidedog .SH DESCRIPTION Guidedog is an utility to easily activate and configure your machine for packet routing, Network Address Translation/IP Masquerading (NAT) and port-forwarding. .br Guidedog is expected to run with superuser privileges. If not, you can import or export configuration files, but you are not allowed to actually apply them. .SH OPTIONS The guidedog does not take any options. .SH SEE ALSO iptables(8) .SH BUGS No known bugs. .SH "SEE ALSO" https://github.com/antocm/guidedog/wiki guidedog-1.2.0/guidedog.cpp000066400000000000000000001420101246321372200155740ustar00rootroot00000000000000/*************************************************************************** guidedog.cpp - description ------------------- begin : Thu Sep 27 22:23:16 CEST 2001 copyright : (C) 2001 by Simon Edwards email : simon@simonzone.com ***************************************************************************/ /*************************************************************************** Converted to a pure Qt5 application begin : December 2014 by : Antonio Martins email : digiplan.pt@gmail.com ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include "guidedog.h" #include "ui_guidedogwindow.h" #include "commandrunner.h" #include "guidedogdoc.h" #include "aboutdialog.h" #include #include #include #include #include #include /////////////////////////////////////////////////////////////////////////// /// - Class AddressValidator /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// AddressValidator::AddressValidator(QWidget *parent) : QValidator(parent) { } /////////////////////////////////////////////////////////////////////////// AddressValidator::~AddressValidator() { } /////////////////////////////////////////////////////////////////////////// QValidator::State AddressValidator::validate(QString &input, int & pos) const { Q_UNUSED(pos); QRegExp sanity("^[0-9a-zA-Z./-]*$"); QRegExp domainnametest("^([a-zA-Z][a-zA-Z0-9-]*\\.)+[a-zA-Z][a-zA-Z0-9-]*$"); QRegExp iptest("^([0-9]+)\\.([0-9]+)\\.([0-9]+)\\.([0-9]+)$"); QRegExp ipmaskedtest("^([0-9]+)\\.([0-9]+)\\.([0-9]+)\\.([0-9]+)/([0-9]+)$"); QRegExp ipmasked2test("^([0-9]+)\\.([0-9]+)\\.([0-9]+)\\.([0-9]+)/([0-9]+)\\.([0-9]+)\\.([0-9]+)\\.([0-9]+)$"); long ipbyte; bool ok; if (input.isNull()) { return Intermediate; } // Smoke text if (!sanity.exactMatch(input)) { return Invalid; } if (input.length() == 0) { return Intermediate; } // Test against the domainname regexp. if (domainnametest.exactMatch(input)) { return Acceptable; } // Ok, now lets try the IP address regexp. if (iptest.exactMatch(input)) { ipbyte = iptest.cap(1).toLong(&ok); if (ipbyte < 0 || ipbyte > 255) { return Intermediate; } ipbyte = iptest.cap(2).toLong(&ok); if (ipbyte < 0 || ipbyte > 255) { return Intermediate; } ipbyte = iptest.cap(3).toLong(&ok); if (ipbyte < 0 || ipbyte > 255) { return Intermediate; } ipbyte = iptest.cap(4).toLong(&ok); if (ipbyte < 0 || ipbyte > 255) { return Intermediate; } return Acceptable; } // Ok, now lets try the IP address regexp. if (ipmaskedtest.exactMatch(input)) { ipbyte = ipmaskedtest.cap(1).toLong(&ok); if (ipbyte < 0 || ipbyte > 255) { return Intermediate; } ipbyte = ipmaskedtest.cap(2).toLong(&ok); if (ipbyte < 0 || ipbyte > 255) { return Intermediate; } ipbyte = ipmaskedtest.cap(3).toLong(&ok); if (ipbyte < 0 || ipbyte > 255) { return Intermediate; } ipbyte = ipmaskedtest.cap(4).toLong(&ok); if (ipbyte < 0 || ipbyte > 255) { return Intermediate; } ipbyte = ipmaskedtest.cap(5).toLong(&ok); if (ipbyte < 0 || ipbyte > 32) { return Intermediate; } return Acceptable; } if (ipmasked2test.exactMatch(input)) { ipbyte = ipmasked2test.cap(1).toLong(&ok); if (ipbyte < 0 || ipbyte > 255) { return Intermediate; } ipbyte = ipmasked2test.cap(2).toLong(&ok); if (ipbyte < 0 || ipbyte > 255) { return Intermediate; } ipbyte = ipmasked2test.cap(3).toLong(&ok); if (ipbyte < 0 || ipbyte > 255) { return Intermediate; } ipbyte = ipmasked2test.cap(4).toLong(&ok); if (ipbyte < 0 || ipbyte > 255) { return Intermediate; } ipbyte = ipmasked2test.cap(5).toLong(&ok); if (ipbyte < 0 || ipbyte > 255) { return Intermediate; } ipbyte = ipmasked2test.cap(6).toLong(&ok); if (ipbyte < 0 || ipbyte > 255) { return Intermediate; } ipbyte = ipmasked2test.cap(7).toLong(&ok); if (ipbyte < 0 || ipbyte > 255) { return Intermediate; } ipbyte = ipmasked2test.cap(8).toLong(&ok); if (ipbyte < 0 || ipbyte > 255) { return Intermediate; } return Acceptable; } return Intermediate; } /////////////////////////////////////////////////////////////////////////// void AddressValidator::fixup(QString &input) const { QString clean, tmp, mask; int i, slashcount; QChar c; long ipbyte; QRegExp snarfnumber("^([0-9]+)"); int l, pos; bool ok; // This is real DWIM (Do What I Mean) code. // Somehow it is meant to take what the user entered and work out // what they meant and then correct the entered string. // It's just a bunch of guesses, hunches and heristics. if (input.isNull()) { // Just in case. input = "0.0.0.0"; return; } // Filter out any bad characters. clean = ""; slashcount = 0; for (i = 0; i < input.length(); i++) { c = input.at(i); if (c == '/') { if (slashcount == 0) { clean.append('/'); slashcount++; } } else if (( c>= '0' && c<= '9') || c == '.' || c == '-' || (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')) { clean.append(c); } } clean.replace(QRegExp("^\\.*"), QString("")); // No dots at the start please. clean.replace(QRegExp("\\.*$"), QString("")); // No dots at the end please. // Remove double dots. do { l = clean.length(); clean.replace(QRegExp("\\.\\."), QString(".")); } while (l != clean.length()); // Do we still have a string? if (clean.length() == 0) { input = "0.0.0.0"; // This should not match much. return; } // Look at the first character and take a guess as to // what kind of value the user attempted to enter. if (clean.at(0).isDigit()) { // Ok, we expect some kind of IP address maybe with a netmask. clean.replace(QRegExp("[A-Za-z-]"), QString("")); // Kill any funny chars. clean.replace(QRegExp("^\\.*"), QString("")); // No dots at the start please. clean.replace(QRegExp("\\.*$"), QString("")); // No dots at the end please. // Remove double dots. do { l = clean.length(); clean.replace(QRegExp("\\.\\."), QString(".")); } while (l != clean.length()); pos = clean.indexOf('/'); if (pos != -1) { mask = clean.right(clean.length() - pos - 1); clean = clean.left(pos); } i = 0; tmp = ""; while (snarfnumber.exactMatch(clean) && i != 4) { ipbyte = snarfnumber.cap(1).toLong(&ok); if (ipbyte > 255) { ipbyte = 255; } i++; tmp.append(QString::number(ipbyte)); tmp.append("."); clean = clean.right(clean.length() - snarfnumber.cap(1).length()); clean.replace(QRegExp("^[^0-9]*"), QString("")); } for (;i < 4; i++) { tmp.append("0."); } tmp.replace(QRegExp("\\.$"), QString("")); if (mask.length() != 0) { // We still have not consumed all the input. // There must be some kind of netmask left. if (mask.contains('.') == 0) { // It must be a single number netmask. tmp.append("/"); ipbyte = mask.toLong(); if (ipbyte > 32) { ipbyte = 32; } tmp.append(QString::number(ipbyte)); } else { // Expecting a dotted quad netmask. tmp.append("/"); i = 0; while (snarfnumber.exactMatch(mask) && i != 4) { ipbyte = snarfnumber.cap(1).toLong(&ok); if (ipbyte > 255) { ipbyte = 255; } i++; tmp.append(QString::number(ipbyte)); tmp.append("."); mask = mask.right(mask.length() - snarfnumber.cap(1).length()); mask.replace(QRegExp("^[^0-9]*"), QString("")); } for (;i < 4; i++) { tmp.append("0."); } tmp.replace(QRegExp("\\.$"), QString("")); } } clean = tmp; } pos = 0; if (validate(clean, pos) != Acceptable) { input ="0.0.0.0"; } else { input = clean; } return; } /////////////////////////////////////////////////////////////////////////// /// - Class IPValidator /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// IPValidator::IPValidator(QWidget *parent) : QValidator(parent) { } /////////////////////////////////////////////////////////////////////////// IPValidator::~IPValidator() { } /////////////////////////////////////////////////////////////////////////// QValidator::State IPValidator::validate(QString &input, int & pos) const { Q_UNUSED(pos); QRegExp sanity("^[0-9./]*$"); QRegExp iptest("^([0-9]+)\\.([0-9]+)\\.([0-9]+)\\.([0-9]+)$"); QRegExp ipmaskedtest("^([0-9]+)\\.([0-9]+)\\.([0-9]+)\\.([0-9]+)/([0-9]+)$"); QRegExp ipmasked2test("^([0-9]+)\\.([0-9]+)\\.([0-9]+)\\.([0-9]+)/([0-9]+)\\.([0-9]+)\\.([0-9]+)\\.([0-9]+)$"); long ipbyte; bool ok; if (input.isNull()) { return Intermediate; } // Smoke text if (!sanity.exactMatch(input)) { return Invalid; } if (input.isEmpty()) { return Intermediate; } // Ok, now lets try the IP address regexp. if (iptest.exactMatch(input)) { ipbyte = iptest.cap(1).toLong(&ok); if (ipbyte < 0 || ipbyte > 255) { return Intermediate; } ipbyte = iptest.cap(2).toLong(&ok); if (ipbyte < 0 || ipbyte > 255) { return Intermediate; } ipbyte = iptest.cap(3).toLong(&ok); if (ipbyte < 0 || ipbyte > 255) { return Intermediate; } ipbyte = iptest.cap(4).toLong(&ok); if (ipbyte < 0 || ipbyte > 255) { return Intermediate; } return Acceptable; } // Ok, now lets try the IP address regexp. if (ipmaskedtest.exactMatch(input)) { ipbyte = ipmaskedtest.cap(1).toLong(&ok); if (ipbyte < 0 || ipbyte > 255) { return Intermediate; } ipbyte = ipmaskedtest.cap(2).toLong(&ok); if (ipbyte < 0 || ipbyte > 255) { return Intermediate; } ipbyte = ipmaskedtest.cap(3).toLong(&ok); if (ipbyte < 0 || ipbyte > 255) { return Intermediate; } ipbyte = ipmaskedtest.cap(4).toLong(&ok); if (ipbyte < 0 || ipbyte > 255) { return Intermediate; } ipbyte = ipmaskedtest.cap(5).toLong(&ok); if (ipbyte < 0 || ipbyte > 32) { return Intermediate; } return Acceptable; } if (ipmasked2test.exactMatch(input)) { ipbyte = ipmasked2test.cap(1).toLong(&ok);; if (ipbyte < 0 || ipbyte > 255) { return Intermediate; } ipbyte = ipmasked2test.cap(2).toLong(&ok); if (ipbyte < 0 || ipbyte > 255) { return Intermediate; } ipbyte = ipmasked2test.cap(3).toLong(&ok); if (ipbyte < 0 || ipbyte > 255) { return Intermediate; } ipbyte = ipmasked2test.cap(4).toLong(&ok); if (ipbyte < 0 || ipbyte > 255) { return Intermediate; } ipbyte = ipmasked2test.cap(5).toLong(&ok); if (ipbyte < 0 || ipbyte > 255) { return Intermediate; } ipbyte = ipmasked2test.cap(6).toLong(&ok); if (ipbyte < 0 || ipbyte > 255) { return Intermediate; } ipbyte = ipmasked2test.cap(7).toLong(&ok); if (ipbyte < 0 || ipbyte > 255) { return Intermediate; } ipbyte = ipmasked2test.cap(8).toLong(&ok); if (ipbyte < 0 || ipbyte > 255) { return Intermediate; } return Acceptable; } return Intermediate; } /////////////////////////////////////////////////////////////////////////// void IPValidator::fixup(QString &input) const { QString clean; QString tmp; QString mask; int i; int slashcount; QChar c; long ipbyte; QRegExp snarfnumber("^([0-9]+)"); int l; int pos; bool ok; // This is real DWIM (Do What I Mean) code. // Somehow it is meant to take what the user entered and work out // what they meant and then correct the entered string. // It's just a bunch of guesses, hunches and heristics. if (input.isNull()) { // Just in case. input = "0.0.0.0"; return; } // Filter out any bad characters. clean = ""; slashcount = 0; for (i = 0; i < input.length(); i++) { c = input.at(i); if (c == '/') { if (slashcount == 0) { clean.append('/'); slashcount++; } } else if ((c >= '0' && c <= '9') || c == '.') { clean.append(c); } } clean.replace(QRegExp("^\\.*"), QString("")); // No dots at the start please. clean.replace(QRegExp("\\.*$"), QString("")); // No dots at the end please. // Remove double dots. do { l = clean.length(); clean.replace(QRegExp("\\.\\."), QString(".")); } while (l != clean.length()); // Do we still have a string? if (clean.length() == 0) { input = "0.0.0.0"; // This should not match much. return; } // Look at the first character and take a guess as to // what kind of value the user attempted to enter. if (clean.at(0).isDigit()) { // Ok, we expect some kind of IP address maybe with a netmask. clean.replace(QRegExp("^\\.*"), QString("")); // No dots at the start please. clean.replace(QRegExp("\\.*$"), QString("")); // No dots at the end please. // Remove double dots. do { l = clean.length(); clean.replace(QRegExp("\\.\\."), QString(".")); } while (l != clean.length()); pos = clean.indexOf('/'); if (pos != -1) { mask = clean.right(clean.length() - pos - 1); clean = clean.left(pos); } i = 0; tmp = ""; while (snarfnumber.exactMatch(clean) && i != 4) { ipbyte = snarfnumber.cap(1).toLong(&ok); if (ipbyte > 255) { ipbyte = 255; } i++; tmp.append(QString::number(ipbyte)); tmp.append("."); clean = clean.right(clean.length() - snarfnumber.cap(1).length()); clean.replace(QRegExp("^[^0-9]*"), QString("")); } for (;i < 4; i++) { tmp.append("0."); } tmp.replace(QRegExp("\\.$"), QString("")); if (mask.length() != 0) { // We still have not consumed all the input. // There must be some kind of netmask left. if (mask.contains('.') == 0) { // It must be a single number netmask. tmp.append("/"); ipbyte = mask.toLong(); if (ipbyte > 32) { ipbyte = 32; } tmp.append(QString::number(ipbyte)); } else { // Expecting a dotted quad netmask. tmp.append("/"); i = 0; while (snarfnumber.exactMatch(mask) && i != 4) { ipbyte = snarfnumber.cap(1).toLong(&ok); if (ipbyte > 255) { ipbyte = 255; } i++; tmp.append(QString::number(ipbyte)); tmp.append("."); mask = mask.right(mask.length() - snarfnumber.cap(1).length()); mask.replace(QRegExp("^[^0-9]*"), QString("")); } for (;i < 4; i++) { tmp.append("0."); } tmp.replace(QRegExp("\\.$"), QString("")); } } clean = tmp; } pos = 0; if (validate(clean, pos) != Acceptable) { input ="0.0.0.0"; } else { input = clean; } return; } /////////////////////////////////////////////////////////////////////////// /// - Class GuideDogApp /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// GuideDogApp::GuideDogApp(QWidget *parent) : QDialog(parent), ui(new Ui::GuideDogApp) { setWindowTitle("Guidedog"); doc = 0; updatinggui = false; ui->setupUi(this); } /////////////////////////////////////////////////////////////////////////// GuideDogApp::~GuideDogApp() { delete doc; delete ui; } /////////////////////////////////////////////////////////////////////////// bool GuideDogApp::initialize(bool god) { waspreviousconfiguration = false; systemconfigmodified = false; // If not running as root, only import export features available superusermode = god; if (!superusermode) { ui->okButton->setEnabled(false); ui->applyButton->setEnabled(false); } doc = new GuidedogDoc(); // All the widgets are in the ui class // Routing page connect(ui->routingcheckbox, SIGNAL(toggled(bool)), this, SLOT(slotRouting(bool))); connect(ui->masqueradecheckbox, SIGNAL(toggled(bool)), this, SLOT(slotMasquerade(bool))); connect(ui->masqueradeftpcheckbox, SIGNAL(toggled(bool)), this, SLOT(slotMasqueradeFTP(bool))); connect(ui->masqueradeirccheckbox, SIGNAL(toggled(bool)), this, SLOT(slotMasqueradeIRC(bool))); connect(ui->nomasqlistbox, SIGNAL(itemClicked(QListWidgetItem *)), this, SLOT(slotNoMasqueradeListBox(QListWidgetItem *))); connect(ui->newnomasqbutton, SIGNAL(clicked()), this, SLOT(slotNewAddressButton())); connect(ui->deleteenomasqbutton, SIGNAL(clicked()), this, SLOT(slotDeleteAddressButton())); addressvalidator = new AddressValidator(ui->nomasqlineedit); ui->nomasqlineedit->setValidator(addressvalidator); connect(ui->nomasqlineedit, SIGNAL(textChanged(const QString &)), this, SLOT(slotAddressLineEdit(const QString &))); connect(ui->nomasqlineedit, SIGNAL(returnPressed()), this, SLOT(slotAddressLineEditReturn())); // Forwarding page connect(ui->forwardlistbox, SIGNAL(itemClicked(QListWidgetItem *)), this, SLOT(slotForwardListBox(QListWidgetItem *))); connect(ui->newforwardbutton, SIGNAL(clicked()), this, SLOT(slotNewForwardButton())); connect(ui->deleteforwardbutton, SIGNAL(clicked()), this, SLOT(slotDeleteForwardButton())); // Original Destination box connect(ui->portprotocolcombobox, SIGNAL(activated(int)), this, SLOT(slotPortProtocolComboBox(int))); connect(ui->originalportspinbox, SIGNAL(valueChanged(int)), this, SLOT(slotOriginalPortSpinBox(int))); // ( ) This machine connect(ui->originalthismachineradio, SIGNAL(toggled(bool)), this, SLOT(slotOriginalMachineRadio())); // ( ) Specify: connect(ui->originalspecifyradio, SIGNAL(toggled(bool)), this, SLOT(slotOriginalSpecifyRadio())); connect(ui->originalspecifylineedit, SIGNAL(textChanged(const QString &)), this, SLOT(slotOriginalSpecifyLineEdit(const QString &))); originalspecifyaddressvalidator = new IPValidator(ui->originalspecifylineedit); ui->originalspecifylineedit->setValidator(originalspecifyaddressvalidator); // New Destination connect(ui->newportspinbox, SIGNAL(valueChanged(int)), this, SLOT(slotNewPortSpinBox(int))); // ( ) This machine connect(ui->newthismachineradio, SIGNAL(toggled(bool)), this, SLOT(slotNewMachineRadio())); // ( ) Specify: connect(ui->newspecifyradio, SIGNAL(toggled(bool)), this, SLOT(slotNewSpecifyRadio())); connect(ui->newspecifylineedit, SIGNAL(textChanged(const QString &)), this, SLOT(slotNewSpecifyLineEdit(const QString &))); newspecifyaddressvalidator = new IPValidator(ui->newspecifylineedit); ui->newspecifylineedit->setValidator(newspecifyaddressvalidator); // Comment line edit connect(ui->commentlineedit, SIGNAL(textChanged(const QString &)), this, SLOT(slotCommentLineEdit(const QString &))); // Advanced Page connect(ui->disablecheckbox, SIGNAL(toggled(bool)), this, SLOT(slotDisableGuidedog(bool))); // Import/Export connect(ui->descriptionedit, SIGNAL(textChanged()), this, SLOT(slotDescriptionChanged())); connect(ui->importbutton, SIGNAL(clicked()), this, SLOT(slotImportButton())); connect(ui->exportbutton, SIGNAL(clicked()), this, SLOT(slotExportButton())); // Main buttons (Help, About, OK, Apply, Cancel) connect(ui->helpButton, SIGNAL(clicked()), this, SLOT(slotHelp())); connect(ui->aboutButton, SIGNAL(clicked()), this, SLOT(slotAbout())); connect(ui->applyButton, SIGNAL(clicked()), this, SLOT(slotApply())); connect(ui->okButton, SIGNAL(clicked()), this, SLOT(slotOk())); connect(ui->cancelButton, SIGNAL(clicked()), this, SLOT(slotCancel())); readOptions(); openDefault(); updatinggui = true; syncGUIFromDoc(); updatinggui = false; return true; } /////////////////////////////////////////////////////////////////////////// void GuideDogApp::saveOptions() { QSettings config("Guidedog", "Guidedog"); config.setValue("General/Geometry", size()); config.setValue("General/CommandrunnerGeometry", commandrunnersize); config.sync(); } /////////////////////////////////////////////////////////////////////////// void GuideDogApp::readOptions() { QSettings config("Guidedog", "Guidedog"); QSize size = config.value("General/Geometry").value(); if (!size.isEmpty()) { resize(size); } commandrunnersize = config.value("General/CommandrunnerGeometry").value(); if (commandrunnersize.isEmpty()) { commandrunnersize.setWidth(400); commandrunnersize.setHeight(300); } } /////////////////////////////////////////////////////////////////////////// void GuideDogApp::syncGUIFromDoc() { int i; ui->routingcheckbox->setChecked(doc->isRouting()); ui->masqueradecheckbox->setChecked(doc->isMasquerade()); ui->masqueradeftpcheckbox->setChecked(doc->isMasqueradeFTP()); ui->masqueradeirccheckbox->setChecked(doc->isMasqueradeIRC()); ui->descriptionedit->setText(doc->description); ui->disablecheckbox->setChecked(doc->isDisabled()); // Populate the nomasq list box. ui->nomasqlistbox->clear(); for (i = 0; i < doc->nomasqueradelist.count(); i++) { ui->nomasqlistbox->addItem(doc->nomasqueradelist.at(i).getAddress()); } // Select the first item. if (doc->nomasqueradelist.count() != 0) { ui->nomasqlistbox->setCurrentRow(0); ui->nomasqlineedit->setText(doc->nomasqueradelist.at(ui->nomasqlistbox->currentRow()).getAddress()); } // Populate the forward rule box. ui->forwardlistbox->clear(); for (i = 0; i < doc->forwardrulelist.count(); i++) { ui->forwardlistbox->addItem(doc->forwardrulelist.at(i).getSummary()); } // Select the first item. if (doc->forwardrulelist.count() != 0) { ui->forwardlistbox->setCurrentRow(0); if (ui->forwardlistbox->currentRow() != -1) { setForwardRule(&(doc->forwardrulelist[ui->forwardlistbox->currentRow()])); } else { setForwardRule(0); } } enabledGUIStuff(); } /////////////////////////////////////////////////////////////////////////// void GuideDogApp::setForwardRule(const GuidedogPortForwardRule *rule) { if (!rule) { ui->originalportspinbox->setValue(0); ui->portprotocolcombobox->setCurrentIndex(0); ui->originalthismachineradio->setChecked(true); ui->originalspecifyradio->setChecked(false); ui->originalspecifylineedit->setText(""); ui->newportspinbox->setValue(0); ui->newthismachineradio->setChecked(true); ui->newspecifyradio->setChecked(true); ui->newspecifylineedit->setText(""); ui->commentlineedit->setText(""); } else { ui->originalportspinbox->setValue(rule->originalport); ui->portprotocolcombobox->setCurrentIndex(rule->iptype == IPPROTO_TCP ? 0 : 1 ); ui->originalthismachineradio->setChecked(rule->specifyoriginal != true); ui->originalspecifyradio->setChecked(rule->specifyoriginal); ui->originalspecifylineedit->setText(rule->originaladdress.getAddress()); ui->newportspinbox->setValue(rule->newport); ui->newthismachineradio->setChecked(rule->specifynewaddress != true ); ui->newspecifyradio->setChecked(rule->specifynewaddress); ui->newspecifylineedit->setText(rule->newaddress.getAddress()); ui->commentlineedit->setText(rule->comment); } } /////////////////////////////////////////////////////////////////////////// void GuideDogApp::enabledGUIStuff() { bool active, gotaddys, gotrules; GuidedogPortForwardRule rule; active = !doc->isDisabled(); ui->routingcheckbox->setEnabled(active); ui->masqueradecheckbox->setEnabled(doc->isRouting() && active); ui->masqueradeftpcheckbox->setEnabled(doc->isRouting() && doc->isMasquerade() && active); ui->masqueradeirccheckbox->setEnabled(doc->isRouting() && doc->isMasquerade() && active); gotaddys = doc->nomasqueradelist.count() != 0; ui->nomasqlistbox->setEnabled(doc->isRouting() && doc->isMasquerade() && active && gotaddys); ui->nomasqlineedit->setEnabled(doc->isRouting() && doc->isMasquerade() && active && gotaddys); ui->newnomasqbutton->setEnabled(doc->isRouting() && doc->isMasquerade() && active); ui->deleteenomasqbutton->setEnabled(doc->isRouting() && doc->isMasquerade() && active && gotaddys); gotrules = doc->forwardrulelist.count() != 0; ui->forwardlistbox->setEnabled(active && gotrules); ui->newforwardbutton->setEnabled(active); ui->deleteforwardbutton->setEnabled(active && gotrules); ui->originalportspinbox->setEnabled(active && gotrules); ui->portprotocolcombobox->setEnabled(active && gotrules); ui->originalthismachineradio->setEnabled(active && gotrules); ui->originalspecifyradio->setEnabled(active && gotrules); ui->originalspecifylineedit->setEnabled(active && gotrules); ui->newportspinbox->setEnabled(active && gotrules); ui->newthismachineradio->setEnabled(active && gotrules); ui->newspecifyradio->setEnabled(active && gotrules); ui->newspecifylineedit->setEnabled(active && gotrules); ui->commentlineedit->setEnabled(active && gotrules); ui->arrow->setEnabled(active && gotrules); if (gotrules) { qDebug("Current row is now: %d", ui->forwardlistbox->currentRow()); rule = doc->forwardrulelist[ui->forwardlistbox->currentRow()]; ui->originalspecifylineedit->setEnabled(active && rule.specifyoriginal); ui->newspecifylineedit->setEnabled(active && rule.specifynewaddress); } } /////////////////////////////////////////////////////////////////////////// void GuideDogApp::slotOk() { QString errorstring; QString filename(SYSTEM_RC_GUIDEDOG); if (doc->saveScript(filename, errorstring) == false) { QMessageBox::critical(this, tr("Error - Guidedog"), QString(tr("An error occurred while writing the script to disk.\n\n" "(Detailed message: \"%1\")")).arg(errorstring)); return; } if (applyScript(true)) { saveOptions(); accept(); } } /////////////////////////////////////////////////////////////////////////// void GuideDogApp::slotCancel() { QString errorstring; QMessageBox::StandardButton reply; if (waspreviousconfiguration && systemconfigmodified) { // This is where things become complex. // Should we try to restore things to how they were before this program started? reply = QMessageBox::warning(this, tr("Warning - Guidedog"), tr("The system's routing configuration has been modified.\n\n" "Shall I restore it to the previous configuration?\n\n" "These changes may disrupt current network connections."), QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel); // "Yes, revert to the previous settings." switch(reply) { case QMessageBox::Yes: openDefault(); if (applyScript(false)) { saveOptions(); accept(); } break; // "Just leave the settings alone and piss off!!" case QMessageBox::No: saveOptions(); accept(); break; // "Forget I ever pressed the Cancel button." default: break; } } else { // Simple Cancel. saveOptions(); accept(); } } /////////////////////////////////////////////////////////////////////////// void GuideDogApp::slotApply() { applyScript(true); } /////////////////////////////////////////////////////////////////////////// void GuideDogApp::slotAbout() { AboutDialog *aboutDialog = new AboutDialog(this); aboutDialog->show(); } /////////////////////////////////////////////////////////////////////////// void GuideDogApp::slotHelp() { QDesktopServices::openUrl(QUrl("http://www.simonzone.com/software/guidedog/manual/", QUrl::TolerantMode)); } /////////////////////////////////////////////////////////////////////////// void GuideDogApp::slotRouting(bool on) { if (updatinggui) return; updatinggui = true; doc->setRouting(on); enabledGUIStuff(); updatinggui = false; } /////////////////////////////////////////////////////////////////////////// void GuideDogApp::slotMasquerade(bool on) { if (updatinggui) return; updatinggui = true; doc->setMasquerade(on); enabledGUIStuff(); updatinggui = false; } /////////////////////////////////////////////////////////////////////////// void GuideDogApp::slotMasqueradeFTP(bool on) { if (updatinggui) return; updatinggui = true; doc->setMasqueradeFTP(on); updatinggui = false; } /////////////////////////////////////////////////////////////////////////// void GuideDogApp::slotMasqueradeIRC(bool on) { if (updatinggui) return; updatinggui = true; doc->setMasqueradeIRC(on); updatinggui = false; } /////////////////////////////////////////////////////////////////////////// void GuideDogApp::slotForwardListBox(QListWidgetItem *item) { GuidedogPortForwardRule rule; if (item == 0) { return; } if (updatinggui) return; updatinggui = true; rule = doc->forwardrulelist.at(ui->forwardlistbox->currentRow()); setForwardRule(&rule); enabledGUIStuff(); updatinggui = false; } /////////////////////////////////////////////////////////////////////////// void GuideDogApp::slotDisableGuidedog(bool on) { if (updatinggui) return; updatinggui = true; doc->setDisabled(on); syncGUIFromDoc(); updatinggui = false; } /////////////////////////////////////////////////////////////////////////// void GuideDogApp::slotImportButton() { QString filename, errorstring; GuidedogDoc *tmpdoc; if (updatinggui) return; updatinggui = true; filename = QFileDialog::getOpenFileName(this, tr("Import Configuration")); if (filename.isEmpty()) { updatinggui = false; return; } tmpdoc = new GuidedogDoc(); if (tmpdoc->openScript(filename, errorstring) == false) { // Stick up a good ol' error message. QMessageBox::critical(this, tr("Error - Guidedog"), QString(tr("Guidedog was unable to read the file at %1 as being a Guidedog script.\n" "This probably means that this file in not actually a Guidedog script.\n\n" "(Detailed message \"%2\")")).arg(filename).arg(errorstring)); delete tmpdoc; updatinggui = false; return; } // That loaded ok. Re-configure the GUI. delete doc; //Switcherroo doc = tmpdoc; syncGUIFromDoc(); updatinggui = false; } /////////////////////////////////////////////////////////////////////////// void GuideDogApp::slotExportButton() { QString filename, errorstring; if (updatinggui) return; updatinggui = true; filename = QFileDialog::getSaveFileName(this, tr("Export Configuration")); if (filename.isEmpty()) { updatinggui = false; return; } if (!doc->saveScript(filename, errorstring)) { QMessageBox::critical(this, tr("Error - Guidedog"), QString(tr("An error occurred while writing the script to %1.\n\n" "(Detailed message: \"%2\")")).arg(filename).arg(errorstring)); } updatinggui = false; } /////////////////////////////////////////////////////////////////////////// void GuideDogApp::slotDescriptionChanged() { if (updatinggui) return; updatinggui = true; doc->description = ui->descriptionedit->toPlainText(); updatinggui = false; } /////////////////////////////////////////////////////////////////////////// void GuideDogApp::slotNoMasqueradeListBox(QListWidgetItem *item) { QString address; if (updatinggui) return; updatinggui = true; if (item == 0) return; address = doc->nomasqueradelist.at(ui->nomasqlistbox->currentRow()).getAddress(); ui->nomasqlineedit->setText(address); updatinggui = false; } /////////////////////////////////////////////////////////////////////////// void GuideDogApp::slotNewAddressButton() { if (updatinggui) return; updatinggui = true; IPRange *new_address = new IPRange("new.address"); doc->nomasqueradelist.append(*new_address); ui->nomasqlistbox->addItem((doc->nomasqueradelist.last()).getAddress()); ui->nomasqlineedit->setText((doc->nomasqueradelist.last()).getAddress()); ui->nomasqlistbox->setCurrentRow(ui->nomasqlistbox->count() - 1); enabledGUIStuff(); updatinggui = false; } /////////////////////////////////////////////////////////////////////////// void GuideDogApp::slotDeleteAddressButton() { int rowIndex; if (updatinggui) return; updatinggui = true; rowIndex = ui->nomasqlistbox->currentRow(); if (rowIndex >= 0) { ui->nomasqlistbox->takeItem(rowIndex); doc->nomasqueradelist.removeAt(rowIndex); if (doc->nomasqueradelist.count()) { if (rowIndex == 0) { ui->nomasqlineedit->setText(doc->nomasqueradelist.at(0).getAddress()); ui->nomasqlistbox->setCurrentItem(ui->nomasqlistbox->item(0)); } else { ui->nomasqlineedit->setText(doc->nomasqueradelist.at(rowIndex - 1).getAddress()); ui->nomasqlistbox->setCurrentItem(ui->nomasqlistbox->item(rowIndex - 1)); } } else { ui->nomasqlineedit->setText(""); ui->nomasqlistbox->setDisabled(true); ui->deleteenomasqbutton->setDisabled(true); ui->nomasqlineedit->setDisabled(true); } if (ui->nomasqlistbox->currentRow() == -1) { ui->nomasqlistbox->setCurrentItem(ui->nomasqlistbox->item(0)); } } enabledGUIStuff(); updatinggui = false; } /////////////////////////////////////////////////////////////////////////// void GuideDogApp::slotAddressLineEdit(const QString &s) { int i; if (updatinggui) return; updatinggui = true; i = ui->nomasqlistbox->currentRow(); doc->nomasqueradelist[i].setAddress(s); ui->nomasqlistbox->item(i)->setText(s); updatinggui = false; } /////////////////////////////////////////////////////////////////////////// void GuideDogApp::slotAddressLineEditReturn() { } /////////////////////////////////////////////////////////////////////////// void GuideDogApp::slotNewForwardButton() { GuidedogPortForwardRule newrule; if (updatinggui) return; updatinggui = true; //newrule = new GuidedogPortForwardRule(); doc->forwardrulelist.append(newrule); ui->forwardlistbox->addItem((doc->forwardrulelist.last()).getSummary()); setForwardRule(&newrule); ui->forwardlistbox->setCurrentRow(ui->forwardlistbox->count() - 1); enabledGUIStuff(); updatinggui = false; } /////////////////////////////////////////////////////////////////////////// void GuideDogApp::slotDeleteForwardButton() { GuidedogPortForwardRule rule; int rowIndex; if (updatinggui) return; updatinggui = true; rowIndex = ui->forwardlistbox->currentRow(); qDebug("Deleting row: %d", rowIndex); rule = doc->forwardrulelist.at(rowIndex); if (rowIndex >= 0) { ui->forwardlistbox->takeItem(rowIndex); doc->forwardrulelist.removeAt(rowIndex); if (rowIndex == 0) { ui->forwardlistbox->setCurrentRow(0); } else { ui->forwardlistbox->setCurrentRow(rowIndex - 1); } if (ui->forwardlistbox->currentRow() == -1) { setForwardRule(0); } else { setForwardRule(&doc->forwardrulelist[ui->forwardlistbox->currentRow()]); } enabledGUIStuff(); } updatinggui = false; } /////////////////////////////////////////////////////////////////////////// void GuideDogApp::slotOriginalMachineRadio() { int i; GuidedogPortForwardRule *rule; if (updatinggui) return; updatinggui = true; ui->originalthismachineradio->setChecked(true); ui->originalspecifyradio->setChecked(false); i = ui->forwardlistbox->currentRow(); rule = &(doc->forwardrulelist[i]); if (rule != 0) { rule->specifyoriginal = false; ui->forwardlistbox->item(i)->setText(rule->getSummary()); } enabledGUIStuff(); updatinggui = false; } /////////////////////////////////////////////////////////////////////////// void GuideDogApp::slotOriginalSpecifyRadio() { int i; GuidedogPortForwardRule *rule; if (updatinggui) return; updatinggui = true; ui->originalspecifyradio->setChecked(true); ui->originalthismachineradio->setChecked(false); i = ui->forwardlistbox->currentRow(); rule = &(doc->forwardrulelist[i]); if (rule != 0) { rule->specifyoriginal = true; ui->forwardlistbox->item(i)->setText(rule->getSummary()); } enabledGUIStuff(); updatinggui = false; } /////////////////////////////////////////////////////////////////////////// void GuideDogApp::slotNewMachineRadio() { int i; GuidedogPortForwardRule *rule; if (updatinggui) return; updatinggui = true; ui->newthismachineradio->setChecked(true); ui->newspecifyradio->setChecked(false); i = ui->forwardlistbox->currentRow(); rule = &(doc->forwardrulelist[i]); if (rule != 0) { rule->specifynewaddress = false; ui->forwardlistbox->item(i)->setText(rule->getSummary()); } enabledGUIStuff(); updatinggui = false; } /////////////////////////////////////////////////////////////////////////// void GuideDogApp::slotNewSpecifyRadio() { int i; GuidedogPortForwardRule *rule; if (updatinggui) return; updatinggui = true; ui->newspecifyradio->setChecked(true); ui->newthismachineradio->setChecked(false); i = ui->forwardlistbox->currentRow(); rule = &(doc->forwardrulelist[i]); if (rule != 0) { rule->specifynewaddress = true; ui->forwardlistbox->item(i)->setText(rule->getSummary()); } enabledGUIStuff(); updatinggui = false; } /////////////////////////////////////////////////////////////////////////// void GuideDogApp::slotOriginalPortSpinBox(int x) { int i; GuidedogPortForwardRule *rule; if (updatinggui) return; updatinggui = true; i = ui->forwardlistbox->currentRow(); rule = &(doc->forwardrulelist[i]); if (rule != 0) { rule->originalport = x; // Update the forward listbox ui->forwardlistbox->item(i)->setText(rule->getSummary()); } updatinggui = false; } /////////////////////////////////////////////////////////////////////////// void GuideDogApp::slotNewPortSpinBox(int x) { int i; GuidedogPortForwardRule *rule; if (updatinggui) return; updatinggui = true; i = ui->forwardlistbox->currentRow(); rule = &(doc->forwardrulelist[i]); if (rule != 0) { rule->newport = x; // Update the forward listbox ui->forwardlistbox->item(i)->setText(rule->getSummary()); } updatinggui = false; } /////////////////////////////////////////////////////////////////////////// void GuideDogApp::slotPortProtocolComboBox(int x) { int i; GuidedogPortForwardRule *rule; if (updatinggui) return; updatinggui = true; i = ui->forwardlistbox->currentRow(); rule = &(doc->forwardrulelist[i]); if (rule != 0) { rule->iptype = x == 0 ? IPPROTO_TCP : IPPROTO_UDP; // Update the forward listbox ui->forwardlistbox->item(i)->setText(rule->getSummary()); } updatinggui = false; } /////////////////////////////////////////////////////////////////////////// void GuideDogApp::slotOriginalSpecifyLineEdit(const QString &s) { int i; GuidedogPortForwardRule *rule; if (updatinggui) return; updatinggui = true; i = ui->forwardlistbox->currentRow(); rule = &(doc->forwardrulelist[i]); if (rule != 0) { rule->originaladdress.setAddress(s); // Update the forward listbox ui->forwardlistbox->item(i)->setText(rule->getSummary()); } updatinggui = false; } /////////////////////////////////////////////////////////////////////////// void GuideDogApp::slotNewSpecifyLineEdit(const QString &s) { int i; GuidedogPortForwardRule *rule; if (updatinggui) return; updatinggui = true; i = ui->forwardlistbox->currentRow(); rule = &(doc->forwardrulelist[i]); if (rule != 0) { rule->newaddress.setAddress(s); // Update the forward listbox ui->forwardlistbox->item(i)->setText(rule->getSummary()); } updatinggui = false; } /////////////////////////////////////////////////////////////////////////// void GuideDogApp::slotCommentLineEdit(const QString &s) { int i; GuidedogPortForwardRule *rule; if (updatinggui) return; updatinggui = true; i = ui->forwardlistbox->currentRow(); rule = &(doc->forwardrulelist[i]); if (rule != 0) { rule->comment = s; // Update the forward listbox ui->forwardlistbox->item(i)->setText(rule->getSummary()); } updatinggui = false; } /////////////////////////////////////////////////////////////////////////// bool GuideDogApp::applyScript(bool warnfirst) { QString finalRules; CommandRunner cr(this); if (!doc->isDisabled()) { // Normal apply if (warnfirst) { QMessageBox msgBox; msgBox.setWindowTitle(tr("Warning - Guidedog")); msgBox.setText(tr("You are about to modify the system's routing configuration.\n" "These changes may disrupt current network connections.\n\n" "Do you wish to continue?")); QAbstractButton *myContinueButton = msgBox.addButton(tr("Continue"), QMessageBox::AcceptRole); QAbstractButton *myCancelButton = msgBox.addButton(tr("Cancel"), QMessageBox::RejectRole); msgBox.setDefaultButton((QPushButton *)myContinueButton); msgBox.setIcon(QMessageBox::Warning); msgBox.exec(); if(msgBox.clickedButton() == myCancelButton) { return false; } } QTextStream mFwRules(&finalRules); if (doc->writeScript(mFwRules) == false) { return false; } // Now we run the tmp script in our super friendly window. if (!commandrunnersize.isEmpty()) { cr.resize(commandrunnersize); } cr.setWindowTitle(tr("Modify Routing Configuration")); cr.setHeading(tr("Configuring...\n\nOutput:")); cr.run(QString("export GUIDEDOG_VERBOSE=1\n" + finalRules + "\n")); systemconfigmodified = true; commandrunnersize = cr.size(); return true; } else { // If we are to actually disable the firewall because the user has set // the Disable checkbox in the advanced section, then we use a different // warning question and use a different method to reset the network stack. if (warnfirst) { QMessageBox msgBox; msgBox.setWindowTitle(tr("Warning - Guidedog")); msgBox.setText(tr("You are about to reset the system's routing configuration.\n" "These changes may also disrupt current network connections.\n\n" "Do you wish to continue?")); QAbstractButton *myContinueButton = msgBox.addButton(tr("Continue"), QMessageBox::AcceptRole); QAbstractButton *myCancelButton = msgBox.addButton(tr("Cancel"), QMessageBox::RejectRole); msgBox.setDefaultButton((QPushButton *)myContinueButton); msgBox.setIcon(QMessageBox::Warning); msgBox.exec(); if(msgBox.clickedButton() == myCancelButton) { return false; } } if (resetSystemConfiguration()) { return false; } else { systemconfigmodified = true; return true; } } return false; } /////////////////////////////////////////////////////////////////////////// bool GuideDogApp::resetSystemConfiguration() { CommandRunner cr(this); if (!commandrunnersize.isEmpty()) { cr.resize(commandrunnersize); } cr.setWindowTitle(tr("Resetting system configuration")); cr.setHeading(tr("Resetting system configuration...\n\nOutput:")); cr.run(QString( "echo \"Using iptables.\"\n" "echo \"Resetting nat table rules.\"\n" "PATH=/bin:/sbin:/usr/bin:/usr/sbin\n" "/sbin/sysctl -w net.ipv4.ip_forward=0\n" "iptables -t nat -F\n" "iptables -t nat -X\n" "iptables -t nat -P PREROUTING ACCEPT\n" "iptables -t nat -P POSTROUTING ACCEPT\n" "iptables -t nat -P OUTPUT ACCEPT\n" "echo \"Finished.\"\n")); commandrunnersize = cr.size(); return true; } /////////////////////////////////////////////////////////////////////////// void GuideDogApp::openDefault() { QString filename(SYSTEM_RC_GUIDEDOG); QString errorstring; QFileInfo fileinfo(SYSTEM_RC_GUIDEDOG); // if (!superusermode) { // return; // Sorry, if you are not root then you get no default firewall. // } if (!fileinfo.exists()) { // There doesn't appear to be a previous Guarddog firewall script. // Just warn the user about the ramifications. QMessageBox::information(this, tr("Information - Guidedog"), QString(tr("Guidedog was unable to find a Guidedog script at %1.\n" "This is probably ok, it just means that this is the first time Guidedog has been run on this system.\n" "But please be aware that the settings shown may not represent the system's current routing configuration.\n" "Your Guidedog settings will take effect once you use the 'Apply' button or exit Guidedog using 'Ok'.").arg(filename))); } else { if (doc->openScript(filename, errorstring) == false) { doc->factoryDefaults(); // We were unable to open the guarddog firewall. QMessageBox::critical(this, tr("Error - Guidedog"), QString(tr("Guidedog was unable to read the file at %1 as being a Guidedog script.\n" "Please be aware that the settings shown may not represent the system's current routing configuration.\n\n" "(Detailed message \"%2\")")).arg(filename).arg(errorstring)); } else { waspreviousconfiguration = true; } } } guidedog-1.2.0/guidedog.h000066400000000000000000000104521246321372200152450ustar00rootroot00000000000000/*************************************************************************** guidedog.h - description ------------------- begin : Thu Sep 27 22:23:16 CEST 2001 copyright : (C) 2001 by Simon Edwards email : simon@simonzone.com ***************************************************************************/ /*************************************************************************** Converted to a pure Qt5 application begin : December 2014 by : Antonio Martins email : digiplan.pt@gmail.com ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef GUIDEDOG_H #define GUIDEDOG_H #include "simelineedit.h" #include "guidedogdoc.h" #include #include #include #include #ifdef HAVE_CONFIG_H #include #endif #define SYSTEM_RC_GUIDEDOG "/etc/rc.guidedog" class AddressValidator : public QValidator { Q_OBJECT public: explicit AddressValidator(QWidget *parent = 0); ~AddressValidator(); virtual State validate(QString &input, int & pos) const; virtual void fixup(QString &input) const; }; class IPValidator : public QValidator { Q_OBJECT public: explicit IPValidator(QWidget *parent = 0); ~IPValidator(); virtual State validate(QString &input, int & pos) const; virtual void fixup(QString &input) const; }; namespace Ui { class GuideDogApp; } /** Guidedog is the base class of the project */ class GuideDogApp : public QDialog { Q_OBJECT public: explicit GuideDogApp(QWidget *parent = 0); ~GuideDogApp(); bool initialize(bool god); void openDefault(); bool applyScript(bool warnfirst); bool resetSystemConfiguration(); protected: void saveOptions(); void readOptions(); public slots: // Dialog main buttons void slotOk(); void slotApply(); void slotCancel(); void slotAbout(); void slotHelp(); // Routing void slotRouting(bool on); void slotMasquerade(bool on); void slotMasqueradeFTP(bool on); void slotMasqueradeIRC(bool on); void slotNoMasqueradeListBox(QListWidgetItem *item); void slotNewAddressButton(); void slotDeleteAddressButton(); void slotAddressLineEdit(const QString &s); void slotAddressLineEditReturn(); // Forwarding void slotForwardListBox(QListWidgetItem *item); void slotNewForwardButton(); void slotDeleteForwardButton(); // Original destination void slotOriginalPortSpinBox(int x); void slotOriginalMachineRadio(); void slotOriginalSpecifyRadio(); void slotOriginalSpecifyLineEdit(const QString &); void slotPortProtocolComboBox(int x); // New destination void slotNewMachineRadio(); void slotNewSpecifyRadio(); void slotNewSpecifyLineEdit(const QString &s); void slotNewPortSpinBox(int x); // Comment void slotCommentLineEdit(const QString &); // Import/Export void slotDisableGuidedog(bool on); void slotImportButton(); void slotExportButton(); void slotDescriptionChanged(); private: bool superusermode; bool systemconfigmodified; bool waspreviousconfiguration; GuidedogDoc *doc; bool updatinggui; void syncGUIFromDoc(); void enabledGUIStuff(); void setForwardRule(const GuidedogPortForwardRule *rule); Ui::GuideDogApp *ui; // The widgets that were previously here have been replaced by the ones in the ui AddressValidator *addressvalidator; IPValidator *originalspecifyaddressvalidator; IPValidator *newspecifyaddressvalidator; QSize commandrunnersize; }; #endif // GUIDEDOG_H guidedog-1.2.0/guidedog.pro000066400000000000000000000013121246321372200156110ustar00rootroot00000000000000#------------------------------------------------- # # Project created by QtCreator 2014-12-08T19:54:32 # #------------------------------------------------- QT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = guidedog TEMPLATE = app SOURCES += main.cpp\ guidedog.cpp \ simelineedit.cpp \ guidedogdoc.cpp \ commandrunner.cpp \ iprange.cpp \ aboutdialog.cpp HEADERS += guidedog.h \ simelineedit.h \ commandrunner.h \ iprange.h \ guidedogdoc.h \ aboutdialog.h FORMS += \ guidedogwindow.ui \ aboutdialog.ui RESOURCES += \ resources.qrc OTHER_FILES += \ AUTHORS \ COPYING \ INSTALL \ README \ ChangeLog guidedog-1.2.0/guidedogdoc.cpp000066400000000000000000000523761246321372200163010ustar00rootroot00000000000000/*************************************************************************** guidedogdoc.cpp - description ------------------- begin : Thu Sep 27 2001 copyright : (C) 2001 by Simon Edwards email : simon@simonzone.com ***************************************************************************/ /*************************************************************************** Converted to a pure Qt5 application begin : December 2014 by : Antonio Martins email : digiplan.pt@gmail.com ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include "guidedogdoc.h" #include "guidedog.h" #include #include /////////////////////////////////////////////////////////////////////////// GuidedogPortForwardRule::GuidedogPortForwardRule() { specifyoriginal = false; specifynewaddress = false; iptype = IPPROTO_TCP; originalport = 0; newport = 0; } /////////////////////////////////////////////////////////////////////////// QString GuidedogPortForwardRule::getSummary() const { QString str; if (specifyoriginal) { str += originaladdress.getAddress(); str += ":"; } if (iptype == IPPROTO_TCP) { str += "TCP "; } else { str += "UDP "; } str += QString::number(originalport); str += " -> "; if (specifynewaddress) { str += newaddress.getAddress(); str += ":"; } str += QString::number(newport); str += " "; str += comment; return str; } /////////////////////////////////////////////////////////////////////////// GuidedogDoc::GuidedogDoc() { factoryDefaults(); } /////////////////////////////////////////////////////////////////////////// GuidedogDoc::~GuidedogDoc(){ } /////////////////////////////////////////////////////////////////////////// void GuidedogDoc::setDisabled(bool on) { disabled = on; } /////////////////////////////////////////////////////////////////////////// bool GuidedogDoc::isDisabled() { return disabled; } /////////////////////////////////////////////////////////////////////////// void GuidedogDoc::setRouting(bool on) { routing = on; } /////////////////////////////////////////////////////////////////////////// bool GuidedogDoc::isRouting() { return routing; } /////////////////////////////////////////////////////////////////////////// void GuidedogDoc::setMasquerade(bool on) { masquerade = on; } /////////////////////////////////////////////////////////////////////////// bool GuidedogDoc::isMasquerade() { return masquerade; } /////////////////////////////////////////////////////////////////////////// void GuidedogDoc::setMasqueradeFTP(bool on) { masqueradeftp = on; } /////////////////////////////////////////////////////////////////////////// bool GuidedogDoc::isMasqueradeFTP() { return masqueradeftp; } /////////////////////////////////////////////////////////////////////////// void GuidedogDoc::setMasqueradeIRC(bool on) { masqueradeirc = on; } /////////////////////////////////////////////////////////////////////////// bool GuidedogDoc::isMasqueradeIRC() { return masqueradeirc; } /////////////////////////////////////////////////////////////////////////// void GuidedogDoc::factoryDefaults() { disabled = false; routing = false; masquerade = false; masqueradeftp = false; masqueradeirc = false; description = ""; } /////////////////////////////////////////////////////////////////////////// bool GuidedogDoc::writeScript(QTextStream &stream) { int c, oldc, i; GuidedogPortForwardRule *rule; //stream.setEncoding(QTextStream::Latin1); stream << "#!/bin/sh\n" "# [Guidedog]\n" "# DO NOT EDIT!\n" "# This script was generated by \"Guidedog\" by Simon Edwards and Antonio Cardoso Martins\n" "# http://www.simonzone.com/software/guidedog/ This script requires Linux\n" "# kernel above or equal than 2.4.x and iptables.\n" "#\n" "# [Description]\n"; c = 0; oldc = 0; while ((c = description.indexOf('\n', c)) >= 0) { stream << "# " << description.mid(oldc, c - oldc) << "\n"; oldc = c + 1; c++; } c = (int)description.length(); stream << "# " << description.mid(oldc, c - oldc) << "\n"; stream << "# [Config]\n" "# DISABLED="<< (disabled ? 1 : 0) << "\n" "# ROUTING="<< (routing ? 1 : 0) << "\n" "# MASQUERADE=" << (masquerade ? 1 : 0) << "\n" "# MASQUERADEFTP=" << (masqueradeftp ? 1 : 0) << "\n" "# MASQUERADEIRC=" << (masqueradeirc ? 1 : 0) << "\n"; for (i = 0; i < nomasqueradelist.count(); i++) { stream << "# NOMASQUERADEADDRESS=" << nomasqueradelist.at(i).getAddress() << "\n"; } for (i = 0; i < forwardrulelist.count(); i++) { rule = &forwardrulelist[i]; stream << "# [Forwarding]\n" "# TYPE=" << (rule->iptype == IPPROTO_TCP ? "TCP" : "UDP") << "\n" "# ORIGINALPORT=" << (rule->originalport) << "\n" "# SPECIFYORIGINALADDRESS=" << (rule->specifyoriginal ? "1" : "0") << "\n" "# ORIGINALADDRESS=" << (rule->originaladdress.getAddress()) << "\n" "# NEWPORT=" << (rule->newport) << "\n" "# SPECIFYNEWADDRESS=" << (rule->specifynewaddress) << "\n" "# NEWADDRESS=" << (rule->newaddress.getAddress()) << "\n" "# COMMENT=" << (rule->comment) << "\n"; } stream << "# [End]\n" "\n" "# Real code starts here\n" "# If you change the line below then also change the # DISABLED line above.\n"; if (disabled) { stream << "DISABLE_GUIDEDOG=1\n"; } else { stream << "DISABLE_GUIDEDOG=0\n"; } stream << "if [ $DISABLE_GUIDEDOG -eq 0 ]; then\n" "# Set the path\n" "PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/sbin\n" "if test -z $GUIDEDOG_VERBOSE; then\n" " GUIDEDOG_VERBOSE=0\n" "fi;\n" "logger -p auth.info -t guidedog Configuring routing now.\n" "[ $GUIDEDOG_VERBOSE -eq 1 ] && echo \"Resetting routing rules.\"\n" // Clear the nat table. "# Shut down routing\n" "echo 0 > /proc/sys/net/ipv4/ip_forward 2> /dev/null\n" "# iptables -t nat -P PREROUTING DROP\n" "# iptables -t nat -P POSTROUTING DROP\n" "# iptables -t nat -P OUTPUT DROP\n" "iptables -t mangle -P PREROUTING DROP\n" "iptables -t mangle -P POSTROUTING DROP\n" "# Delete any existing chains\n" "iptables -t nat -F\n" "iptables -t nat -X\n" "iptables -t mangle -F\n" "iptables -t mangle -X\n" "\n" "# Enable/disable routing\n"; if (routing) { stream << "[ $GUIDEDOG_VERBOSE -eq 1 ] && echo \"" << QObject::tr("Enabling routing.") << "\"\n"; } else { stream << "[ $GUIDEDOG_VERBOSE -eq 1 ] && echo \"" << QObject::tr("Disabling routing.") << "\"\n"; } // Code to enable/disable routing. stream << "echo " << (routing ? 1 : 0) << " > /proc/sys/net/ipv4/ip_forward 2> /dev/null\n" "\n" "[ $GUIDEDOG_VERBOSE -eq 1 ] && echo \"Loading kernel modules.\"\n" "modprobe iptable_nat\n"; if (routing && masquerade) { if (masqueradeftp) { stream << "modprobe ip_nat_ftp\n"; } if (masqueradeirc) { stream << "modprobe ip_nat_irc\n"; } } stream << "# Port forwarding/Tunnelling\n" "iptables -t nat -N gforward\n" "iptables -t nat -N ftolocal\n" "iptables -t mangle -N gforward\n" "iptables -t mangle -N ftolocal\n" "\n" "# Switch the current language for a moment\n" "GUIDEDOG_BACKUP_LANG=$LANG\n" "GUIDEDOG_BACKUP_LC_ALL=$LC_ALL\n" "LANG=US\n" "LC_ALL=US\n" "export LANG\n" "export LC_ALL\n" "# Work out our local IPs.\n" "LOCAL_IP=`ip -4 addr |grep inet | cut -d \"/\" -f 1 |cut -d \" \" -f 6`\n" "# Restore the language setting\n" "LANG=$GUIDEDOG_BACKUP_LANG\n" "LC_ALL=$GUIDEDOG_BACKUP_LC_ALL\n" "export LANG\n" "export LC_ALL\n" "for X in $LOCAL_IP ; do\n" " iptables -t nat -A gforward -d $X -j ftolocal\n" " iptables -t mangle -A gforward -d $X -j ftolocal\n" "done\n"; for (i = 0; i < forwardrulelist.count(); i++) { rule = &forwardrulelist[i]; if (rule->specifyoriginal) { stream << "# " << (rule->comment) << "\n"; if (rule->specifynewaddress) { stream << "iptables -t mangle -A gforward " "-p " << (rule->iptype == IPPROTO_TCP ? "tcp" : "udp") << " " "--dport " << (rule->originalport) << " " "-d " << (rule->originaladdress.getAddress()) << " " "-j MARK --set-mark 1\n"; } stream << "iptables -t nat -A gforward " "-p " << (rule->iptype == IPPROTO_TCP ? "tcp" : "udp") << " " "--dport " << (rule->originalport) << " " "-d " << (rule->originaladdress.getAddress()) << " "; if (rule->specifynewaddress) { stream << "-j DNAT --to-destination " << (rule->newaddress.getAddress()) << ":"; } else { // Redirecting to the local machine. stream << "-j REDIRECT --to-ports "; } stream << (rule->newport) << "\n"; } } for (i = 0; i < forwardrulelist.count(); i++) { rule = &forwardrulelist[i]; if (rule->specifyoriginal == false) { stream << "# " << (rule->comment) << "\n"; if (rule->specifynewaddress) { stream << "iptables -t mangle -A ftolocal " "-p " << (rule->iptype == IPPROTO_TCP ? "tcp" : "udp") << " " "--dport " << (rule->originalport) << " " "-j MARK --set-mark 1\n"; } stream << "iptables -t nat -A ftolocal " "-p " << (rule->iptype == IPPROTO_TCP ? "tcp" : "udp") << " " "--dport " << (rule->originalport) << " "; if (rule->specifynewaddress) { stream << "-j DNAT --to-destination " << (rule->newaddress.getAddress()) << ":"; } else { // Redirecting to the local machine. stream << "-j REDIRECT --to-ports "; } stream << (rule->newport) << "\n"; } } stream << "iptables -t nat -A PREROUTING -j gforward\n" "iptables -t nat -A OUTPUT -j gforward\n" "iptables -t mangle -A PREROUTING -j gforward\n" "# Marked packets are in the process of being port forwarded.\n" "# We also need to source Nat them too.\n" "iptables -t nat -A POSTROUTING -m mark --mark 1 -j MASQUERADE\n"; // Code to enable/disable masquerade. if (routing && masquerade) { // Fill up the NAT table with rules. stream << "[ $GUIDEDOG_VERBOSE -eq 1 ] && echo \"Inserting masquerade rules.\"\n" "iptables -t nat -N fromprivate\n" "# Packets from the private IP range to another private IP range are untouched.\n" "iptables -t nat -A fromprivate -d 192.168.0.0/16 -j ACCEPT\n" "iptables -t nat -A fromprivate -d 172.16.0.0/12 -j ACCEPT\n" "iptables -t nat -A fromprivate -d 10.0.0.0/8 -j ACCEPT\n" "# Packets that get here are from the private address range\n" "# and are trying to get out to the internet. We NAT them.\n" "iptables -t nat -A fromprivate -j MASQUERADE\n" "\n"; stream << "# No-masquerade addresses.\n"; for (i = 0; i < nomasqueradelist.count(); i++) { stream << "iptables -t nat -A POSTROUTING -d " << nomasqueradelist[i].getAddress() << " -j ACCEPT\n"; } stream << "# Siphon off any packets that are from the private IP range.\n" "iptables -t nat -A POSTROUTING -s 192.168.0.0/16 -j fromprivate\n" "iptables -t nat -A POSTROUTING -s 172.16.0.0/12 -j fromprivate\n" "iptables -t nat -A POSTROUTING -s 10.0.0.0/8 -j fromprivate\n" "# packets that get here can just hit the default policy.\n" "\n"; } stream << "iptables -t nat -P PREROUTING ACCEPT\n" "iptables -t nat -P POSTROUTING ACCEPT\n" "iptables -t nat -P OUTPUT ACCEPT\n" "iptables -t mangle -P PREROUTING ACCEPT\n" "iptables -t mangle -P POSTROUTING ACCEPT\n" "iptables -t mangle -P OUTPUT ACCEPT\n" "[ $GUIDEDOG_VERBOSE -eq 1 ] && echo \"" << QObject::tr("Finished.") << "\"\n" "fi;\n" // Matches the disable guidedog IF. "true\n"; return true; } /////////////////////////////////////////////////////////////////////////// bool GuidedogDoc::readScript(QTextStream &stream, QString &errorstring) { QString s; bool addcr; bool ok; uint i; GuidedogPortForwardRule *rule; IPRange *nomasqaddress; const char *parameterlist[] = { "# DISABLED=", "# ROUTING=", "# MASQUERADE=", "# MASQUERADEFTP=", "# MASQUERADEIRC=", "# NOMASQUERADEADDRESS=", 0}; const char *forwardparameterlist[] = { "# TYPE=", "# ORIGINALPORT=", "# SPECIFYORIGINALADDRESS=", "# ORIGINALADDRESS=", "# NEWPORT=", "# SPECIFYNEWADDRESS=", "# NEWADDRESS=", "# COMMENT=", 0 }; QString rightpart; rule=0; //stream.setEncoding(QTextStream::Latin1); s = stream.readLine(); if (s.isNull()) { errorstring = QObject::tr("Error reading first line of the script."); goto error; } s = stream.readLine(); if (s.isNull()) { errorstring = QObject::tr("Error reading second line of the script. Expected [Guidedog]"); goto error; } if (s != "# [Guidedog]") { errorstring = QObject::tr("Error reading script. This does not appear to be a Guidedog script."); goto error; } // Read past the boring human readable copperplate stuff. do { s = stream.readLine(); if (s.isNull()) { errorstring = QObject::tr("Error reading script. (Before Description section)."); goto error; } } while (s != "# [Description]"); // Read the config description. description = ""; addcr = false; while (true) { s = stream.readLine(); if (s.isNull()) { errorstring = QObject::tr("Error reading script. (In Description section)."); goto error; } if (s == "# [Config]") { break; } if (addcr == true) { description.append("\n"); } addcr = true; description.append(s.right(s.length() - 3)); } // Read the Config s = stream.readLine(); while (true) { if (s.isNull()) { errorstring = QObject::tr("Error reading script. (In Config section)."); goto error; } if (s.startsWith("# [End]") || s.startsWith("# [Forwarding]")) { break; // We've got to the end of this part of the show. } // Try to identify the line we are looking at. for (i = 0; parameterlist[i]!=0; i++) { if (s.startsWith(parameterlist[i])) { break; } } if (parameterlist[i] != 0) { rightpart = s.right(s.length() - strlen(parameterlist[i])); } switch(i) { case 0: // DISABLED disabled = rightpart == "1"; break; case 1: // ROUTING routing = rightpart == "1"; break; case 2: // MASQUERADE masquerade = rightpart == "1"; break; case 3: // MASQUERADEFTP masqueradeftp = rightpart == "1"; break; case 4: // MASQUERADEIRC masqueradeirc = rightpart == "1"; break; case 5: // NOMASQUERADEADDRESS nomasqueradelist << IPRange(); nomasqaddress = &nomasqueradelist.last(); nomasqaddress->setAddress(rightpart); break; default: // Should we complain? break; } s = stream.readLine(); } while (true) { if (s.startsWith("# [Forwarding]")) { // Create a new forwarding rule. forwardrulelist << GuidedogPortForwardRule(); rule = &forwardrulelist.last(); } if (s.startsWith("# [End]")) { break; // We've got to the end of this part of the show. } // Try to identify the line we are looking at. for (i = 0; forwardparameterlist[i] != 0; i++) { if (s.startsWith(forwardparameterlist[i])) { break; } } if (forwardparameterlist[i] != 0) { rightpart = s.right(s.length() - strlen(forwardparameterlist[i])); } switch(i) { case 0: // TYPE if (rightpart == "TCP") { rule->iptype = IPPROTO_TCP; } else { rule->iptype = IPPROTO_UDP; } break; case 1: // ORIGINALPORT rule->originalport = rightpart.toUInt(&ok); if (!ok) { qDebug("Error in toUint conversion for originalport"); } break; case 2: // SPECIFYORIGINALADDRESS rule->specifyoriginal = rightpart == "0" ? false : true; break; case 3: // ORIGINALADDRESS rule->originaladdress.setAddress(rightpart); break; case 4: // NEWPORT rule->newport = rightpart.toUInt(&ok); if (!ok) { qDebug("Error in toUint conversion for newport"); } break; case 5: // SPECIFYNEWADDRESS rule->specifynewaddress = rightpart == "0" ? false : true; break; case 6: // NEWADDRESS rule->newaddress.setAddress(rightpart); break; case 7: // COMMENT rule->comment = rightpart; break; default: break; } s = stream.readLine(); } return true; error: return false; } /////////////////////////////////////////////////////////////////////////// bool GuidedogDoc::openScript(const QString &filename, QString &errorstring) { QFile file(filename); if (file.open(QIODevice::ReadOnly)) { QTextStream stream(&file); if (readScript(stream, errorstring)) { file.close(); return true; } else { file.close(); return false; } } else { errorstring = QObject::tr("Unable to open the script from reading."); return false; } } /////////////////////////////////////////////////////////////////////////// bool GuidedogDoc::saveScript(const QString &filename, QString &errorstring) { QFile file(filename); // We want it root executable. file.setPermissions(filename, QFileDevice::ReadOwner | QFileDevice::WriteOwner | QFileDevice::ExeOwner); if (!file.open(QIODevice::ReadWrite | QIODevice::Text)) { errorstring = QObject::tr("An error occurred while writing '%1'. The operating system has this to report about the error: %2") .arg(filename).arg(strerror(file.error())); return false; } QTextStream out(&file); if (writeScript(out)) { if (file.error() != 0) { errorstring = QObject::tr("An error occurred while writing '%1'. The operating system has this to report about the error: %2") .arg(filename).arg(strerror(file.error())); return false; } file.close(); if (file.error() != 0) { errorstring = QObject::tr("An error occurred while writing '%1'. The operating system has this to report about the error: %2") .arg(filename).arg(strerror(file.error())); return false; } return true; } else { file.close(); return false; } } guidedog-1.2.0/guidedogdoc.h000066400000000000000000000052571246321372200157420ustar00rootroot00000000000000/*************************************************************************** guidedogdoc.h - description ------------------- begin : Thu Sep 27 2001 copyright : (C) 2001 by Simon Edwards email : simon@simonzone.com ***************************************************************************/ /*************************************************************************** Converted to a pure Qt5 application begin : December 2014 by : Antonio Martins email : digiplan.pt@gmail.com ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef GUIDEDOGDOC_H #define GUIDEDOGDOC_H #include "iprange.h" #include #include #include class GuidedogPortForwardRule { public: GuidedogPortForwardRule(); bool specifyoriginal; IPRange originaladdress; bool specifynewaddress; IPRange newaddress; uchar iptype; uint originalport; uint newport; QString comment; QString getSummary() const; }; class GuidedogDoc { public: GuidedogDoc(); ~GuidedogDoc(); void setDisabled(bool on); bool isDisabled(); void setRouting(bool on); bool isRouting(); void setMasquerade(bool on); bool isMasquerade(); void setMasqueradeFTP(bool on); bool isMasqueradeFTP(); void setMasqueradeIRC(bool on); bool isMasqueradeIRC(); bool writeScript(QTextStream &stream); bool readScript(QTextStream &stream, QString &errorstring); bool openScript(const QString &filename, QString &errorstring); bool saveScript(const QString &filename, QString &errorstring); QString description; void factoryDefaults(); // FIXME: Should use function interfaces here, and not direct. QList forwardrulelist; QList nomasqueradelist; private: bool disabled; bool routing; bool masquerade; bool masqueradeftp; bool masqueradeirc; }; #endif guidedog-1.2.0/guidedogwindow.ui000066400000000000000000000633421246321372200166710ustar00rootroot00000000000000 GuideDogApp 0 0 645 560 0 0 645 560 Advanced Network Configuration - Guidedog :/images/hi48-app-guidedog.png:/images/hi48-app-guidedog.png 0 Routing 6 9 9 9 9 Enable routing 0 0 1 1 IP Masquerade 6 9 9 9 9 Enable IP Masquerade 0 0 0 0 0 Qt::Horizontal QSizePolicy::Fixed 21 20 6 0 0 0 0 Masquerade FTP Masquerade IRC 6 0 0 0 0 0 0 No-masquerade addresses Qt::Horizontal Network destinations that should be contacted without using IP masquerade: 0 0 0 0 6 0 0 0 0 New Address Delete Address 6 0 0 0 0 Address: Addresses can be host names, network names or IP addresses. Masks can be specified as network masks or plain numbers. e.g. 192.168.1.0/255.255.255.0 or 192.168.1.0/24 true Forwarding 6 9 9 9 9 Port forwarding rules: 6 0 0 0 0 New rule Delete rule 6 0 0 0 0 Original destination 6 9 9 9 9 0 0 0 0 6 65535 IP Address: TCP UDP Port: 0 0 0 0 6 This machine Qt::Horizontal 21 20 Specify: :/images/little_right_arrow.png New destination 6 9 9 9 9 0 0 0 0 6 IP Address: 65535 Port: 0 0 0 0 6 This machine Qt::Horizontal 21 20 Specify: 6 0 0 0 0 Comment: Advanced 6 9 9 9 9 Disable Guidedog 0 0 Import/Export 6 9 9 9 9 Description: 6 0 0 0 0 Import... Export... &Help Qt::Horizontal 40 20 A&bout &OK &Apply &Cancel SimeLineEdit QLineEdit
simelineedit.h
guidedog-1.2.0/icons/000077500000000000000000000000001246321372200144165ustar00rootroot00000000000000guidedog-1.2.0/icons/hicolor/000077500000000000000000000000001246321372200160555ustar00rootroot00000000000000guidedog-1.2.0/icons/hicolor/32x32/000077500000000000000000000000001246321372200166365ustar00rootroot00000000000000guidedog-1.2.0/icons/hicolor/32x32/apps/000077500000000000000000000000001246321372200176015ustar00rootroot00000000000000guidedog-1.2.0/icons/hicolor/32x32/apps/guidedog.png000066400000000000000000000045441246321372200221050ustar00rootroot00000000000000PNG  IHDR szzgAMA abKGD pHYs  ~tIME  ^RIDATxm$G}oUuUO<>=BHQDA"B(A&EB 'ȎlQ}ypOǙ駪 +.(RT-9N#DY}=yy+oef3~?=}Zwcrot,;_}7ܹ=ŇOU;w s2K|(ߜ7 Wӿtc.ܷvO|KueQ DQ,~;ƳUJi}gW8~\ߎkoKq:S; 0;Wr}́k{٠xإ,]/̥S0 UD( \{åO>_]/<)?k}Dk{a7IS#tHA@S-HUU"G*xY=F:*HUYsOwͿ_TC?2GY5]&nLσZ [Ux㬤< /AYP9~ G=|[Hjz"+2H4)r/Uh7X2 4IQ2k9?^\_ARݯ}?pI"Ď)"E1-Q2`k>.u=smf{SXJpqíu'.^o=f =V$Om5yiY[$,L`N$Q"G q(_3Gu奵o\ՁΞCZy~m8)g3( /$UY* %P[4cM299D+AZXG(+GAYf8p-ә^@ O^ʢ$ ӔZ!hy({#.UvɎ6A_-)%EUF"pUk-(^!0Мh9em%;ʢ_QKI0IENDB`guidedog-1.2.0/icons/hicolor/48x48/000077500000000000000000000000001246321372200166545ustar00rootroot00000000000000guidedog-1.2.0/icons/hicolor/48x48/apps/000077500000000000000000000000001246321372200176175ustar00rootroot00000000000000guidedog-1.2.0/icons/hicolor/48x48/apps/guidedog.png000066400000000000000000000106301246321372200221140ustar00rootroot00000000000000PNG  IHDR00WgAMA abKGD pHYs  ~tIME  w=SIDATx{egUs?9۷4bt10 PQ ,J33"Zj{,)ftX8%%q;&N7Iv9g_?nkhҹ&YUv{~{o-x λo֡|k$g^ېOƫC\BdR>穰eNRFۅ~Cyϓj)e[[e}Q]~ƹ>v=w}{?ŵν@8F4svbl}?D-wB*?"<Ϧ+CGG{}҇>}sijq;|tLSRGiMl> ̟75oXpc:裗O_]kccz_S/xVJ9pitBٽ^L\|"۶˪zy5yA5i};{~>fN٧GKO}[mz~RB.wmb>"7gw=o͑F`\0EN KϹ;0~])JJb5TF6>+ѻϏhkN_}͔5nn$Z4EH,V*a_Eqf"<^P|@F9P7#w|vͪwZ l<3f{26}4KjZvB_ H!<;[6x/{2Op \w f1ߦYLm=}dQw^ 4; ҐjM"XnmtoϾ|/_S[_z2* KbAX;0XX67?ro{=! P Wuu_[jk;DH,JxBl ]e?dᆳU?TSO-MI<dAt GY[ ۴jO'zg>I} ?0ܢ.1Ң¹ߴt%]ۡ RtQ+&w$̙ZeǞe|h :]A5HPiܮiO|-/y'|a_?>|3lSn^BtH t7h EaF W' '0ͻTx`uj+T$HB4ubff ΋}kz|fү[$on,wAy8xx8Gkg^-|>B@m`e#OG֊̪~+nP(1V -mig^?rsL| ƾx<jFdb%R"d&Ե#!J V&$Ysk@DH%1Db <@ѻ{Lyѯ}GW}u#9B\bb $E1#/W(.0\94)6+arm3 e RKB{? FB)EzoZbM5>,ƽlmu=;??Ͽc!p!M~T+ŲZHH@ \WW)C:ѻ1RHpֳ=-֓ k,EV&9DEtN5_IRo8r\7]?-}e2ZWzofKDHFǦ!M!-u:.oTL#1PJe8&M3TDv]vq}7'>u/ggϞ8dRW1&k=բ6>lKW6._rB >=ͩX;y5I"ƄKXp(#Ɋc \m8w g0MHteQar`uHJ2!-Y,'F(]blBQf8{"[,Է9R|17iET 5-C`w- % Kvvk6Ze-Je0ȑXI36;bP@b A%HR،9a1M&yycev)҇\nB/$mٙ/ޙs`2z3V %+ LZC 1|4wΗN:oݙS Bm3>u41ljфcCE лz3U#H4(ˌ(f(G9J+"&MSDt](]w4mGgFH)@׿ٷ_EB[V풶mQg9 BD ڐ 1zFIM HL1V!,֒%@54]G\n "ij+uNMdd;""Ҵ &YNt]׳\.qޑ$pI4>zŌoZcCZc Ftꮣn;1idܡm:I2F6ÉК41bCxG⿼7ӾfZt)LN |a|)J)@kI;Pl\u]Tt.` $u'[,Ie&zm-;SiR>"F'&w{"eK|-ⓜ}JNm2AT:$ٙ-mZ4! @ #ʂ2Z~|.R5nI$9Ĉ)B\FBhƇJdQ-FE⯧u:$YB(i0F6xﯽ'kD 1$:jbCaBi Fc|iރ x@DDIA/@jo:Jhf vIb2η-J^#uڽ^B)!RcXLHӔݝ=;ށoUTW tP8%Q=a j;z1Fkc $xm Q @J="ӄr<"#JN{GWBףFJA{)q/J{){t5bZd-RnoZB{ R/~P#6IENDB`guidedog-1.2.0/icons/locolor/000077500000000000000000000000001246321372200160675ustar00rootroot00000000000000guidedog-1.2.0/icons/locolor/16x16/000077500000000000000000000000001246321372200166545ustar00rootroot00000000000000guidedog-1.2.0/icons/locolor/16x16/apps/000077500000000000000000000000001246321372200176175ustar00rootroot00000000000000guidedog-1.2.0/icons/locolor/16x16/apps/guidedog.png000066400000000000000000000004611246321372200221150ustar00rootroot00000000000000PNG  IHDRRgAMA a'PLTEXXXXX000@@8BtRNS@fbKGDH pHYs  ~tIME ,!!sIDATxc`(@,b 308J`Hc"$jd1*52r"@F3Hu3&uEA= lIڂ rՋ" RIENDB`guidedog-1.2.0/icons/locolor/32x32/000077500000000000000000000000001246321372200166505ustar00rootroot00000000000000guidedog-1.2.0/icons/locolor/32x32/apps/000077500000000000000000000000001246321372200176135ustar00rootroot00000000000000guidedog-1.2.0/icons/locolor/32x32/apps/guidedog.png000066400000000000000000000010011246321372200221000ustar00rootroot00000000000000PNG  IHDR TggAMA a-PLTEXXXX000X@@@qtRNS@fbKGDH pHYs  ~tIME +=IDATx]=N0Ӧ賝?b:5!\CU$L u ܀s1Hg,q]g ;. ę4ɤy43н10kis7 mcTZ穰eNRFۅ~Cyϓj)e[[e}Q]~ƹ>v=w}{?ŵν@8F4svbl}?D-wB*?"<Ϧ+CGG{}҇>}sijq;|tLSRGiMl> ̟75oXpc:裗O_]kccz_S/xVJ9pitBٽ^L\|"۶˪zy5yA5i};{~>fN٧GKO}[mz~RB.wmb>"7gw=o͑F`\0EN KϹ;0~])JJb5TF6>+ѻϏhkN_}͔5nn$Z4EH,V*a_Eqf"<^P|@F9P7#w|vͪwZ l<3f{26}4KjZvB_ H!<;[6x/{2Op \w f1ߦYLm=}dQw^ 4; ҐjM"XnmtoϾ|/_S[_z2* KbAX;0XX67?ro{=! P Wuu_[jk;DH,JxBl ]e?dᆳU?TSO-MI<dAt GY[ ۴jO'zg>I} ?0ܢ.1Ң¹ߴt%]ۡ RtQ+&w$̙ZeǞe|h :]A5HPiܮiO|-/y'|a_?>|3lSn^BtH t7h EaF W' '0ͻTx`uj+T$HB4ubff ΋}kz|fү[$on,wAy8xx8Gkg^-|>B@m`e#OG֊̪~+nP(1V -mig^?rsL| ƾx<jFdb%R"d&Ե#!J V&$Ysk@DH%1Db <@ѻ{Lyѯ}GW}u#9B\bb $E1#/W(.0\94)6+arm3 e RKB{? FB)EzoZbM5>,ƽlmu=;??Ͽc!p!M~T+ŲZHH@ \WW)C:ѻ1RHpֳ=-֓ k,EV&9DEtN5_IRo8r\7]?-}e2ZWzofKDHFǦ!M!-u:.oTL#1PJe8&M3TDv]vq}7'>u/ggϞ8dRW1&k=բ6>lKW6._rB >=ͩX;y5I"ƄKXp(#Ɋc \m8w g0MHteQar`uHJ2!-Y,'F(]blBQf8{"[,Է9R|17iET 5-C`w- % Kvvk6Ze-Je0ȑXI36;bP@b A%HR،9a1M&yycev)҇\nB/$mٙ/ޙs`2z3V %+ LZC 1|4wΗN:oݙS Bm3>u41ljфcCE лz3U#H4(ˌ(f(G9J+"&MSDt](]w4mGgFH)@׿ٷ_EB[V풶mQg9 BD ڐ 1zFIM HL1V!,֒%@54]G\n "ij+uNMdd;""Ҵ &YNt]׳\.qޑ$pI4>zŌoZcCZc Ftꮣn;1idܡm:I2F6ÉК41bCxG⿼7ӾfZt)LN |a|)J)@kI;Pl\u]Tt.` $u'[,Ie&zm-;SiR>"F'&w{"eK|-ⓜ}JNm2AT:$ٙ-mZ4! @ #ʂ2Z~|.R5nI$9Ĉ)B\FBhƇJdQ-FE⯧u:$YB(i0F6xﯽ'kD 1$:jbCaBi Fc|iރ x@DDIA/@jo:Jhf vIb2η-J^#uڽ^B)!RcXLHӔݝ=;ށoUTW tP8%Q=a j;z1Fkc $xm Q @J="ӄr<"#JN{GWBףFJA{)q/J{){t5bZd-RnoZB{ R/~P#6IENDB`guidedog-1.2.0/images/laserwarn.png000066400000000000000000000007351246321372200172610ustar00rootroot00000000000000PNG  IHDR"":G gAMA abKGD pHYs  @AtIME12LZIDATxK0 E]Z QքTT _p%ƱDGRJJG,}ےR6!: ܕY-Ќ:ڏkY[B%ߔilfSsXsPY)Gz*:8%g½K\J+i5TbF<̍w""|=#O_uӭaDIENDB`guidedog-1.2.0/images/little_right_arrow.png000066400000000000000000000003171246321372200211630ustar00rootroot00000000000000PNG  IHDRRPLTE@@$tRNS@fbKGDH pHYs  tIME"-IDATxc`@L 0c@@P3` % d]psPLF R>IENDB`guidedog-1.2.0/iprange.cpp000066400000000000000000000131221246321372200154330ustar00rootroot00000000000000/*************************************************************************** iprange.cpp - description ------------------- begin : Thu May 10 08:08:00 EST 2001 copyright : (C) 2000-2001 by Simon Edwards email : simon@simonzone.com ***************************************************************************/ /*************************************************************************** Converted to a pure Qt5 application begin : December 2014 by : Antonio Martins email : digiplan.pt@gmail.com ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include "iprange.h" #include /////////////////////////////////////////////////////////////////////////// IPRange::IPRange() { gottype = false; } /////////////////////////////////////////////////////////////////////////// IPRange::IPRange(const QString &a) { setAddress(a); } /////////////////////////////////////////////////////////////////////////// IPRange::~IPRange() { } /////////////////////////////////////////////////////////////////////////// void IPRange::setAddress(const QString &a) { address = a; gottype = false; } /////////////////////////////////////////////////////////////////////////// QString IPRange::getAddress() const { return address; } /////////////////////////////////////////////////////////////////////////// IPRangeType IPRange::getType() { if (!gottype) { type = guessType(); gottype = true; } return type; } /////////////////////////////////////////////////////////////////////////// IPRangeType IPRange::guessType() { QRegExp sanity("^[0-9a-zA-Z./-]*$"); QRegExp domainnametest("^([a-zA-Z0-9-]+\\.)+[a-zA-Z0-9-]+$"); QRegExp iptest("^([0-9]+)\\.([0-9]+)\\.([0-9]+)\\.([0-9]+)$"); QRegExp ipmaskedtest("^([0-9]+)\\.([0-9]+)\\.([0-9]+)\\.([0-9]+)/([0-9]+)$"); QRegExp ipmasked2test("^([0-9]+)\\.([0-9]+)\\.([0-9]+)\\.([0-9]+)/([0-9]+)\\.([0-9]+)\\.([0-9]+)\\.([0-9]+)$"); bool ok; long ipbyte; // Smoke text if (!sanity.exactMatch(address)) { return invalid; } if (address.length() == 0) { return invalid; } // Test against the domainname regexp. if (domainnametest.exactMatch(address)) { return domainname; } // Ok, now lets try the IP address regexp. if (iptest.exactMatch(address)) { ipbyte = iptest.cap(1).toLong(&ok); // Yep, it returns char *. if (ipbyte < 0 || ipbyte > 255) { return invalid; } ipbyte = iptest.cap(2).toLong(&ok); if (ipbyte < 0 || ipbyte > 255) { return invalid; } ipbyte = iptest.cap(3).toLong(&ok); if (ipbyte < 0 || ipbyte > 255) { return invalid; } ipbyte = iptest.cap(4).toLong(&ok); if (ipbyte < 0 || ipbyte > 255) { return invalid; } return ip; } // Ok, now lets try the IP address regexp. if (ipmaskedtest.exactMatch(address)) { ipbyte = ipmaskedtest.cap(1).toLong(&ok); // Yep, it returns char *. if (ipbyte < 0 || ipbyte > 255) { return invalid; } ipbyte = ipmaskedtest.cap(2).toLong(&ok); if (ipbyte < 0 || ipbyte > 255) { return invalid; } ipbyte = ipmaskedtest.cap(3).toLong(&ok); if (ipbyte < 0 || ipbyte > 255) { return invalid; } ipbyte = ipmaskedtest.cap(4).toLong(&ok); if (ipbyte < 0 || ipbyte > 255) { return invalid; } ipbyte = ipmaskedtest.cap(5).toLong(&ok); if (ipbyte < 0 || ipbyte > 32) { return invalid; } return iprange; } if (ipmasked2test.exactMatch(address)) { ipbyte = ipmasked2test.cap(1).toLong(&ok); // Yep, it returns char *. if (ipbyte < 0 || ipbyte > 255) { return invalid; } ipbyte = ipmasked2test.cap(2).toLong(&ok); if (ipbyte < 0 || ipbyte > 255) { return invalid; } ipbyte = ipmasked2test.cap(3).toLong(&ok); if (ipbyte < 0 || ipbyte > 255) { return invalid; } ipbyte = ipmasked2test.cap(4).toLong(&ok); if (ipbyte < 0 || ipbyte > 255) { return invalid; } ipbyte = ipmasked2test.cap(5).toLong(&ok); if (ipbyte < 0 || ipbyte > 255) { return invalid; } ipbyte = ipmasked2test.cap(6).toLong(&ok); if (ipbyte < 0 || ipbyte > 255) { return invalid; } ipbyte = ipmasked2test.cap(7).toLong(&ok); if (ipbyte < 0 || ipbyte > 255) { return invalid; } ipbyte = ipmasked2test.cap(8).toLong(&ok); if (ipbyte < 0 || ipbyte > 255) { return invalid; } return iprange; } return invalid; } guidedog-1.2.0/iprange.h000066400000000000000000000034521246321372200151050ustar00rootroot00000000000000/*************************************************************************** iprange.h - description ------------------- begin : Thu May 10 08:08:00 EST 2001 copyright : (C) 2000-2001 by Simon Edwards email : simon@simonzone.com ***************************************************************************/ /*************************************************************************** Converted to a pure Qt5 application begin : December 2014 by : Antonio Martins email : digiplan.pt@gmail.com ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef IPRANGE_H #define IPRANGE_H #ifdef HAVE_CONFIG_H #include #endif #include enum IPRangeType {invalid, localmachine, domainname, ip, iprange}; class IPRange { public: IPRange(); IPRange(const QString &a); ~IPRange(); void setAddress(const QString &a); QString getAddress() const; IPRangeType getType(); private: QString address; bool gottype; IPRangeType type; IPRangeType guessType(); }; #endif guidedog-1.2.0/main.cpp000066400000000000000000000043661246321372200147440ustar00rootroot00000000000000/*************************************************************************** main.cpp - description ------------------- begin : Thu Sep 27 22:23:16 CEST 2001 copyright : (C) 2001 by Simon Edwards email : simon@simonzone.com ***************************************************************************/ /*************************************************************************** Converted to a pure Qt5 application begin : December 2014 by : Antonio Martins email : digiplan.pt@gmail.com ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include "guidedog.h" #include #include // #include #include int main(int argc, char *argv[]) { QApplication app(argc, argv); // QCommandLineParser parser; // parser.addHelpOption(); // parser.addVersionOption(); // parser.addPositionalArgument("file", QObject::tr("main", "The file to open.")); // parser.process(app); GuideDogApp w; if (w.initialize(getuid() == 0)) { w.show(); if (getuid() != 0) { QMessageBox::information(0, QObject::tr("Information - Guidedog"), QObject::tr( "Since you do not have superuser privileges, Guidedog is\n" "running with reduced functionality. Scripts may be \n" "Imported/Exported, but the system's networking settings\n" "may not be changed.\n")); } return app.exec(); } } guidedog-1.2.0/resources.qrc000066400000000000000000000003101246321372200160160ustar00rootroot00000000000000 images/hi48-app-guidedog.png images/laserwarn.png images/little_right_arrow.png guidedog-1.2.0/simelineedit.cpp000066400000000000000000000053551246321372200164720ustar00rootroot00000000000000/*************************************************************************** simelineedit.cpp - ------------------- begin : Sat May 12 23:25:00 CET 2001 copyright : (C) 2000-2001 by Simon Edwards email : simon@simonzone.com ***************************************************************************/ /*************************************************************************** Converted to a pure Qt5 application begin : December 2014 by : Antonio Martins email : digiplan.pt@gmail.com ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include "simelineedit.h" #include #include /////////////////////////////////////////////////////////////////////////// SimeLineEdit::SimeLineEdit(QWidget *parent) : QLineEdit(parent) { } /////////////////////////////////////////////////////////////////////////// SimeLineEdit::~SimeLineEdit() { } /////////////////////////////////////////////////////////////////////////// // This is just a small modification for when the user hits the return key. // We just give the focus back to the parent widget. void SimeLineEdit::keyPressEvent(QKeyEvent *e) { QString t; t = text(); QLineEdit::keyPressEvent(e); if (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return) { e->accept(); if (t != text()) { emit textChanged(text()); // This is bullshit. If keyPressEvent() changed the text // then I expect a textChanged() signal to be emitted. I should not have to DIY. } if (parentWidget() != 0) { parentWidget()->setFocus(); } } } /////////////////////////////////////////////////////////////////////////// void SimeLineEdit::focusOutEvent() { const QValidator *v; QString t; int pos; v = validator(); if (v != 0) { t = text(); pos = 0; if (v->validate(t, pos) != QValidator::Acceptable) { v->fixup(t); setText(t); } } } guidedog-1.2.0/simelineedit.h000066400000000000000000000032251246321372200161310ustar00rootroot00000000000000/*************************************************************************** simelineedit.h - ------------------- begin : Sat May 12 23:25:00 CET 2001 copyright : (C) 2000-2001 by Simon Edwards email : simon@simonzone.com ***************************************************************************/ /*************************************************************************** Converted to a pure Qt5 application begin : December 2014 by : Antonio Martins email : digiplan.pt@gmail.com ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef SIMELINEEDIT_H #define SIMELINEEDIT_H #ifdef HAVE_CONFIG_H #include #endif #include class SimeLineEdit : public QLineEdit { public: SimeLineEdit(QWidget *parent); ~SimeLineEdit(); protected: virtual void keyPressEvent(QKeyEvent *e); virtual void focusOutEvent(); }; #endif guidedog-1.2.0/system/000077500000000000000000000000001246321372200146275ustar00rootroot00000000000000guidedog-1.2.0/system/guidedog-root.desktop000066400000000000000000000003301246321372200207660ustar00rootroot00000000000000[Desktop Entry] Type=Application Name=Guidedog as root GenericName=Run guidedog as user root Comment=Advanced routing configuration utiliy Keywords=iptables;forward Exec=gksudo guidedog Icon=guidedog.png Terminal=0 guidedog-1.2.0/system/guidedog.desktop000066400000000000000000000002431246321372200200100ustar00rootroot00000000000000[Desktop Entry] Type=Application Name=Guidedog Comment=Advanced routing configuration utiliy Keywords=iptables;forward Exec=guidedog Icon=guidedog.png Terminal=0 guidedog-1.2.0/system/guidedog.ifupdown000077500000000000000000000006531246321372200202020ustar00rootroot00000000000000#!/bin/sh # If we are being called by ifupdown when it changes a PPP interface, # and if the appropriate file is in place to do this for PPP anyway, # don't do anything. [ -x /etc/ppp/ip-up.d/51guidedog -a "$MODE" = "start" -a "$METHOD" = "ppp" ] && exit 0 [ -x /etc/ppp/ip-down.d/51guidedog -a "$MODE" = "stop" -a "$METHOD" = "ppp" ] && exit 0 # setup guidedog if [ -x /etc/rc.guidedog ]; then /bin/sh /etc/rc.guidedog fi guidedog-1.2.0/system/menu000066400000000000000000000002761246321372200155230ustar00rootroot00000000000000?package(guidedog):needs="X11" section="Applications/System/Security"\ title="guidedog" icon="guidedog" command="/usr/bin/guidedog"\ longtitle="IP masq/forwarding configuration utility"