Skip to content

Commit

Permalink
Initial version
Browse files Browse the repository at this point in the history
  • Loading branch information
DblK committed Dec 15, 2021
0 parents commit 8b758e8
Show file tree
Hide file tree
Showing 20 changed files with 1,917 additions and 0 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: golangci-lint
on:
push:
tags:
- v*
branches:
- master
- main
pull_request:
permissions:
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
# pull-requests: read
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: v1.29

# Optional: working directory, useful for monorepos
# working-directory: somedir

# Optional: golangci-lint command line arguments.
# args: --issues-exit-code=0

# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true

# Optional: if set to true then the action will use pre-installed Go.
# skip-go-installation: true

# Optional: if set to true then the action don't cache or restore ~/go/pkg.
# skip-pkg-cache: true

# Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
# skip-build-cache: true
32 changes: 32 additions & 0 deletions .github/workflows/goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: goreleaser

on:
push:
tags:
- '*'

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
-
id: vars
run: |
echo ::set-output name=go_version::$(cat go.mod | head -3 | tail -1 | cut -d ' ' -f 2)
echo "Using Go version ${{ steps.vars.outputs.go_version }}"
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ steps.vars.outputs.go_version }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
distribution: goreleaser
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# OS
.DS_Store

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# TinShop specific
config.yaml
titles.US.en.json
/dist
32 changes: 32 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This is an example .goreleaser.yml file with some sane defaults.
# Make sure to check the documentation at http://goreleaser.com
before:
hooks:
# You may remove this if you don't use go modules.
- go mod tidy
builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
archives:
- replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^doc:'
- '^test:'
- '^wip:'
10 changes: 10 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"cSpell.words": [
"dblk",
"fsnotify",
"goreleaser",
"tinshop",
"titledb",
"tmpl"
]
}
111 changes: 111 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<p align="center">
<p align="center">
<img alt="TinShop" src="./logo.png" width="50%">
</p>
<p align="center">
Your own personal shop right into tinfoil!
</p>

