goshs

command module
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 8, 2023 License: MIT Imports: 12 Imported by: 0

README

Version GitHub GitHub go.mod Go version GitHub issues goreleaser Go Report Card

goshs-logo

goshs is a replacement for Python's SimpleHTTPServer. It allows uploading and downloading via HTTP/S with either self-signed certificate or user provided certificate and you can use HTTP basic auth.

goshs-screenshot

Features

  • Download or view files
    • Bulk download as .zip file
  • Upload files (Drag & Drop)
  • Basic Authentication
  • Transport Layer Security (HTTPS)
    • self-signed
    • provide own certificate
  • Non persistent clipboard
    • Download clipboard entries as .json file
  • WebDAV support
  • Read-Only and Upload-Only mode
  • Silent mode (no webserver output)
  • Retrieve json on cli

Installation

Release

You can download the executable from the release section

Go

go get -u github.com/patrickhener/goshs
go install github.com/patrickhener/goshs@latest

Build yourself

Building requirements are ugilfy-js and wt. After installing those 2 packages you can easily just:

git clone https://github.com/patrickhener/goshs.git
cd goshs
make build

Usage

> goshs -h

goshs v0.3.1
Usage: goshs [options]

Web server options:
  -i,  --ip           The ip/if-name to listen on             (default: 0.0.0.0)
  -p,  --port         The port to listen on                   (default: 8000)
  -d,  --dir          The web root directory                  (default: current working path)
  -w,  --webdav       Also serve using webdav protocol        (default: false)
  -wp, --webdav-port  The port to listen on for webdav        (default: 8001)
  -ro, --read-only    Read only mode, no upload possible      (default: false)
  -uo, --upload-only  Upload only mode, no download possible  (default: false)
  -si, --silent       Running without dir listing             (default: false)

TLS options:
  -s,  --ssl          Use TLS
  -ss, --self-signed  Use a self-signed certificate
  -sk, --server-key   Path to server key
  -sc, --server-cert  Path to server certificate

Authentication options:
  -b, --basic-auth    Use basic authentication (user:pass - user can be empty)

Misc options:
  -V  --verbose       Activate verbose log output             (default: false)
  -v                  Print the current goshs version

Usage examples:
  Start with default values:    	./goshs
  Start with wevdav support:    	./goshs -w
  Start with different port:    	./goshs -p 8080
  Start with self-signed cert:  	./goshs -s -ss
  Start with custom cert:       	./goshs -s -sk <path to key> -sc <path to cert>
  Start with basic auth:        	./goshs -b secret-user:$up3r$3cur3
  Start with basic auth empty user:	./goshs -b :$up3r$3cur3

Examples

Serve from your current directory

goshs

Serve from your current directory with webdav enabled on custom port

goshs -w -wp 8081

Serve from another directory

goshs -d /path/to/directory

Serve from port 1337

goshs -p 1337

Password protect the service

goshs -b secret-user:VeryS3cureP4$$w0rd

Please note: goshs uses HTTP basic authentication. It is recommended to use SSL option with basic authentication to prevent from credentials beeing transfered in cleartext over the line.

Use TLS connection

Self-Signed

goshs -s -ss

Provide own certificate

goshs -s -sk server.key -sc server.crt

Run in silent mode
This mode will omit the dir listing on the web interface. Also you will not have access to the clipboard or upload form. Still you could upload a file using the corresponding post request (see examples).

goshs -si

Retrieve the directory listing in json format
You can now retrieve the directory listing in json format. This is meant to be used with curl for example in environments where you do not have a browser on hand.

curl -s localhost:8000/?json | jq
[
  {
    "name": ".git/",
    "is_dir": true,
    "is_symlink": false,
    "symlink_target": "",
    "extension": "",
    "size_bytes": 4096,
    "last_modified": "2023-02-28T15:38:11.982+01:00"
  },
  {
    "name": ".github/",
    "is_dir": true,
    "is_symlink": false,
    "symlink_target": "",
    "extension": "",
    "size_bytes": 4096,
    "last_modified": "2023-02-28T10:27:35.524+01:00"
  },
  {
    "name": ".gitignore",
    "is_dir": false,
    "is_symlink": false,
    "symlink_target": "",
    "extension": ".gitignore",
    "size_bytes": 48,
    "last_modified": "2023-02-20T07:58:46.436+01:00"
  },
  ... snip ...

Or with path:

curl -s localhost:8000/utils?json | jq
[
  {
    "name": "utils.go",
    "is_dir": false,
    "is_symlink": false,
    "symlink_target": "",
    "extension": ".go",
    "size_bytes": 2218,
    "last_modified": "2023-02-28T15:28:54.783+01:00"
  },
  {
    "name": "utils_test.go",
    "is_dir": false,
    "is_symlink": false,
    "symlink_target": "",
    "extension": ".go",
    "size_bytes": 2012,
    "last_modified": "2023-02-28T15:28:12.748+01:00"
  }
]

Credits

A special thank you goes to sc0tfree for inspiring this project with his project updog written in Python.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package ca will handle the creation of certificates for TSL encrypted communication Credits: Shane Utt https://shaneutt.com/blog/golang-ca-and-signed-cert-go/
Package ca will handle the creation of certificates for TSL encrypted communication Credits: Shane Utt https://shaneutt.com/blog/golang-ca-and-signed-cert-go/
Package clipboard will provide the functionality of a clipboard
Package clipboard will provide the functionality of a clipboard
Package httpserver will contain the main httpserver functionality of goshs
Package httpserver will contain the main httpserver functionality of goshs
Package logger will take care of all logging messages using logrus
Package logger will take care of all logging messages using logrus
Package utils has general utility functions
Package utils has general utility functions
Package ws will provide websocket functionality to keep the browser windows in sync
Package ws will provide websocket functionality to keep the browser windows in sync

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL