Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support: custom url and change to go mod #268

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM golang:1.13 as builder
ENV GO111MODULE=on
ENV GOPROXY https://goproxy.io
ENV CGO_ENABLED 0
ENV GOOS linux
ENV GO15VENDOREXPERIMENT 1
ENV GOFLAGS -mod=vendor

WORKDIR /app

#RUN go mod download
COPY . .
RUN go build -o /bin/gotty *.go

FROM golang:1.13 as runner
WORKDIR /app

COPY --from=builder /bin/gotty /bin/gotty
EXPOSE 8000

VOLUME /data

CMD ["gotty"]
54 changes: 0 additions & 54 deletions Godeps/Godeps.json

This file was deleted.

5 changes: 0 additions & 5 deletions Godeps/Readme

This file was deleted.

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ By default, GoTTY starts a web server at port 8080. Open the URL on your web bro
--permit-write, -w Permit clients to write to the TTY (BE CAREFUL) [$GOTTY_PERMIT_WRITE]
--credential value, -c value Credential for Basic Authentication (ex: user:pass, default disabled) [$GOTTY_CREDENTIAL]
--random-url, -r Add a random string to the URL [$GOTTY_RANDOM_URL]
--custom-url value Add a custom string to the URL [$GOTTY_CUSTOM_URL]
--random-url-length value Random URL length (default: 8) [$GOTTY_RANDOM_URL_LENGTH]
--tls, -t Enable TLS/SSL [$GOTTY_TLS]
--tls-crt value TLS/SSL certificate file path (default: "~/.gotty.crt") [$GOTTY_TLS_CRT]
Expand Down
15 changes: 15 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module github.com/yudai/gotty

go 1.12

require (
github.com/NYTimes/gziphandler v0.0.0-20170804200234-967539e5e271
github.com/codegangsta/cli v1.19.1
github.com/elazarl/go-bindata-assetfs v0.0.0-20150813044622-d5cac425555c
github.com/fatih/structs v0.0.0-20150526064352-a9f7daa9c272
github.com/gorilla/websocket v0.0.0-20150811171432-b6ab76f1fe98
github.com/hashicorp/go-multierror v0.0.0-20150608033521-56912fb08d85
github.com/kr/pty v0.0.0-20150511174710-5cf931ef8f76
github.com/pkg/errors v0.0.0-20161029093637-248dadf4e906
github.com/yudai/hcl v0.0.0-20151013225006-5fa2393b3552
)
6 changes: 5 additions & 1 deletion resources/xterm_customize.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
font-family: "DejaVu Sans Mono", "Everson Mono", FreeMono, Menlo, Terminal, monospace, "Apple Symbols";
}

.terminal .xterm-rows > div {
font-family: SFMono-Regular,Consolas,Liberation Mono,Menlo,Courier,monospace;
}

.xterm-overlay {
font-family: "DejaVu Sans Mono", "Everson Mono", FreeMono, Menlo, Terminal, monospace, "Apple Symbols";
border-radius: 15px;
Expand All @@ -16,4 +20,4 @@
transform: translate(-50%, -50%);
user-select: none;
transition: opacity 180ms ease-in;
}
}
1 change: 1 addition & 0 deletions server/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type Options struct {
EnableBasicAuth bool `hcl:"enable_basic_auth" default:"false"`
Credential string `hcl:"credential" flagName:"credential" flagSName:"c" flagDescribe:"Credential for Basic Authentication (ex: user:pass, default disabled)" default:""`
EnableRandomUrl bool `hcl:"enable_random_url" flagName:"random-url" flagSName:"r" flagDescribe:"Add a random string to the URL" default:"false"`
CustomUrl string `hcl:"custom_url" flagName:"custom-url" flagDescribe:"Add a custom string to the URL" default:""`
RandomUrlLength int `hcl:"random_url_length" flagName:"random-url-length" flagDescribe:"Random URL length" default:"8"`
EnableTLS bool `hcl:"enable_tls" flagName:"tls" flagSName:"t" flagDescribe:"Enable TLS/SSL" default:"false"`
TLSCrtFile string `hcl:"tls_crt_file" flagName:"tls-crt" flagDescribe:"TLS/SSL certificate file path" default:"~/.gotty.crt"`
Expand Down
4 changes: 2 additions & 2 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ func (server *Server) Run(ctx context.Context, options ...RunOption) error {

counter := newCounter(time.Duration(server.options.Timeout) * time.Second)

path := "/"
path := "/" + server.options.CustomUrl
if server.options.EnableRandomUrl {
path = "/" + randomstring.Generate(server.options.RandomUrlLength) + "/"
path = "/" + server.options.CustomUrl + randomstring.Generate(server.options.RandomUrlLength) + "/"
}

handlers := server.setupHandlers(cctx, cancel, path, counter)
Expand Down