we're back

This commit is contained in:
delorean 2024-08-18 20:19:17 -05:00
parent 8459f9e4c8
commit e69c2a6685
17 changed files with 144 additions and 218 deletions

0
.dockerignore Normal file → Executable file
View File

1
.gitignore vendored Normal file → Executable file
View File

@ -1,3 +1,4 @@
files/
*.db
hardfiles
todo

View File

@ -1,12 +0,0 @@
FROM golang:1.21-alpine as builder
WORKDIR /build
COPY go.mod go.sum ./
RUN go mod download
COPY *.go ./
RUN go build -o hardfiles main.go
FROM golang:1.21-alpine as app
WORKDIR /app
COPY --from=builder /build/hardfiles .
RUN mkdir files
CMD ["./hardfiles"]

0
LICENSE Normal file → Executable file
View File

0
README.md Normal file → Executable file
View File

0
config.toml Normal file → Executable file
View File

View File

@ -1,11 +0,0 @@
services:
hardfiles:
container_name: hardfiles
image: git.supernets.org/supernets/hardfiles:latest
build: .
volumes:
- "$PWD/files:/app/files"
- "$PWD/www:/app/www"
- "$PWD/config.toml:/app/config.toml"
ports:
- "5000:5000"

2
go.mod Normal file → Executable file
View File

