Skip to content

Commit 34fd02c

Browse files
authored
Merge pull request #48 from wrfly/feature/exec-id
using exec ID to share
2 parents 0447fd2 + f13c772 commit 34fd02c

File tree

21 files changed

+403
-601
lines changed

21 files changed

+403
-601
lines changed

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ image:
4343
push-image:
4444
docker push $(IMAGE)
4545

46-
4746
.PHONY: push-develop
4847
push-develop:
4948
docker tag $(IMAGE) $(IMAGE):develop

README.md

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -130,23 +130,14 @@ After you exec some commands, you will see the inputs and outputs under the
130130

131131
### Real-time sharing
132132

133-
```bash
134-
docker run -dti --restart always --name container-web-tty \
135-
-p 8080:8080 \
136-
-e WEB_TTY_SHARE=true \
137-
-v /var/run/docker.sock:/var/run/docker.sock \
138-
wrfly/container-web-tty
139-
```
140-
141-
By enabling this feature, you can share the container's inputs and outputs
142-
with others via the share link (click the container's image to get the link).
133+
You can always share the container's inputs and outputs with others via the exec
134+
link, just share the `/exec/<exec-ID>` to them!
143135

144-
#### Collaborate
136+
### Collaborate
145137

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

160151
## Options
161152

@@ -172,8 +163,7 @@ GLOBAL OPTIONS:
172163
--docker-host value docker host path (default: "/var/run/docker.sock")
173164
--docker-ps value docker ps options
174165
--enable-audit, --audit enable audit the container outputs (default: false)
175-
--enable-collaborate, --clb shared terminal can write to the same TTY (default: false)
176-
--enable-share, --share enable share the container's terminal (default: false)
166+
--enable-collaborate, --clb collaborate on the same TTY process (default: false)
177167
--grpc-auth value grpc auth token (default: "password")
178168
--grpc-port value grpc server port, -1 for disable the grpc server (default: -1)
179169
--grpc-proxy value grpc proxy address, in the format of http://127.0.0.1:8080 or socks5://127.0.0.1:1080

config/config.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ type ServerConfig struct {
5151
WSOrigin string
5252
Term string `default:"xterm"`
5353
ShowLocation bool
54-
EnableShare bool
55-
Collaborate bool
54+
Collaborate bool
5655

5756
// audit
5857
EnableAudit bool

container/docker/slave.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"time"
55

66
apiTypes "github.com/docker/docker/api/types"
7+
"github.com/sirupsen/logrus"
78
)
89

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

3738
func (enj *execInjector) Write(p []byte) (n int, err error) {
38-
// logrus.Debugf("input: %v\n", p)
39+
logrus.Debugf("input: %v\n", p)
3940
return enj.hResp.Conn.Write(p)
4041
}
4142

4243
func (enj *execInjector) Exit() error {
43-
enj.Write([]byte{3}) // ^C
44-
enj.Write([]byte{4}) // ^D
44+
enj.Write([]byte{3, 13, 4, 13}) // ^C, ^D, enter
4545
close(enj.activeChan)
4646
return enj.hResp.Conn.Close()
4747
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ require (
3131
github.com/spf13/pflag v1.0.3 // indirect
3232
github.com/ugorji/go/codec v0.0.0-20190320090025-2dc34c0b8780 // indirect
3333
github.com/wrfly/ecp v0.1.1-0.20190725160759-97269b9e95f0
34-
github.com/wrfly/pubsub v0.0.0-20200307185349-b35c047681a4
34+
github.com/wrfly/pubsub v0.0.0-20200314104228-47828c5578b6
3535
github.com/yudai/gotty v2.0.0-alpha.3+incompatible
3636
golang.org/x/net v0.0.0-20190326090315-15845e8f865b
3737
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 // indirect

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ github.com/ugorji/go/codec v0.0.0-20190320090025-2dc34c0b8780 h1:vG/gY/PxA3v3l04
7474
github.com/ugorji/go/codec v0.0.0-20190320090025-2dc34c0b8780/go.mod h1:iT03XoTwV7xq/+UGwKO3UbC1nNNlopQiY61beSdrtOA=
7575
github.com/wrfly/ecp v0.1.1-0.20190725160759-97269b9e95f0 h1:Zy3Chk4CvwAqJ6YgQym6hJQEk4JE7iPbHRfxkru6Zn0=
7676
github.com/wrfly/ecp v0.1.1-0.20190725160759-97269b9e95f0/go.mod h1:cmmFTD+MLlrDa3/EO3gjeKLKUhHiYP3cgaaJamIS1NU=
77-
github.com/wrfly/pubsub v0.0.0-20200307185349-b35c047681a4 h1:G8zs08Ln8gek2TpeM1dgYFlUepEK6JNCM966Sf1kT+8=
78-
github.com/wrfly/pubsub v0.0.0-20200307185349-b35c047681a4/go.mod h1:WFtPVb6GumrLEVcAHZPSbjZmvWgenDSi4ceFW7k1r30=
77+
github.com/wrfly/pubsub v0.0.0-20200314104228-47828c5578b6 h1:iuI+7TJcnnKB3WH08PmK5Y4c66Tf2XNXmnvLpIFFP30=
78+
github.com/wrfly/pubsub v0.0.0-20200314104228-47828c5578b6/go.mod h1:WFtPVb6GumrLEVcAHZPSbjZmvWgenDSi4ceFW7k1r30=
7979
github.com/yudai/gotty v2.0.0-alpha.3+incompatible h1:eUFSuV4B2g+Rj+PS3HxhvOGEu2klWRzsl/7z7T/NUJQ=
8080
github.com/yudai/gotty v2.0.0-alpha.3+incompatible/go.mod h1:QBg0hL6VTVdqQk0qoBYk631EHLRH+XtR4wtbVi64UJ4=
8181
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793 h1:u+LnwYTOOW7Ukr/fppxEb1Nwz0AtPflrblfvUudpo+I=

main.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,6 @@ func main() {
128128
Usage: "enable container restart",
129129
Destination: &conf.Server.Control.Restart,
130130
},
131-
&cli.BoolFlag{
132-
Name: "enable-share",
133-
Aliases: []string{"share"},
134-
EnvVars: util.EnvVars("share"),
135-
Usage: "enable share the container's terminal",
136-
Destination: &conf.Server.EnableShare,
137-
},
138131
&cli.BoolFlag{
139132
Name: "enable-collaborate",
140133
Aliases: []string{"clb"},

resources/clipboard.min.js

Lines changed: 0 additions & 7 deletions
This file was deleted.

resources/list.html

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
<title>{{ .title }}</title>
77
<link rel="icon" type="image/png" href="/favicon.png">
88
<link rel="stylesheet" href="/css/list.css" />
9-
<script src="/js/clipboard.min.js"></script>
109
</head>
1110

1211
<body>
@@ -38,17 +37,9 @@
3837
{{ range $i, $e := .containers }}
3938
<tr {{ if (eq (mod $i 2) 1) -}}class="t c ver2"{{- end }}>
4039
<td class="column1" title="exec into container">
41-
<a href="/exec/{{ printf "%.12s" .ID }}" value="{{ .ID }}" target="_blank">{{ printf "%.12s" .ID }}</a>
40+
<a href="/e/{{ printf "%.12s" .ID }}" value="{{ .ID }}" target="_blank">{{ printf "%.12s" .ID }}</a>
4241
</td>
43-
{{- if $share -}}
44-
<td class="column2" title="{{ .Image }} | share tty">
45-
<a href="#" class="copy" data-clipboard-text="/share/{{ printf "%.12s" .ID }}">{{ printf .Image }}</a>
46-
</td>
47-
{{- else -}}
48-
<td class="column2" title="{{ .Image }}">
49-
{{ printf .Image }}
50-
</td>
51-
{{- end -}}
42+
<td class="column2" title="{{ .Image }}">{{ printf .Image }}</td>
5243
<td class="column3" title="{{ .Command }}">{{ printf .Command }}</td>
5344
<td class="column4" title="{{ .Name }}">
5445
<a href="/logs/{{ printf "%.12s" .ID }}?follow=1&tail=10" target="_blank" title="get logs">{{ printf .Name }}</a>
@@ -74,21 +65,6 @@
7465
</div>
7566

7667
<script src="/js/control.js"></script>
77-
<script>
78-
var clipboard = new ClipboardJS('.copy', {
79-
text: function (trigger) {
80-
return trigger.baseURI.replace('/#','') + trigger.getAttribute('data-clipboard-text');
81-
}
82-
});
83-
clipboard.on('success', function (e) {
84-
console.info('Action:', e.action);
85-
console.info('Text:', e.text);
86-
console.info('Trigger:', e.trigger);
87-
88-
e.clearSelection();
89-
alert("share link ("+e.text+") copied!");
90-
});
91-
</script>
9268
</body>
9369

9470
</html>

0 commit comments

Comments
 (0)