Skip to content

Commit 53d4651

Browse files
authored
Merge pull request #46 from wrfly/develop
feat: enable collabrate
2 parents d7e2476 + c3f4f98 commit 53d4651

File tree

3 files changed

+41
-24
lines changed

3 files changed

+41
-24
lines changed

README.md

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -141,32 +141,48 @@ docker run -dti --restart always --name container-web-tty \
141141
By enabling this feature, you can share the container's inputs and outputs
142142
with others via the share link (click the container's image to get the link).
143143

144+
#### Collaborate
145+
146+
```bash
147+
docker run -dti --restart always --name container-web-tty \
148+
-p 8080:8080 \
149+
-e WEB_TTY_SHARE=true \
150+
-e WEB_TTY_COLLABORATE=true \
151+
-v /var/run/docker.sock:/var/run/docker.sock \
152+
wrfly/container-web-tty
153+
```
154+
155+
By enabling this feature, once you exec into the container, you can share your
156+
process with others, that means anyone got the shareable link would type the command
157+
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)
159+
144160
## Options
145161

146162
```txt
147163
GLOBAL OPTIONS:
148-
--addr value server binding address
149-
--audit-dir value container audit log dir path
150-
--backend value, -b value backend type, 'docker' or 'kube' or 'grpc'(remote)
151-
--control-all, --ctl-a enable container control
152-
--control-restart, --ctl-r enable container restart
153-
--control-start, --ctl-s enable container start
154-
--control-stop, --ctl-t enable container stop
155-
--debug, -d debug mode (log-level=debug enable pprof)
156-
--docker-host value docker host path
157-
--docker-ps value docker ps options
158-
--enable-audit, --audit enable audit the container outputs
159-
--enable-share, --share enable share the container's terminal
160-
--extra-args value pass extra args to the backend
161-
--grpc-auth value grpc auth token
162-
--grpc-port value grpc server port, -1 for disable the grpc server
163-
--grpc-proxy value grpc proxy address, in the format of http://127.0.0.1:8080 or socks5://127.0.0.1:1080
164-
--grpc-servers value upstream servers, for proxy mode(grpc address and port), use comma for split
165-
--help, -h show help
166-
--idle-time value time out of an idle connection
167-
--kube-config value kube config path
168-
--port value, -p value HTTP server port, -1 for disable the HTTP server
169-
--version, -v print the version
164+
--addr value server binding address (default: "0.0.0.0")
165+
--audit-dir value container audit log dir path (default: "audit")
166+
--backend value, -b value backend type, 'docker' or 'kube' or 'grpc'(remote) (default: "docker")
167+
--control-all, --ctl-a enable container control (default: false)
168+
--control-restart, --ctl-r enable container restart (default: false)
169+
--control-start, --ctl-s enable container start (default: false)
170+
--control-stop, --ctl-t enable container stop (default: false)
171+
--debug, -d debug mode (log-level=debug enable pprof) (default: false)
172+
--docker-host value docker host path (default: "/var/run/docker.sock")
173+
--docker-ps value docker ps options
174+
--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)
177+
--grpc-auth value grpc auth token (default: "password")
178+
--grpc-port value grpc server port, -1 for disable the grpc server (default: -1)
179+
--grpc-proxy value grpc proxy address, in the format of http://127.0.0.1:8080 or socks5://127.0.0.1:1080
180+
--grpc-servers value upstream servers, for proxy mode(grpc address and port), use comma for split
181+
--help, -h show help (default: false)
182+
--idle-time value time out of an idle connection
183+
--kube-config value kube config path (default: "/home/mr/.kube/config")
184+
--port value, -p value HTTP server port, -1 for disable the HTTP server (default: 8080)
185+
--version, -v print the version (default: false)
170186
```
171187

172188
## Show-off

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ func main() {
137137
},
138138
&cli.BoolFlag{
139139
Name: "enable-collaborate",
140-
Aliases: []string{"collaborate"},
140+
Aliases: []string{"clb"},
141141
EnvVars: util.EnvVars("collaborate"),
142142
Usage: "shared terminal can write to the same TTY",
143143
Destination: &conf.Server.Collaborate,

route/exec.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@ func (server *Server) processTTY(ctx context.Context, timeoutCancel context.Canc
134134
}
135135

136136
wrapper := &wsWrapper{conn}
137-
masterTTY, err := types.NewMasterTTY(ctx, containerTTY, container.ID)
137+
shareID := fmt.Sprintf("%s-%d", container.ID, time.Now().UnixNano())
138+
masterTTY, err := types.NewMasterTTY(ctx, containerTTY, shareID)
138139
if err != nil {
139140
return err
140141
}

0 commit comments

Comments
 (0)