Use a better method to reload command presets

This commit is contained in:
NI
2020-03-12 21:18:08 +08:00
parent b2210ce2b6
commit 1009cd4284
12 changed files with 206 additions and 374 deletions

View File

@@ -72,9 +72,7 @@ func (a Application) run(
) (bool, error) { ) (bool, error) {
var err error var err error
loaderName, c, cErr := cLoader( loaderName, c, cErr := cLoader(a.logger.Context("Configuration"))
a.logger.Context("Configuration"),
commands.Reconfigure)
if cErr != nil { if cErr != nil {
a.logger.Error("\"%s\" loader cannot load configuration: %s", a.logger.Error("\"%s\" loader cannot load configuration: %s",
@@ -83,6 +81,16 @@ func (a Application) run(
return false, cErr return false, cErr
} }
// Allowing command to alter presets
c.Presets, err = commands.Reconfigure(c.Presets)
if err != nil {
a.logger.Error("Unable to reconfigure presets: %s", err)
return false, err
}
// Verify all configuration
err = c.Verify() err = c.Verify()
if err != nil { if err != nil {

View File

@@ -45,13 +45,15 @@ type Command func(
// Builder builds a command // Builder builds a command
type Builder struct { type Builder struct {
name string
command Command command Command
configurator configuration.Reconfigurator configurator configuration.PresetReloader
} }
// Register builds a Builder for registration // Register builds a Builder for registration
func Register(c Command, p configuration.Reconfigurator) Builder { func Register(name string, c Command, p configuration.PresetReloader) Builder {
return Builder{ return Builder{
name: name,
command: c, command: c,
configurator: p, configurator: p,
} }
@@ -62,7 +64,11 @@ type Commands [MaxCommandID + 1]Builder
// Register registers a new command // Register registers a new command
func (c *Commands) Register( func (c *Commands) Register(
id byte, cb Command, ps configuration.Reconfigurator) { id byte,
name string,
cb Command,
ps configuration.PresetReloader,
) {
if id > MaxCommandID { if id > MaxCommandID {
panic("Command ID must be not greater than MaxCommandID") panic("Command ID must be not greater than MaxCommandID")
} }
@@ -71,7 +77,7 @@ func (c *Commands) Register(
panic(fmt.Sprintf("Command %d already been registered", id)) panic(fmt.Sprintf("Command %d already been registered", id))
} }
(*c)[id] = Register(cb, ps) (*c)[id] = Register(name, cb, ps)
} }
// Run creates command executer // Run creates command executer
@@ -96,15 +102,27 @@ func (c Commands) Run(
// Reconfigure lets commands reset configuration // Reconfigure lets commands reset configuration
func (c Commands) Reconfigure( func (c Commands) Reconfigure(
p configuration.Configuration, p []configuration.Preset,
) configuration.Configuration { ) ([]configuration.Preset, error) {
newP := make([]configuration.Preset, 0, len(p))
for i := range c { for i := range c {
if c[i].configurator == nil { for pp := range p {
if c[i].name != p[pp].Type {
continue continue
} }
p = c[i].configurator(p) newPP, pErr := c[i].configurator(p[pp])
if pErr == nil {
newP = append(newP, newPP)
continue
} }
return p return nil, pErr
}
}
return newP, nil
} }

View File

@@ -171,7 +171,7 @@ func (d *dummyStreamCommand) Release() error {
func TestHandlerHandleStream(t *testing.T) { func TestHandlerHandleStream(t *testing.T) {
cmds := Commands{} cmds := Commands{}
cmds.Register(0, newDummyStreamCommand, nil) cmds.Register(0, "name", newDummyStreamCommand, nil)
readerDataInput := make(chan []byte) readerDataInput := make(chan []byte)

View File

@@ -24,7 +24,7 @@ import (
// New creates a new commands group // New creates a new commands group
func New() command.Commands { func New() command.Commands {
return command.Commands{ return command.Commands{
command.Register(newTelnet, parseTelnetConfig), command.Register("Telnet", newTelnet, parseTelnetConfig),
command.Register(newSSH, parseSSHConfig), command.Register("SSH", newSSH, parseSSHConfig),
} }
} }

View File

@@ -203,28 +203,20 @@ func newSSH(
} }
} }
func parseSSHConfig(p configuration.Configuration) configuration.Configuration { func parseSSHConfig(p configuration.Preset) (configuration.Preset, error) {
for i := range p.Presets { oldHost := p.Host
if p.Presets[i].Type != "SSH" {
continue
}
oldHost := p.Presets[i].Host _, _, sErr := net.SplitHostPort(p.Host)
_, _, sErr := net.SplitHostPort(p.Presets[i].Host)
if sErr != nil { if sErr != nil {
p.Presets[i].Host = net.JoinHostPort( p.Host = net.JoinHostPort(p.Host, sshDefaultPortString)
p.Presets[i].Host,
sshDefaultPortString)
} }
if len(p.Presets[i].Host) <= 0 { if len(p.Host) <= 0 {
p.Presets[i].Host = oldHost p.Host = oldHost
}
} }
return p return p, nil
} }
func (d *sshClient) Bootup( func (d *sshClient) Bootup(

View File

@@ -76,30 +76,20 @@ func newTelnet(
} }
} }
func parseTelnetConfig( func parseTelnetConfig(p configuration.Preset) (configuration.Preset, error) {
p configuration.Configuration, oldHost := p.Host
) configuration.Configuration {
for i := range p.Presets {
if p.Presets[i].Type != "Telnet" {
continue
}
oldHost := p.Presets[i].Host _, _, sErr := net.SplitHostPort(p.Host)
_, _, sErr := net.SplitHostPort(p.Presets[i].Host)
if sErr != nil { if sErr != nil {
p.Presets[i].Host = net.JoinHostPort( p.Host = net.JoinHostPort(p.Host, telnetDefaultPortString)
p.Presets[i].Host,
telnetDefaultPortString)
} }
if len(p.Presets[i].Host) <= 0 { if len(p.Host) <= 0 {
p.Presets[i].Host = oldHost p.Host = oldHost
}
} }
return p return p, nil
} }
func (d *telnetClient) Bootup( func (d *telnetClient) Bootup(

View File

@@ -21,11 +21,8 @@ import (
"github.com/niruix/sshwifty/application/log" "github.com/niruix/sshwifty/application/log"
) )
// Reconfigurator reloads configuration // PresetReloader reloads preset
type Reconfigurator func(p Configuration) Configuration type PresetReloader func(p Preset) (Preset, error)
// Loader Configuration loader // Loader Configuration loader
type Loader func( type Loader func(log log.Logger) (name string, cfg Configuration, err error)
log log.Logger,
r Reconfigurator,
) (name string, cfg Configuration, err error)

View File

@@ -28,10 +28,7 @@ const (
// Direct creates a loader that return raw configuration data directly. // Direct creates a loader that return raw configuration data directly.
// Good for integration. // Good for integration.
func Direct(cfg Configuration) Loader { func Direct(cfg Configuration) Loader {
return func( return func(log log.Logger) (string, Configuration, error) {
log log.Logger,
r Reconfigurator,
) (string, Configuration, error) {
return directTypeName, cfg, nil return directTypeName, cfg, nil
} }
} }

View File

@@ -44,10 +44,7 @@ func parseEviro(name string) string {
// Enviro creates an environment variable based configuration loader // Enviro creates an environment variable based configuration loader
func Enviro() Loader { func Enviro() Loader {
return func( return func(log log.Logger) (string, Configuration, error) {
log log.Logger,
r Reconfigurator,
) (string, Configuration, error) {
log.Info("Loading configuration from environment variables ...") log.Info("Loading configuration from environment variables ...")
dialTimeout, _ := strconv.ParseUint( dialTimeout, _ := strconv.ParseUint(
@@ -123,7 +120,7 @@ func Enviro() Loader {
} }
} }
return enviroTypeName, r(Configuration{ return enviroTypeName, Configuration{
HostName: cfg.HostName, HostName: cfg.HostName,
SharedKey: cfg.SharedKey, SharedKey: cfg.SharedKey,
DialTimeout: time.Duration(cfg.DialTimeout) * time.Second, DialTimeout: time.Duration(cfg.DialTimeout) * time.Second,
@@ -133,6 +130,6 @@ func Enviro() Loader {
Servers: []Server{cfgSer.build()}, Servers: []Server{cfgSer.build()},
Presets: presets, Presets: presets,
OnlyAllowPresetRemotes: cfg.OnlyAllowPresetRemotes, OnlyAllowPresetRemotes: cfg.OnlyAllowPresetRemotes,
}), nil }, nil
} }
} }

View File

@@ -135,10 +135,7 @@ func (f fileCfgCommon) build() (fileCfgCommon, error) {
}, nil }, nil
} }
func loadFile( func loadFile(filePath string) (string, Configuration, error) {
filePath string,
r Reconfigurator,
) (string, Configuration, error) {
f, fErr := os.Open(filePath) f, fErr := os.Open(filePath)
if fErr != nil { if fErr != nil {
@@ -174,7 +171,7 @@ func loadFile(
presets[i] = finalCfg.Presets[i].build() presets[i] = finalCfg.Presets[i].build()
} }
return fileTypeName, r(Configuration{ return fileTypeName, Configuration{
HostName: finalCfg.HostName, HostName: finalCfg.HostName,
SharedKey: finalCfg.SharedKey, SharedKey: finalCfg.SharedKey,
DialTimeout: time.Duration(finalCfg.DialTimeout) * DialTimeout: time.Duration(finalCfg.DialTimeout) *
@@ -185,19 +182,16 @@ func loadFile(
Servers: servers, Servers: servers,
Presets: presets, Presets: presets,
OnlyAllowPresetRemotes: cfg.OnlyAllowPresetRemotes, OnlyAllowPresetRemotes: cfg.OnlyAllowPresetRemotes,
}), nil }, nil
} }
// File creates a configuration file loader // File creates a configuration file loader
func File(customPath string) Loader { func File(customPath string) Loader {
return func( return func(log log.Logger) (string, Configuration, error) {
log log.Logger,
r Reconfigurator,
) (string, Configuration, error) {
if len(customPath) > 0 { if len(customPath) > 0 {
log.Info("Loading configuration from: %s", customPath) log.Info("Loading configuration from: %s", customPath)
return loadFile(customPath, r) return loadFile(customPath)
} }
log.Info("Loading configuration from one of the default " + log.Info("Loading configuration from one of the default " +
@@ -239,7 +233,7 @@ func File(customPath string) Loader {
log.Info("Configuration file \"%s\" has been selected", log.Info("Configuration file \"%s\" has been selected",
fallbackFileSearchList[f]) fallbackFileSearchList[f])
return loadFile(fallbackFileSearchList[f], r) return loadFile(fallbackFileSearchList[f])
} }
return fileTypeName, Configuration{}, fmt.Errorf( return fileTypeName, Configuration{}, fmt.Errorf(

View File

@@ -30,14 +30,11 @@ const (
// Redundant creates a group of loaders. They will be executed one by one until // Redundant creates a group of loaders. They will be executed one by one until
// one of it successfully returned a configuration // one of it successfully returned a configuration
func Redundant(loaders ...Loader) Loader { func Redundant(loaders ...Loader) Loader {
return func( return func(log log.Logger) (string, Configuration, error) {
log log.Logger,
r Reconfigurator,
) (string, Configuration, error) {
ll := log.Context("Redundant") ll := log.Context("Redundant")
for i := range loaders { for i := range loaders {
lLoaderName, lCfg, lErr := loaders[i](ll, r) lLoaderName, lCfg, lErr := loaders[i](ll)
if lErr != nil { if lErr != nil {
ll.Warning("Unable to load configuration from \"%s\": %s", ll.Warning("Unable to load configuration from \"%s\": %s",

View File

@@ -20,296 +20,138 @@ package controller
//go:generate go run ./static_page_generater ../../.tmp/dist ./static_pages.go //go:generate go run ./static_page_generater ../../.tmp/dist ./static_pages.go
//go:generate go fmt ./static_pages.go //go:generate go fmt ./static_pages.go
// This file is generated by `go generate` at Mon, 12 Aug 2019 11:04:30 CST // This file is generated by `go generate` at Thu, 12 Mar 2020 20:25:38 CST
// DO NOT EDIT! // DO NOT EDIT!
import "io/ioutil" import "github.com/niruix/sshwifty/application/controller/static_pages"
import "bytes"
import "fmt"
import "compress/gzip"
import "encoding/base64"
import "time" import "time"
import "crypto/sha256"
// WARNING: THIS GENERATION IS FOR DEBUG / DEVELOPMENT ONLY, DO NOT
// USE IT IN PRODUCTION!
func staticFileGen(filePath string) staticData {
content, readErr := ioutil.ReadFile(filePath)
if readErr != nil {
panic(fmt.Sprintln("Cannot read file:", readErr))
}
compressed := bytes.NewBuffer(make([]byte, 0, 1024))
compresser, compresserBuildErr := gzip.NewWriterLevel(
compressed, gzip.BestCompression)
if compresserBuildErr != nil {
panic(fmt.Sprintln("Cannot build data compresser:", compresserBuildErr))
}
contentLen := len(content)
_, compressErr := compresser.Write(content)
if compressErr != nil {
panic(fmt.Sprintln("Cannot write compressed data:", compressErr))
}
compressErr = compresser.Flush()
if compressErr != nil {
panic(fmt.Sprintln("Cannot write compressed data:", compressErr))
}
content = append(content, compressed.Bytes()...)
getHash := func(b []byte) []byte {
h := sha256.New()
h.Write(b)
return h.Sum(nil)
}
return staticData{
data: content[0:contentLen],
dataHash: base64.StdEncoding.EncodeToString(
getHash(content[0:contentLen])[:8]),
compressd: content[contentLen:],
compressdHash: base64.StdEncoding.EncodeToString(
getHash(content[contentLen:])[:8]),
created: time.Now(),
}
}
var ( var (
staticPages = map[string]staticData{ staticPages = map[string]staticData{
"13ec0eb5bdb821ff4930237d7c9f943f.woff2": staticFileGen( "0.2591207cde2357871355.js": parseStaticData(static_pages.Static0()),
"/home/rany/Development/Projects/webssh/.tmp/dist/13ec0eb5bdb821ff4930237d7c9f943f.woff2", "010c539b67fe9bacabc4ec5dbff1546b.svg": parseStaticData(static_pages.Static1()),
), "0b3811d040152efecd499f74a840805b.woff2": parseStaticData(static_pages.Static2()),
"13efe6cbc10b97144a28310ebdeda594.woff": staticFileGen( "132527c8a67bf941ca84add5608a81a3.woff": parseStaticData(static_pages.Static3()),
"/home/rany/Development/Projects/webssh/.tmp/dist/13efe6cbc10b97144a28310ebdeda594.woff", "13ec0eb5bdb821ff4930237d7c9f943f.woff2": parseStaticData(static_pages.Static4()),
), "13efe6cbc10b97144a28310ebdeda594.woff": parseStaticData(static_pages.Static5()),
"1d6594826615607f6dc860bb49258acb.woff": staticFileGen( "1d6594826615607f6dc860bb49258acb.woff": parseStaticData(static_pages.Static6()),
"/home/rany/Development/Projects/webssh/.tmp/dist/1d6594826615607f6dc860bb49258acb.woff", "2.2591207cde2357871355.js": parseStaticData(static_pages.Static7()),
), "23d1ed95cedfe6dc88667aa59d91a620.woff2": parseStaticData(static_pages.Static8()),
"313a65630d341645c13e4f2a0364381d.woff": staticFileGen( "2591207cde2357871355.css": parseStaticData(static_pages.Static9()),
"/home/rany/Development/Projects/webssh/.tmp/dist/313a65630d341645c13e4f2a0364381d.woff", "2591207cde2357871355.css.map": parseStaticData(static_pages.Static10()),
), "2591207cde2357871355.js": parseStaticData(static_pages.Static11()),
"35b07eb2f8711ae08d1f58c043880930.woff": staticFileGen( "3.2591207cde2357871355.js": parseStaticData(static_pages.Static12()),
"/home/rany/Development/Projects/webssh/.tmp/dist/35b07eb2f8711ae08d1f58c043880930.woff", "313a65630d341645c13e4f2a0364381d.woff": parseStaticData(static_pages.Static13()),
), "35b07eb2f8711ae08d1f58c043880930.woff": parseStaticData(static_pages.Static14()),
"4248c72df3d263be21b6d.css": staticFileGen( "3aa797141ef00f0aa9fc.css": parseStaticData(static_pages.Static15()),
"/home/rany/Development/Projects/webssh/.tmp/dist/4248c72df3d263be21b6d.css", "3aa797141ef00f0aa9fc.css.map": parseStaticData(static_pages.Static16()),
), "4.2591207cde2357871355.js": parseStaticData(static_pages.Static17()),
"4248c72df3d263be21b6d.js": staticFileGen( "4357beb823a5f8d65c260f045d9e019a.woff2": parseStaticData(static_pages.Static18()),
"/home/rany/Development/Projects/webssh/.tmp/dist/4248c72df3d263be21b6d.js", "4fe0f73cc919ba2b7a3c36e4540d725c.woff": parseStaticData(static_pages.Static19()),
), "5.2591207cde2357871355.js": parseStaticData(static_pages.Static20()),
"4357beb823a5f8d65c260f045d9e019a.woff2": staticFileGen( "50d75e48e0a3ddab1dd15d6bfb9d3700.woff": parseStaticData(static_pages.Static21()),
"/home/rany/Development/Projects/webssh/.tmp/dist/4357beb823a5f8d65c260f045d9e019a.woff2", "59eb3601394dd87f30f82433fb39dd94.woff2": parseStaticData(static_pages.Static22()),
), "5b4a33e176ff736a74f0ca2dd9e6b396.woff2": parseStaticData(static_pages.Static23()),
"4fe0f73cc919ba2b7a3c36e4540d725c.woff": staticFileGen( "6.2591207cde2357871355.js": parseStaticData(static_pages.Static24()),
"/home/rany/Development/Projects/webssh/.tmp/dist/4fe0f73cc919ba2b7a3c36e4540d725c.woff", "73f0a88bbca1bec19fb1303c689d04c6.woff2": parseStaticData(static_pages.Static25()),
), "83e114c316fcc3f23f524ec3e1c65984.woff": parseStaticData(static_pages.Static26()),
"50d75e48e0a3ddab1dd15d6bfb9d3700.woff": staticFileGen( "8a96edbbcd9a6991d79371aed0b0288e.woff": parseStaticData(static_pages.Static27()),
"/home/rany/Development/Projects/webssh/.tmp/dist/50d75e48e0a3ddab1dd15d6bfb9d3700.woff", "8ec888af4672fe48c5560b5e7c0ecb78.woff": parseStaticData(static_pages.Static28()),
), "90d1676003d9c28c04994c18bfd8b558.woff2": parseStaticData(static_pages.Static29()),
"59eb3601394dd87f30f82433fb39dd94.woff2": staticFileGen( "94008e69aaf05da75c0bbf8f8bb0db41.woff2": parseStaticData(static_pages.Static30()),
"/home/rany/Development/Projects/webssh/.tmp/dist/59eb3601394dd87f30f82433fb39dd94.woff2", "DEPENDENCIES.md": parseStaticData(static_pages.Static31()),
), "LICENSE.md": parseStaticData(static_pages.Static32()),
"5b4a33e176ff736a74f0ca2dd9e6b396.woff2": staticFileGen( "README.md": parseStaticData(static_pages.Static33()),
"/home/rany/Development/Projects/webssh/.tmp/dist/5b4a33e176ff736a74f0ca2dd9e6b396.woff2", "ad538a69b0e8615ed0419c4529344ffc.woff2": parseStaticData(static_pages.Static34()),
), "android-chrome-144x144.png": parseStaticData(static_pages.Static35()),
"73f0a88bbca1bec19fb1303c689d04c6.woff2": staticFileGen( "android-chrome-192x192.png": parseStaticData(static_pages.Static36()),
"/home/rany/Development/Projects/webssh/.tmp/dist/73f0a88bbca1bec19fb1303c689d04c6.woff2", "android-chrome-256x256.png": parseStaticData(static_pages.Static37()),
), "android-chrome-36x36.png": parseStaticData(static_pages.Static38()),
"83e114c316fcc3f23f524ec3e1c65984.woff": staticFileGen( "android-chrome-384x384.png": parseStaticData(static_pages.Static39()),
"/home/rany/Development/Projects/webssh/.tmp/dist/83e114c316fcc3f23f524ec3e1c65984.woff", "android-chrome-48x48.png": parseStaticData(static_pages.Static40()),
), "android-chrome-512x512.png": parseStaticData(static_pages.Static41()),
"8a96edbbcd9a6991d79371aed0b0288e.woff": staticFileGen( "android-chrome-72x72.png": parseStaticData(static_pages.Static42()),
"/home/rany/Development/Projects/webssh/.tmp/dist/8a96edbbcd9a6991d79371aed0b0288e.woff", "android-chrome-96x96.png": parseStaticData(static_pages.Static43()),
), "apple-touch-icon-1024x1024.png": parseStaticData(static_pages.Static44()),
"90d1676003d9c28c04994c18bfd8b558.woff2": staticFileGen( "apple-touch-icon-114x114.png": parseStaticData(static_pages.Static45()),
"/home/rany/Development/Projects/webssh/.tmp/dist/90d1676003d9c28c04994c18bfd8b558.woff2", "apple-touch-icon-120x120.png": parseStaticData(static_pages.Static46()),
), "apple-touch-icon-144x144.png": parseStaticData(static_pages.Static47()),
"94008e69aaf05da75c0bbf8f8bb0db41.woff2": staticFileGen( "apple-touch-icon-152x152.png": parseStaticData(static_pages.Static48()),
"/home/rany/Development/Projects/webssh/.tmp/dist/94008e69aaf05da75c0bbf8f8bb0db41.woff2", "apple-touch-icon-167x167.png": parseStaticData(static_pages.Static49()),
), "apple-touch-icon-180x180.png": parseStaticData(static_pages.Static50()),
"ad538a69b0e8615ed0419c4529344ffc.woff2": staticFileGen( "apple-touch-icon-57x57.png": parseStaticData(static_pages.Static51()),
"/home/rany/Development/Projects/webssh/.tmp/dist/ad538a69b0e8615ed0419c4529344ffc.woff2", "apple-touch-icon-60x60.png": parseStaticData(static_pages.Static52()),
), "apple-touch-icon-72x72.png": parseStaticData(static_pages.Static53()),
"android-chrome-144x144.png": staticFileGen( "apple-touch-icon-76x76.png": parseStaticData(static_pages.Static54()),
"/home/rany/Development/Projects/webssh/.tmp/dist/android-chrome-144x144.png", "apple-touch-icon-precomposed.png": parseStaticData(static_pages.Static55()),
), "apple-touch-icon.png": parseStaticData(static_pages.Static56()),
"android-chrome-192x192.png": staticFileGen( "apple-touch-startup-image-1182x2208.png": parseStaticData(static_pages.Static57()),
"/home/rany/Development/Projects/webssh/.tmp/dist/android-chrome-192x192.png", "apple-touch-startup-image-1242x2148.png": parseStaticData(static_pages.Static58()),
), "apple-touch-startup-image-1496x2048.png": parseStaticData(static_pages.Static59()),
"android-chrome-256x256.png": staticFileGen( "apple-touch-startup-image-1536x2008.png": parseStaticData(static_pages.Static60()),
"/home/rany/Development/Projects/webssh/.tmp/dist/android-chrome-256x256.png", "apple-touch-startup-image-320x460.png": parseStaticData(static_pages.Static61()),
), "apple-touch-startup-image-640x1096.png": parseStaticData(static_pages.Static62()),
"android-chrome-36x36.png": staticFileGen( "apple-touch-startup-image-640x920.png": parseStaticData(static_pages.Static63()),
"/home/rany/Development/Projects/webssh/.tmp/dist/android-chrome-36x36.png", "apple-touch-startup-image-748x1024.png": parseStaticData(static_pages.Static64()),
), "apple-touch-startup-image-750x1294.png": parseStaticData(static_pages.Static65()),
"android-chrome-384x384.png": staticFileGen( "apple-touch-startup-image-768x1004.png": parseStaticData(static_pages.Static66()),
"/home/rany/Development/Projects/webssh/.tmp/dist/android-chrome-384x384.png", "b52fac2bb93c5858f3f2675e4b52e1de.woff2": parseStaticData(static_pages.Static67()),
), "browserconfig.xml": parseStaticData(static_pages.Static68()),
"android-chrome-48x48.png": staticFileGen( "c023bfb8571ccdf77bdd94a308ea3162.svg": parseStaticData(static_pages.Static69()),
"/home/rany/Development/Projects/webssh/.tmp/dist/android-chrome-48x48.png", "c6af87fef241bf953aa3.css": parseStaticData(static_pages.Static70()),
), "c6af87fef241bf953aa3.css.map": parseStaticData(static_pages.Static71()),
"android-chrome-512x512.png": staticFileGen( "c73eb1ceba3321a80a0aff13ad373cb4.woff": parseStaticData(static_pages.Static72()),
"/home/rany/Development/Projects/webssh/.tmp/dist/android-chrome-512x512.png", "cc2fadc3928f2f223418887111947b40.woff": parseStaticData(static_pages.Static73()),
), "d26871e8149b5759f814fd3c7a4f784b.woff2": parseStaticData(static_pages.Static74()),
"android-chrome-72x72.png": staticFileGen( "d3b47375afd904983d9be8d6e239a949.woff": parseStaticData(static_pages.Static75()),
"/home/rany/Development/Projects/webssh/.tmp/dist/android-chrome-72x72.png", "d4a48f0f981279da0e207e47516f4354.woff": parseStaticData(static_pages.Static76()),
), "d569415005f26953bb9c3c52895355eb.woff2": parseStaticData(static_pages.Static77()),
"android-chrome-96x96.png": staticFileGen( "e72f2a56d5e5f8c8decc.css": parseStaticData(static_pages.Static78()),
"/home/rany/Development/Projects/webssh/.tmp/dist/android-chrome-96x96.png", "e72f2a56d5e5f8c8decc.css.map": parseStaticData(static_pages.Static79()),
), "e8eaae902c3a4dacb9a5062667e10576.woff2": parseStaticData(static_pages.Static80()),
"apple-touch-icon-1024x1024.png": staticFileGen( "error.html": parseStaticData(static_pages.Static81()),
"/home/rany/Development/Projects/webssh/.tmp/dist/apple-touch-icon-1024x1024.png", "f5902d5ef961717ed263902fc429e6ae.woff": parseStaticData(static_pages.Static82()),
), "f75569f8a5fab0893fa712d8c0d9c3fe.woff2": parseStaticData(static_pages.Static83()),
"apple-touch-icon-114x114.png": staticFileGen( "f93c333e41413ed8548b714ad10a14fe.woff2": parseStaticData(static_pages.Static84()),
"/home/rany/Development/Projects/webssh/.tmp/dist/apple-touch-icon-114x114.png", "favicon-16x16.png": parseStaticData(static_pages.Static85()),
), "favicon-32x32.png": parseStaticData(static_pages.Static86()),
"apple-touch-icon-120x120.png": staticFileGen( "favicon.ico": parseStaticData(static_pages.Static87()),
"/home/rany/Development/Projects/webssh/.tmp/dist/apple-touch-icon-120x120.png", "fdea8596c4f9e3699f0cd51255a9e0f1.woff": parseStaticData(static_pages.Static88()),
), "firefox_app_128x128.png": parseStaticData(static_pages.Static89()),
"apple-touch-icon-144x144.png": staticFileGen( "firefox_app_512x512.png": parseStaticData(static_pages.Static90()),
"/home/rany/Development/Projects/webssh/.tmp/dist/apple-touch-icon-144x144.png", "firefox_app_60x60.png": parseStaticData(static_pages.Static91()),
), "index.html": parseStaticData(static_pages.Static92()),
"apple-touch-icon-152x152.png": staticFileGen( "manifest.json": parseStaticData(static_pages.Static93()),
"/home/rany/Development/Projects/webssh/.tmp/dist/apple-touch-icon-152x152.png", "manifest.webapp": parseStaticData(static_pages.Static94()),
), "mstile-144x144.png": parseStaticData(static_pages.Static95()),
"apple-touch-icon-167x167.png": staticFileGen( "mstile-150x150.png": parseStaticData(static_pages.Static96()),
"/home/rany/Development/Projects/webssh/.tmp/dist/apple-touch-icon-167x167.png", "mstile-310x150.png": parseStaticData(static_pages.Static97()),
), "mstile-310x310.png": parseStaticData(static_pages.Static98()),
"apple-touch-icon-180x180.png": staticFileGen( "mstile-70x70.png": parseStaticData(static_pages.Static99()),
"/home/rany/Development/Projects/webssh/.tmp/dist/apple-touch-icon-180x180.png", "robots.txt": parseStaticData(static_pages.Static100()),
),
"apple-touch-icon-57x57.png": staticFileGen(
"/home/rany/Development/Projects/webssh/.tmp/dist/apple-touch-icon-57x57.png",
),
"apple-touch-icon-60x60.png": staticFileGen(
"/home/rany/Development/Projects/webssh/.tmp/dist/apple-touch-icon-60x60.png",
),
"apple-touch-icon-72x72.png": staticFileGen(
"/home/rany/Development/Projects/webssh/.tmp/dist/apple-touch-icon-72x72.png",
),
"apple-touch-icon-76x76.png": staticFileGen(
"/home/rany/Development/Projects/webssh/.tmp/dist/apple-touch-icon-76x76.png",
),
"apple-touch-icon-precomposed.png": staticFileGen(
"/home/rany/Development/Projects/webssh/.tmp/dist/apple-touch-icon-precomposed.png",
),
"apple-touch-icon.png": staticFileGen(
"/home/rany/Development/Projects/webssh/.tmp/dist/apple-touch-icon.png",
),
"apple-touch-startup-image-1182x2208.png": staticFileGen(
"/home/rany/Development/Projects/webssh/.tmp/dist/apple-touch-startup-image-1182x2208.png",
),
"apple-touch-startup-image-1242x2148.png": staticFileGen(
"/home/rany/Development/Projects/webssh/.tmp/dist/apple-touch-startup-image-1242x2148.png",
),
"apple-touch-startup-image-1496x2048.png": staticFileGen(
"/home/rany/Development/Projects/webssh/.tmp/dist/apple-touch-startup-image-1496x2048.png",
),
"apple-touch-startup-image-1536x2008.png": staticFileGen(
"/home/rany/Development/Projects/webssh/.tmp/dist/apple-touch-startup-image-1536x2008.png",
),
"apple-touch-startup-image-320x460.png": staticFileGen(
"/home/rany/Development/Projects/webssh/.tmp/dist/apple-touch-startup-image-320x460.png",
),
"apple-touch-startup-image-640x1096.png": staticFileGen(
"/home/rany/Development/Projects/webssh/.tmp/dist/apple-touch-startup-image-640x1096.png",
),
"apple-touch-startup-image-640x920.png": staticFileGen(
"/home/rany/Development/Projects/webssh/.tmp/dist/apple-touch-startup-image-640x920.png",
),
"apple-touch-startup-image-748x1024.png": staticFileGen(
"/home/rany/Development/Projects/webssh/.tmp/dist/apple-touch-startup-image-748x1024.png",
),
"apple-touch-startup-image-750x1294.png": staticFileGen(
"/home/rany/Development/Projects/webssh/.tmp/dist/apple-touch-startup-image-750x1294.png",
),
"apple-touch-startup-image-768x1004.png": staticFileGen(
"/home/rany/Development/Projects/webssh/.tmp/dist/apple-touch-startup-image-768x1004.png",
),
"b52fac2bb93c5858f3f2675e4b52e1de.woff2": staticFileGen(
"/home/rany/Development/Projects/webssh/.tmp/dist/b52fac2bb93c5858f3f2675e4b52e1de.woff2",
),
"browserconfig.xml": staticFileGen(
"/home/rany/Development/Projects/webssh/.tmp/dist/browserconfig.xml",
),
"c599374e350aa7225ee3e8a114e8d8d7.svg": staticFileGen(
"/home/rany/Development/Projects/webssh/.tmp/dist/c599374e350aa7225ee3e8a114e8d8d7.svg",
),
"c73eb1ceba3321a80a0aff13ad373cb4.woff": staticFileGen(
"/home/rany/Development/Projects/webssh/.tmp/dist/c73eb1ceba3321a80a0aff13ad373cb4.woff",
),
"cc2fadc3928f2f223418887111947b40.woff": staticFileGen(
"/home/rany/Development/Projects/webssh/.tmp/dist/cc2fadc3928f2f223418887111947b40.woff",
),
"d26871e8149b5759f814fd3c7a4f784b.woff2": staticFileGen(
"/home/rany/Development/Projects/webssh/.tmp/dist/d26871e8149b5759f814fd3c7a4f784b.woff2",
),
"d3b47375afd904983d9be8d6e239a949.woff": staticFileGen(
"/home/rany/Development/Projects/webssh/.tmp/dist/d3b47375afd904983d9be8d6e239a949.woff",
),
"e8eaae902c3a4dacb9a5062667e10576.woff2": staticFileGen(
"/home/rany/Development/Projects/webssh/.tmp/dist/e8eaae902c3a4dacb9a5062667e10576.woff2",
),
"ea4853ff509fe5f353d52586fcb94e20.svg": staticFileGen(
"/home/rany/Development/Projects/webssh/.tmp/dist/ea4853ff509fe5f353d52586fcb94e20.svg",
),
"f5902d5ef961717ed263902fc429e6ae.woff": staticFileGen(
"/home/rany/Development/Projects/webssh/.tmp/dist/f5902d5ef961717ed263902fc429e6ae.woff",
),
"f75569f8a5fab0893fa712d8c0d9c3fe.woff2": staticFileGen(
"/home/rany/Development/Projects/webssh/.tmp/dist/f75569f8a5fab0893fa712d8c0d9c3fe.woff2",
),
"favicon-16x16.png": staticFileGen(
"/home/rany/Development/Projects/webssh/.tmp/dist/favicon-16x16.png",
),
"favicon-32x32.png": staticFileGen(
"/home/rany/Development/Projects/webssh/.tmp/dist/favicon-32x32.png",
),
"favicon.ico": staticFileGen(
"/home/rany/Development/Projects/webssh/.tmp/dist/favicon.ico",
),
"firefox_app_128x128.png": staticFileGen(
"/home/rany/Development/Projects/webssh/.tmp/dist/firefox_app_128x128.png",
),
"firefox_app_512x512.png": staticFileGen(
"/home/rany/Development/Projects/webssh/.tmp/dist/firefox_app_512x512.png",
),
"firefox_app_60x60.png": staticFileGen(
"/home/rany/Development/Projects/webssh/.tmp/dist/firefox_app_60x60.png",
),
"index.html": staticFileGen(
"/home/rany/Development/Projects/webssh/.tmp/dist/index.html",
),
"manifest.json": staticFileGen(
"/home/rany/Development/Projects/webssh/.tmp/dist/manifest.json",
),
"manifest.webapp": staticFileGen(
"/home/rany/Development/Projects/webssh/.tmp/dist/manifest.webapp",
),
"mstile-144x144.png": staticFileGen(
"/home/rany/Development/Projects/webssh/.tmp/dist/mstile-144x144.png",
),
"mstile-150x150.png": staticFileGen(
"/home/rany/Development/Projects/webssh/.tmp/dist/mstile-150x150.png",
),
"mstile-310x150.png": staticFileGen(
"/home/rany/Development/Projects/webssh/.tmp/dist/mstile-310x150.png",
),
"mstile-310x310.png": staticFileGen(
"/home/rany/Development/Projects/webssh/.tmp/dist/mstile-310x310.png",
),
"mstile-70x70.png": staticFileGen(
"/home/rany/Development/Projects/webssh/.tmp/dist/mstile-70x70.png",
),
} }
) )
// parseStaticData parses result from a static file returner and generate
// a new `staticData` item
func parseStaticData(
fileStart int,
fileEnd int,
compressedStart int,
compressedEnd int,
contentHash string,
compressedHash string,
creation time.Time,
data []byte,
contentType string,
) staticData {
return staticData{
data: data[fileStart:fileEnd],
dataHash: contentHash,
compressd: data[compressedStart:compressedEnd],
compressdHash: compressedHash,
created: creation,
contentType: contentType,
}
}