项目作者: gesellix

项目描述 :
A Windows Named Pipe Http Echo Server
高级语言: Go
项目地址: git://github.com/gesellix/go-npipe.git
创建时间: 2016-07-15T21:49:33Z
项目社区:https://github.com/gesellix/go-npipe

开源协议:

下载


Windows Named Pipe Http Echo Server.

About

This little tool creates a Windows Named Pipe and listens for HTTP requests.
Request bodies will be returned with a prefix [echo].

Requests on /exit will stop the tool and remove the pipe.

The request method will be ignored, so you can use any of GET, POST or whatever.

Usage in integration tests

This tool comes in handy when running integration tests. There’s no built-in way to create a named pipe in the JVM,
so you end up trying to create some JNI/JNA implementation
to make the syscall.aspx) for you…
or you use a native binary to handle everything for you and simply call it via exec.

You can find my own use case in the integration tests for the Docker Client.
As soon as the project is built on a Windows system, the integration tests verify
the basic ability to use a named pipe socket for communication with the Docker engine.

Yeah, Windows only, but who cares? ¯_(ツ)_/¯

Since Windows Named Pipes are a Windows only concept (similar to Unix Domain Sockets), you would probably expect
Windows specific sources or build configurations. Thanks to Golang this isn’t necessary: the cross compiler
works very well and creates a nice Windows native executable. I’m a fan of automation, which is why
you’ll always find the most recent version of this tool on the Docker Hub, packaged as Docker image.
The Docker image isn’t expected to be run, but it serves to leverage the build and distribution of this tool.
See below for details!

Build/Install

Command Line

  1. go get -d github.com/gesellix/go-npipe
  2. cd src
  3. CGO_ENABLED=0 GOARCH=amd64 GOOS=windows go build -o npipe.exe main.go

Docker :whale:

  1. docker build -t npipe:local -f linux/Dockerfile .
  2. docker create --name npipe npipe:local
  3. # Or from the Docker Hub (linux):
  4. #docker create --name npipe gesellix/npipe
  5. # Or from the Docker Hub (windows):
  6. #docker create --name npipe gesellix/npipe:windows
  7. docker cp npipe:/npipe.exe .
  8. docker rm npipe

Run

  1. npipe.exe \\.\pipe\the_pipe

List pipes (PowerShell)

  1. get-childitem \\.\pipe\

Contributing/Feedback

If you have any kind of feedback or would like to improve this little tool,
please submit an issue or create a pull request!