Создание модуля программно-аппаратного комплекса по протоколам высокого уровня под операционную систему Linux

Дипломная работа - Компьютеры, программирование

Другие дипломы по предмету Компьютеры, программирование



ible(false);.setVisible(false);.setVisible(false);.setVisible(false);.pack();

}dhcpAddDialogClean(){.setSelectedIndex(0);.setValue(null);.setValue(null);.setValue(null);.setValue(null);

}dnsAddDialogClean(){.setValue(null);.setSelectedIndex(0);.setText("");

}runCheck(String name){passed = false;.setText("");.append("Проверка \nустановки демонов... \n\n");dr = new DoRuntime();{.append(dr.installVerify(name)+"\n");(name){"isc-dhcp-server":(dr.isInstalled==true){.setEnabled(false);.setEnabled(true);.setEnabled(true);= true;

}.setEnabled(true);;"bind9":(dr.isInstalled==true){.setEnabled(false);.setEnabled(true);.setEnabled(true);= true;

}.setEnabled(true);;"exim4":(dr.isInstalled==true){.setEnabled(false);.setEnabled(true);.setEnabled(true);.setEnabled(true);= true;

}.setEnabled(true);;"proftpd":(dr.isInstalled==true){.setEnabled(false);.setEnabled(true);.setEnabled(true);= true;

}.setEnabled(true);;"squid":(dr.isInstalled==true){.setEnabled(false);.setEnabled(true);= true;

}.setEnabled(true);;

}

} catch(IOException e) {}passed;

}runCheckDaemon(String name){.append("\nПроверка \nзапуска демонов... \n\n");dr = new DoRuntime();{.makeProcSh(name);("chmod +x proc.sh");(name){"isc-dhcp-server":(dr.isRunning()==true){.append(name+": запущен"+"\n");.setEnabled(false);.setEnabled(true);

}{.append(name+": не запущен"+"\n");.setEnabled(true);.setEnabled(false);

};"named/named":(dr.isRunning()==true){.append("bind9: запущен"+"\n");.setEnabled(false);.setEnabled(true);

}{.append("bind9: не запущен"+"\n");.setEnabled(true);.setEnabled(false);

};"exim4/exim":(dr.isRunning()==true){.append("exim4: запущен"+"\n");.setEnabled(false);.setEnabled(true);

}{.append("exim4: не запущен"+"\n");.setEnabled(true);.setEnabled(false);

};"proftpd":(dr.isRunning()==true){.append(name+": запущен"+"\n");.setEnabled(false);.setEnabled(true);

}{.append(name+": не запущен"+"\n");.setEnabled(true);.setEnabled(false);

};"squid":(dr.isRunning()==true){.append(name+": запущен"+"\n");.setEnabled(false);.setEnabled(true);

}{.append(name+": не запущен"+"\n");.setEnabled(true);.setEnabled(false);

};

}

} catch (IOException ex) {}

}daemonInstall(String daemonName){ex_com = "gnome-terminal -x part2/"+daemonName+"_install.sh";{(ex_com);

} catch (IOException ex) {}{.sleep(8000);

} catch (InterruptedException ex) {}(runCheck(daemonName))(daemonName);

}daemonStartStop(String daemonName, String command){ex_com = "gnome-terminal -x part2/"+daemonName+"_"+command+".sh";{(ex_com);

} catch (IOException ex) {}(runCheck(daemonName))(daemonName);

}makeSh(String filename, String[] command) throws IOException{file = new File("part2/"+filename);(file.exists()) {.delete();

}(Writer output = new BufferedWriter(new FileWriter(file))) {.write("#!/bin/bash");.write("\n");(int i = 0; i < command.length; i++).write("su --command="+"+command[i]+");.write("\n");.close();

}

}makeBackupSh(String source, String destination) throws IOException{file = new File("part2/backup.sh");(file.exists()) {.delete();

}(Writer output = new BufferedWriter(new FileWriter(file))) {.write("#!/bin/bash");.write("\n");.write("su --command="+" + "cp "+source + " " + destination +");.write("\n");.close();

}

}identRegSubnets() throws FileNotFoundException, IOException{.removeAllItems();.addItem("");file = new File("/etc/dhcp/dhcpd.conf");line;[] words;in = new BufferedReader(new FileReader(file));((line = in.readLine()) != null){(line.contains("subnet")){= line.split("\\s+");.addItem(words[1]);

}

}

}findMac(File source, String mac) throws FileNotFoundException, IOException{found = false;line;[] words;in = new BufferedReader(new FileReader(source));((line = in.readLine()) != null && found != true){(line.contains("hardware")){= line.split("\\s+");(words[3].equals(mac))= true;

}

}found;

}findSubnet(File source, String subnet) throws FileNotFoundException, IOException{found = false;line;[] words;

in = new BufferedReader(new FileReader(source));

((line = in.readLine()) != null && found != true){(line.contains("subnet")){= line.split("\\s+");(words[1].equals(subnet))= true;

}

}found;

}detectLastIP(String subnet) throws FileNotFoundException, IOException{lastIP = 255;file = new File("/etc/dhcp/dhcpd.conf");in = new BufferedReader(new FileReader(file));line;[] words;[] numb;endReached = false;(!(line = in.readLine()).contains("subnet "+subnet)) {}(!line.contains("host") || line != null){= in.readLine();(line == null){= true;;

}

}(!endReached){(!line.contains("fixed-address"))= in.readLine();= line.split("\\.");= words[3].split("\\;");= Integer.parseInt(numb[0]);

}lastIP;

}makeDHCPConf() throws IOException{("/etc/dhcp/dhcpd.conf","/etc/dhcp/backup/dhcpd.conf."+getTimestamp());com = "chmod +x part2/backup.sh";com1 = "gnome-terminal -x part2/backup.sh";{(com);(com1);

} catch (IOException ex) {}{.sleep(8000);

} catch (InterruptedException ex) {}file = new File("/etc/dhcp/dhcpd.conf");dhcpOption = dhcpAddOptions.getSelectedItem().toString();(dhcpOption){"подсеть":netDest = dhcpAddNetMac.getText();(!findSubnet(file,netDest)){netmask = dhcpAddNetmask.getText();gateway = (String) dhcpAddRouter.getValue();dns = (String) dhcpAddDns.getValue();(gateway == null)= "";(dns == null)= "";(Writer output = new BufferedWriter(new FileWriter(file, true))) {.write("\nsubnet "+netDest+" netmask "+netmask+" {"+"\n");.write("\t"+"option routers "+ gateway +";\n");.write("\t"+"option domain-name-servers "+ dns +";\n");.write("} #sub-network "+netDest+" end\n");.close();.showMessageDialog(this.dhcpAddDialog, "Подсеть " + netDest + "\nc маской сети " + netmask

+ "\nуспешно зарегистрирована");

}

}.showMessageDialog(this.dhcpAddDialog,

"Данная подсеть уже зарегистрирована",

1){fileNew=newFile("/etc/dhcp/dhcpd.conf.new");">"Ошибка регистрации подсети",.ERROR_MESSAGE);;"узел":subnetIn = dhcpAddSubnets.getSelectedItem().toString();line;[] words;lastIP;MAC = dhcpAddNetMac.getText();in = new BufferedReader(new FileReader(file));= subnetIn.split("\\.");= detectLastIP(subnetIn) - 1;(!findMac(file,MAC)){(lastIP > 1){fileNew = new File("/etc/dhcp/dhcpd.conf.new");

(fileNew.exists()) {.delete();

}(Writer output = new BufferedWriter(new FileWriter(fileNew))) {(!(line = in.readLine()).contains("subnet "+subnetIn)).write(line+"\n");.write(line+"\n");(int i = 0; i < 2; i++){= in.readLine();.write(line+"\n");

}.write("\n");.write("host h" + words[2] + "_" + lastIP + " {" + "\n");.write("\thardware ethernet " + MAC + " ;" + "\n");obtainIP = words[0] + "." + words[1] + "." + words[2] + "." + lastIP;.write("\tfixed-address " + obtainIP + ";\n");.write("\t}\n");((line = in.readLine()) != null).write(line+"\n");.close();input = new BufferedReader(new FileReader(fileNew));(Writer out = new BufferedWriter(new FileWriter(file))) {((line = input.readLine()) != null).write(line+"\n");

}.showMessageDialog(this.dhcpAddDialog, "Узлу с MAC-адресом " + MAC + " \nбудет выдан следующий IP-адрес: " + obtainIP);

}

}.showMessageDialog(this.dhcpAddDialog,

"В данной подсети нет свободного IP-адреса."

+ "\nПожалуйста, проверьте файл dhcpd.conf"

+ "\nили выберите другую подсеть.",

"Ошибка регистрации узла",.ERROR_MESSAGE);;

}.showMessageDialog(this.dhcpAddDialog,

"Узел с MAC-адресом: "+MAC

+ "\nуже зарегистрирован в сети",

"Ошибка регистрации узла",.ERROR_MESSAGE);

}

}prepareZoneFile(String pathfile, String zoneName) throws IOException{file = new File(pathfile);(Writer output = new BufferedWriter(new FileWriter(file))) {.write(";\n");.write("; BIND data file\n");.write(";\n");.write("$TTL 604800\n");.write("@