mirror of
https://github.com/tarampampam/error-pages.git
synced 2024-08-30 18:22:40 +00:00
Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
36c5472987 | |||
717542e045 | |||
940bd0405f |
1
.github/workflows/tests.yml
vendored
1
.github/workflows/tests.yml
vendored
@ -154,6 +154,7 @@ jobs: # Docs: <https://git.io/JvxXE>
|
||||
test -f ./out/app-down/404.html
|
||||
test -f ./out/connection/404.html
|
||||
test -f ./out/matrix/404.html
|
||||
test -f ./out/orient/404.html
|
||||
|
||||
docker-image:
|
||||
name: Build docker image
|
||||
|
16
CHANGELOG.md
16
CHANGELOG.md
@ -4,6 +4,22 @@ All notable changes to this package will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog][keepachangelog] and this project adheres to [Semantic Versioning][semver].
|
||||
|
||||
## v2.24.0
|
||||
|
||||
### Added
|
||||
|
||||
- Support for IPv6 addresses in the `--listen` flag [#191]
|
||||
|
||||
[#191]:https://github.com/tarampampam/error-pages/issues/191
|
||||
|
||||
## v2.23.0
|
||||
|
||||
### Added
|
||||
|
||||
- Template `orient` [#190]
|
||||
|
||||
[#190]:https://github.com/tarampampam/error-pages/pull/190
|
||||
|
||||
## v2.22.0
|
||||
|
||||
### Changed
|
||||
|
@ -12,7 +12,10 @@
|
||||
<a href="https://github.com/tarampampam/error-pages/blob/master/LICENSE"><img src="https://img.shields.io/github/license/tarampampam/error-pages.svg?maxAge=30&style=flat-square" alt="" /></a>
|
||||
</p>
|
||||
|
||||
<p align="center"><sup>22 feb. 2022 - ⚡ Our Docker image was downloaded <strong>one MILLION times</strong> from the docker hub! ⚡</sup></p>
|
||||
<p align="center"><sup>
|
||||
22 feb. 2022 - ⚡ Our Docker image was downloaded <strong>one MILLION times</strong> from the docker hub! ⚡<br/>
|
||||
10 apr. 2023 - ⚡ <strong>Two million times</strong> from the docker hub and <strong>one million</strong> from the ghcr! ⚡
|
||||
</sup></p>
|
||||
|
||||
One day you may want to replace the standard error pages of your HTTP server with something more original and pretty. That's what this repository was created for :) It contains:
|
||||
|
||||
@ -123,6 +126,7 @@ Transfer/sec: 140.23MB
|
||||
| `app-down` | [![app-down][app-down-screen]][app-down-link] |
|
||||
| `connection` | [![connection][connection-screen]][connection-link] |
|
||||
| `matrix` | [![matrix][matrix-screen]][matrix-link] |
|
||||
| `orient` | [![orient][orient-screen]][orient-link] |
|
||||
|
||||
> Note: `noise` template highly uses the CPU, be careful
|
||||
|
||||
@ -148,6 +152,8 @@ Transfer/sec: 140.23MB
|
||||
[connection-link]:https://tarampampam.github.io/error-pages/connection/404.html
|
||||
[matrix-screen]:https://hsto.org/webt/ng/tf/oi/ngtfoiolvmq6hf15kimcxmhprhk.gif
|
||||
[matrix-link]:https://tarampampam.github.io/error-pages/matrix/404.html
|
||||
[orient-screen]:https://hsto.org/webt/pz/eu/v_/pzeuv_lyeqr0xpusa4zfrtgk7sa.png
|
||||
[orient-link]:https://tarampampam.github.io/error-pages/orient/404.html
|
||||
|
||||
## 🦾 Contributors
|
||||
|
||||
|
@ -15,6 +15,7 @@ templates:
|
||||
- path: ./templates/app-down.html
|
||||
- path: ./templates/connection.html
|
||||
- path: ./templates/matrix.html
|
||||
- path: ./templates/orient.html
|
||||
|
||||
formats:
|
||||
json:
|
||||
|
@ -17,7 +17,7 @@ var ConfigFileFlag = &cli.StringFlag{ //nolint:gochecknoglobals
|
||||
var ListenAddrFlag = &cli.StringFlag{ //nolint:gochecknoglobals
|
||||
Name: "listen",
|
||||
Aliases: []string{"l"},
|
||||
Usage: "IP address to Listen on",
|
||||
Usage: "IP (v4 or v6) address to Listen on",
|
||||
Value: "0.0.0.0",
|
||||
EnvVars: []string{env.ListenAddr.String()},
|
||||
}
|
||||
|
@ -1,7 +1,10 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/fasthttp/router"
|
||||
@ -57,8 +60,24 @@ func NewServer(log *zap.Logger) Server {
|
||||
}
|
||||
|
||||
// Start server.
|
||||
func (s *Server) Start(ip string, port uint16) error {
|
||||
return s.fast.ListenAndServe(ip + ":" + strconv.Itoa(int(port)))
|
||||
func (s *Server) Start(ip string, port uint16) (err error) {
|
||||
if net.ParseIP(ip) == nil {
|
||||
return errors.New("invalid IP address")
|
||||
}
|
||||
|
||||
var ln net.Listener
|
||||
|
||||
if strings.Count(ip, ":") >= 2 { //nolint:gomnd // ipv6
|
||||
if ln, err = net.Listen("tcp6", fmt.Sprintf("[%s]:%d", ip, port)); err != nil {
|
||||
return err
|
||||
}
|
||||
} else { // ipv4
|
||||
if ln, err = net.Listen("tcp4", fmt.Sprintf("%s:%d", ip, port)); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return s.fast.Serve(ln)
|
||||
}
|
||||
|
||||
type templatePicker interface {
|
||||
|
279
templates/orient.html
Normal file
279
templates/orient.html
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user