Giter VIP home page Giter VIP logo

forestnode-io / oneshot Goto Github PK

View Code? Open in Web Editor NEW
331.0 10.0 9.0 2.65 MB

A first-come first-served single-fire HTTP server. Easily transfer files to and from your terminal and any browser.

Home Page: https://www.oneshot.uno

License: MIT License

Go 87.62% Makefile 0.58% Shell 1.18% Emacs Lisp 0.09% Roff 2.61% JavaScript 0.32% TypeScript 5.87% HTML 1.61% HCL 0.11%
cli command-line file-transfer nat-traversal p2p terminal upnp-portmapper webrtc

oneshot's People

Contributors

bbigras avatar ericonr avatar homiermorphism avatar kianmeng avatar lukasnxyz avatar raphaelreyna avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

oneshot's Issues

Send command uses public IP address instead of private.

Describe the bug
I don't know if this is in purpose, but I've been using oneshot for a while now and it's always used my computers private IP address (LAN). I downloaded oneshot-bin via paru today and ran it trying to transfer a pdf file and it opened the server on my LAN's public_ip:8080 instead of my machine's private_ip:8080.

To Reproduce
oneshot send "path/to/file.pdf"

Expected behavior
listening on http://private_ip:8080

Output and error messages
listening on http://public_ip:8080

Desktop

  • OS: Arch Linux
  • Kernel Version: 6.6.10-arch1-1

The ability for oneshot to print/return information about the GET request (for oidc flows)

When doing development / debug / testing of oauth/openid flows - the interactive web browser portion finishes with a redirect to a URL that is meant to receive the authorisation code in a URL param (at which point it will go and do some code exchanges).

Scripting testing of this in something like bash is painful - but I think oneshot with very minimal additions could help out.

As a proof of concept - I used oneshot like this

 oneshot -D -S 'echo "$QUERY_STRING"'

and set up my oauth redirect to http://127.0.0.1:8080.

I initiated my oauth flow in bash, launched a browser to do the login portion, and see that the page then redirects to oneshot with a GET of

http://127.0.0.1:8080?code=ABCDEFGH&state=XYZ

(i.e. the browser shows the output of the shell/CGI and then exits .. code=ABCDEFGH&state=XYZ)

However, I have no way of getting that information out of the invocation of oneshot in my bash script. I was thinking of a series of command line flags that would instruct oneshot to print this information on the end of the request.

So something like

--echo-from-client query_string

where the sky is the limit for what details of the client could be shown. I'd possibly start with any of the variables that are in the environment of the CGI launch.

query_string
http_user_agent
remote_host
http_accept

So the expected invocation pattern would be

QUERY=$(oneshot -q -D -S 'echo "Thanks"' --echo-from-client query_string)

I realise this is a bit outside the box from what oneshot was intended for - but does fall into the category of things that I need a http server that only responds once for!

Powershell path parsing problem (Windows)

When the -s flag is used to pass in a shell to use, oneshot parses the path as having double slashes. This then leads to a 'file not found' error.

example: C:\Windows\System32\WindowsPowerShell\v1\powershell.exe -> C:\Windows\System32\WindowsPowerShell\v1\powershell.exe

Compiling: cannot load embed: malformed module path "embed": missing dot in first path element

I attempted to compile it from source. I ran git clone https://github.com/raphaelreyna/oneshot.git && cd oneshot && sudo make install and I got the following output:

