Code Monkey home page Code Monkey logo

links's Introduction

logo

๐Ÿ”— Table of Contents

๐Ÿ’ป Installation

Check out the releases page for prebuilt versions.

๐Ÿณ Container Images (ghcr)

$ docker run -it --rm ghcr.io/lrstanley/links:master
$ docker run -it --rm ghcr.io/lrstanley/links:0.9.0
$ docker run -it --rm ghcr.io/lrstanley/links:latest
$ docker run -it --rm ghcr.io/lrstanley/links:0.8.0
$ docker run -it --rm ghcr.io/lrstanley/links:0.7.0
$ docker run -it --rm ghcr.io/lrstanley/links:0.6.0

๐Ÿงฐ Source

Note that you must have Go installed (latest is usually best).

$ git clone https://github.com/lrstanley/links.git && cd links
$ make
$ ./links --help

โš™๏ธ Usage

$ links --help
Usage:
  links [OPTIONS] [add | delete]

Application Options:
  -s, --site-name=                      site url, used for url generation (default: https://links.wtf) [$SITE_URL]
      --session-dir=                    optional location to store temporary sessions [$SESSION_DIR]
  -q, --quiet                           don't log to stdout [$QUIET]
      --debug                           enable debugging (pprof endpoints) [$DEBUG]
  -b, --http=                           ip:port pair to bind to (default: :8080) [$HTTP]
  -p, --behind-proxy                    if X-Forwarded-For headers should be trusted [$PROXY]
  -d, --db=                             path to database file (default: store.db) [$DB_PATH]
      --key-length=                     default length of key (uuid) for generated urls (default: 4) [$KEY_LENGTH]
      --http-pre-include=               HTTP include which is included directly after css is included (near top of the page)
                                        [$HTTP_PRE_INCLUDE]
      --http-post-include=              HTTP include which is included directly after js is included (near bottom of the page)
                                        [$HTTP_POST_INCLUDE]
  -e, --export-file=                    file to export db to (default: links.export)
      --export-json                     export db to json elements
  -v, --version                         display the version of links.wtf and exit

TLS Options:
      --tls.enable                      run tls server rather than standard http [$TLS_ENABLE]
  -c, --tls.cert=                       path to ssl cert file [$TLS_CERT_PATH]
  -k, --tls.key=                        path to ssl key file [$TLS_KEY_PATH]

Safe Browsing Support:
      --safebrowsing.api-key=           Google API Key used for querying SafeBrowsing, disabled if not provided (see:
                                        https://github.com/lrstanley/links#google-safebrowsing) [$SAFEBROWSING_API_KEY]
      --safebrowsing.db=                path to SafeBrowsing database file (default: safebrowsing.db) [$SAFEBROWSING_DB_PATH]
      --safebrowsing.update-period=     duration between updates to the SafeBrowsing API local database (default: 1h)
                                        [$SAFEBROWSING_UPDATE_PERIOD]
      --safebrowsing.redirect-fallback  if the SafeBrowsing request fails (local cache, and remote hit), this still lets the
                                        redirect happen [$SAFEBROWSING_REDIRECT_FALLBACK]

Prometheus Metrics:
      --prom.enabled                    enable exposing of prometheus metrics (on std port, or --prometheus.addr) [$PROM_ENABLED]
      --prom.addr=                      expose on custom address/port, e.g. ':9001' (all ips) or 'localhost:9001' (local only)
                                        [$PROM_ADDR]
      --prom.endpoint=                  endpoint to expose metrics on (default: /metrics) [$PROM_ENDPOINT]

Help Options:
  -h, --help                            Show this help message

Available commands:
  add     add a link
  delete  delete a link, id, or link matching an author

Dot-env

Links also supports a .env file for loading environment variables. Example:

SAFEBROWSING_API_KEY=<your-secret-key>
FOO=BAR

Example

$ links -s "http://your-domain.com" -b "0.0.0.0:80" -d links.db

Google SafeBrowsing

Links supports utilizing Google SafeBrowsing, (see Safe Browsing Support under ##Usage). This helps prevent users being redirected to malicious or otherwise harmful websites. It does require a Google Developer account (free).

  1. Go to the Google Developer Console
  2. Create a new project (dropdown top left, click NEW PROJECT)
  3. Enable the "Safe Browsing" API
  4. Create a new credential (API key)

Screenshot example:

Using as a library

Links also has a Go client library which you can use, which adds a simple wrapper around an http call, to make shortening links simpler. Download it using the following go get command:

$ go get -u github.com/lrstanley/links/client

View the documentation here

Example

package main

import (
	"fmt"
	"log"

	links "github.com/lrstanley/links/client"
)

func main() {
	uri, err := links.Shorten("https://your-long-link.com/longer/link", "", nil)
	if err != nil {
		log.Fatalf("unable to shorten link: %s", err)
	}

	fmt.Printf("shortened: %s
", uri.String())
}

API

Shortening a link is quite easy. simply send a POST request to https://example.com/add, which will return JSON-safe information as shown below:

$ curl --data "url=http://google.com" https://example.com/add
{"url": "https://example.com/27f4", "success": true}

Password protection

You can also password protect a link, simply by adding a password variable to the payload:

$ curl --data 'url=https://google.com/example&encrypt=y0urp4$$w0rd' https://example.com/add
{"url": "https://example.com/abc123", "success": true}

๐Ÿ™‹โ€โ™‚๏ธ Support & Assistance

  • โค๏ธ Please review the Code of Conduct for guidelines on ensuring everyone has the best experience interacting with the community.
  • ๐Ÿ™‹โ€โ™‚๏ธ Take a look at the support document on guidelines for tips on how to ask the right questions.
  • ๐Ÿž For all features/bugs/issues/questions/etc, head over here.

๐Ÿค Contributing

  • โค๏ธ Please review the Code of Conduct for guidelines on ensuring everyone has the best experience interacting with the community.
  • ๐Ÿ“‹ Please review the contributing doc for submitting issues/a guide on submitting pull requests and helping out.
  • ๐Ÿ—๏ธ For anything security related, please review this repositories security policy.

โš–๏ธ License

MIT License

Copyright (c) 2014 Liam Stanley <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Also located here

links's People

Contributors

dependabot[bot] avatar lrstanley 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

Watchers

 avatar  avatar  avatar  avatar  avatar

links's Issues

Prevent duplicate shortening

Links, by default, creates duplicate IDs for the same URL. that behaviour can be changed to look up if the URL is in the database, and return the corresponding short ID.

If a user does want new IDs, they should be able to create them by using an encryption string.

In short, any URL that does not have an encryption string, will always return the same ID. and in case the URL has an encryption string, it will return a new ID.

HTML pre/post include & HTML entities encoding

Test: ./links --http-pre-include="<input type='hidden' value='test'>"

Using pre/post include outputs the text encoded onto the page, so you can't include raw HTML (which is the point of the commands).

Looking here: flosch/pongo2#129

I think we need:

{% autoescape off %}
{% endautoescape %}

Wrapping both of the outputs.

panic: could not locate box "static"

Hello!

I'm trying to generate a snap package for this project using goreleaser. But I'm getting this error:

2017/08/07 10:26:05 main.go:53: initialized logger
2017/08/07 10:26:05 database.go:204: verifying access to db: store.db
2017/08/07 10:26:05 database.go:207: successfully verified access to db
panic: could not locate box "static"

goroutine 1 [running]:
github.com/GeertJohan/go%2erice.MustFindBox(0x97acad, 0x6, 0x11)
        /home/ubuntu/workspace/go/src/github.com/GeertJohan/go.rice/box.go:110+0x94
main.setupTmpl()
        /home/ubuntu/workspace/lrstanley/links.ml/templates.go:28 +0x3a
main.httpServer()
        /home/ubuntu/workspace/lrstanley/links.ml/http.go:29 +0x9c
main.main()
        /home/ubuntu/workspace/lrstanley/links.ml/main.go:99 +0x299

Snaps are the new packaging system that we are developing here at Ubuntu. They have a strong confinement, so the installed snap can only access the things allowed by the user. But I'm not sure what this "static" error could mean. Do you have any idea?

To try it in Ubuntu, extact the attached file and run:

sudo snap install *.snap --dangerous
linksml.links

linksml_0.2.2_amd64.zip

Here are my additions to the .goreleaser.yml file:
https://github.com/elopio/links.ml/blob/dc4d9488c3254d71bca2f6728b64365ee04ce97f/.goreleaser.yml#L20

Enhance randomization

Links uses a 4 character set by default. therefore, the possible combinations are 62^4 = 14,776,336 (almost 14 million).

if the character set is increased to 6, for example, it increases to possible combinations to approximately 56 billion.

although having a six character ID is not ideally desirable, the default behaviour can be changed to exhaust the combinations with the current default character set, i.e., 4 characters, and then jump to 5 character set combinations, and then 6, and so on.

Custom ID through web interface

Links allows creating custom IDs through the CLI, but not the web interface. it would be ideal if the latter is possible too.

New links.ml feels a bit sluggish

Not sure if it's me, but it seems that trying to visit a shorten URL takes a bit longer than usual, and sometimes when POSTing to the API, the URL fails to shorten

Auth error overflows to a newly opened instance

When a wrong decryption string is entered repeatedly, the auth error piles up, with one error for each failed decryption.

Screenshot_2019-09-24-09-44-36-284_com android chrome

It would be neat if it just updated the old error on the consecutive failed decryption similar to how the input form simply refreshes the "unable to parse URL error" on the home page, instead of returning multiple errors.

Also, when a new instance of Links is opened, it displays the failed decryption errors in the previous Auth page.

Screenshot_2019-09-24-09-45-06-512_com android chrome

However, there is a timeout, wherein the old errors are deleted, and a new failed decryption displays only the current error

Screenshot_2019-09-24-09-45-54-755_com android chrome

Although, there is still the issue of the error overflowing to a newly opened instance

Screenshot_2019-09-24-09-46-05-280_com android chrome

Note : Sorry for the huge screenshots. I intended to share mobile screenshots to describe how piling up of errors can be troublesome for the UI.

Google SafeBrowsing integration

via local database matching, add option to periodically delete any shortened urls which match this.. or just disable redirecting (in case it gets removed from safe browsing again).

Privacy policy

This redirector seems to be quite popular (almost 3 million links generated) so I think there should be some link on the page with the privacy policy, or right here at github.

Administration Area

As briefly discussed over IRC, It'd be a nice idea to have some form of administration area where the site owner is able to moderate the links that have been created as well as manually adding their own with a custom/exact link reference.

E.g. https://links.wtf/google -> https://google.com

The reason for an area for this is because the current database isn't easy to directly modify so that these can be manually added.

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.