Compare commits

...

4 Commits

Author SHA1 Message Date
vxclutch
645fdc37d8 maint: remove deps and add docs 2026-06-04 07:30:08 -04:00
vxclutch
35d908cd73 maint: update todo 2026-06-03 08:26:20 -04:00
vxclutch
f188264f39 maint: done with todo 2026-06-03 08:25:50 -04:00
vxclutch
1436b8cf2f save 2026-06-03 08:23:45 -04:00
7 changed files with 42 additions and 26 deletions

View File

@@ -1 +1,21 @@
# LASH (Local Area Share HTTP)
## Usage
Using lash is pretty simple. You just provide any amount of command line
arguments and it will generate a share link, and a code. You either go-to
http://<your-local-ip>:port or goto http://<your-share-link> to access the
files.
## Building from Source
Lash only has one dependency and that it is Go >= 1.26.3. To build it you just
run either of the two following commands.
```sh
$ make
```
or
```sh
$ go build -o lash ./bin/main.go
```

7
TODO
View File

@@ -1,6 +1 @@
maint: document more
feat: improve flags
feat: replace uuid dep with custom id generator
feat: multiple files
fix: remove `_` prefix
fix: make mDNS only build on windows
feat: sumbit code with press of enter key

View File

@@ -37,7 +37,7 @@ func main() {
errx.Log("Your share link is %s", share.GenerateShareLink(*port))
errx.Log("Your token is \033[1;92m%s\033[0m", lash.Token)
errx.Log("starting server at http://0.0.0.0:%d", *port)
errx.Log("starting server at http://%s:%d", share.GetLocalIP(), *port)
if err := server.ListenAndServe(); err != nil {
errx.FatalPerror(err)
}

2
go.mod
View File

@@ -1,5 +1,3 @@
module lash
go 1.26.3
require github.com/google/uuid v1.6.0

2
go.sum
View File

@@ -1,2 +0,0 @@
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=

View File

@@ -34,6 +34,10 @@ var keys []string = []string{
"wash",
"vote",
"onyx",
"snow",
"john",
"json",
"fang",
}
func Generate(n int) (code string) {

View File

@@ -7,7 +7,6 @@ import (
"lash"
"lash/internal/errx"
"net/http"
"os"
"strconv"
)
@@ -47,36 +46,38 @@ func (h FileHandler) APIHandler(w http.ResponseWriter, r *http.Request) {
func (h FileHandler) FileHandler(w http.ResponseWriter, r *http.Request) {
if sent >= h.Ctx.N && h.Ctx.N != -1 {
w.WriteHeader(http.StatusTooManyRequests)
os.Exit(0)
http.Error(w, "Too many requests", http.StatusTooManyRequests)
return
}
w.WriteHeader(http.StatusOK)
filename := h.FileData[0].FileName
if len(h.FileData) > 1 {
filename = "lash.zip"
}
w.Header().Set("Content-Disposition", fmt.Sprintf(`attachment; filename="%s"`, filename))
w.Header().Set("Content-Type", "application/octet-stream")
if len(h.FileData) == 1 {
w.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=%s", h.FileData[0].FileName))
w.Header().Set("Content-Type", "application/octet-stream")
w.Header().Set("Content-Length", strconv.Itoa(len(h.FileData[0].FileName)))
w.Write(h.FileData[0].Contents)
w.Header().Set("Content-Length", strconv.Itoa(len(h.FileData[0].Contents)))
w.WriteHeader(http.StatusOK)
_, _ = w.Write(h.FileData[0].Contents)
} else {
w.Header().Set("Content-Disposition", "attachment; filename=lash.zip")
w.Header().Set("Content-Type", "application/octet-stream")
w.WriteHeader(http.StatusOK)
zw := zip.NewWriter(w)
defer zw.Close()
for _, f := range h.FileData {
w, err := zw.Create(f.FileName)
fw, err := zw.Create(f.FileName)
if err != nil {
errx.FatalPerror(err)
}
_, err = w.Write(f.Contents)
_, err = fw.Write(f.Contents)
if err != nil {
errx.FatalPerror(err)
}
}
}
sent++
}