@ -12,6 +12,8 @@ require (
)
require (
github.com/alecthomas/chroma/v2 v2.13.0 // indirect
github.com/dlclark/regexp2 v1.11.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
golang.org/x/net v0.17.0 // indirect

4
go.sum Normal file → Executable file
View File

@ -1,8 +1,12 @@
github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8=
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/alecthomas/chroma/v2 v2.13.0 h1:VP72+99Fb2zEcYM0MeaWJmV+xQvz5v5cxRHd+ooU1lI=
github.com/alecthomas/chroma/v2 v2.13.0/go.mod h1:BUGjjsD+ndS6eX37YgTchSEG+Jg9Jv1GiZs9sqPqztk=
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dlclark/regexp2 v1.11.0 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxKI=
github.com/dlclark/regexp2 v1.11.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0=
github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=

24
main.go Normal file → Executable file
View File

@ -6,6 +6,7 @@ import (
"net/http"
"os"
"strconv"
"strings"
"time"
"github.com/BurntSushi/toml"
@ -110,13 +111,11 @@ func Exists(path string) bool {
}
func UploadHandler(w http.ResponseWriter, r *http.Request) {
// expiry time
var ttl int64
ttl = 0
var ttl int64 = 0 //expiration
file, _, err := r.FormFile("file")
if err != nil {
log.Error().Err(err).Msg("empty file form field")
w.WriteHeader(http.StatusBadRequest)
return
}
@ -180,9 +179,11 @@ func UploadHandler(w http.ResponseWriter, r *http.Request) {
hostedurl := "https://" + conf.VHost + "/uploads/" + name
w.Header().Set("Location", hostedurl)
if strings.Contains(name, "jpeg") || strings.Contains(name, "png") || strings.Contains(name, "jpg") || strings.Contains(name, "txt") || strings.Contains(name, "csv") || strings.Contains(name, "pdf") {
w.Header().Set("Location", hostedurl)
}
w.WriteHeader(http.StatusSeeOther)
w.Write([]byte(hostedurl))
w.Write([]byte(hostedurl + "\n"))
}
func Cull() {
@ -229,6 +230,7 @@ func main() {
if err = landlock.V2.BestEffort().RestrictPaths(
landlock.RWDirs(conf.FileFolder),
landlock.RWDirs(conf.Webroot),
// landlock.RWDirs("/tmp"),
landlock.RWFiles(conf.DBFile),
); err != nil {
log.Warn().Err(err).Msg("could not landlock")
@ -279,10 +281,12 @@ func main() {
go Cull()
serv := &http.Server{
Addr: ":" + conf.LPort,
Handler: r,
ErrorLog: nil,
IdleTimeout: 20 * time.Second,
Addr: ":" + conf.LPort,
Handler: r,
ErrorLog: nil,
IdleTimeout: 60 * time.Second,
ReadTimeout: 600 * time.Second,
WriteTimeout: 600 * time.Second,
}
log.Warn().Msg("shredding is only effective on HDD volumes")

BIN
www/delirious.gif Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 290 KiB

0
www/fist.ico Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

0
www/header.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 63 KiB

After

Width:  |  Height:  |  Size: 63 KiB

302
www/index.html Normal file → Executable file
View File

@ -3,26 +3,107 @@
<head>
<script type="text/javascript" src="//code.jquery.com/jquery-1.10.2.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="The Hardest file hosting solution, creating by the Hardest people online."/>
<link rel="icon" href="fist.ico">
<title>HARDFILES</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Rajdhani:wght@300;400;500;600;700&display=swap" rel="stylesheet">
<style>
body {
font-family: sans-serif;
background-image: url('https://media.tenor.com/fYnd0R6F-0UAAAAC/gun-revolver.gif');
background-size: cover;
background-position: center;
@keyframes rainbowbtn {
0%{background-color: lime;}
10%{background-color: red;}
20%{background-color: purple;}
30%{background-color: hotpink;}
40%{background-color: orange;}
50%{background-color: yellow;}
60%{background-color: turquoise;}
70%{background-color: aqua;}
80%{background-color: cyan;}
90%{background-color: blue;}
100%{background-color: lime;}
}
@media (prefers-color-scheme: dark) {
@keyframes rainbowbox {
0%{color: lime; border: 1px dashed lime;}
10%{color: red; border: 1px dashed red;}
20%{color: purple; border: 1px dashed purple;}
30%{color: hotpink; border: 1px dashed hotpink;}
40%{color: orange; border: 1px dashed orange;}
50%{color: yellow; border: 1px dashed yellow;}
60%{color: turquoise; border: 1px dashed turquoise;}
70%{color: aqua; border: 1px dashed aqua;}
80%{color: cyan; border: 1px dashed cyan;}
90%{color: blue; border: 1px dashed blue;}
100%{color: lime; border: 1px dashed lime;}
}
@media (prefers-color-scheme: dark) {
body {
overflow: hidden;
background: black;
background-image: url('https://media.tenor.com/fYnd0R6F-0UAAAAC/gun-revolver.gif');
background-image: url('revolver.gif');
background-size: cover;
background-position: center;
color: white;
}
}
.container {
@media (min-width: 768px) {
body {
background-image: url('delirious.gif') !important;
}
.container {
width: 750px;
}
.hf {
font-size: 3rem;
}
.hflogo {
width: 50% !important;
}
#fupload {
width: 20rem;
}
.subform {
margin-top: 0 !important;
}
}
@media (min-width: 992px) {
.container {
width: 970px;
}
}
@media (min-width: 1200px) {
.container {
width: 1170px;
}
.hf {
font-size: 5rem;
}
#curl {
display: block !important;
}
}
body {
font-family: sans-serif;
background-image: url('pentagram.gif');
background-size: cover;
background-position: center;
}
.container {
padding-right: 15px;
padding-left: 15px;
margin-right: auto;
@ -33,142 +114,14 @@
justify-content: center;
height: 100vh;
}
@media (min-width: 768px) {
.container {
width: 750px;
}
.hf {
font-size: 3rem;
}
.hflogo {
width: 50% !important;
}
}
@media (min-width: 992px) {
.container {
width: 970px;
}
}
@media (min-width: 1200px) {
.container {
width: 1170px;
}
.hf {
font-size: 5rem;
}
}
input,select {
margin-bottom: 1em;
}
.file-upload{
display:block;
text-align:center;
font-family: Helvetica, Arial, sans-serif;
font-size: 12px;
width: 300px;
}
.file-upload .file-select{
display:block;
border: 2px solid #dce4ec;
color: black;
cursor:pointer;
height:40px;
line-height:40px;
text-align:left;
background:#FFFFFF;
overflow:hidden;
position:relative;
}
.file-upload .file-select .file-select-button{
background:#dce4ec;
padding:0 10px;
display:inline-block;
height:40px;
line-height:40px;
}
.file-upload .file-select .file-select-name{
line-height:40px;
display:inline-block;
padding:0 10px;
}
.file-upload .file-select:hover{
border-color:red;
transition:all .2s ease-in-out;
-moz-transition:all .2s ease-in-out;
-webkit-transition:all .2s ease-in-out;
-o-transition:all .2s ease-in-out;
}
.file-upload .file-select:hover .file-select-button{
background:red;
color:#FFFFFF;
transition:all .2s ease-in-out;
-moz-transition:all .2s ease-in-out;
-webkit-transition:all .2s ease-in-out;
-o-transition:all .2s ease-in-out;
}
.file-upload.active .file-select{
border-color:red;
transition:all .2s ease-in-out;
-moz-transition:all .2s ease-in-out;
-webkit-transition:all .2s ease-in-out;
-o-transition:all .2s ease-in-out;
}
.file-upload.active .file-select .file-select-button{
background:red;
color:#FFFFFF;
transition:all .2s ease-in-out;
-moz-transition:all .2s ease-in-out;
-webkit-transition:all .2s ease-in-out;
-o-transition:all .2s ease-in-out;
}
.file-upload .file-select input[type=file]{
z-index:100;
cursor:pointer;
position:absolute;
height:100%;
width:100%;
top:0;
left:0;
opacity:0;
filter:alpha(opacity=0);
}
.file-upload .file-select.file-select-disabled{
opacity:0.65;
}
.file-upload .file-select.file-select-disabled:hover{
cursor:default;
display:block;
border: 2px solid #dce4ec;
color: red;
cursor:pointer;
height:40px;
line-height:40px;
margin-top:5px;
text-align:left;
background:#FFFFFF;
overflow:hidden;
position:relative;
}
.file-upload .file-select.file-select-disabled:hover .file-select-button{
background:#dce4ec;
color:#666666;
padding:0 10px;
display:inline-block;
height:40px;
line-height:40px;
}
.file-upload .file-select.file-select-disabled:hover .file-select-name{
line-height:40px;
display:inline-block;
padding:0 10px;
}
.subform {
.subform {
display: flex;
flex-direction: column;
align-items: center;
}
button {
button {
display: inline-block;
border: 0;
outline: 0;
@ -193,64 +146,49 @@
-webkit-text-size-adjust:none;
box-shadow: 0 1px 2px rgba(0,0,0,.15);
}
button:hover {
background: #c93c1d;
-webkit-transition:all .25s ease-in-out;
-moz-transition:all .25s ease-in-out;
-o-transition:all .25s ease-in-out;
transition:all .25s ease-in-out;
button:hover {
animation: rainbowbtn 0.2s infinite;
color:black !important;
}
button:active {
background: #ae3318;
}
button.light {
button.light {
background: #fff;
color: #555759;
}
button.light:hover {
background: red;
color: #fff;
}
.hflogo {
.hflogo {
width: 90%;
}
input {
animation: rainbowbox 6s infinite;
cursor: pointer;
}
.litfont {
font-family: "Source Code Pro", monospace;
font-optical-sizing: auto;
font-style: normal;
}
</style>
</head>
<body>
<div class="container">
<img src="header.png" class="hflogo" alt="supernets" style="margin-top: 10rem;">
<h2 style="font-size: 1rem; color: #ffffff; font-weight: 200;">curl -F file=@example.png https://hardfiles.org/</h1>
<form method="POST" class="subform" enctype="multipart/form-data">
<div class="file-upload" style="display: flex; justify-content: center; width: 25rem;">
<div class="file-select" style="width: 100%;">
<div class="file-select-button" id="fileName">Browse</div>
<div class="file-select-name" id="noFile" style="cursor: pointer;">No file chosen...</div>
<input type="file" name="file" id="chooseFile">
</div>
<img src="header.png" class="hflogo" alt="hardfiles" style="margin-top: 3rem;">
<h2 id="curl" class="litfont" style="display: none; font-size: 1rem; color: #ffffff; text-align: center; font-weight: lighter;">curl -F file=@example.png https://hardfiles.org/</h1>
<form method="POST" class="subform" enctype="multipart/form-data" style="margin-top: 0.5rem;">
<div style="display: flex; align-items: center; justify-content: center;">
<input type="file" id="fupload" name="file" style="background-color: black; padding: 12px; border-radius: 5px; color: white;" />
<button class="light" type="submit" style="margin-left: 0.7rem;">up</button>
</div>
</form>
<p style="color: white; font-weight: 300;">⚠️ Uploads are erased after 24 hours</p>
<p style="color: white; font-weight: bold; font-size:0.8rem;" class="litfont">⚠️ Uploads are destroyed after 24 hours</p>
</div>
<div style="position: relative;">
<a href="https://supernets.org/" target="_blank" style="position: absolute; bottom: 10px; right:10px; display: flex; align-items: center; text-decoration: none;">
<p style="font-weight:200; color:#ffffff">A SUPERNETS</p>
<img src="https://git.supernets.org/assets/img/logo.png" width="30px" style="margin: 0 5px;">
<p style="font-weight:200; color: #ffffff">SERVICE</p>
<div id="callingcard" style="position: relative;">
<a href="https://supernets.org/" target="_blank" style="position: absolute; bottom: 20px; right:1px; display: flex; align-items: center; text-decoration: none;">
<img src="supernets_logo.png" width="40px;">
</a>
</div>
</body>
</html>
<script>
$('#chooseFile').bind('change', function () {
var filename = $("#chooseFile").val();
if (/^\s*$/.test(filename)) {
$(".file-upload").removeClass('active');
$("#noFile").text("No file chosen...");
}
else {
$(".file-upload").addClass('active');
$("#noFile").text(filename.replace("C:\\fakepath\\", ""));
}
});
</script>

BIN
www/pentagram.gif Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 962 KiB

BIN
www/revolver.gif Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 542 KiB

BIN
www/supernets_logo.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB