Browse Source

Merge a76ee54545 into 2f1de6fdb3

pull/140/merge
gufertum 5 years ago
committed by GitHub
parent
commit
65f5c63127
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 42 additions and 5 deletions
  1. +3
    -3
      Dockerfile
  2. +2
    -0
      README.md
  3. +17
    -1
      cmd/cmd.go
  4. +1
    -1
      main.go
  5. +9
    -0
      server/handlers.go
  6. +10
    -0
      server/server.go

+ 3
- 3
Dockerfile View File

@@ -1,11 +1,11 @@
FROM golang:1.7-alpine
LABEL maintainer="Remco Verhoef <remco@dutchcoders.io>"
LABEL maintainer="Thomas Schädler <thomas@lambda.li>"

# Copy the local package files to the container's workspace.
ADD . /go/src/github.com/dutchcoders/transfer.sh
ADD . /go/src/github.com/gufertum/transfer.sh

# build & install server
RUN go build -o /go/bin/transfersh github.com/dutchcoders/transfer.sh
RUN go build -o /go/bin/transfersh github.com/gufertum/transfer.sh

ENTRYPOINT ["/go/bin/transfersh", "--listener", ":8080", "--provider", "s3"]



+ 2
- 0
README.md View File

@@ -71,6 +71,8 @@ gdrive-client-json-filepath | path to client json config for gdrive provider| |
gdrive-local-config-path | path to local transfer.sh config cache for gdrive provider| |
lets-encrypt-hosts | hosts to use for lets encrypt certificates (comma seperated) | |
log | path to log file| |
domain-url-scheme | domain url scheme (http or https) when running behind a proxy| |
domain-url-host | domain url host (fqdn) when running behind a proxy| |

If you want to use TLS using lets encrypt certificates, set lets-encrypt-hosts to your domain, set tls-listener to :443 and enable force-https.



+ 17
- 1
cmd/cmd.go View File

@@ -7,8 +7,8 @@ import (

"strings"

"github.com/dutchcoders/transfer.sh/server"
"github.com/fatih/color"
"github.com/gufertum/transfer.sh/server"
"github.com/minio/cli"
)

@@ -173,6 +173,16 @@ var globalFlags = []cli.Flag{
Usage: "pass for http basic auth",
Value: "",
},
cli.StringFlag{
Name: "domain-url-scheme",
Usage: "domain url scheme (http or https) when running behind a proxy",
Value: "",
},
cli.StringFlag{
Name: "domain-url-host",
Usage: "domain url host (fqdn) when running behind a proxy",
Value: "",
},
}

type Cmd struct {
@@ -308,6 +318,12 @@ func New() *Cmd {
panic("Provider not set or invalid.")
}

if domainUrlScheme := c.String("domain-url-scheme"); domainUrlScheme == "" {
} else if domainUrlHost := c.String("domain-url-host"); domainUrlHost == "" {
} else {
options = append(options, server.DomainUrl(domainUrlScheme, domainUrlHost))
}

srvr, err := server.New(
options...,
)


+ 1
- 1
main.go View File

@@ -1,6 +1,6 @@
package main

import "github.com/dutchcoders/transfer.sh/cmd"
import "github.com/gufertum/transfer.sh/cmd"

func main() {
app := cmd.New()


+ 9
- 0
server/handlers.go View File

@@ -300,6 +300,11 @@ func (s *Server) postHandler(w http.ResponseWriter, r *http.Request) {
}

relativeURL, _ := url.Parse(path.Join(token, filename))
var mappedUrl = getURL(r)
if s.DomainUrlScheme != "" && s.DomainUrlHost != "" {
mappedUrl.Scheme = s.DomainUrlScheme
mappedUrl.Host = s.DomainUrlHost
}
fmt.Fprint(w, getURL(r).ResolveReference(relativeURL).String())
}
}
@@ -443,6 +448,10 @@ func (s *Server) putHandler(w http.ResponseWriter, r *http.Request) {

w.Header().Set("X-Url-Delete", resolveUrl(r, deleteUrl, true))

if s.DomainUrlScheme != "" && s.DomainUrlHost != "" {
relativeURL.Scheme = s.DomainUrlScheme
relativeURL.Host = s.DomainUrlHost
}
fmt.Fprint(w, resolveUrl(r, relativeURL, false))
}



+ 10
- 0
server/server.go View File

@@ -210,6 +210,13 @@ func HttpAuthCredentials(user string, pass string) OptionFn {
}
}

func DomainUrl(scheme string, host string) OptionFn {
return func(srvr *Server) {
srvr.DomainUrlScheme = scheme
srvr.DomainUrlHost = host
}
}

type Server struct {
AuthUser string
AuthPass string
@@ -244,6 +251,9 @@ type Server struct {
Certificate string

LetsEncryptCache string
DomainUrlScheme string
DomainUrlHost string
}

func New(options ...OptionFn) (*Server, error) {


Loading…
Cancel
Save