go build -ldflags "-X github.com/raphaelreyna/oneshot/cmd.version=`git describe --tags --abbrev=0` -X github.com/raphaelreyna/oneshot/cmd.date="`date +"%d-%B-%Y"`" -s -w" .
go: downloading github.com/raphaelreyna/ez-cgi v0.7.3
go: downloading github.com/google/uuid v1.2.0
go: downloading github.com/spf13/cobra v1.0.0
go: downloading github.com/jf-tech/iohelper v1.0.2
go: downloading github.com/grandcat/zeroconf v1.0.0
go: downloading github.com/gorilla/mux v1.7.4
go: downloading github.com/spf13/pflag v1.0.3
go: extracting github.com/raphaelreyna/ez-cgi v0.7.3
go: extracting github.com/gorilla/mux v1.7.4
go: extracting github.com/grandcat/zeroconf v1.0.0
go: downloading github.com/cenkalti/backoff v2.2.1+incompatible
go: downloading github.com/miekg/dns v1.1.27
go: downloading golang.org/x/net v0.0.0-20200602114024-627f9648deb9
go: extracting github.com/jf-tech/iohelper v1.0.2
go: extracting github.com/spf13/cobra v1.0.0
go: extracting github.com/google/uuid v1.2.0
go: extracting github.com/spf13/pflag v1.0.3
go: extracting github.com/cenkalti/backoff v2.2.1+incompatible
go: extracting github.com/miekg/dns v1.1.27
go: downloading golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550
go: downloading golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd
go: extracting golang.org/x/net v0.0.0-20200602114024-627f9648deb9
go: extracting golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550
go: extracting golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd
go: finding github.com/grandcat/zeroconf v1.0.0
go: finding github.com/cenkalti/backoff v2.2.1+incompatible
go: finding github.com/miekg/dns v1.1.27
go: finding golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550
go: finding golang.org/x/net v0.0.0-20200602114024-627f9648deb9
go: finding golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd
go: finding github.com/google/uuid v1.2.0
go: finding github.com/raphaelreyna/ez-cgi v0.7.3
go: finding github.com/jf-tech/iohelper v1.0.2
go: finding github.com/gorilla/mux v1.7.4
go: finding github.com/spf13/cobra v1.0.0
go: finding github.com/spf13/pflag v1.0.3
build github.com/raphaelreyna/oneshot: cannot load embed: malformed module path "embed": missing dot in first path element
make: *** [Makefile:11: oneshot] Error 1

To Reproduce
Steps to reproduce the behavior:

  1. Run 'git clone https://github.com/raphaelreyna/oneshot.git && cd oneshot && sudo make install'
  2. See error:
build github.com/raphaelreyna/oneshot: cannot load embed: malformed module path "embed": missing dot in first path element
make: *** [Makefile:11: oneshot] Error 1

Desktop (please complete the following information):

  • OS: Ubuntu 20.04 LTS

Invalid CSRF token

Describe the bug
When trying to upload a file, it shows this error:
error :: 2021/08/05 17:17:03 server.go:128: Invalid CSRF token

To Reproduce
Steps to reproduce the behavior:

  1. Run oneshot -u .
  2. Upload file from a browser.
  3. It shows this error error :: 2021/08/05 17:17:03 server.go:128: Invalid CSRF token

Expected behavior
File Uploaded Successfully.

Output and error messages
error :: 2021/08/05 17:17:03 server.go:128: Invalid CSRF token

Desktop (please complete the following information):

  • OS: Arch Linux
  • Version v1.5.0

Cannot connect to the IP address

I am running Windows 7 and I can't seem to connect to that machine from other devices. Is it some bug in the program or do I need to manually change some network visibility options?

bind localhost only

hi,
oneshot is a cool tool ;-)
we can change the listening port : would it also be possible to change the address ? to bind only localhost for example (e.g. behind apache or nginx).
regards, lacsaP.

version command panics

Describe the bug
As title

To Reproduce
Steps to reproduce the behavior:

  1. Run 'oneshot version'

Expected behavior
Version output shows up.

Output and error messages

panic: interface conversion: pflag.Value is *pflag.stringValue, not *flagargs.OutputFormat [recovered]
	panic: interface conversion: pflag.Value is *pflag.stringValue, not *flagargs.OutputFormat

goroutine 1 [running]:
main.main.func1()
	/Users/rr/Code/ForestNode/oneshot/v2/cmd/main.go:45 +0x73
panic({0x1893aa0?, 0xc0001d1a70?})
	/opt/homebrew/Cellar/go/1.21.0/libexec/src/runtime/panic.go:914 +0x21f
github.com/forestnode-io/oneshot/v2/pkg/commands/root.subCommands.(*Cmd).Cobra.func1(0x1b08bc0?, {0xc0003a6120?, 0x0?, 0x213e940?})
	/Users/rr/Code/ForestNode/oneshot/v2/pkg/commands/version/cobra.go:30 +0x485
