Skip to content

Commit a79b46e

Browse files
committed
small corrections
1 parent 0bec852 commit a79b46e

File tree

7 files changed

+79
-65
lines changed

7 files changed

+79
-65
lines changed

readme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Include:
2020
14) NTP-server.
2121
15) Host TCP-ping.
2222
16) SNMP-MRTG traffic monitor.
23-
17. Anonymous FTP-server.
23+
17) Anonymous FTP-server.
2424

2525
Need JRE-1.8:
2626

readme.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Include:
2020
14) NTP-server.
2121
15) Host TCP-ping.
2222
16) SNMP-MRTG traffic monitor.
23-
17. Anonymous FTP-server.
23+
17) Anonymous FTP-server.
2424

2525
Need JRE-1.8:
2626

src/main/java/my/harp07/PjFrame.java

+15-13
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,14 @@ public class PjFrame extends javax.swing.JFrame {
5858
public static Thread mrtgThread;
5959
public static int FW = 960;
6060
public static int FH = 600;
61+
public static ImageIcon iconOn = new ImageIcon(PjFrame.class.getResource("/img/go-green-krug-16.png"));
62+
public static ImageIcon iconOf = new ImageIcon(PjFrame.class.getResource("/img/stop-16.png"));
6163
public static List<String> lookAndFeelsDisplay = new ArrayList<>();
6264
public static List<String> lookAndFeelsRealNames = new ArrayList<>();
6365
public static String currentLAF = "de.muntjak.tinylookandfeel.TinyLookAndFeel";
6466
public static String currentTheme = "lib/themes/Default.theme";
6567
public static List<String> tinyTemes = new ArrayList<>();
66-
public static String zagolovok = "Pure Java Network Tools, v1.0.93, build 03-12-2023";
68+
public static String zagolovok = "Pure Java Network Tools, v1.0.94, build 03-12-2023";
6769

6870
public PjFrame() {
6971
initComponents();
@@ -118,7 +120,7 @@ public static void MyInstLF(String lf) {
118120
public static void InstallLF() {
119121
MyInstLF("de.muntjak.tinylookandfeel.TinyLookAndFeel");
120122
MyInstLF("javax.swing.plaf.metal.MetalLookAndFeel");
121-
MyInstLF("org.pushingpixels.substance.api.skin.SubstanceSaharaLookAndFeel");
123+
/*MyInstLF("org.pushingpixels.substance.api.skin.SubstanceSaharaLookAndFeel");
122124
MyInstLF("org.pushingpixels.substance.api.skin.SubstanceAutumnLookAndFeel");
123125
MyInstLF("org.pushingpixels.substance.api.skin.SubstanceCremeLookAndFeel");
124126
MyInstLF("org.pushingpixels.substance.api.skin.SubstanceCremeCoffeeLookAndFeel");
@@ -143,7 +145,7 @@ public static void InstallLF() {
143145
MyInstLF("org.pushingpixels.substance.api.skin.SubstanceBusinessLookAndFeel");
144146
MyInstLF("org.pushingpixels.substance.api.skin.SubstanceMarinerLookAndFeel");
145147
MyInstLF("org.pushingpixels.substance.api.skin.SubstanceCeruleanLookAndFeel");
146-
MyInstLF("org.pushingpixels.substance.api.skin.SubstanceTwilightLookAndFeel");
148+
MyInstLF("org.pushingpixels.substance.api.skin.SubstanceTwilightLookAndFeel");*/
147149
//
148150
/*MyInstLF("com.jtattoo.plaf.acryl.AcrylLookAndFeel");
149151
MyInstLF("com.jtattoo.plaf.aero.AeroLookAndFeel");
@@ -1794,8 +1796,8 @@ private void btnBooleanSyslogItemStateChanged(java.awt.event.ItemEvent evt) {//G
17941796
btnBooleanSyslog.setSelected(false);
17951797
return;
17961798
}
1797-
ImageIcon iconOn = new ImageIcon(getClass().getResource("/img/get-16.png"));
1798-
ImageIcon iconOf = new ImageIcon(getClass().getResource("/img/stop-16.png"));
1799+
//ImageIcon iconOn = new ImageIcon(getClass().getResource("/img/get-16.png"));
1800+
//ImageIcon iconOf = new ImageIcon(getClass().getResource("/img/stop-16.png"));
17991801
if (evt.getStateChange() == ItemEvent.SELECTED) {
18001802
PjSyslog.go(taSyslogResult);
18011803
btnBooleanSyslog.setText("Stop syslog-server ");
@@ -2013,8 +2015,8 @@ private void btnBooleanPingFloodItemStateChanged(java.awt.event.ItemEvent evt) {
20132015
btnBooleanPingFlood.setSelected(false);
20142016
return;
20152017
}
2016-
ImageIcon iconOn = new ImageIcon(getClass().getResource("/img/get-16.png"));
2017-
ImageIcon iconOf = new ImageIcon(getClass().getResource("/img/stop-16.png"));
2018+
//ImageIcon iconOn = new ImageIcon(getClass().getResource("/img/get-16.png"));
2019+
//ImageIcon iconOf = new ImageIcon(getClass().getResource("/img/stop-16.png"));
20182020
if (evt.getStateChange() == ItemEvent.SELECTED) {
20192021
PjPingFlood.go(taPingFloodResult);
20202022
btnBooleanPingFlood.setText("Stop Ping Flood ");
@@ -2038,8 +2040,8 @@ private void btnUdpFloodActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F
20382040
}//GEN-LAST:event_btnUdpFloodActionPerformed
20392041

20402042
private void btnBooleanTftpItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_btnBooleanTftpItemStateChanged
2041-
ImageIcon iconOn = new ImageIcon(getClass().getResource("/img/get-16.png"));
2042-
ImageIcon iconOf = new ImageIcon(getClass().getResource("/img/stop-16.png"));
2043+
//ImageIcon iconOn = new ImageIcon(getClass().getResource("/img/get-16.png"));
2044+
//ImageIcon iconOf = new ImageIcon(getClass().getResource("/img/stop-16.png"));
20432045
if (evt.getStateChange() == ItemEvent.SELECTED) {
20442046
btnBooleanTftp.setText("Stop TFTP-server ");
20452047
btnBooleanTftp.setIcon(iconOf);
@@ -2073,8 +2075,8 @@ private void btnTftpSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F
20732075
}//GEN-LAST:event_btnTftpSaveActionPerformed
20742076

20752077
private void btnBooleanNtpItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_btnBooleanNtpItemStateChanged
2076-
ImageIcon iconOn = new ImageIcon(getClass().getResource("/img/get-16.png"));
2077-
ImageIcon iconOf = new ImageIcon(getClass().getResource("/img/stop-16.png"));
2078+
//ImageIcon iconOn = new ImageIcon(getClass().getResource("/img/get-16.png"));
2079+
//ImageIcon iconOf = new ImageIcon(getClass().getResource("/img/stop-16.png"));
20782080
if (evt.getStateChange() == ItemEvent.SELECTED) {
20792081
btnBooleanNtp.setText("Stop NTP-server ");
20802082
btnBooleanNtp.setIcon(iconOf);
@@ -2110,8 +2112,8 @@ private void btnTcpPingClearActionPerformed(java.awt.event.ActionEvent evt) {//G
21102112
}//GEN-LAST:event_btnTcpPingClearActionPerformed
21112113

21122114
private void btnBooleanFtpItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_btnBooleanFtpItemStateChanged
2113-
ImageIcon iconOn = new ImageIcon(getClass().getResource("/img/get-16.png"));
2114-
ImageIcon iconOf = new ImageIcon(getClass().getResource("/img/stop-16.png"));
2115+
//ImageIcon iconOn = new ImageIcon(getClass().getResource("/img/get-16.png"));
2116+
//ImageIcon iconOf = new ImageIcon(getClass().getResource("/img/stop-16.png"));
21152117
if (evt.getStateChange() == ItemEvent.SELECTED) {
21162118
btnBooleanFtp.setText("Stop FTP-server ");
21172119
btnBooleanFtp.setIcon(iconOf);

src/main/java/my/harp07/tcp/FTPServer.java

+20-8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
import java.text.SimpleDateFormat;
44
import java.util.ArrayList;
55
import java.util.List;
6+
import javax.swing.ImageIcon;
7+
import static my.harp07.PjFrame.btnBooleanFtp;
8+
import static my.harp07.PjFrame.btnFtpSave;
9+
import static my.harp07.PjFrame.iconOn;
610
import static my.harp07.PjFrame.taFtpResult;
711
import static my.harp07.PjFrame.tfFtpFolder;
812
import org.apache.ftpserver.ConnectionConfig;
@@ -23,7 +27,7 @@
2327
public class FTPServer {
2428

2529
public static FtpServer server;
26-
public static Boolean running = false;
30+
//public static Boolean running = false;
2731
public static SimpleDateFormat sdtf = new SimpleDateFormat("dd.MM.yy HH:mm:ss");
2832
public static int timeout=999;
2933
public static int maxLogins=11;
@@ -81,21 +85,29 @@ public static void go() {
8185
taFtpResult.append("\nWritable = true");
8286
taFtpResult.append("\nFolder = " + tfFtpFolder.getText());
8387
taFtpResult.append("\nFTP-server main thread = " + Thread.currentThread().getName());
84-
running = true;
85-
} catch (FtpServerConfigurationException | FtpException ff) {
86-
taFtpResult.append("Exception at start FTP-server: " + ff.getMessage());
88+
//running = true;
89+
} catch (Exception ff) {
90+
taFtpResult.setText("");
91+
taFtpResult.append("\nException at start FTP-server: " + ff.getMessage());
92+
taFtpResult.append("\nFTP-server stopped = " + server.isStopped());
93+
btnBooleanFtp.setText("Run FTP-server ");
94+
btnBooleanFtp.setIcon(iconOn);
95+
btnFtpSave.setEnabled(true);
8796
}
8897
}
8998

9099
public static void stop() {
91100
try {
92101
server.stop();
93102
taFtpResult.setText("");
94-
taFtpResult.append("\nServer running = " + !server.isStopped());
95-
} catch (Exception ex) {
96-
java.util.logging.Logger.getLogger(FTPServer.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
103+
taFtpResult.append("\nFTP-server running = " + !server.isStopped());
104+
} catch (Exception ff) {
105+
//java.util.logging.Logger.getLogger(FTPServer.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
106+
taFtpResult.setText("");
107+
taFtpResult.append("\nException at stop FTP-server: " + ff.getMessage());
108+
//taFtpResult.append("\nFTP-server stopped = " + server.isStopped());
97109
}
98-
taFtpResult.append("\nServer shut down = " + server.isStopped());
110+
taFtpResult.append("\nFTP-server stopped = " + server.isStopped());
99111
}
100112

101113
}

src/main/java/my/harp07/udp/PjSyslog.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ public static void runEmbeddedSyslog(JTextArea ta) {
3333
}
3434
try {
3535
sd = new DatagramSocket(port);
36-
ta.append("udp-port " + port + " was free and START listen\n");
37-
ta.append("Service syslog START on udp-port " + port + ", potok = " + Thread.currentThread().getName() + " start\n");
36+
ta.append("\nUDP-port " + port + " was free and START listen");
37+
ta.append("\nService syslog START on udp-port " + port + ", potok = " + Thread.currentThread().getName() + " start\n");
3838
} catch (SocketException e) {
3939
frame.btnBooleanSyslog.setSelected(false);
40-
ta.append("Can't start listening: " + e.getMessage()+"\n");
40+
ta.append("\nException - can't start listening: " + e.getMessage()+"\n");
4141
//System.out.println("\nCan't start listening: " + e.getMessage());
4242
if (sd != null) {
4343
sd.close();

src/main/java/my/harp07/udp/SimpleNTPServer.java

+10-4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import java.io.IOException;
99
import java.net.DatagramPacket;
1010
import java.net.DatagramSocket;
11+
import static my.harp07.PjFrame.btnBooleanNtp;
12+
import static my.harp07.PjFrame.iconOn;
1113
import static my.harp07.PjFrame.spinnerNTP;
1214
import static my.harp07.PjFrame.taNtpResult;
1315

@@ -85,9 +87,9 @@ public void connect() throws IOException {
8587
if (port == 0) {
8688
port = socket.getLocalPort();
8789
}
88-
System.out.println("NTP-server running on port " + port + "/UDP");
90+
//System.out.println("NTP-server running on port " + port + "/UDP");
8991
taNtpResult.setText("");
90-
taNtpResult.append("NTP-server running on port " + port + "/UDP\n");
92+
taNtpResult.append("\nNTP-server running on port " + port + "/UDP\n");
9193
taNtpResult.append("NTP-server thread = " + Thread.currentThread().getName() + "\n");
9294
}
9395
}
@@ -192,8 +194,12 @@ public static void go() {
192194
final SimpleNTPServer timeServer = new SimpleNTPServer(port);
193195
try {
194196
timeServer.start();
195-
} catch (final IOException e) {
196-
e.printStackTrace();
197+
} catch (Exception e) {
198+
taNtpResult.append("\nException at start server = " + e.getMessage());
199+
btnBooleanNtp.setText("Run NTP-server ");
200+
btnBooleanNtp.setIcon(iconOn);
201+
spinnerNTP.setEnabled(true);
202+
//e.printStackTrace();
197203
}
198204
}
199205

src/main/java/my/harp07/udp/TFTPServer.java

+29-35
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
import java.util.logging.Level;
1919
import java.util.logging.LogManager;
2020
import java.util.logging.Logger;
21+
import static my.harp07.PjFrame.btnBooleanTftp;
22+
import static my.harp07.PjFrame.btnTftpSave;
23+
import static my.harp07.PjFrame.iconOn;
2124
import static my.harp07.PjFrame.taTftpResult;
2225
import static my.harp07.PjFrame.tfTftpFolder;
2326
import org.apache.commons.net.io.FromNetASCIIOutputStream;
@@ -762,50 +765,41 @@ void sendData(final TFTP tftp, final TFTPPacket data) throws IOException {
762765
}
763766

764767
public static void go() {
765-
/*if (args.length != 1) {
766-
System.out.println("You must provide 1 argument - the base path for the server to serve from.");
767-
System.exit(1);
768-
}*/
769-
770768
//TFTPServer ts;
771769
try {
772770
ts = new TFTPServer(new File(tfTftpFolder.getText()), new File(tfTftpFolder.getText()), ServerMode.GET_AND_PUT);
773771
ts.setSocketTimeout(2000);
774-
} catch (IOException ex) {
775-
java.util.logging.Logger.getLogger(TFTPServer.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
776-
}
777-
778-
jul.log(Level.INFO, "Fully multi-threaded TFTP Server running, folder = " + tfTftpFolder.getText());
779-
taTftpResult.setText("");
780-
taTftpResult.append("Fully multi-threaded TFTP Server running, folder = " + tfTftpFolder.getText());
781-
taTftpResult.append("\nserver port = " + ts.port_);
782-
taTftpResult.append("\nserver mode = " + ts.mode_);
783-
taTftpResult.append("\nserver read-folder = " + ts.serverReadDirectory_);
784-
taTftpResult.append("\nserver write-folder = " + ts.serverWriteDirectory_);
785-
taTftpResult.append("\nserver main-thread name = " + ts.serverThread.getName());
786-
//new InputStreamReader(System.in).read();
787-
//Scanner sc = new Scanner(System.in);
788-
/*new Thread(() -> {
789-
while (true) {
790-
if (btnTftpSave.isEnabled()) {
791-
ts.shutdown();
792-
jul.log(Level.INFO, "Server shut down.");
793-
taTftpResult.append("\nServer shut down.");
794-
//System.exit(0);
795-
}
796-
}
797-
}).start();*/
772+
jul.log(Level.INFO, "Fully multi-threaded TFTP Server running, folder = " + tfTftpFolder.getText());
773+
taTftpResult.setText("");
774+
taTftpResult.append("\nFully multi-threaded TFTP Server running, folder = " + tfTftpFolder.getText());
775+
taTftpResult.append("\nserver port = " + ts.port_);
776+
taTftpResult.append("\nserver mode = " + ts.mode_);
777+
taTftpResult.append("\nserver read-folder = " + ts.serverReadDirectory_);
778+
taTftpResult.append("\nserver write-folder = " + ts.serverWriteDirectory_);
779+
taTftpResult.append("\nserver main-thread name = " + ts.serverThread.getName());
780+
} catch (Exception ff) {
781+
//java.util.logging.Logger.getLogger(TFTPServer.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
782+
taTftpResult.setText("");
783+
taTftpResult.append("\nException at start TFTP-server: " + ff.getMessage());
784+
btnBooleanTftp.setText("Run TFTP-server ");
785+
btnBooleanTftp.setIcon(iconOn);
786+
btnTftpSave.setEnabled(true);
787+
}
798788
}
799789

800790
public static void stop() {
801-
ts.shutdown();
802791
try {
803-
taTftpResult.append("\nServer running = " + ts.isRunning());
804-
} catch (Exception ex) {
805-
java.util.logging.Logger.getLogger(TFTPServer.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
792+
ts.shutdown();
793+
taTftpResult.setText("");
794+
taTftpResult.append("\n\nServer running = " + ts.isRunning());
795+
//ts=null;
796+
//taTftpResult.append("\nServer shut down.");
797+
} catch (Exception ff) {
798+
//java.util.logging.Logger.getLogger(TFTPServer.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
799+
taTftpResult.setText("");
800+
taTftpResult.append("\nException at stop TFTP-server: " + ff.getMessage());
801+
ts=null;
806802
}
807-
ts=null;
808-
taTftpResult.append("\nServer shut down.");
809803
}
810804

811805
}

0 commit comments

Comments
 (0)