Skip to content

Commit b2f72d6

Browse files
committed
add alert
1 parent 7c8d9c3 commit b2f72d6

File tree

21 files changed

+1469
-276
lines changed

21 files changed

+1469
-276
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,19 @@
1010
## Licensing
1111
Entry is released under [MIT](https://github.com/laincloud/entry/blob/master/LICENSE) license.
1212

13+
## 部署
14+
15+
### 配置
16+
17+
请参考 [example.json](example.json) 编写配置文件,并上传到 lvault:
18+
19+
```
20+
lain secret add ${LAIN-Domain} web /lain/app/prod.json -f example.json
21+
```
22+
23+
> - `smtp.address` 需要包含端口,如:${mail-address}:25
24+
> - `smtp.password` 可选,为空时不使用 auth
25+
1326
## 审计
1427

1528
## 开发
@@ -20,3 +33,7 @@ Entry is released under [MIT](https://github.com/laincloud/entry/blob/master/LIC
2033
go get -u github.com/go-swagger/go-swagger/cmd/swagger # 安装 swagger
2134
swagger generate server -f ./swagger.yml -t server/gen # 生成代码
2235
```
36+
37+
- `server/gen` 下除 `server/gen/restapi/configure_entry.go` 外均由 `go-swagger` 生成,请不要手动修改
38+
- `server/gen/restapi/configure_entry.go` 包含初始化逻辑以及后端 API 配置
39+
- `server/handler` 包含后端 API 的实际逻辑

TODOs.org

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
CLOSED: [2018-03-08 Thu 19:14]
1010
* DONE 前端:commands content
1111
CLOSED: [2018-03-09 Fri 20:16]
12-
* TODO 前端:sessions -> commands 跳转
13-
* TODO 后端:会话记录
14-
* TODO 前端:会话重放
12+
* DONE 前端:sessions -> commands 跳转
13+
CLOSED: [2018-03-22 Thu 17:48]
14+
* DONE 后端:会话记录
15+
CLOSED: [2018-03-22 Thu 17:48]
16+
* DONE 前端:会话重放
17+
CLOSED: [2018-03-22 Thu 17:48]
18+
* TODO 后端:监控报警

frontend/src/MyAxios.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import axios from 'axios';
22

33
const myAxios = axios.create({
44
headers: {
5-
'Accept': 'application/vnd.laincloud.entry.v1+json'
5+
'Accept': 'application/vnd.laincloud.entry.v3+json'
66
}
77
});
88

lain.yaml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,28 @@ appname: entry
33
build:
44
base: golang:1.10
55
prepare:
6-
version: 20180207
6+
version: 20180309
77
script:
88
# - sed -i 's|deb.debian.org|mirrors.tuna.tsinghua.edu.cn|g' /etc/apt/sources.list
99
# - sed -i 's|security.debian.org|mirrors.tuna.tsinghua.edu.cn/debian-security|g' /etc/apt/sources.list
10-
# - curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
11-
# - echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
12-
# - apt-get -y update && apt-get -y install golang-glide
13-
# - apt-get -y update && apt-get -y install yarn
10+
- curl -sL https://deb.nodesource.com/setup_9.x | bash -
11+
- apt-get -y update && apt-get -y install apt-transport-https ca-certificates golang-glide nodejs
12+
- curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
13+
- echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
14+
- apt-get -y update && apt-get -y install yarn
1415
- mkdir -p $GOPATH/src/github.com/laincloud/entry
1516
- cp -rf . $GOPATH/src/github.com/laincloud/entry
16-
# - cd $GOPATH/src/github.com/laincloud/entry && glide install
17+
- cd $GOPATH/src/github.com/laincloud/entry && glide install
1718
- go install github.com/laincloud/entry/server/gen/cmd/entry-server
18-
# - cd $GOPATH/src/github.com/laincloud/entry/frontend/ && yarn install
19+
- cd $GOPATH/src/github.com/laincloud/entry/frontend/ && yarn install
1920
script:
2021
- cp -rf . $GOPATH/src/github.com/laincloud/entry
2122
- go install github.com/laincloud/entry/server/gen/cmd/entry-server
22-
# - cd $GOPATH/src/github.com/laincloud/entry/frontend/ && yarn build
23+
- cd $GOPATH/src/github.com/laincloud/entry/frontend/ && yarn build
2324

2425
test:
2526
script:
26-
- go test github.com/laincloud/entry/server
27+
- go test github.com/laincloud/entry/server/...
2728

2829
release:
2930
dest_base: laincloud/nginx:1.13
@@ -32,7 +33,7 @@ release:
3233
dest: /lain/app/entry-server
3334
- src: nginx.conf
3435
dest: /etc/nginx/conf.d/default.conf
35-
- src: frontend/build
36+
- src: $GOPATH/src/github.com/laincloud/entry/frontend/build
3637
dest: /usr/share/nginx/html
3738

3839
web: # backend
@@ -46,7 +47,7 @@ web: # backend
4647
secret_files:
4748
- /lain/app/prod.json
4849
cloud_volumes:
49-
type: multi
50+
type: single
5051
dirs:
5152
- /cloud
5253

server/config/config.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
type Config struct {
1313
MySQL MySQL `json:"mysql"`
1414
SSO SSO `json:"sso"`
15+
SMTP SMTP `json:"smtp"`
1516
}
1617

1718
// NewConfig return an initialized configuration
@@ -65,3 +66,10 @@ type SSO struct {
6566
EntryGroup string `json:"entry_group"`
6667
Scope string `json:"scope"`
6768
}
69+
70+
// SMTP denotes SMTP configuration
71+
type SMTP struct {
72+
Address string `json:"address"`
73+
FromEmail string `json:"from_email"`
74+
Password string `json:"password"`
75+
}

server/gen/restapi/configure_entry.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,6 @@ func configureAPI(api *operations.EntryAPI) http.Handler {
106106
api.AuthLogoutHandler = auth.LogoutHandlerFunc(func(params auth.LogoutParams) middleware.Responder {
107107
return handler.Logout(params, g)
108108
})
109-
api.AuthGetMeHandler = auth.GetMeHandlerFunc(func(params auth.GetMeParams) middleware.Responder {
110-
return handler.GetMe(params, g)
111-
})
112109
api.ConfigGetConfigHandler = swaggerconfig.GetConfigHandlerFunc(func(params swaggerconfig.GetConfigParams) middleware.Responder {
113110
return handler.GetConfig(params, g)
114111
})

server/gen/restapi/doc.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/gen/restapi/embedded_spec.go

Lines changed: 4 additions & 88 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/gen/restapi/operations/entry_api.go

Lines changed: 6 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/handler/enter.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,15 @@ func Enter(ctx context.Context, conn *websocket.Conn, r *http.Request, g *global
6262
}
6363
defer timingFile.Close()
6464

65+
replay := &sessionReplay{
66+
typescriptFile: typescriptFile,
67+
timingFile: timingFile,
68+
}
69+
pipe := &pipe{
70+
requestBuffer: make(chan []byte),
71+
responseBuffer: make(chan []byte),
72+
}
73+
6574
termType := r.Header.Get("term-type")
6675
if len(termType) == 0 {
6776
termType = "xterm-256color"
@@ -95,9 +104,9 @@ func Enter(ctx context.Context, conn *websocket.Conn, r *http.Request, g *global
95104
wg := &sync.WaitGroup{}
96105
wg.Add(3)
97106
go handleAliveDetection(conn, stopSignal, msgMarshaller, writeLock)
98-
go handleRequest(conn, s, stdinPipeWriter, wg, exec.ID, msgUnmarshaller, g)
99-
go handleResponse(conn, stdoutPipeReader, wg, message.ResponseMessage_STDOUT, msgMarshaller, writeLock, typescriptFile, timingFile)
100-
go handleResponse(conn, stderrPipeReader, wg, message.ResponseMessage_STDERR, msgMarshaller, writeLock, typescriptFile, timingFile)
107+
go handleRequest(conn, s, stdinPipeWriter, wg, exec.ID, msgUnmarshaller, g, pipe)
108+
go handleResponse(conn, stdoutPipeReader, wg, message.ResponseMessage_STDOUT, msgMarshaller, writeLock, replay, pipe)
109+
go handleResponse(conn, stderrPipeReader, wg, message.ResponseMessage_STDERR, msgMarshaller, writeLock, replay, pipe)
101110
go func() {
102111
if err = g.DockerClient.StartExec(exec.ID, docker.StartExecOptions{
103112
Detach: false,

0 commit comments

Comments
 (0)