Przeglądaj źródła

further simplifying

pull/294/head
stefanbenten 4 lat temu
rodzic
commit
bd1ebe5186
4 zmienionych plików z 70 dodań i 68 usunięć
  1. +1
    -1
      README.md
  2. +4
    -20
      cmd/cmd.go
  3. +48
    -47
      server/server.go
  4. +17
    -0
      server/utils/template.go

+ 1
- 1
README.md Wyświetl plik

@@ -105,7 +105,7 @@ basedir | path storage for local/gdrive provider| |
cleanup-interval | interval to clean up expired files from local storage | 1 |
gdrive-client-json-filepath | path to oauth client json config for gdrive provider| |
gdrive-local-config-path | path to store local transfer.sh config cache for gdrive provider| |
gdrive-chunk-size | chunk size for gdrive upload in megabytes, must be lower than available memory (8 MB) | |
gdrive-chunk-size | chunk size for gdrive upload in megabytes, must be lower than available memory | 16 |
lets-encrypt-hosts | hosts to use for lets encrypt certificates (comma seperated) | |
log | path to log file| |



+ 4
- 20
cmd/cmd.go Wyświetl plik

@@ -11,25 +11,9 @@ import (
"github.com/dutchcoders/transfer.sh/server/utils"
"github.com/fatih/color"
"github.com/urfave/cli"
"google.golang.org/api/googleapi"
)

var Version = "1.1.4"
var helpTemplate = `NAME:
{{.Name}} - {{.Usage}}

DESCRIPTION:
{{.Description}}

USAGE:
{{.Name}} {{if .Flags}}[flags] {{end}}command{{if .Flags}}{{end}} [arguments...]

COMMANDS:
{{range .Commands}}{{join .Names ", "}}{{ "\t" }}{{.Usage}}
{{end}}{{if .Flags}}
FLAGS:
{{range .Flags}}{{.}}
{{end}}{{end}}`
const Version = "1.1.4"

var globalFlags = []cli.Flag{
cli.StringFlag{
@@ -150,8 +134,8 @@ var globalFlags = []cli.Flag{
},
cli.IntFlag{
Name: "gdrive-chunk-size",
Usage: "",
Value: googleapi.DefaultUploadChunkSize / 1024 / 1024,
Usage: "chunk size for gdrive upload in megabytes, must be lower than available memory",
Value: 16,
},
cli.IntFlag{
Name: "rate-limit",
@@ -236,7 +220,7 @@ func New() *Cmd {
app.Description = `Easy file sharing from the command line`
app.Version = Version
app.Flags = globalFlags
app.CustomAppHelpTemplate = helpTemplate
app.CustomAppHelpTemplate = utils.HelpTemplate
app.Commands = []cli.Command{
{
Name: "version",


+ 48
- 47
server/server.go Wyświetl plik

@@ -59,6 +59,50 @@ const _24K = (1 << 3) * 24
// parse request with maximum memory of _5Megabytes
const _5M = (1 << 20) * 5


type Server struct {
AuthUser string
AuthPass string

logger *log.Logger

tlsConfig *tls.Config

profilerEnabled bool

locks map[string]*sync.Mutex

rateLimitRequests int

storage storage.Storage

lifetime time.Duration

forceHTTPs bool

ipFilterOptions *utils.IPFilterOptions

VirusTotalKey string
ClamAVDaemonHost string

tempPath string

webPath string
proxyPath string
gaKey string
userVoiceKey string

TLSListenerOnly bool

ListenerString string
TLSListenerString string
ProfileListenerString string

Certificate string

LetsEncryptCache string
}

type OptionFn func(*Server)

func ClamavHost(s string) OptionFn {
@@ -244,49 +288,6 @@ func FilterOptions(options utils.IPFilterOptions) OptionFn {
}
}

type Server struct {
AuthUser string
AuthPass string

logger *log.Logger

tlsConfig *tls.Config

profilerEnabled bool

locks map[string]*sync.Mutex

rateLimitRequests int

storage storage.Storage

lifetime time.Duration

forceHTTPs bool

ipFilterOptions *utils.IPFilterOptions

VirusTotalKey string
ClamAVDaemonHost string

tempPath string

webPath string
proxyPath string
gaKey string
userVoiceKey string

TLSListenerOnly bool

ListenerString string
TLSListenerString string
ProfileListenerString string

Certificate string

LetsEncryptCache string
}

func New(options ...OptionFn) (*Server, error) {
s := &Server{
locks: map[string]*sync.Mutex{},
@@ -299,10 +300,6 @@ func New(options ...OptionFn) (*Server, error) {
return s, nil
}

func init() {
rand.Seed(time.Now().UTC().UnixNano())
}

func (s *Server) Run() {
listening := false

@@ -477,3 +474,7 @@ func (s *Server) Run() {
func stripPrefix(path string) string {
return strings.Replace(path, web.Prefix+"/", "", -1)
}

func init() {
rand.Seed(time.Now().UTC().UnixNano())
}

+ 17
- 0
server/utils/template.go Wyświetl plik

@@ -0,0 +1,17 @@
package utils

const HelpTemplate = `NAME:
{{.Name}} - {{.Usage}}

DESCRIPTION:
{{.Description}}

USAGE:
{{.Name}} {{if .Flags}}[flags] {{end}}command{{if .Flags}}{{end}} [arguments...]

COMMANDS:
{{range .Commands}}{{join .Names ", "}}{{ "\t" }}{{.Usage}}
{{end}}{{if .Flags}}
FLAGS:
{{range .Flags}}{{.}}
{{end}}{{end}}`

Ładowanie…
Anuluj
Zapisz