Skip to content

Commit 6ce5b7d

Browse files
committed
Added Public Ip to server, fixed README.md, included fileserver.html, style.css
1 parent 0a8110f commit 6ce5b7d

File tree

5 files changed

+163
-3
lines changed

5 files changed

+163
-3
lines changed

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@ TO BE ADDED
1717
# Modules
1818
Cat - prints file contents
1919
UCat - prints url contents
20+
List - lists files in directory
21+
CD - changes current directory
22+
Help - prints the helpscreen
2023
CLS - clears the screen
2124
Exit - exits the program
22-
Help - prints the helpscreen
23-
Scan - scans a file for a keyword
25+
Scan - scans a file for a keyword
26+
Json - prints beautified json
27+
Fileshare - shares files to a server
28+
Rename - renames a file

src/main/java/de/jo/util/Strings.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
import de.jo.modules.Module;
99
import de.jo.modules.impl.other.ModuleHelp;
1010

11+
import java.io.BufferedReader;
1112
import java.io.IOException;
13+
import java.io.InputStreamReader;
14+
import java.net.URL;
1215
import java.nio.charset.StandardCharsets;
1316
import java.util.List;
1417

@@ -196,4 +199,16 @@ public static String sha256(String input) {
196199
return Hashing.sha256().hashString(input, StandardCharsets.UTF_8).toString();
197200
}
198201

202+
public static String publicIP() {
203+
try {
204+
URL whatismyip = new URL("http://checkip.amazonaws.com");
205+
BufferedReader in = new BufferedReader(new InputStreamReader(
206+
whatismyip.openStream()));
207+
String ip = in.readLine();
208+
return ip;
209+
} catch(Exception ex) {
210+
return null;
211+
}
212+
}
213+
199214
}

src/main/java/de/jo/web/FileServer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public void handle(HttpExchange ex) throws IOException {
108108
}
109109
});
110110
server.start();
111-
System.out.println(ConsoleColors.YELLOW+"> "+ConsoleColors.YELLOW_BRIGHT+"Started server on port: "+port);
111+
System.out.println(ConsoleColors.YELLOW+"> "+ConsoleColors.YELLOW_BRIGHT+"Started server: "+Strings.publicIP()+", on port: "+port);
112112
}
113113

114114
/**

src/main/resources/fileserver.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>%TITLE%</title>
5+
<link rel="stylesheet" href="style.css">
6+
</head>
7+
<body>
8+
<div id="center">
9+
<h1 class="centerelement"><u>%TITLE%</u></h1>
10+
</div>
11+
<div id="description">%DESCRIPTION%</div>
12+
<div>
13+
<ul>
14+
%FILES%
15+
</ul>
16+
</div>
17+
</body>
18+
</html>

src/main/resources/style.css

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
body {
2+
background-color: #333333;
3+
color: #FFFFFF;
4+
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
5+
font-weight: lighter;
6+
font-size: 1.5vw;
7+
}
8+
9+
#center {
10+
display: flex;
11+
align-items: center;
12+
width: 100vw;
13+
}
14+
15+
h1 {
16+
font-size: 4vw;
17+
margin: auto;
18+
margin-bottom: 10vh;
19+
text-transform: uppercase;
20+
}
21+
22+
#description {
23+
background-color: #393939;
24+
font-size: 2vw;
25+
}
26+
27+
28+
ul {
29+
list-style: none;
30+
margin: 0;
31+
padding: 0;
32+
}
33+
34+
li {
35+
background-color: #393939;
36+
list-style: none;
37+
height: 10vh;
38+
margin-top: 10px;
39+
display: grid;
40+
grid-template-columns: 75% 25%;
41+
grid-template-rows: 50% 50%;
42+
}
43+
44+
li:hover {
45+
background-color: #3c3c3c;
46+
list-style: none;
47+
height: 10vh;
48+
margin-top: 10px;
49+
display: grid;
50+
grid-template-columns: 75% 25%;
51+
grid-template-rows: 50% 50%;
52+
}
53+
54+
li .filename {
55+
grid-column: span 1;
56+
font-size: 2vw;
57+
padding: 10px;
58+
text-decoration: underline;
59+
60+
}
61+
62+
li .filename:hover {
63+
grid-column: span 1;
64+
font-size: 2.2vw;
65+
padding: 10px;
66+
text-decoration: underline;
67+
68+
}
69+
70+
li .filehash {
71+
font-size: 2vh;
72+
grid-column: span 1;
73+
padding: 10px;
74+
text-transform: uppercase;
75+
}
76+
77+
li .filehash:hover {
78+
grid-column: span 1;
79+
padding: 10px;
80+
text-transform: uppercase;
81+
}
82+
83+
li .filehash button {
84+
font-size: 1.8vh;
85+
border-style: none;
86+
color: white;
87+
background-color: #444444;
88+
}
89+
90+
li .filehash button:hover {
91+
font-size: 1.9vh;
92+
border-style: none;
93+
color: white;
94+
}
95+
96+
97+
98+
li .filelink {
99+
grid-column: span 1;
100+
grid-row: span 2;
101+
border-style: none;
102+
background-color: #363636;
103+
font-style: normal;
104+
color: white;
105+
}
106+
li .filelink:hover {
107+
grid-column: span 1;
108+
grid-row: span 2;
109+
border-style: none;
110+
background-color: #333333;
111+
font-style: normal;
112+
}
113+
li .filelink a {
114+
color: white;
115+
text-decoration: none;
116+
font-size: 3vh;
117+
}
118+
li .filelink a:hover {
119+
color: #CCCCFF;
120+
text-decoration: none;
121+
font-size: 3.2vh;
122+
}

0 commit comments

Comments
 (0)