Git Product home page Git Product logo

go-pb's Introduction

G'day, I am Ilia Frenkel. Nice to meet you! ๐Ÿ‘‹

He/Him / ๐Ÿ‡ฆ๐Ÿ‡บ / ๐Ÿ‡ฎ๐Ÿ‡ฑ / ๐Ÿ‡ท๐Ÿ‡บ /

I am a cybersecurity engineer, DevOps engineer and quality assurance engineer. I like everything containers (not k8s, though), and at the moment, I'm into Golang. I'm looking for some help with Go, either mentoring or learning together. Come to go-pb repo and join me if you are keen. I'm open to other suggestions too.

The best way to contact me is ๐Ÿ“ง[email protected]. My LindkedIn profile will work too. I am also on Mastodon. If you are in Melbourne and want to chat over a coffee or a beer, drop me a note.

go-pb's People

Contributors

davidnewhall avatar dependabot[bot] avatar iliafrenkel avatar krishnaindani avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

go-pb's Issues

Add content type before writing response to improve performance

If we don't set Content-Type header, Go will try and guess it from the content. This may take some time, especially for large responses. Since we know that we send HTML pages we can set the header upfront. We can also set the response status code for clarity.

Here:

e := p.Show(w)

Here:

e := p.Show(w)

And, most importantly, here:

e := p.Show(w)

Notify when the paste is "burned"

When viewing a paste with DeleteAfterRead set to true, notify the user that the paste was deleted and that if she closes the page, the paste will be gone forever.

Design a logo for the project

I'd like to have a logo and some project branding in general:

  • Big logo to use on websites and social networks (1280ร—640px or even bigger).
  • Small logo to use as an icon, favicon for example (32x32px or 64x64px).
  • ASCII art logo, just because it's cool ๐Ÿ˜œ
  • Project colour scheme that we can follow in the UI. At the moment, it's a standard Bootstrap one.

Any help will be greatly appreciated.

Implement paste expiration

The idea is to create a scheduler that will run on a regular interval (or maybe multiple schedulers and multiple intervals) and execute certain tasks:

  • delete expired tasks
  • cleanup old pastes, the ones that haven't been accessed for a long time
  • refresh/invalidate the cache
  • write in-memory data to file/database (such as stats)

In addition to that, the API must not show the pastes that have expired already.

Other ideas are more than welcome!

API calls authentication with JWT tokens

If we want to make our API public we need to implement client authentication and autorisation. I suggest JWT tokens with the RSA signing method that uses asymmetric public/private keys.

In addition to #8.

Statistics for API calls

Gather some stats for the API calls:

  • total numbers per endpoint
  • error numbers per endpoint

Keep the stats locally or consider some 3rd party service.

Cannot paste more than 10,240 characters.

Describe the bug
I cannot paste over 10,240 characters.

To Reproduce
Run the app and try to paste something large.

Expected behaviour
WEB_MAX_BODY_SIZE or --web-max-body-size properly controls the maximum paste size.

Screenshots
I cloned, ran make build (because make failed), then ran the app:

go-pb$ GOPB_DEBUG=true WEB_MAX_BODY_SIZE=6000000 build/go-pb --web-max-body-size=6000000
go-pb v0.0.9-alpha
2022/01/08 01:58:43.756 [INFO]  {cmd/main.go:84 main.main} Options: {Timeouts:{Shutdown:10s HTTPRead:15s HTTPWrite:15s HTTPIdle:1m0s} Web:{Proto:http Host:localhost Port:8080 LogFile: LogMode:production BrandName:Go PB BrandTagline:A nice and simple pastebin alternative that you can host yourself. Assets:./assets Templates:./templates BootstrapTheme:original Logo:bighead.svg MaxBodySize:6000000} DB:{Type:memory Connection:} Auth:{Secret: TokenDuration:5m0s CookieDuration:24h0m0s Issuer:go-pb URL:http://localhost:8080 GitHubCID: GitHubCSEC: GoogleCID: GoogleCSEC: TwitterCID: TwitterCSEC:} Debug:true LogFile:}

Screen Shot 2022-01-08 at 2 03 28 AM

Desktop (please complete the following information):

  • OS: macOS 10.15.7
  • Browser Safari
  • Version 15.2 (old)

Not sure what else to try.

Password protected pastes

With a regular paste, all you need to know is its URL. I want to set a password on a paste so that the user will need to enter it to view the paste, in addition to knowing the URL.

Password must be stored as a hash. If it is lost, there will be no way to restore it.

List of public pastes

Is your feature request related to a problem? Please describe.
As a logged in user there is no way for me to see a list of public pastes.

Describe the solution you'd like
Showing a paginated list of public pastes would be nice. Similar to "My Pastes" list.

Describe alternatives you've considered
There are no alternatives at the moment. You can see the last 10 public pastes when you are not logged in.

Additional context
N/A

Docker images for other architectures

Is your feature request related to a problem? Please describe.
At the moment, we only build docker images for amd64. Many people use ARM systems nowadays - Raspberry Pi, new macs. It'd be nice to have pre-build docker images for arm and arm64.

Describe the solution you'd like
GoReleaser supports building multi-platform images: https://goreleaser.com/customization/docker_manifest/

Describe alternatives you've considered
N/A

Additional context
N/A

Private pastes

Add an ability to mark the paste private so that only the person who created the paste could view it.

Implement API rate limiting

If we ever going to make our API public we need to be able to protect it. I suggest implementing rate limiting on two levels:

  • Rate limit by client IP address. Allow a certain amount of requests per a certain time period. For example, 50 requests per minute.
  • Rate limit globally as primitive protection against DDOS.

This is in addition to #9.

Don't request paste Body for listing

Describe the bug
When building a page with the list of pastes the result of the query contains full pastes, body included. This can get very big. We don't need the body for pastes list anyway.

Additional context
In the same way, as we have FindRequest struct, we should define FindResponse struct that will only contain the fields we need.

Admin interface

We need an admin interface to manage users and pastes. Also, to see stats and configure whatever is configurable.
A detailed list of features needs to be created.

API should always return JSON

Some API endpoints return plain text instead of JSON, mainly errors. For example:

c.String(http.StatusBadRequest, fmt.Sprintf("request body contains malformed JSON (at position %d)", syntaxError.Offset))

or
c.String(http.StatusNotFound, "paste not found")

API must always return JSON. We need to define a common error structure that will be returned and replace plain text responses with JSON ones.

Create a build pipeline

Build pipeline:

  • Using GitHub action and GoReleaser
  • Automatic triggering:
    • when PR is opened, trigger test pipeline
    • when PR is merged to main trigger test pipeline
    • each commit to main triggers the testing pipeline
    • when a new version tag v* is created on the main branch trigger test and build pipelines
  • Test pipeline for testing PRs and commits
  • Build pipeline that generates multiple artefacts:
    • binaries for darwin/amd64, darwin/arm64, windows/amd64, linux/amd64, linux/arm64, freebsd/amd64
    • docker images for amd64 and arm64 architectures

Paginated list of all my pastes

Is your feature request related to a problem? Please describe.
As a logged in user I want to be able to see all my pastes. At the moment I can only see the last 10.

Describe the solution you'd like
Implement a paginated list of all user's pastes.

Paste view count

Is your feature request related to a problem? Please describe.
It'd be nice to be able to see how many times a public paste has been viewed.

Describe the solution you'd like
Every time a unique visitor views a paste record it. Show the total count on the paste view and list pages.

Additional context
A unique visitor == one session. All the views within a single session should be counted as one.

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.