Skip to content

Commit

Permalink
Merge pull request #48 from wrfly/feature/exec-id
Browse files Browse the repository at this point in the history
using exec ID to share
  • Loading branch information
wrfly authored Mar 28, 2020
2 parents 0447fd2 + f13c772 commit 34fd02c
Show file tree
Hide file tree
Showing 21 changed files with 403 additions and 601 deletions.
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ image:
push-image:
docker push $(IMAGE)


.PHONY: push-develop
push-develop:
docker tag $(IMAGE) $(IMAGE):develop
Expand Down
20 changes: 5 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,23 +130,14 @@ After you exec some commands, you will see the inputs and outputs under the

### Real-time sharing

```bash
docker run -dti --restart always --name container-web-tty \
-p 8080:8080 \
-e WEB_TTY_SHARE=true \
-v /var/run/docker.sock:/var/run/docker.sock \
wrfly/container-web-tty
```

By enabling this feature, you can share the container's inputs and outputs
with others via the share link (click the container's image to get the link).
You can always share the container's inputs and outputs with others via the exec
link, just share the `/exec/<exec-ID>` to them!

#### Collaborate
### Collaborate

```bash
docker run -dti --restart always --name container-web-tty \
-p 8080:8080 \
-e WEB_TTY_SHARE=true \
-e WEB_TTY_COLLABORATE=true \
-v /var/run/docker.sock:/var/run/docker.sock \
wrfly/container-web-tty
Expand All @@ -155,7 +146,7 @@ docker run -dti --restart always --name container-web-tty \
By enabling this feature, once you exec into the container, you can share your
process with others, that means anyone got the shareable link would type the command
to the tty you are working on. You can edit the same file, type the same code, in the
same TTY! (P.S. Only the first exec process would be shared to others)
same TTY! Just share the exec link to your friend!

## Options

Expand All @@ -172,8 +163,7 @@ GLOBAL OPTIONS:
--docker-host value docker host path (default: "/var/run/docker.sock")
--docker-ps value docker ps options
--enable-audit, --audit enable audit the container outputs (default: false)
--enable-collaborate, --clb shared terminal can write to the same TTY (default: false)
--enable-share, --share enable share the container's terminal (default: false)
--enable-collaborate, --clb collaborate on the same TTY process (default: false)
--grpc-auth value grpc auth token (default: "password")
--grpc-port value grpc server port, -1 for disable the grpc server (default: -1)
--grpc-proxy value grpc proxy address, in the format of http://127.0.0.1:8080 or socks5://127.0.0.1:1080
Expand Down
3 changes: 1 addition & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ type ServerConfig struct {
WSOrigin string
Term string `default:"xterm"`
ShowLocation bool
EnableShare bool
Collaborate bool
Collaborate bool

// audit
EnableAudit bool
Expand Down
6 changes: 3 additions & 3 deletions container/docker/slave.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"time"

apiTypes "github.com/docker/docker/api/types"
"github.com/sirupsen/logrus"
)

// execInjector implement webtty.Slave
Expand Down Expand Up @@ -35,13 +36,12 @@ func (enj *execInjector) Read(p []byte) (n int, err error) {
}

func (enj *execInjector) Write(p []byte) (n int, err error) {
// logrus.Debugf("input: %v\n", p)
logrus.Debugf("input: %v\n", p)
return enj.hResp.Conn.Write(p)
}

func (enj *execInjector) Exit() error {
enj.Write([]byte{3}) // ^C
enj.Write([]byte{4}) // ^D
enj.Write([]byte{3, 13, 4, 13}) // ^C, ^D, enter
close(enj.activeChan)
return enj.hResp.Conn.Close()
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ require (
github.com/spf13/pflag v1.0.3 // indirect
github.com/ugorji/go/codec v0.0.0-20190320090025-2dc34c0b8780 // indirect
github.com/wrfly/ecp v0.1.1-0.20190725160759-97269b9e95f0
github.com/wrfly/pubsub v0.0.0-20200307185349-b35c047681a4
github.com/wrfly/pubsub v0.0.0-20200314104228-47828c5578b6
github.com/yudai/gotty v2.0.0-alpha.3+incompatible
golang.org/x/net v0.0.0-20190326090315-15845e8f865b
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ github.com/ugorji/go/codec v0.0.0-20190320090025-2dc34c0b8780 h1:vG/gY/PxA3v3l04
github.com/ugorji/go/codec v0.0.0-20190320090025-2dc34c0b8780/go.mod h1:iT03XoTwV7xq/+UGwKO3UbC1nNNlopQiY61beSdrtOA=
github.com/wrfly/ecp v0.1.1-0.20190725160759-97269b9e95f0 h1:Zy3Chk4CvwAqJ6YgQym6hJQEk4JE7iPbHRfxkru6Zn0=
github.com/wrfly/ecp v0.1.1-0.20190725160759-97269b9e95f0/go.mod h1:cmmFTD+MLlrDa3/EO3gjeKLKUhHiYP3cgaaJamIS1NU=
github.com/wrfly/pubsub v0.0.0-20200307185349-b35c047681a4 h1:G8zs08Ln8gek2TpeM1dgYFlUepEK6JNCM966Sf1kT+8=
github.com/wrfly/pubsub v0.0.0-20200307185349-b35c047681a4/go.mod h1:WFtPVb6GumrLEVcAHZPSbjZmvWgenDSi4ceFW7k1r30=
github.com/wrfly/pubsub v0.0.0-20200314104228-47828c5578b6 h1:iuI+7TJcnnKB3WH08PmK5Y4c66Tf2XNXmnvLpIFFP30=
github.com/wrfly/pubsub v0.0.0-20200314104228-47828c5578b6/go.mod h1:WFtPVb6GumrLEVcAHZPSbjZmvWgenDSi4ceFW7k1r30=
github.com/yudai/gotty v2.0.0-alpha.3+incompatible h1:eUFSuV4B2g+Rj+PS3HxhvOGEu2klWRzsl/7z7T/NUJQ=
github.com/yudai/gotty v2.0.0-alpha.3+incompatible/go.mod h1:QBg0hL6VTVdqQk0qoBYk631EHLRH+XtR4wtbVi64UJ4=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793 h1:u+LnwYTOOW7Ukr/fppxEb1Nwz0AtPflrblfvUudpo+I=
Expand Down
7 changes: 0 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,6 @@ func main() {
Usage: "enable container restart",
Destination: &conf.Server.Control.Restart,
},
&cli.BoolFlag{
Name: "enable-share",
Aliases: []string{"share"},
EnvVars: util.EnvVars("share"),
Usage: "enable share the container's terminal",
Destination: &conf.Server.EnableShare,
},
&cli.BoolFlag{
Name: "enable-collaborate",
Aliases: []string{"clb"},
Expand Down
7 changes: 0 additions & 7 deletions resources/clipboard.min.js

This file was deleted.

28 changes: 2 additions & 26 deletions resources/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<title>{{ .title }}</title>
<link rel="icon" type="image/png" href="/favicon.png">
<link rel="stylesheet" href="/css/list.css" />
<script src="/js/clipboard.min.js"></script>
</head>

<body>
Expand Down Expand Up @@ -38,17 +37,9 @@
{{ range $i, $e := .containers }}
<tr {{ if (eq (mod $i 2) 1) -}}class="t c ver2"{{- end }}>
<td class="column1" title="exec into container">
<a href="/exec/{{ printf "%.12s" .ID }}" value="{{ .ID }}" target="_blank">{{ printf "%.12s" .ID }}</a>
<a href="/e/{{ printf "%.12s" .ID }}" value="{{ .ID }}" target="_blank">{{ printf "%.12s" .ID }}</a>
</td>
{{- if $share -}}
<td class="column2" title="{{ .Image }} | share tty">
<a href="#" class="copy" data-clipboard-text="/share/{{ printf "%.12s" .ID }}">{{ printf .Image }}</a>
</td>
{{- else -}}
<td class="column2" title="{{ .Image }}">
{{ printf .Image }}
</td>
{{- end -}}
<td class="column2" title="{{ .Image }}">{{ printf .Image }}</td>
<td class="column3" title="{{ .Command }}">{{ printf .Command }}</td>
<td class="column4" title="{{ .Name }}">
<a href="/logs/{{ printf "%.12s" .ID }}?follow=1&tail=10" target="_blank" title="get logs">{{ printf .Name }}</a>
Expand All @@ -74,21 +65,6 @@
</div>

<script src="/js/control.js"></script>
<script>
var clipboard = new ClipboardJS('.copy', {
text: function (trigger) {
return trigger.baseURI.replace('/#','') + trigger.getAttribute('data-clipboard-text');
}
});
clipboard.on('success', function (e) {
console.info('Action:', e.action);
console.info('Text:', e.text);
console.info('Trigger:', e.trigger);

e.clearSelection();
alert("share link ("+e.text+") copied!");
});
</script>
</body>

</html>
Loading

0 comments on commit 34fd02c

Please sign in to comment.