Changeset 8901c47
- Timestamp:
- Apr 16, 2013 7:59:40 AM (5 weeks ago)
- Branches:
- master, 9.1-release
- Children:
- 470af24
- Parents:
- 17235d6
- Location:
- src-qt4/warden-gui
- Files:
-
- 4 edited
-
dialogEditIP.cpp (modified) (6 diffs)
-
dialogEditIP.h (modified) (2 diffs)
-
dialogEditIP.ui (modified) (2 diffs)
-
dialogwarden.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src-qt4/warden-gui/dialogEditIP.cpp
r0cfe72f r8901c47 14 14 #include <QProcess> 15 15 #include <QString> 16 #include <QFile> 16 17 #include <QFileDialog> 17 18 #include <QMessageBox> … … 22 23 #include "dialogEditIP.h" 23 24 24 void dialogEditIP::programInit(QString jIP, QStringList IPs) 25 { 26 wardenIP = jIP; 27 listIP->clear(); 28 for ( int i=0; i<IPs.count() ; i++) 29 if ( ! IPs.at(i).isEmpty() ) 30 listIP->addItem(IPs.at(i)); 25 void dialogEditIP::programInit(QString name) 26 { 27 JailDir = pcbsd::Utils::getValFromPCConf("/usr/local/etc/warden.conf", "JDIR"); 28 jailName = name; 29 QString tmp; 30 31 // Lets start loading IP addresses 32 QFile file( JailDir + "/." + jailName + ".meta/ipv4" ); 33 if ( file.exists() && file.open( QIODevice::ReadOnly ) ) { 34 QTextStream stream( &file ); tmp=""; tmp = stream.readLine(); 35 lineIP->setText(tmp); 36 if ( ! tmp.isEmpty() ) 37 checkIPv4->setChecked(true); 38 file.close(); 39 } 40 41 file.setFileName( JailDir + "/." + jailName + ".meta/bridge-ipv4" ); 42 if ( file.exists() && file.open( QIODevice::ReadOnly ) ) { 43 QTextStream stream( &file ); tmp=""; tmp = stream.readLine(); 44 lineIPBridge->setText(tmp); 45 if ( ! tmp.isEmpty() ) 46 checkIPv4Bridge->setChecked(true); 47 file.close(); 48 } 49 50 file.setFileName( JailDir + "/." + jailName + ".meta/defaultrouter-ipv4" ); 51 if ( file.exists() && file.open( QIODevice::ReadOnly ) ) { 52 QTextStream stream( &file ); tmp=""; tmp = stream.readLine(); 53 lineIPRouter->setText(tmp); 54 if ( ! tmp.isEmpty() ) 55 checkIPv4Router->setChecked(true); 56 file.close(); 57 } 58 59 file.setFileName( JailDir + "/." + jailName + ".meta/ipv6" ); 60 if ( file.exists() && file.open( QIODevice::ReadOnly ) ) { 61 QTextStream stream( &file ); tmp=""; tmp = stream.readLine(); 62 lineIP6->setText(tmp); 63 if ( ! tmp.isEmpty() ) 64 checkIPv6->setChecked(true); 65 file.close(); 66 } 67 68 file.setFileName( JailDir + "/." + jailName + ".meta/bridge-ipv6" ); 69 if ( file.exists() && file.open( QIODevice::ReadOnly ) ) { 70 QTextStream stream( &file ); tmp=""; tmp = stream.readLine(); 71 lineIP6Bridge->setText(tmp); 72 if ( ! tmp.isEmpty() ) 73 checkIPv6Bridge->setChecked(true); 74 file.close(); 75 } 76 77 file.setFileName( JailDir + "/." + jailName + ".meta/defaultrouter-ipv6" ); 78 if ( file.exists() && file.open( QIODevice::ReadOnly ) ) { 79 QTextStream stream( &file ); tmp=""; tmp = stream.readLine(); 80 lineIP6Router->setText(tmp); 81 if ( ! tmp.isEmpty() ) 82 checkIPv6Router->setChecked(true); 83 file.close(); 84 } 31 85 32 86 // Our buttons / slots 87 connect( checkIPv4, SIGNAL( clicked() ), this, SLOT( slotCheckChecks() ) ); 88 connect( checkIPv4Bridge, SIGNAL( clicked() ), this, SLOT( slotCheckChecks() ) ); 89 connect( checkIPv4Router, SIGNAL( clicked() ), this, SLOT( slotCheckChecks() ) ); 90 connect( checkIPv6, SIGNAL( clicked() ), this, SLOT( slotCheckChecks() ) ); 91 connect( checkIPv6Bridge, SIGNAL( clicked() ), this, SLOT( slotCheckChecks() ) ); 92 connect( checkIPv6Router, SIGNAL( clicked() ), this, SLOT( slotCheckChecks() ) ); 93 33 94 connect( pushSave, SIGNAL( clicked() ), this, SLOT( slotSaveClicked() ) ); 34 95 connect( pushCancel, SIGNAL( clicked() ), this, SLOT( slotCancelClicked() ) ); 35 96 connect( pushAdd, SIGNAL( clicked() ), this, SLOT( slotAddClicked() ) ); 36 97 connect( pushRemove, SIGNAL( clicked() ), this, SLOT( slotRemClicked() ) ); 98 99 slotCheckChecks(); 100 } 101 102 void dialogEditIP::slotCheckChecks() 103 { 104 lineIP->setEnabled(checkIPv4->isChecked()); 105 lineIPBridge->setEnabled(checkIPv4Bridge->isChecked()); 106 lineIPRouter->setEnabled(checkIPv4Router->isChecked()); 107 lineIP6->setEnabled(checkIPv6->isChecked()); 108 lineIP6Bridge->setEnabled(checkIPv6Bridge->isChecked()); 109 lineIP6Router->setEnabled(checkIPv6Router->isChecked()); 110 37 111 } 38 112 … … 44 118 bool dialogEditIP::sanityCheckSettings() 45 119 { 120 if ( checkIPv4->isChecked() && ! checkValidBlock(lineIP->text(), QString("IPv4")) ) { 121 QMessageBox::critical(this, tr("Warden"), tr("Invalid IPv4 address!"), QMessageBox::Ok, QMessageBox::Ok); 122 return false; 123 } 124 if ( checkIPv4Bridge->isChecked() && ! checkValidBlock(lineIPBridge->text(), QString("IPv4")) ) { 125 QMessageBox::critical(this, tr("Warden"), tr("Invalid IPv4 bridge address!"), QMessageBox::Ok, QMessageBox::Ok); 126 return false; 127 } 128 if ( checkIPv4Router->isChecked() && ! checkValidBlock(lineIPRouter->text(), QString("IPv4")) ) { 129 QMessageBox::critical(this, tr("Warden"), tr("Invalid IPv4 router address!"), QMessageBox::Ok, QMessageBox::Ok); 130 return false; 131 } 132 if ( checkIPv6->isChecked() && ! checkValidBlock(lineIP6->text(), QString("IPv6")) ) { 133 QMessageBox::critical(this, tr("Warden"), tr("Invalid IPv6 address!"), QMessageBox::Ok, QMessageBox::Ok); 134 return false; 135 } 136 if ( checkIPv6Bridge->isChecked() && ! checkValidBlock(lineIP6Bridge->text(), QString("IPv6")) ) { 137 QMessageBox::critical(this, tr("Warden"), tr("Invalid IPv6 bridge address!"), QMessageBox::Ok, QMessageBox::Ok); 138 return false; 139 } 140 if ( checkIPv6Router->isChecked() && ! checkValidBlock(lineIP6Router->text(), QString("IPv6")) ) { 141 QMessageBox::critical(this, tr("Warden"), tr("Invalid IPv6 router address!"), QMessageBox::Ok, QMessageBox::Ok); 142 return false; 143 } 144 46 145 return true; 47 146 } … … 59 158 void dialogEditIP::saveSettings() 60 159 { 160 QString tmp; 161 QFile file; 162 163 // Start saving settings 164 file.setFileName( JailDir + "/." + jailName + ".meta/ipv4" ); 165 if ( checkIPv4->isChecked() ) { 166 if ( file.open( QIODevice::WriteOnly ) ) { 167 QTextStream stream( &file ); tmp = lineIP->text(); 168 if (tmp.indexOf("/") == -1) 169 tmp = tmp + "/24"; 170 stream << tmp; 171 file.close(); 172 } 173 } else { 174 file.remove(); 175 } 176 177 file.setFileName( JailDir + "/." + jailName + ".meta/bridge-ipv4" ); 178 if ( checkIPv4Bridge->isChecked() ) { 179 if ( file.open( QIODevice::WriteOnly ) ) { 180 QTextStream stream( &file ); tmp = lineIPBridge->text(); 181 if (tmp.indexOf("/") == -1) 182 tmp = tmp + "/24"; 183 stream << tmp; 184 file.close(); 185 } 186 } else { 187 file.remove(); 188 } 189 190 file.setFileName( JailDir + "/." + jailName + ".meta/defaultrouter-ipv4" ); 191 if ( checkIPv4Router->isChecked() ) { 192 if ( file.open( QIODevice::WriteOnly ) ) { 193 QTextStream stream( &file ); tmp = lineIPRouter->text(); 194 if (tmp.indexOf("/") == -1) 195 tmp = tmp + "/24"; 196 stream << tmp; 197 file.close(); 198 } 199 } else { 200 file.remove(); 201 } 202 203 file.setFileName( JailDir + "/." + jailName + ".meta/ipv6" ); 204 if ( checkIPv6->isChecked() ) { 205 if ( file.open( QIODevice::WriteOnly ) ) { 206 QTextStream stream( &file ); tmp = lineIP6->text(); 207 if (tmp.indexOf("/") == -1) 208 tmp = tmp + "/64"; 209 stream << tmp; 210 file.close(); 211 } 212 } else { 213 file.remove(); 214 } 215 216 file.setFileName( JailDir + "/." + jailName + ".meta/bridge-ipv6" ); 217 if ( checkIPv6Bridge->isChecked() ) { 218 if ( file.open( QIODevice::WriteOnly ) ) { 219 QTextStream stream( &file ); tmp = lineIP6Bridge->text(); 220 if (tmp.indexOf("/") == -1) 221 tmp = tmp + "/64"; 222 stream << tmp; 223 file.close(); 224 } 225 } else { 226 file.remove(); 227 } 228 229 file.setFileName( JailDir + "/." + jailName + ".meta/defaultrouter-ipv6" ); 230 if ( checkIPv6Router->isChecked() ) { 231 if ( file.open( QIODevice::WriteOnly ) ) { 232 QTextStream stream( &file ); tmp = lineIP6Router->text(); 233 if (tmp.indexOf("/") == -1) 234 tmp = tmp + "/64"; 235 stream << tmp; 236 file.close(); 237 } 238 } else { 239 file.remove(); 240 } 241 242 /* 61 243 QStringList IPs; 62 244 for ( int i=0; i<listIP->count() ; i++) … … 76 258 QCoreApplication::processEvents(); 77 259 } 260 */ 78 261 79 262 } … … 96 279 } 97 280 281 bool dialogEditIP::checkValidBlock(QString block, QString type) 282 { 283 QString url = block; 284 285 // Strip off the /24 part 286 if ( url.indexOf("/") != -1 ) 287 url.truncate(url.indexOf("/")); 288 289 if ( type == "IPv4" ) { 290 if ( ! pcbsd::Utils::validateIPV4(url) ) 291 return false; 292 293 } else { 294 if ( ! pcbsd::Utils::validateIPV6(url) ) 295 return false; 296 297 } 298 299 return true; 300 } 301 98 302 void dialogEditIP::slotRemClicked() 99 303 { -
src-qt4/warden-gui/dialogEditIP.h
r1f0939e r8901c47 15 15 } 16 16 17 void programInit(QString , QStringList);17 void programInit(QString); 18 18 19 19 public slots: … … 27 27 void slotCancelClicked(); 28 28 void slotSaveClicked(); 29 void slotCheckChecks(); 29 30 30 31 private: 31 32 void displayRepos(); 32 33 void saveSettings(); 33 QString wardenIP; 34 bool checkValidBlock(QString block, QString type); 35 QString jailName; 36 QString JailDir; 34 37 35 38 signals: -
src-qt4/warden-gui/dialogEditIP.ui
r1f0939e r8901c47 7 7 <x>0</x> 8 8 <y>0</y> 9 <width> 413</width>10 <height> 327</height>9 <width>502</width> 10 <height>413</height> 11 11 </rect> 12 12 </property> 13 13 <property name="windowTitle"> 14 <string> RepositoryConfiguration</string>14 <string>IP Configuration</string> 15 15 </property> 16 16 <property name="windowIcon"> … … 26 26 <layout class="QGridLayout" name="gridLayout"> 27 27 <item row="0" column="0"> 28 <widget class="QListWidget" name="listIP"/> 29 </item> 30 <item row="1" column="0" colspan="2"> 31 <layout class="QHBoxLayout" name="horizontalLayout_2"> 32 <item> 33 <spacer name="horizontalSpacer_2"> 34 <property name="orientation"> 35 <enum>Qt::Horizontal</enum> 36 </property> 37 <property name="sizeHint" stdset="0"> 38 <size> 39 <width>40</width> 40 <height>20</height> 41 </size> 42 </property> 43 </spacer> 44 </item> 45 <item> 46 <widget class="QPushButton" name="pushAdd"> 47 <property name="text"> 48 <string>&Add</string> 49 </property> 50 <property name="icon"> 51 <iconset> 52 <normaloff>:/add.png</normaloff>:/add.png</iconset> 53 </property> 54 </widget> 55 </item> 56 <item> 57 <widget class="QPushButton" name="pushRemove"> 58 <property name="text"> 59 <string>&Remove</string> 60 </property> 61 <property name="icon"> 62 <iconset> 63 <normaloff>:/remove.png</normaloff>:/remove.png</iconset> 64 </property> 65 </widget> 66 </item> 67 </layout> 28 <widget class="QTabWidget" name="tabWidget"> 29 <property name="currentIndex"> 30 <number>0</number> 31 </property> 32 <widget class="QWidget" name="tab"> 33 <attribute name="title"> 34 <string>IPv4</string> 35 </attribute> 36 <layout class="QGridLayout" name="gridLayout_4"> 37 <item row="0" column="0"> 38 <widget class="QCheckBox" name="checkIPv4"> 39 <property name="text"> 40 <string>IPv4 Address</string> 41 </property> 42 <property name="checked"> 43 <bool>false</bool> 44 </property> 45 </widget> 46 </item> 47 <item row="1" column="0"> 48 <widget class="QLineEdit" name="lineIP"> 49 <property name="enabled"> 50 <bool>false</bool> 51 </property> 52 <property name="inputMask"> 53 <string notr="true"/> 54 </property> 55 <property name="alignment"> 56 <set>Qt::AlignHCenter</set> 57 </property> 58 </widget> 59 </item> 60 <item row="2" column="0"> 61 <widget class="QCheckBox" name="checkIPv4Bridge"> 62 <property name="text"> 63 <string>IPv4 Bridge Address</string> 64 </property> 65 </widget> 66 </item> 67 <item row="3" column="0"> 68 <widget class="QLineEdit" name="lineIPBridge"> 69 <property name="enabled"> 70 <bool>false</bool> 71 </property> 72 </widget> 73 </item> 74 <item row="4" column="0"> 75 <widget class="QCheckBox" name="checkIPv4Router"> 76 <property name="text"> 77 <string>IPv4 Default Router</string> 78 </property> 79 </widget> 80 </item> 81 <item row="5" column="0"> 82 <widget class="QLineEdit" name="lineIPRouter"> 83 <property name="enabled"> 84 <bool>false</bool> 85 </property> 86 </widget> 87 </item> 88 <item row="6" column="0"> 89 <spacer name="verticalSpacer_2"> 90 <property name="orientation"> 91 <enum>Qt::Vertical</enum> 92 </property> 93 <property name="sizeHint" stdset="0"> 94 <size> 95 <width>20</width> 96 <height>140</height> 97 </size> 98 </property> 99 </spacer> 100 </item> 101 </layout> 102 </widget> 103 <widget class="QWidget" name="tab_3"> 104 <attribute name="title"> 105 <string>IPv6</string> 106 </attribute> 107 <layout class="QGridLayout" name="gridLayout_5"> 108 <item row="0" column="0"> 109 <widget class="QCheckBox" name="checkIPv6"> 110 <property name="text"> 111 <string>IPv6 Address</string> 112 </property> 113 </widget> 114 </item> 115 <item row="1" column="0"> 116 <widget class="QLineEdit" name="lineIP6"> 117 <property name="enabled"> 118 <bool>false</bool> 119 </property> 120 </widget> 121 </item> 122 <item row="2" column="0"> 123 <widget class="QCheckBox" name="checkIPv6Bridge"> 124 <property name="text"> 125 <string>IPv6 Bridge Address</string> 126 </property> 127 </widget> 128 </item> 129 <item row="3" column="0"> 130 <widget class="QLineEdit" name="lineIP6Bridge"> 131 <property name="enabled"> 132 <bool>false</bool> 133 </property> 134 </widget> 135 </item> 136 <item row="4" column="0"> 137 <widget class="QCheckBox" name="checkIPv6Router"> 138 <property name="text"> 139 <string>IPv6 Default Router</string> 140 </property> 141 </widget> 142 </item> 143 <item row="5" column="0"> 144 <widget class="QLineEdit" name="lineIP6Router"> 145 <property name="enabled"> 146 <bool>false</bool> 147 </property> 148 </widget> 149 </item> 150 <item row="6" column="0"> 151 <spacer name="verticalSpacer"> 152 <property name="orientation"> 153 <enum>Qt::Vertical</enum> 154 </property> 155 <property name="sizeHint" stdset="0"> 156 <size> 157 <width>20</width> 158 <height>140</height> 159 </size> 160 </property> 161 </spacer> 162 </item> 163 </layout> 164 </widget> 165 <widget class="QWidget" name="tab_2"> 166 <attribute name="title"> 167 <string>Advanced</string> 168 </attribute> 169 <layout class="QGridLayout" name="gridLayout_3"> 170 <item row="0" column="0"> 171 <widget class="QComboBox" name="comboBox"> 172 <item> 173 <property name="text"> 174 <string>IPv4 Aliases</string> 175 </property> 176 </item> 177 <item> 178 <property name="text"> 179 <string>IPv4 Bridge Aliases</string> 180 </property> 181 </item> 182 <item> 183 <property name="text"> 184 <string>IPv6 Aliases</string> 185 </property> 186 </item> 187 <item> 188 <property name="text"> 189 <string>IPv6 Bridge Aliases</string> 190 </property> 191 </item> 192 </widget> 193 </item> 194 <item row="1" column="0"> 195 <widget class="QListWidget" name="listIP"/> 196 </item> 197 <item row="2" column="0"> 198 <layout class="QHBoxLayout" name="horizontalLayout_2"> 199 <item> 200 <spacer name="horizontalSpacer_2"> 201 <property name="orientation"> 202 <enum>Qt::Horizontal</enum> 203 </property> 204 <property name="sizeHint" stdset="0"> 205 <size> 206 <width>40</width> 207 <height>20</height> 208 </size> 209 </property> 210 </spacer> 211 </item> 212 <item> 213 <widget class="QPushButton" name="pushAdd"> 214 <property name="text"> 215 <string>&Add</string> 216 </property> 217 <property name="icon"> 218 <iconset> 219 <normaloff>:/add.png</normaloff>:/add.png</iconset> 220 </property> 221 </widget> 222 </item> 223 <item> 224 <widget class="QPushButton" name="pushRemove"> 225 <property name="text"> 226 <string>&Remove</string> 227 </property> 228 <property name="icon"> 229 <iconset> 230 <normaloff>:/remove.png</normaloff>:/remove.png</iconset> 231 </property> 232 </widget> 233 </item> 234 </layout> 235 </item> 236 </layout> 237 </widget> 238 </widget> 68 239 </item> 69 240 </layout> -
src-qt4/warden-gui/dialogwarden.cpp
rf66423f r8901c47 1455 1455 return; 1456 1456 1457 QString IPs;1458 1459 for (int i=0; i < jailDetails.count(); ++i) {1460 if ( jailDetails.at(i).at(0) != listJails->currentItem()->text(0) )1461 continue;1462 IPs = jailDetails.at(i).at(3);1463 if ( jailDetails.at(i).at(1) == "Pending" )1464 return;1465 break;1466 }1467 1468 1469 1457 dIP = new dialogEditIP(); 1470 1458 connect(dIP, SIGNAL(saved()),this, SLOT(slotMonitorJailDetails()) ); 1471 if ( IPs.isEmpty() ) 1472 dIP->programInit(listJails->currentItem()->text(0), QStringList() ); 1473 else 1474 dIP->programInit(listJails->currentItem()->text(0), IPs.split(" ") ); 1459 dIP->programInit(listJails->currentItem()->text(0)); 1475 1460 dIP->exec(); 1476 1461
Note: See TracChangeset
for help on using the changeset viewer.