github.com/forestnode-io/oneshot/v2/pkg/commands/root.(*rootCommand).setSubCommands.func2(0xc0003a4300, {0x213e940, 0x0, 0x0})
	/Users/rr/Code/ForestNode/oneshot/v2/pkg/commands/root/entry.go:128 +0x6f
github.com/spf13/cobra.(*Command).execute(0xc0003a4300, {0x213e940, 0x0, 0x0})
	/Users/rr/go/pkg/mod/github.com/spf13/[email protected]/command.go:944 +0x863
github.com/spf13/cobra.(*Command).ExecuteC(0xc000290000)
	/Users/rr/go/pkg/mod/github.com/spf13/[email protected]/command.go:1068 +0x3a5
github.com/spf13/cobra.(*Command).Execute(...)
	/Users/rr/go/pkg/mod/github.com/spf13/[email protected]/command.go:992
github.com/spf13/cobra.(*Command).ExecuteContext(...)
	/Users/rr/go/pkg/mod/github.com/spf13/[email protected]/command.go:985
github.com/forestnode-io/oneshot/v2/pkg/commands/root.ExecuteContext({0x1b08d80, 0xc0001caac0})
	/Users/rr/Code/ForestNode/oneshot/v2/pkg/commands/root/entry.go:81 +0x698
main.main()
	/Users/rr/Code/ForestNode/oneshot/v2/cmd/main.go:77 +0x2ed

Desktop (please complete the following information):

  • OS: macOS 13.5
  • Version: 2.0.0

Additional context
None

zip file structure is broken

Describe the bug
while sending folders as zip files the structure of zip files is broken
say for example i'm sending a folder Downloads/folder then the zip file structure while extracting is folder/folder/*.*

To Reproduce
Steps to reproduce the behavior:
oneshot -a zip path to any folder

Expected behavior
the file structure while extracting should be like folder/*.* instead of folder/folder/*.*

Desktop:

  • OS: arch linux
  • Version: 1.3.1

Stderr overwriting Stdout in TTYs when receiving to stdout

Describe the bug
When receiving to stdout, the progress update that gets printed to Stderr overwrites some of the output from Stdout.
This only happens when both Stderr and Stdout are writing to the same TTY.

To Reproduce
Steps to reproduce the behavior:

  1. Run 'oneshot receive' with both stdout and stderr pointed at the same TTY.
  2. See that stdout output was at least partially overwritten by the output of stderr.

Expected behavior
The stdout output is fully visible.

Automatically redirect or allow download with filename

Automatic redirection, because some websites will verify the URL

example: The URL you have entered ends in an extension that we do not support. We only accept image files that end in gz, bz2, vmdk, vhdx, qcow, qcow2, vdi, raw, img, xz. (.zip is not supported).

so i don't know what to do

Allow for custom responses to bots/iMessage/etc.

Currently, oneshot responds to bots/iMessage/etc. with an empty page and 200 OK status.
It'd be nice be able to pass in a flag with a path to a file that will be served to bots/iMessage/etc.

Also, I'm not sure if 200 OK is the most appropriate response; any thoughts or input on this would be greatly appreciated.

The install.sh script is not working

https://github.com/raphaelrena/oneshot/blob/0e1007a910ec6ef0670cccfc557b39b4b6f2394d/install.sh#L18

The above line results current_version being v1.1.3.

The actual link to the download file is
https://github.com/raphaelreyna/oneshot/releases/download/v1.1.3/ oneshot_1.1.3.linux-arm.tar.gz.

But as your substituing the value of the current_version variable, the URL becomes:
https://github.com/raphaelreyna/oneshot/releases/download/v1.1.3/ oneshot_v1.1.3.linux-arm.tar.gz.
(extra 'v' in the URL) which results in an error while the script is trying to download the tar file.

Certain errors not being written out to stderr

Describe the bug
Certain errors are never written to stderr so the user never sees them unless they check the logs.
Noticed this when trying to bind oneshot to a port that's already in use.

To Reproduce
Steps to reproduce the behavior:

  1. Run a command that would result in an error.
  2. See no error

Expected behavior
The error should be visible to the user.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.