[![Actions Status](https://github.com/dblk/tinshop/actions/workflows/golangci-lint.yml/badge.svg)](https://github.com/dblk/tinshop/actions)
[![GitHub go.mod Go version of a Go module](https://img.shields.io/github/go-mod/go-version/dblk/tinshop.svg)](https://github.com/dblk/tinshop)
[![GoDoc reference example](https://img.shields.io/badge/godoc-reference-blue.svg)](https://godoc.org/github.com/dblk/tinshop/v0.0.1)
[![GoReportCard example](https://goreportcard.com/badge/github.com/dblk/tinshop)](https://goreportcard.com/report/github.com/dblk/tinshop)
[![GitHub release](https://img.shields.io/github/release/dblk/tinshop.svg)](https://GitHub.com/dblk/tinshop/releases/)

# Disclaimer

This program **DOES NOT** encourage piracy at all!
It was designed to reduce the time to download/install a game from the Nintendo eShop.
In case you have a ADSL connection, to install latest `Zelda` ([14.4Gb](https://www.nintendo.com/games/detail/the-legend-of-zelda-breath-of-the-wild-switch/)) it can take ages!

On top of that, if you have bought a game on eShop like [Jump Force](https://www.bandainamcoent.com/news/jump-force-sunsetting-announcement), once it is not anymore on the shop how can you install it again?
Using your personal NSP dump, with `tinfoil` and `tinshop` everything should be fine and fast!

# Use

To proper use this software, here is the checklist:
- [ ] _Optional:_ A proper configured `config.yaml`
- [ ] Copy/Paste [`config.example.yaml`](https://github.com/DblK/tinshop/blob/master/config.example.yaml) to `config.yaml`
- [ ] Comment/Uncomment parts in the config according to your needs
- [ ] Games should have in their name `[ID][v0]` to be recognized
- [ ] Retrieve binary from [latest release](https://github.com/DblK/tinshop/releases) or build from source (See `Dev` section below)

Now simply run it and add a shop inside tinfoil with the address setup in `config` (or `http://localIp:3000` if not specified).

# Features

Here is the list of all main features so far:
- [X] Automatically download `titles.US.en.json` if missing at startup
- [X] Basic protection from forged queries (should allow only tinfoil to use the shop)
- [X] Serve from several mounted directories
- [X] Serve from several network directories (Using NFS)
- [X] Display a webpage for forbidden devices

# Dev or build from source

I suggest to use a tiny executable [gow](https://github.com/mitranim/gow) to help you during the process (hot reload, etc..).
For example I use the following command to develop `gow -c run .`.

If you want to build `TinShop` from source, please run `go build`.

And then, simply run `./tinshop`.

## Want to do cross-build generation?

Wanting to generate all possible os binaries (macOS, linux, windows) with all architectures (arm, amd64)?
Here is the command `goreleaser release --snapshot --skip-publish --rm-dist`.

Dead simple, thanks to Golang!

# Roadmap

You can see the [roadmap here](https://github.com/DblK/tinshop/projects/1).

If you have any suggestions, do not hesitate to participate!

# Q & A

## Why use this instead of `X` (NUT or others software)?

It's dead simple, and no dependencies! It's just a single small executable.
Easier to install games without connecting switch or by updating SD card (Nightmare if you are on macOS).

The upcoming features will also be a huge advantage against others software.

## Where do I put my games?

By default, `TinShop` will look into the `games` directory relative to `tinshop` executable.

However in the `config.yaml` file, you can change this.
In the `sources` section, you can have the following:
- `directories`: List of directories where you put your games
- `nfs`: List of NFS shares that contains your games


## Can I set up a `https` endpoint?

Yes, you can!
Use a reverse proxy (like [traefik](https://github.com/traefik/traefik), [caddy](https://github.com/caddyserver/caddy), nginx...) to do tls termination and forward to your instance on port `3000`.

## How can I add a `basic auth` to protect my shop?

TinShop **does not** implement basic auth by itself.
You should configure it inside your reverse proxy.

For other type of protection, you can whitelist (__*__) your own switch and this will do the trick.

__*__ Feature not yet implemented!

## I have tons of missing title displayed in `tinfoil`, what should I do?

First, download and replace the latest [`titles.US.en.json`](https://github.com/AdamK2003/titledb/releases/download/latest/titles.US.en.json) available (or delete it, it will be automatically downloaded at startup).
If this does not solve your issue, then you should use custom titledb entry (__*__) to describe those which are missing.

__*__ Feature not yet implemented!

# Credits

I would like to give back thanks to the people who helped me with or without knowing!
- [Bogdan Rosu Creative](https://www.iconfinder.com/icons/353439/basket_purse_shopping_cart_ecommerce_shop_buy_online_icon) for his shop icon.
- [Dono](https://github.com/Donorhan) for his support and tests.
- [AdamK2003](https://github.com/AdamK2003/titledb) for his up-to-date [`titles.US.en.json`](https://github.com/AdamK2003/titledb/releases/download/latest/titles.US.en.json) and his answers on discord.
21 changes: 21 additions & 0 deletions assets/shop.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>{{.ShopTitle}}</title>
<style>
.copyright {
color: #8a8a8a;
bottom: 0;
position: absolute;
right: 0;
margin: 1rem;
}
</style>
</head>
<body>
<h1>Welcome to {{.ShopTitle}}!</h1>
<h2>Please connect with a switch to be able to browse collection.</h2>
<span class='copyright'>Powered by <a href="https://github.com/DblK/tinshop" target="_blank">TinShop</a>. © 2021 DblK</span>
</body>
</html>
33 changes: 33 additions & 0 deletions config.example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Name of the host [optional]
host: tinshop.example.com

# Protocol (Can be http or https) [optional]
# If you use "https" then you should set up a reverse-proxy in front to handle tls
# And forward the port 443 to "yourIp:3000"
protocol: https

# Port [optional]
# This only affect the url to download games. The web server still run on port 3000.
# If you change the port, you will need to set up a reverse proxy
# port: 3000

# Shop name [optional]
# This is used as title when trying to visit the shop with a non switch device
name: TinShop

# All debug flags will be stored here
debug:
# Display more information when connecting to nfs share
nfs: false

# All sources where we should look for games
# If this section is commented out, then the directory "games" will be looked at
sources:
# Local mounted path [optional]
directories:
- /my/full/path/to/games
- ./games

# NFS Shares [optional]
nfs:
- host:sharePath/to/game/files
Loading

0 comments on commit 8b758e8

Please sign in to comment.