You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

github.com/walter-manger/go-concurrency

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/walter-manger/go-concurrency

v0.0.0-20190618152835-2bc1b3e610ef
Source
Go
Version published
Created
Source

Go Concurrency ( Hasher )

This project is an exploration of the concurrency techniques used in Golang.

Structure

- cmd
  - hashercli
    - main.go
  - hashersrv
    - main.go
- pkg
  - hasher
    - hasher.go
  - api
    - api.go

Starting the Hasher Service

go run cmd/hashersrv/main.go

Will start the Hasher Service and listen on port 8080 by default.

Need Help?

go run cmd/hashersrv/main.go --help
2017/05/02 15:04:40 Starting Hasher Service...

  -addr string
    	The port to listen on (default "8080")
exit status 2

From here, you can interact with the service using these endpoints:

Endpoints

POST /hash

Starts a Hasher job and returns the jobID. All Hasher jobs take 5 seconds to perform.

curl --data "password=somePassword" http://localhost:8080/hash

Example Output:

21

GET /hash/{jobID}

Waits (blocks) for the Hasher job to finish and returns the SHA512 + base64 Encoded password.

curl http://localhost:8080/hash/21

Example Output:

auSfSFKDloNDlfwJo68gFLWDtbIqzMkf8gGnd8sw9dEpMmciJAh73g9M+BzRzR6F5vQgRVoaQRwSvZaOsTVHLw==

GET /stats

Returns a JSON describing statistics for the running Hasher service.

curl http://localhost:8080/stats

Example Output:

{"total":2,"average": 221}

Where total is the number of hash requests since the Hasher Service started, and average is the average time in milliseconds that a /hash/{jobID} took to complete.

An Alternative to curl

Alternatively to running curl, you can interact with the Hasher Service using the Hasher CLI tool.

go run cmd/hashercli/main.go

Need Help?

go run cmd/hashercli/main.go --help
  -addr string
    	The address to send hash requests to (default "http://localhost:8080")
  -numReq int
    	The number of requests to run against the address (default 10)
exit status 2

The Hasher CLI tool will make requests to the Hasher Service at random intervals with somewhat randomized passwords.

FAQs

Package last updated on 18 Jun 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts