Skip to content

Commit

Permalink
Added Public Ip to server, fixed README.md, included fileserver.html,…
Browse files Browse the repository at this point in the history
… style.css
  • Loading branch information
CommandJoo committed Oct 29, 2023
1 parent 0a8110f commit 6ce5b7d
Show file tree
Hide file tree
Showing 5 changed files with 163 additions and 3 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ TO BE ADDED
# Modules
Cat - prints file contents
UCat - prints url contents
List - lists files in directory
CD - changes current directory
Help - prints the helpscreen
CLS - clears the screen
Exit - exits the program
Help - prints the helpscreen
Scan - scans a file for a keyword
Scan - scans a file for a keyword
Json - prints beautified json
Fileshare - shares files to a server
Rename - renames a file
15 changes: 15 additions & 0 deletions src/main/java/de/jo/util/Strings.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
import de.jo.modules.Module;
import de.jo.modules.impl.other.ModuleHelp;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.List;

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

public static String publicIP() {
try {
URL whatismyip = new URL("http://checkip.amazonaws.com");
BufferedReader in = new BufferedReader(new InputStreamReader(
whatismyip.openStream()));
String ip = in.readLine();
return ip;
} catch(Exception ex) {
return null;
}
}

}
2 changes: 1 addition & 1 deletion src/main/java/de/jo/web/FileServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void handle(HttpExchange ex) throws IOException {
}
});
server.start();
System.out.println(ConsoleColors.YELLOW+"> "+ConsoleColors.YELLOW_BRIGHT+"Started server on port: "+port);
System.out.println(ConsoleColors.YELLOW+"> "+ConsoleColors.YELLOW_BRIGHT+"Started server: "+Strings.publicIP()+", on port: "+port);
}

/**
Expand Down
18 changes: 18 additions & 0 deletions src/main/resources/fileserver.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html>
<head>
<title>%TITLE%</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="center">
<h1 class="centerelement"><u>%TITLE%</u></h1>
</div>
<div id="description">%DESCRIPTION%</div>
<div>
<ul>
%FILES%
</ul>
</div>
</body>
</html>
122 changes: 122 additions & 0 deletions src/main/resources/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
body {
background-color: #333333;
color: #FFFFFF;
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
font-weight: lighter;
font-size: 1.5vw;
}

#center {
display: flex;
align-items: center;
width: 100vw;
}

h1 {
font-size: 4vw;
margin: auto;
margin-bottom: 10vh;
text-transform: uppercase;
}

#description {
background-color: #393939;
font-size: 2vw;
}


ul {
list-style: none;
margin: 0;
padding: 0;
}

li {
background-color: #393939;
list-style: none;
height: 10vh;
margin-top: 10px;
display: grid;
grid-template-columns: 75% 25%;
grid-template-rows: 50% 50%;
}

li:hover {
background-color: #3c3c3c;
list-style: none;
height: 10vh;
margin-top: 10px;
display: grid;
grid-template-columns: 75% 25%;
grid-template-rows: 50% 50%;
}

li .filename {
grid-column: span 1;
font-size: 2vw;
padding: 10px;
text-decoration: underline;

}

li .filename:hover {
grid-column: span 1;
font-size: 2.2vw;
padding: 10px;
text-decoration: underline;

}

li .filehash {
font-size: 2vh;
grid-column: span 1;
padding: 10px;
text-transform: uppercase;
}

li .filehash:hover {
grid-column: span 1;
padding: 10px;
text-transform: uppercase;
}

li .filehash button {
font-size: 1.8vh;
border-style: none;
color: white;
background-color: #444444;
}

li .filehash button:hover {
font-size: 1.9vh;
border-style: none;
color: white;
}



li .filelink {
grid-column: span 1;
grid-row: span 2;
border-style: none;
background-color: #363636;
font-style: normal;
color: white;
}
li .filelink:hover {
grid-column: span 1;
grid-row: span 2;
border-style: none;
background-color: #333333;
font-style: normal;
}
li .filelink a {
color: white;
text-decoration: none;
font-size: 3vh;
}
li .filelink a:hover {
color: #CCCCFF;
text-decoration: none;
font-size: 3.2vh;
}

0 comments on commit 6ce5b7d

Please sign in to comment.