完善dockerfile构建镜像

This commit is contained in:
dushixiang 2020-12-24 23:21:51 +08:00
parent 348074670e
commit 72f7dd5dc6
36 changed files with 369 additions and 277 deletions

View File

@ -8,22 +8,33 @@ WORKDIR /app
COPY . . COPY . .
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories RUN go env && CGO_ENABLED=0 go build -o nt main.go
RUN apk add gcc g++
RUN go env && CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -a -ldflags '-linkmode external -extldflags "-static"' -o next_terminal main.go
FROM guacamole/guacd:1.2.0 FROM guacamole/guacd:1.2.0
LABEL MAINTAINER="helloworld1024@foxmail.com" LABEL MAINTAINER="helloworld1024@foxmail.com"
WORKDIR /opt/next_terminal RUN apt-get update && apt-get -y install supervisor
RUN mkdir -p /var/log/supervisor
COPY --from=builder /app/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY --from=builder /app/next_terminal ./ ENV MYSQL_HOSTNAME 127.0.0.1
COPY --from=builder /app/next-terminal.yml ./ ENV MYSQL_PORT 3306
ENV MYSQL_USERNAME mysql
ENV MYSQL_PASSWORD mysql
ENV MYSQL_DATABASE next_terminal
ENV SERVER_PORT 8088
WORKDIR /usr/local/nt
COPY --from=builder /app/nt ./
COPY --from=builder /app/config.yml ./
COPY --from=builder /app/web/build ./web/build COPY --from=builder /app/web/build ./web/build
COPY --from=builder /app/web/src/fonts/Menlo-Regular-1.ttf /usr/share/fonts/
RUN touch next-terminal.db & chmod +x next_terminal RUN mkfontscale && mkfontdir && fc-cache
EXPOSE 8088 EXPOSE $SERVER_PORT
ENTRYPOINT ./next_terminal RUN mkdir recording && mkdir drive
ENTRYPOINT /usr/bin/supervisord

8
config.yml Normal file
View File

@ -0,0 +1,8 @@
mysql:
hostname: 127.0.0.1
port: 3306
username: root
password: root
database: next_terminal
server:
addr: 0.0.0.0:8088

7
go.mod
View File

@ -3,17 +3,16 @@ module next-terminal
go 1.13 go 1.13
require ( require (
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d // indirect
github.com/go-ole/go-ole v1.2.4 // indirect
github.com/gofrs/uuid v3.3.0+incompatible github.com/gofrs/uuid v3.3.0+incompatible
github.com/gorilla/websocket v1.4.2 github.com/gorilla/websocket v1.4.2
github.com/labstack/echo/v4 v4.1.17 github.com/labstack/echo/v4 v4.1.17
github.com/labstack/gommon v0.3.0 github.com/labstack/gommon v0.3.0
github.com/patrickmn/go-cache v2.1.0+incompatible github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/pkg/sftp v1.12.0 github.com/pkg/sftp v1.12.0
github.com/sirupsen/logrus v1.2.0
github.com/spf13/pflag v1.0.3
github.com/spf13/viper v1.7.1 github.com/spf13/viper v1.7.1
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a
gorm.io/driver/mysql v1.0.1 gorm.io/driver/mysql v1.0.3
gorm.io/driver/sqlite v1.1.4
gorm.io/gorm v1.20.7 gorm.io/gorm v1.20.7
) )

85
go.sum
View File

@ -11,11 +11,10 @@ cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqCl
cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I=
cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d h1:G0m3OIz70MZUWq3EgK3CesDbo8upS2Vm9/P3FtgI+Jk=
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
@ -25,9 +24,6 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84=
github.com/boj/redistore v0.0.0-20180917114910-cd5dcc76aeff/go.mod h1:+RTT1BOk5P97fT2CiHkbFQwkK3mjsFAP6zCYV2aXtjw=
github.com/bradfitz/gomemcache v0.0.0-20190329173943-551aad21a668/go.mod h1:H0wQNHz2YrLsuXOZozoeDmnHXkNCRmMW0gwFWDfEZDA=
github.com/bradleypeabody/gorilla-sessions-memcache v0.0.0-20181103040241-659414f458e1/go.mod h1:dkChI7Tbtx7H1Tj7TqGSZMOeGpMP5gLHtjroHd4agiI=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
@ -45,30 +41,10 @@ github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5Kwzbycv
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/gin-contrib/sessions v0.0.3 h1:PoBXki+44XdJdlgDqDrY5nDVe3Wk7wDV/UCOuLP6fBI=
github.com/gin-contrib/sessions v0.0.3/go.mod h1:8C/J6cad3Il1mWYYgtw0w+hqasmpvy25mPkXdOgeB9I=
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
github.com/gin-gonic/gin v1.5.0/go.mod h1:Nd6IXA8m5kNZdNEHMBd93KT+mdY3+bewLgRvmCsR2Do=
github.com/gin-gonic/gin v1.6.3 h1:ahKqKTFpO5KTPHxWZjEdPScmYaGtLo8Y4DMHoEsnp14=
github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M=
github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q=
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
github.com/go-ole/go-ole v1.2.4 h1:nNBDSCOigTSiarFpYE9J/KtEA1IOW4CNeqT9TQDqCxI=
github.com/go-ole/go-ole v1.2.4/go.mod h1:XCwSNxSkXRo4vlyPy93sltvi/qJq0jqQhjqQNIwKuxM=
github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A=
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
github.com/go-playground/locales v0.12.1/go.mod h1:IUMDtCfWo/w/mtMfIE/IG2K+Ey3ygWanZIBtBW0W2TM=
github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q=
github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8=
github.com/go-playground/universal-translator v0.16.0/go.mod h1:1AnU7NaIRDWWzGEKwgtJRd2xk99HeFyHw3yid4rvQIY=
github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no=
github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA=
github.com/go-playground/validator/v10 v10.2.0 h1:KgJ0snyC2R9VXYN2rneOtQcw5aHQB1Vv0sFl1UcHBOY=
github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI=
github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs= github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs=
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
@ -84,28 +60,18 @@ github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFU
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.3 h1:gyjaxf+svBWX08ZjK86iN9geUJF0H6gp2IRKX6Nf6/I=
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
github.com/gomodule/redigo v2.0.0+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4=
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gorilla/context v1.1.1 h1:AWwleXJkX/nhcU9bZSnZoi3h/qGYqQAGhq6zZe/aQW8=
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyCS8BvQ=
github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4=
github.com/gorilla/sessions v1.1.1/go.mod h1:8KCfur6+4Mqcc6S0FEfKuN15Vl5MgXW92AE8ovaJD0w=
github.com/gorilla/sessions v1.1.3 h1:uXoZdcdA5XdXF3QzuSlheVRUvjl+1rKY7zBXL68L9RU=
github.com/gorilla/sessions v1.1.3/go.mod h1:8KCfur6+4Mqcc6S0FEfKuN15Vl5MgXW92AE8ovaJD0w=
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
@ -138,31 +104,26 @@ github.com/jinzhu/now v1.1.1 h1:g39TucaRWyV3dwDO++eEc6qf8TVIQ/Da48WmqjZ3i7E=
github.com/jinzhu/now v1.1.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= github.com/jinzhu/now v1.1.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.9 h1:9yzud/Ht36ygwatGx56VwCZtlI/2AD15T1X2sjSuGns=
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/kidstuff/mongostore v0.0.0-20181113001930-e650cd85ee4b/go.mod h1:g2nVr8KZVXJSS97Jo8pJ0jgq29P6H7dG0oplUA86MQw=
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/fs v0.1.0 h1:Jskdu9ieNAYnjxsi0LbQp1ulIKZV1LAFgK1tWhpZgl8= github.com/kr/fs v0.1.0 h1:Jskdu9ieNAYnjxsi0LbQp1ulIKZV1LAFgK1tWhpZgl8=
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/labstack/echo v1.4.4 h1:1bEiBNeGSUKxcPDGfZ/7IgdhJJZx8wV/pICJh4W2NJI=
github.com/labstack/echo v3.3.10+incompatible h1:pGRcYk231ExFAyoAjAfD85kQzRJCRI8bbnE7CX5OEgg=
github.com/labstack/echo/v4 v4.1.17 h1:PQIBaRplyRy3OjwILGkPg89JRtH2x5bssi59G2EL3fo= github.com/labstack/echo/v4 v4.1.17 h1:PQIBaRplyRy3OjwILGkPg89JRtH2x5bssi59G2EL3fo=
github.com/labstack/echo/v4 v4.1.17/go.mod h1:Tn2yRQL/UclUalpb5rPdXDevbkJ+lp/2svdyFBg6CHQ= github.com/labstack/echo/v4 v4.1.17/go.mod h1:Tn2yRQL/UclUalpb5rPdXDevbkJ+lp/2svdyFBg6CHQ=
github.com/labstack/gommon v0.3.0 h1:JEeO0bvc78PKdyHxloTKiF8BD5iGrH8T6MSeGvSgob0= github.com/labstack/gommon v0.3.0 h1:JEeO0bvc78PKdyHxloTKiF8BD5iGrH8T6MSeGvSgob0=
github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k= github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k=
github.com/leodido/go-urn v1.1.0/go.mod h1:+cyI34gQWZcE1eQU7NVgKkkzdXDQHr1dBMtdAPozLkw=
github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y=
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4= github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4=
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
@ -174,10 +135,7 @@ github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hd
github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ= github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ=
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-sqlite3 v1.14.5 h1:1IdxlwTNazvbKJQSxoJ5/9ECbEeaTTyeU7sEAZ5KKTQ=
github.com/mattn/go-sqlite3 v1.14.5/go.mod h1:WVKg1VTActs4Qso6iwGbiFih2UIHo0ENGwNd0Lj+XmI=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/memcachier/mc v2.0.1+incompatible/go.mod h1:7bkvFE61leUBvXz+yxsOnGBQSZpBSPIMUQSmmSHvuXc=
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
@ -187,12 +145,8 @@ github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0Qu
github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLDQ0W1YjYsBW+p8U2u7vzgW2SQVmlNazg=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
@ -220,15 +174,15 @@ github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y8
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
github.com/quasoft/memstore v0.0.0-20180925164028-84a050167438/go.mod h1:wTPjTepVu7uJBYgZ0SdWHQlIas582j6cn2jgk4DDdlg=
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
github.com/shirou/gopsutil v3.20.10+incompatible h1:kQuRhh6h6y4luXvnmtu/lJEGtdJ3q8lbu9NQY99GP+o= github.com/sirupsen/logrus v1.2.0 h1:juTguoYk5qI21pwyTXY3B3Y5cOTH3ZUyZCg1v/mihuo=
github.com/shirou/gopsutil v3.20.10+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
@ -248,14 +202,11 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo=
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs=
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8=
@ -389,10 +340,9 @@ google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ij
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE=
gopkg.in/go-playground/validator.v9 v9.29.1/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWdVbfP1avr/N00E2vyQ=
gopkg.in/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno= gopkg.in/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno=
gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
@ -401,16 +351,11 @@ gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I= gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gorm.io/driver/mysql v1.0.1 h1:omJoilUzyrAp0xNoio88lGJCroGdIOen9hq2A/+3ifw= gorm.io/driver/mysql v1.0.3 h1:+JKBYPfn1tygR1/of/Fh2T8iwuVwzt+PEJmKaXzMQXg=
gorm.io/driver/mysql v1.0.1/go.mod h1:KtqSthtg55lFp3S5kUXqlGaelnWpKitn4k1xZTnoiPw= gorm.io/driver/mysql v1.0.3/go.mod h1:twGxftLBlFgNVNakL7F+P/x9oYqoymG3YYT8cAfI9oI=
gorm.io/driver/sqlite v1.1.4 h1:PDzwYE+sI6De2+mxAneV9Xs11+ZyKV6oxD3wDGkaNvM= gorm.io/gorm v1.20.4/go.mod h1:0HFTzE/SqkGTzK6TlDPPQbAYCluiVvhzoA1+aVyzenw=
gorm.io/driver/sqlite v1.1.4/go.mod h1:mJCeTFr7+crvS+TRnWc5Z3UvwxUN1BGBLMrf5LA9DYw=
gorm.io/gorm v1.9.19/go.mod h1:0HFTzE/SqkGTzK6TlDPPQbAYCluiVvhzoA1+aVyzenw=
gorm.io/gorm v1.20.0 h1:qfIlyaZvrF7kMWY3jBdEBXkXJ2M5MFYMTppjILxS3fQ=
gorm.io/gorm v1.20.0/go.mod h1:0HFTzE/SqkGTzK6TlDPPQbAYCluiVvhzoA1+aVyzenw=
gorm.io/gorm v1.20.7 h1:rMS4CL3pNmYq1V5/X+nHHjh1Dx6dnf27+Cai5zabo+M= gorm.io/gorm v1.20.7 h1:rMS4CL3pNmYq1V5/X+nHHjh1Dx6dnf27+Cai5zabo+M=
gorm.io/gorm v1.20.7/go.mod h1:0HFTzE/SqkGTzK6TlDPPQbAYCluiVvhzoA1+aVyzenw= gorm.io/gorm v1.20.7/go.mod h1:0HFTzE/SqkGTzK6TlDPPQbAYCluiVvhzoA1+aVyzenw=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=

45
main.go
View File

@ -1,12 +1,15 @@
package main package main
import ( import (
"fmt"
"github.com/labstack/gommon/log" "github.com/labstack/gommon/log"
"github.com/patrickmn/go-cache" "github.com/patrickmn/go-cache"
"gorm.io/driver/sqlite" "gorm.io/driver/mysql"
"gorm.io/gorm" "gorm.io/gorm"
"gorm.io/gorm/logger"
"next-terminal/pkg/api" "next-terminal/pkg/api"
"next-terminal/pkg/config" "next-terminal/pkg/config"
"next-terminal/pkg/global"
"next-terminal/pkg/handle" "next-terminal/pkg/handle"
"next-terminal/pkg/model" "next-terminal/pkg/model"
"next-terminal/pkg/utils" "next-terminal/pkg/utils"
@ -19,18 +22,24 @@ func main() {
} }
func Run() error { func Run() error {
config.NextTerminal = config.SetupConfig() global.Config = config.SetupConfig()
var err error var err error
//config.DB, err = gorm.Open(mysql.Open(config.NextTerminal.Dsn), &gorm.Config{ dsn := fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?charset=utf8mb4&parseTime=True&loc=Local",
// Logger: logger.Default.LogMode(logger.Info), global.Config.Mysql.Username,
//}) global.Config.Mysql.Password,
config.DB, err = gorm.Open(sqlite.Open("next-terminal.db"), &gorm.Config{}) global.Config.Mysql.Hostname,
global.Config.Mysql.Port,
global.Config.Mysql.Database,
)
global.DB, err = gorm.Open(mysql.Open(dsn), &gorm.Config{
Logger: logger.Default.LogMode(logger.Info),
})
if err != nil { if err != nil {
log.Fatal("连接数据库异常", err) log.Fatal("连接数据库异常", err)
} }
if err := config.DB.AutoMigrate(&model.User{}); err != nil { if err := global.DB.AutoMigrate(&model.User{}); err != nil {
return err return err
} }
@ -53,23 +62,23 @@ func Run() error {
} }
} }
if err := config.DB.AutoMigrate(&model.Asset{}); err != nil { if err := global.DB.AutoMigrate(&model.Asset{}); err != nil {
return err return err
} }
if err := config.DB.AutoMigrate(&model.Session{}); err != nil { if err := global.DB.AutoMigrate(&model.Session{}); err != nil {
return err return err
} }
if err := config.DB.AutoMigrate(&model.Command{}); err != nil { if err := global.DB.AutoMigrate(&model.Command{}); err != nil {
return err return err
} }
if err := config.DB.AutoMigrate(&model.Credential{}); err != nil { if err := global.DB.AutoMigrate(&model.Credential{}); err != nil {
return err return err
} }
if err := config.DB.AutoMigrate(&model.Property{}); err != nil { if err := global.DB.AutoMigrate(&model.Property{}); err != nil {
return err return err
} }
if err := config.DB.AutoMigrate(&model.Num{}); err != nil { if err := global.DB.AutoMigrate(&model.Num{}); err != nil {
return err return err
} }
@ -81,13 +90,15 @@ func Run() error {
} }
} }
config.Cache = cache.New(5*time.Minute, 10*time.Minute) global.Cache = cache.New(5*time.Minute, 10*time.Minute)
config.Store = config.NewStore() global.Store = global.NewStore()
e := api.SetupRoutes() e := api.SetupRoutes()
if err := handle.InitProperties(); err != nil {
return err
}
// 启动定时任务 // 启动定时任务
//go handle.RunTicker() //go handle.RunTicker()
go handle.RunDataFix() go handle.RunDataFix()
go handle.InitProperties()
return e.Start(config.NextTerminal.Addr) return e.Start(global.Config.Server.Addr)
} }

View File

@ -1,4 +0,0 @@
next-terminal:
# dsn: root:root@tcp(127.0.0.1:3306)/next-terminal?charset=utf8mb4&parseTime=True&loc=Local
dsn: root:mysql@tcp(172.16.101.32:3306)/next-terminal?charset=utf8mb4&parseTime=True&loc=Local
addr: 0.0.0.0:8088

View File

@ -2,7 +2,7 @@ package api
import ( import (
"github.com/labstack/echo/v4" "github.com/labstack/echo/v4"
"next-terminal/pkg/config" "next-terminal/pkg/global"
"next-terminal/pkg/model" "next-terminal/pkg/model"
"next-terminal/pkg/utils" "next-terminal/pkg/utils"
"time" "time"
@ -29,7 +29,7 @@ func LoginEndpoint(c echo.Context) error {
token := utils.UUID() token := utils.UUID()
config.Cache.Set(token, user, time.Minute*time.Duration(30)) global.Cache.Set(token, user, time.Minute*time.Duration(30))
model.UpdateUserById(&model.User{Online: true}, user.ID) model.UpdateUserById(&model.User{Online: true}, user.ID)
@ -38,7 +38,7 @@ func LoginEndpoint(c echo.Context) error {
func LogoutEndpoint(c echo.Context) error { func LogoutEndpoint(c echo.Context) error {
token := GetToken(c) token := GetToken(c)
config.Cache.Delete(token) global.Cache.Delete(token)
return Success(c, nil) return Success(c, nil)
} }

View File

@ -2,14 +2,14 @@ package api
import ( import (
"github.com/labstack/echo/v4" "github.com/labstack/echo/v4"
"next-terminal/pkg/config" "next-terminal/pkg/global"
"strings" "strings"
"time" "time"
) )
func Auth(next echo.HandlerFunc) echo.HandlerFunc { func Auth(next echo.HandlerFunc) echo.HandlerFunc {
urls := []string{"download", "login"} urls := []string{"download", "recording", "login", "static", "favicon", "logo"}
return func(c echo.Context) error { return func(c echo.Context) error {
// 路由拦截 - 登录身份、资源权限判断等 // 路由拦截 - 登录身份、资源权限判断等
@ -23,12 +23,12 @@ func Auth(next echo.HandlerFunc) echo.HandlerFunc {
} }
token := GetToken(c) token := GetToken(c)
user, found := config.Cache.Get(token) user, found := global.Cache.Get(token)
if !found { if !found {
c.Logger().Error("您的登录信息已失效,请重新登录后再试。") c.Logger().Error("您的登录信息已失效,请重新登录后再试。")
return Fail(c, 403, "您的登录信息已失效,请重新登录后再试。") return Fail(c, 403, "您的登录信息已失效,请重新登录后再试。")
} }
config.Cache.Set(token, user, time.Minute*time.Duration(30)) global.Cache.Set(token, user, time.Minute*time.Duration(30))
return next(c) return next(c)
} }
} }

View File

@ -4,7 +4,7 @@ import (
"github.com/labstack/echo/v4" "github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware" "github.com/labstack/echo/v4/middleware"
"net/http" "net/http"
"next-terminal/pkg/config" "next-terminal/pkg/global"
"next-terminal/pkg/model" "next-terminal/pkg/model"
) )
@ -12,7 +12,6 @@ const Token = "X-Auth-Token"
func SetupRoutes() *echo.Echo { func SetupRoutes() *echo.Echo {
// Echo instance
e := echo.New() e := echo.New()
e.File("/", "web/build/index.html") e.File("/", "web/build/index.html")
@ -22,6 +21,15 @@ func SetupRoutes() *echo.Echo {
// Middleware // Middleware
e.Use(middleware.Logger()) e.Use(middleware.Logger())
//fd, _ := os.OpenFile(
// "nt.log",
// os.O_RDWR|os.O_APPEND,
// 0666,
//)
//writer := io.MultiWriter(fd, os.Stdout)
//e.Logger.SetOutput(writer)
e.Use(middleware.Recover()) e.Use(middleware.Recover())
e.Use(middleware.CORSWithConfig(middleware.CORSConfig{ e.Use(middleware.CORSWithConfig(middleware.CORSConfig{
Skipper: middleware.DefaultSkipper, Skipper: middleware.DefaultSkipper,
@ -92,6 +100,7 @@ func SetupRoutes() *echo.Echo {
sessions.DELETE("/:id/rmdir", SessionRmDirEndpoint) sessions.DELETE("/:id/rmdir", SessionRmDirEndpoint)
sessions.DELETE("/:id/rm", SessionRmEndpoint) sessions.DELETE("/:id/rm", SessionRmEndpoint)
sessions.DELETE("/:id", SessionDeleteEndpoint) sessions.DELETE("/:id", SessionDeleteEndpoint)
sessions.GET("/:id/recording", SessionRecordingEndpoint)
} }
e.GET("/properties", PropertyGetEndpoint) e.GET("/properties", PropertyGetEndpoint)
@ -137,7 +146,7 @@ func GetToken(c echo.Context) string {
func GetCurrentAccount(c echo.Context) (model.User, bool) { func GetCurrentAccount(c echo.Context) (model.User, bool) {
token := GetToken(c) token := GetToken(c)
get, b := config.Cache.Get(token) get, b := global.Cache.Get(token)
if b { if b {
return get.(model.User), true return get.(model.User), true
} }

View File

@ -5,10 +5,11 @@ import (
"errors" "errors"
"fmt" "fmt"
"github.com/labstack/echo/v4" "github.com/labstack/echo/v4"
"github.com/labstack/gommon/log"
"io" "io"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"next-terminal/pkg/config" "next-terminal/pkg/global"
"next-terminal/pkg/model" "next-terminal/pkg/model"
"next-terminal/pkg/utils" "next-terminal/pkg/utils"
"os" "os"
@ -42,12 +43,14 @@ func SessionDeleteEndpoint(c echo.Context) error {
sessionIds := c.Param("id") sessionIds := c.Param("id")
split := strings.Split(sessionIds, ",") split := strings.Split(sessionIds, ",")
for i := range split { for i := range split {
model.DeleteSessionById(split[i])
drivePath, err := model.GetRecordingPath() drivePath, err := model.GetRecordingPath()
if err != nil { if err != nil {
continue continue
} }
_ = os.Remove(path.Join(drivePath, split[i])) if err := os.RemoveAll(path.Join(drivePath, split[i])); err != nil {
return err
}
model.DeleteSessionById(split[i])
} }
return Success(c, nil) return Success(c, nil)
@ -70,7 +73,7 @@ func SessionDiscontentEndpoint(c echo.Context) error {
split := strings.Split(sessionIds, ",") split := strings.Split(sessionIds, ",")
for i := range split { for i := range split {
tun, ok := config.Store.Get(split[i]) tun, ok := global.Store.Get(split[i])
if ok { if ok {
CloseSession(split[i], tun) CloseSession(split[i], tun)
} }
@ -78,9 +81,9 @@ func SessionDiscontentEndpoint(c echo.Context) error {
return Success(c, nil) return Success(c, nil)
} }
func CloseSession(sessionId string, tun config.Tun) { func CloseSession(sessionId string, tun global.Tun) {
_ = tun.Tun.Close() _ = tun.Tun.Close()
config.Store.Del(sessionId) global.Store.Del(sessionId)
session := model.Session{} session := model.Session{}
session.ID = sessionId session.ID = sessionId
@ -172,7 +175,7 @@ func SessionUploadEndpoint(c echo.Context) error {
remoteFile := path.Join(remoteDir, filename) remoteFile := path.Join(remoteDir, filename)
if "ssh" == session.Protocol { if "ssh" == session.Protocol {
tun, ok := config.Store.Get(sessionId) tun, ok := global.Store.Get(sessionId)
if !ok { if !ok {
return errors.New("获取sftp客户端失败") return errors.New("获取sftp客户端失败")
} }
@ -226,7 +229,7 @@ func SessionDownloadEndpoint(c echo.Context) error {
remoteFile := c.QueryParam("file") remoteFile := c.QueryParam("file")
if "ssh" == session.Protocol { if "ssh" == session.Protocol {
tun, ok := config.Store.Get(sessionId) tun, ok := global.Store.Get(sessionId)
if !ok { if !ok {
return errors.New("获取sftp客户端失败") return errors.New("获取sftp客户端失败")
} }
@ -273,7 +276,7 @@ func SessionLsEndpoint(c echo.Context) error {
} }
remoteDir := c.QueryParam("dir") remoteDir := c.QueryParam("dir")
if "ssh" == session.Protocol { if "ssh" == session.Protocol {
tun, ok := config.Store.Get(sessionId) tun, ok := global.Store.Get(sessionId)
if !ok { if !ok {
return errors.New("获取sftp客户端失败") return errors.New("获取sftp客户端失败")
} }
@ -334,7 +337,7 @@ func SessionMkDirEndpoint(c echo.Context) error {
} }
remoteDir := c.QueryParam("dir") remoteDir := c.QueryParam("dir")
if "ssh" == session.Protocol { if "ssh" == session.Protocol {
tun, ok := config.Store.Get(sessionId) tun, ok := global.Store.Get(sessionId)
if !ok { if !ok {
return errors.New("获取sftp客户端失败") return errors.New("获取sftp客户端失败")
} }
@ -365,7 +368,7 @@ func SessionRmDirEndpoint(c echo.Context) error {
} }
remoteDir := c.QueryParam("dir") remoteDir := c.QueryParam("dir")
if "ssh" == session.Protocol { if "ssh" == session.Protocol {
tun, ok := config.Store.Get(sessionId) tun, ok := global.Store.Get(sessionId)
if !ok { if !ok {
return errors.New("获取sftp客户端失败") return errors.New("获取sftp客户端失败")
} }
@ -407,7 +410,7 @@ func SessionRmEndpoint(c echo.Context) error {
} }
remoteFile := c.QueryParam("file") remoteFile := c.QueryParam("file")
if "ssh" == session.Protocol { if "ssh" == session.Protocol {
tun, ok := config.Store.Get(sessionId) tun, ok := global.Store.Get(sessionId)
if !ok { if !ok {
return errors.New("获取sftp客户端失败") return errors.New("获取sftp客户端失败")
} }
@ -428,3 +431,14 @@ func SessionRmEndpoint(c echo.Context) error {
} }
return nil return nil
} }
func SessionRecordingEndpoint(c echo.Context) error {
sessionId := c.Param("id")
recordingPath, err := model.GetRecordingPath()
if err != nil {
return err
}
recording := path.Join(recordingPath, sessionId, "recording")
log.Printf("读取录屏文件:%s", recording)
return c.File(recording)
}

View File

@ -6,7 +6,7 @@ import (
"github.com/labstack/echo/v4" "github.com/labstack/echo/v4"
"github.com/pkg/sftp" "github.com/pkg/sftp"
"log" "log"
"next-terminal/pkg/config" "next-terminal/pkg/global"
"next-terminal/pkg/guacd" "next-terminal/pkg/guacd"
"next-terminal/pkg/model" "next-terminal/pkg/model"
"path" "path"
@ -60,9 +60,9 @@ func TunEndpoint(c echo.Context) error {
} }
if propertyMap[guacd.EnableRecording] == "true" { if propertyMap[guacd.EnableRecording] == "true" {
configuration.SetParameter(guacd.CreateRecordingPath, path.Join(propertyMap[guacd.CreateRecordingPath], sessionId)) configuration.SetParameter(guacd.RecordingPath, path.Join(propertyMap[guacd.RecordingPath], sessionId))
} else { } else {
configuration.SetParameter(guacd.CreateRecordingPath, "") configuration.SetParameter(guacd.RecordingPath, "")
} }
configuration.Protocol = session.Protocol configuration.Protocol = session.Protocol
@ -110,15 +110,15 @@ func TunEndpoint(c echo.Context) error {
} }
fmt.Printf("=====================================================\n") fmt.Printf("=====================================================\n")
fmt.Printf("connect to %v with config: %+v\n", addr, configuration) fmt.Printf("connect to %v with global: %+v\n", addr, configuration)
fmt.Printf("=====================================================\n") fmt.Printf("=====================================================\n")
tun := config.Tun{ tun := global.Tun{
Tun: tunnel, Tun: tunnel,
SftpClient: sftpClient, SftpClient: sftpClient,
} }
config.Store.Set(sessionId, tun) global.Store.Set(sessionId, tun)
if len(session.ConnectionId) == 0 { if len(session.ConnectionId) == 0 {
session.ConnectionId = tunnel.UUID session.ConnectionId = tunnel.UUID

View File

@ -1,14 +1,63 @@
package config package config
import ( import (
"github.com/patrickmn/go-cache" "github.com/spf13/pflag"
"gorm.io/gorm" "github.com/spf13/viper"
"log"
) )
var DB *gorm.DB type Config struct {
Server *Server
Mysql *Mysql
}
var Cache *cache.Cache type Mysql struct {
Hostname string
Port int
Username string
Password string
Database string
}
var NextTerminal *NextTerminalConfig type Server struct {
Addr string
}
var Store *TunStore func SetupConfig() *Config {
viper.SetConfigName("config")
viper.SetConfigType("yaml")
viper.AddConfigPath("/etc/nt/")
viper.AddConfigPath("$HOME/.nt")
viper.AddConfigPath(".")
pflag.String("mysql.hostname", "127.0.0.1", "mysql hostname")
pflag.Int("mysql.port", 3306, "mysql port")
pflag.String("mysql.username", "mysql", "mysql username")
pflag.String("mysql.password", "mysql", "mysql password")
pflag.String("mysql.database", "next_terminal", "mysql database")
pflag.String("server.addr", "0.0.0.0:8088", "server listen addr")
pflag.Parse()
_ = viper.BindPFlags(pflag.CommandLine)
err := viper.ReadInConfig()
if err != nil {
log.Fatal(err)
}
var config = &Config{
Mysql: &Mysql{
Hostname: viper.GetString("mysql.hostname"),
Port: viper.GetInt("mysql.port"),
Username: viper.GetString("mysql.username"),
Password: viper.GetString("mysql.password"),
Database: viper.GetString("mysql.database"),
},
Server: &Server{
Addr: viper.GetString("server.addr"),
},
}
return config
}

View File

@ -1,31 +0,0 @@
package config
import (
"github.com/spf13/viper"
"log"
)
type NextTerminalConfig struct {
Dsn string
Addr string
}
func SetupConfig() *NextTerminalConfig {
viper.SetConfigName("next-terminal")
viper.SetConfigType("yaml")
viper.AddConfigPath("/etc/next-terminal/")
viper.AddConfigPath("$HOME/.next-terminal")
viper.AddConfigPath(".")
err := viper.ReadInConfig()
if err != nil {
log.Fatal(err)
}
var config = &NextTerminalConfig{
Dsn: viper.GetString("next-terminal.dsn"),
Addr: viper.GetString("next-terminal.addr"),
}
return config
}

15
pkg/global/global.go Normal file
View File

@ -0,0 +1,15 @@
package global
import (
"github.com/patrickmn/go-cache"
"gorm.io/gorm"
"next-terminal/pkg/config"
)
var DB *gorm.DB
var Cache *cache.Cache
var Config *config.Config
var Store *TunStore

View File

@ -1,4 +1,4 @@
package config package global
import ( import (
"github.com/pkg/sftp" "github.com/pkg/sftp"

View File

@ -48,7 +48,7 @@ func RunDataFix() {
} }
} }
func InitProperties() { func InitProperties() error {
propertyMap := model.FindAllPropertiesMap() propertyMap := model.FindAllPropertiesMap()
if len(propertyMap[guacd.Host]) == 0 { if len(propertyMap[guacd.Host]) == 0 {
@ -56,7 +56,9 @@ func InitProperties() {
Name: guacd.Host, Name: guacd.Host,
Value: "127.0.0.1", Value: "127.0.0.1",
} }
_ = model.CreateNewProperty(&property) if err := model.CreateNewProperty(&property); err != nil {
return err
}
} }
if len(propertyMap[guacd.Port]) == 0 { if len(propertyMap[guacd.Port]) == 0 {
@ -64,7 +66,9 @@ func InitProperties() {
Name: guacd.Port, Name: guacd.Port,
Value: "4822", Value: "4822",
} }
_ = model.CreateNewProperty(&property) if err := model.CreateNewProperty(&property); err != nil {
return err
}
} }
if len(propertyMap[guacd.EnableRecording]) == 0 { if len(propertyMap[guacd.EnableRecording]) == 0 {
@ -72,7 +76,9 @@ func InitProperties() {
Name: guacd.EnableRecording, Name: guacd.EnableRecording,
Value: "true", Value: "true",
} }
_ = model.CreateNewProperty(&property) if err := model.CreateNewProperty(&property); err != nil {
return err
}
} }
if len(propertyMap[guacd.RecordingPath]) == 0 { if len(propertyMap[guacd.RecordingPath]) == 0 {
@ -81,7 +87,14 @@ func InitProperties() {
Name: guacd.RecordingPath, Name: guacd.RecordingPath,
Value: path + "/recording/", Value: path + "/recording/",
} }
_ = model.CreateNewProperty(&property) if !utils.Exists(property.Value) {
if err := os.Mkdir(property.Value, os.ModePerm); err != nil {
return err
}
}
if err := model.CreateNewProperty(&property); err != nil {
return err
}
} }
if len(propertyMap[guacd.CreateRecordingPath]) == 0 { if len(propertyMap[guacd.CreateRecordingPath]) == 0 {
@ -89,7 +102,9 @@ func InitProperties() {
Name: guacd.CreateRecordingPath, Name: guacd.CreateRecordingPath,
Value: "true", Value: "true",
} }
_ = model.CreateNewProperty(&property) if err := model.CreateNewProperty(&property); err != nil {
return err
}
} }
if len(propertyMap[guacd.DriveName]) == 0 { if len(propertyMap[guacd.DriveName]) == 0 {
@ -97,7 +112,9 @@ func InitProperties() {
Name: guacd.DriveName, Name: guacd.DriveName,
Value: "File-System", Value: "File-System",
} }
_ = model.CreateNewProperty(&property) if err := model.CreateNewProperty(&property); err != nil {
return err
}
} }
if len(propertyMap[guacd.DrivePath]) == 0 { if len(propertyMap[guacd.DrivePath]) == 0 {
@ -108,7 +125,14 @@ func InitProperties() {
Name: guacd.DrivePath, Name: guacd.DrivePath,
Value: path + "/drive/", Value: path + "/drive/",
} }
_ = model.CreateNewProperty(&property) if !utils.Exists(property.Value) {
if err := os.Mkdir(property.Value, os.ModePerm); err != nil {
return err
}
}
if err := model.CreateNewProperty(&property); err != nil {
return err
}
} }
if len(propertyMap[guacd.FontName]) == 0 { if len(propertyMap[guacd.FontName]) == 0 {
@ -116,7 +140,9 @@ func InitProperties() {
Name: guacd.FontName, Name: guacd.FontName,
Value: "menlo", Value: "menlo",
} }
_ = model.CreateNewProperty(&property) if err := model.CreateNewProperty(&property); err != nil {
return err
}
} }
if len(propertyMap[guacd.FontSize]) == 0 { if len(propertyMap[guacd.FontSize]) == 0 {
@ -124,7 +150,9 @@ func InitProperties() {
Name: guacd.FontSize, Name: guacd.FontSize,
Value: "12", Value: "12",
} }
_ = model.CreateNewProperty(&property) if err := model.CreateNewProperty(&property); err != nil {
return err
}
} }
if len(propertyMap[guacd.ColorScheme]) == 0 { if len(propertyMap[guacd.ColorScheme]) == 0 {
@ -132,7 +160,9 @@ func InitProperties() {
Name: guacd.ColorScheme, Name: guacd.ColorScheme,
Value: "gray-black", Value: "gray-black",
} }
_ = model.CreateNewProperty(&property) if err := model.CreateNewProperty(&property); err != nil {
return err
}
} }
if len(propertyMap[guacd.EnableDrive]) == 0 { if len(propertyMap[guacd.EnableDrive]) == 0 {
@ -140,7 +170,9 @@ func InitProperties() {
Name: guacd.EnableDrive, Name: guacd.EnableDrive,
Value: "true", Value: "true",
} }
_ = model.CreateNewProperty(&property) if err := model.CreateNewProperty(&property); err != nil {
return err
}
} }
if len(propertyMap[guacd.EnableWallpaper]) == 0 { if len(propertyMap[guacd.EnableWallpaper]) == 0 {
@ -148,7 +180,9 @@ func InitProperties() {
Name: guacd.EnableWallpaper, Name: guacd.EnableWallpaper,
Value: "false", Value: "false",
} }
_ = model.CreateNewProperty(&property) if err := model.CreateNewProperty(&property); err != nil {
return err
}
} }
if len(propertyMap[guacd.EnableTheming]) == 0 { if len(propertyMap[guacd.EnableTheming]) == 0 {
@ -156,7 +190,9 @@ func InitProperties() {
Name: guacd.EnableTheming, Name: guacd.EnableTheming,
Value: "false", Value: "false",
} }
_ = model.CreateNewProperty(&property) if err := model.CreateNewProperty(&property); err != nil {
return err
}
} }
if len(propertyMap[guacd.EnableFontSmoothing]) == 0 { if len(propertyMap[guacd.EnableFontSmoothing]) == 0 {
@ -164,7 +200,9 @@ func InitProperties() {
Name: guacd.EnableFontSmoothing, Name: guacd.EnableFontSmoothing,
Value: "false", Value: "false",
} }
_ = model.CreateNewProperty(&property) if err := model.CreateNewProperty(&property); err != nil {
return err
}
} }
if len(propertyMap[guacd.EnableFullWindowDrag]) == 0 { if len(propertyMap[guacd.EnableFullWindowDrag]) == 0 {
@ -172,7 +210,9 @@ func InitProperties() {
Name: guacd.EnableFullWindowDrag, Name: guacd.EnableFullWindowDrag,
Value: "false", Value: "false",
} }
_ = model.CreateNewProperty(&property) if err := model.CreateNewProperty(&property); err != nil {
return err
}
} }
if len(propertyMap[guacd.EnableDesktopComposition]) == 0 { if len(propertyMap[guacd.EnableDesktopComposition]) == 0 {
@ -180,7 +220,9 @@ func InitProperties() {
Name: guacd.EnableDesktopComposition, Name: guacd.EnableDesktopComposition,
Value: "false", Value: "false",
} }
_ = model.CreateNewProperty(&property) if err := model.CreateNewProperty(&property); err != nil {
return err
}
} }
if len(propertyMap[guacd.EnableMenuAnimations]) == 0 { if len(propertyMap[guacd.EnableMenuAnimations]) == 0 {
@ -188,7 +230,9 @@ func InitProperties() {
Name: guacd.EnableMenuAnimations, Name: guacd.EnableMenuAnimations,
Value: "false", Value: "false",
} }
_ = model.CreateNewProperty(&property) if err := model.CreateNewProperty(&property); err != nil {
return err
}
} }
if len(propertyMap[guacd.DisableBitmapCaching]) == 0 { if len(propertyMap[guacd.DisableBitmapCaching]) == 0 {
@ -196,7 +240,9 @@ func InitProperties() {
Name: guacd.DisableBitmapCaching, Name: guacd.DisableBitmapCaching,
Value: "false", Value: "false",
} }
_ = model.CreateNewProperty(&property) if err := model.CreateNewProperty(&property); err != nil {
return err
}
} }
if len(propertyMap[guacd.DisableOffscreenCaching]) == 0 { if len(propertyMap[guacd.DisableOffscreenCaching]) == 0 {
@ -204,7 +250,9 @@ func InitProperties() {
Name: guacd.DisableOffscreenCaching, Name: guacd.DisableOffscreenCaching,
Value: "false", Value: "false",
} }
_ = model.CreateNewProperty(&property) if err := model.CreateNewProperty(&property); err != nil {
return err
}
} }
if len(propertyMap[guacd.DisableGlyphCaching]) == 0 { if len(propertyMap[guacd.DisableGlyphCaching]) == 0 {
@ -212,6 +260,9 @@ func InitProperties() {
Name: guacd.DisableGlyphCaching, Name: guacd.DisableGlyphCaching,
Value: "false", Value: "false",
} }
_ = model.CreateNewProperty(&property) if err := model.CreateNewProperty(&property); err != nil {
return err
} }
} }
return nil
}

View File

@ -1,7 +1,7 @@
package model package model
import ( import (
"next-terminal/pkg/config" "next-terminal/pkg/global"
"next-terminal/pkg/utils" "next-terminal/pkg/utils"
) )
@ -27,12 +27,12 @@ func (r *Asset) TableName() string {
} }
func FindAllAsset() (o []Asset, err error) { func FindAllAsset() (o []Asset, err error) {
err = config.DB.Find(&o).Error err = global.DB.Find(&o).Error
return return
} }
func FindAssetByConditions(protocol string) (o []Asset, err error) { func FindAssetByConditions(protocol string) (o []Asset, err error) {
db := config.DB db := global.DB
if len(protocol) > 0 { if len(protocol) > 0 {
db = db.Where("protocol = ?", protocol) db = db.Where("protocol = ?", protocol)
@ -42,7 +42,7 @@ func FindAssetByConditions(protocol string) (o []Asset, err error) {
} }
func FindPageAsset(pageIndex, pageSize int, name, protocol string) (o []Asset, total int64, err error) { func FindPageAsset(pageIndex, pageSize int, name, protocol string) (o []Asset, total int64, err error) {
db := config.DB db := global.DB
if len(name) > 0 { if len(name) > 0 {
db = db.Where("name like ?", "%"+name+"%") db = db.Where("name like ?", "%"+name+"%")
} }
@ -60,27 +60,27 @@ func FindPageAsset(pageIndex, pageSize int, name, protocol string) (o []Asset, t
} }
func CreateNewAsset(o *Asset) (err error) { func CreateNewAsset(o *Asset) (err error) {
if err = config.DB.Create(o).Error; err != nil { if err = global.DB.Create(o).Error; err != nil {
return err return err
} }
return nil return nil
} }
func FindAssetById(id string) (o Asset, err error) { func FindAssetById(id string) (o Asset, err error) {
err = config.DB.Where("id = ?", id).First(&o).Error err = global.DB.Where("id = ?", id).First(&o).Error
return return
} }
func UpdateAssetById(o *Asset, id string) { func UpdateAssetById(o *Asset, id string) {
o.ID = id o.ID = id
config.DB.Updates(o) global.DB.Updates(o)
} }
func DeleteAssetById(id string) { func DeleteAssetById(id string) {
config.DB.Where("id = ?", id).Delete(&Asset{}) global.DB.Where("id = ?", id).Delete(&Asset{})
} }
func CountAsset() (total int64, err error) { func CountAsset() (total int64, err error) {
err = config.DB.Find(&Asset{}).Count(&total).Error err = global.DB.Find(&Asset{}).Count(&total).Error
return return
} }

View File

@ -1,7 +1,7 @@
package model package model
import ( import (
"next-terminal/pkg/config" "next-terminal/pkg/global"
"next-terminal/pkg/utils" "next-terminal/pkg/utils"
) )
@ -18,7 +18,7 @@ func (r *Command) TableName() string {
func FindPageCommand(pageIndex, pageSize int, name, content string) (o []Command, total int64, err error) { func FindPageCommand(pageIndex, pageSize int, name, content string) (o []Command, total int64, err error) {
db := config.DB db := global.DB
if len(name) > 0 { if len(name) > 0 {
db = db.Where("name like ?", "%"+name+"%") db = db.Where("name like ?", "%"+name+"%")
} }
@ -35,22 +35,22 @@ func FindPageCommand(pageIndex, pageSize int, name, content string) (o []Command
} }
func CreateNewCommand(o *Command) (err error) { func CreateNewCommand(o *Command) (err error) {
if err = config.DB.Create(o).Error; err != nil { if err = global.DB.Create(o).Error; err != nil {
return err return err
} }
return nil return nil
} }
func FindCommandById(id string) (o Command, err error) { func FindCommandById(id string) (o Command, err error) {
err = config.DB.Where("id = ?", id).First(&o).Error err = global.DB.Where("id = ?", id).First(&o).Error
return return
} }
func UpdateCommandById(o *Command, id string) { func UpdateCommandById(o *Command, id string) {
o.ID = id o.ID = id
config.DB.Updates(o) global.DB.Updates(o)
} }
func DeleteCommandById(id string) { func DeleteCommandById(id string) {
config.DB.Where("id = ?", id).Delete(&Command{}) global.DB.Where("id = ?", id).Delete(&Command{})
} }

View File

@ -1,7 +1,7 @@
package model package model
import ( import (
"next-terminal/pkg/config" "next-terminal/pkg/global"
"next-terminal/pkg/utils" "next-terminal/pkg/utils"
) )
@ -18,12 +18,12 @@ func (r *Credential) TableName() string {
} }
func FindAllCredential() (o []Credential, err error) { func FindAllCredential() (o []Credential, err error) {
err = config.DB.Find(&o).Error err = global.DB.Find(&o).Error
return return
} }
func FindPageCredential(pageIndex, pageSize int, name string) (o []Credential, total int64, err error) { func FindPageCredential(pageIndex, pageSize int, name string) (o []Credential, total int64, err error) {
db := config.DB db := global.DB
if len(name) > 0 { if len(name) > 0 {
db = db.Where("name like ?", "%"+name+"%") db = db.Where("name like ?", "%"+name+"%")
} }
@ -36,7 +36,7 @@ func FindPageCredential(pageIndex, pageSize int, name string) (o []Credential, t
} }
func CreateNewCredential(o *Credential) (err error) { func CreateNewCredential(o *Credential) (err error) {
if err = config.DB.Create(o).Error; err != nil { if err = global.DB.Create(o).Error; err != nil {
return err return err
} }
return nil return nil
@ -44,20 +44,20 @@ func CreateNewCredential(o *Credential) (err error) {
func FindCredentialById(id string) (o Credential, err error) { func FindCredentialById(id string) (o Credential, err error) {
err = config.DB.Where("id = ?", id).First(&o).Error err = global.DB.Where("id = ?", id).First(&o).Error
return return
} }
func UpdateCredentialById(o *Credential, id string) { func UpdateCredentialById(o *Credential, id string) {
o.ID = id o.ID = id
config.DB.Updates(o) global.DB.Updates(o)
} }
func DeleteCredentialById(id string) { func DeleteCredentialById(id string) {
config.DB.Where("id = ?", id).Delete(&Credential{}) global.DB.Where("id = ?", id).Delete(&Credential{})
} }
func CountCredential() (total int64, err error) { func CountCredential() (total int64, err error) {
err = config.DB.Find(&Credential{}).Count(&total).Error err = global.DB.Find(&Credential{}).Count(&total).Error
return return
} }

View File

@ -1,7 +1,7 @@
package model package model
import ( import (
"next-terminal/pkg/config" "next-terminal/pkg/global"
) )
type Num struct { type Num struct {
@ -13,13 +13,13 @@ func (r *Num) TableName() string {
} }
func FindAllTemp() (o []Num) { func FindAllTemp() (o []Num) {
if config.DB.Find(&o).Error != nil { if global.DB.Find(&o).Error != nil {
return nil return nil
} }
return return
} }
func CreateNewTemp(o *Num) (err error) { func CreateNewTemp(o *Num) (err error) {
err = config.DB.Create(o).Error err = global.DB.Create(o).Error
return return
} }

View File

@ -1,7 +1,7 @@
package model package model
import ( import (
"next-terminal/pkg/config" "next-terminal/pkg/global"
"next-terminal/pkg/guacd" "next-terminal/pkg/guacd"
) )
@ -15,24 +15,24 @@ func (r *Property) TableName() string {
} }
func FindAllProperties() (o []Property) { func FindAllProperties() (o []Property) {
if config.DB.Find(&o).Error != nil { if global.DB.Find(&o).Error != nil {
return nil return nil
} }
return return
} }
func CreateNewProperty(o *Property) (err error) { func CreateNewProperty(o *Property) (err error) {
err = config.DB.Create(o).Error err = global.DB.Create(o).Error
return return
} }
func UpdatePropertyByName(o *Property, name string) { func UpdatePropertyByName(o *Property, name string) {
o.Name = name o.Name = name
config.DB.Updates(o) global.DB.Updates(o)
} }
func FindPropertyByName(name string) (o Property, err error) { func FindPropertyByName(name string) (o Property, err error) {
err = config.DB.Where("name = ?", name).First(&o).Error err = global.DB.Where("name = ?", name).First(&o).Error
return return
} }

View File

@ -1,7 +1,7 @@
package model package model
import ( import (
"next-terminal/pkg/config" "next-terminal/pkg/global"
"next-terminal/pkg/utils" "next-terminal/pkg/utils"
"time" "time"
) )
@ -57,7 +57,7 @@ type SessionVo struct {
func FindPageSession(pageIndex, pageSize int, status, userId, clientIp, assetId, protocol string) (results []SessionVo, total int64, err error) { func FindPageSession(pageIndex, pageSize int, status, userId, clientIp, assetId, protocol string) (results []SessionVo, total int64, err error) {
db := config.DB db := global.DB
var params []interface{} var params []interface{}
params = append(params, status) params = append(params, status)
@ -103,40 +103,40 @@ func FindPageSession(pageIndex, pageSize int, status, userId, clientIp, assetId,
} }
func FindSessionByStatus(status string) (o []Session, err error) { func FindSessionByStatus(status string) (o []Session, err error) {
err = config.DB.Where("status = ?", status).Find(&o).Error err = global.DB.Where("status = ?", status).Find(&o).Error
return return
} }
func CreateNewSession(o *Session) (err error) { func CreateNewSession(o *Session) (err error) {
err = config.DB.Create(o).Error err = global.DB.Create(o).Error
return return
} }
func FindSessionById(id string) (o Session, err error) { func FindSessionById(id string) (o Session, err error) {
err = config.DB.Where("id = ?", id).First(&o).Error err = global.DB.Where("id = ?", id).First(&o).Error
return return
} }
func FindSessionByConnectionId(connectionId string) (o Session, err error) { func FindSessionByConnectionId(connectionId string) (o Session, err error) {
err = config.DB.Where("connection_id = ?", connectionId).First(&o).Error err = global.DB.Where("connection_id = ?", connectionId).First(&o).Error
return return
} }
func UpdateSessionById(o *Session, id string) { func UpdateSessionById(o *Session, id string) {
o.ID = id o.ID = id
config.DB.Updates(o) global.DB.Updates(o)
} }
func DeleteSessionById(id string) { func DeleteSessionById(id string) {
config.DB.Where("id = ?", id).Delete(&Session{}) global.DB.Where("id = ?", id).Delete(&Session{})
} }
func DeleteSessionByStatus(status string) { func DeleteSessionByStatus(status string) {
config.DB.Where("status = ?", status).Delete(&Session{}) global.DB.Where("status = ?", status).Delete(&Session{})
} }
func CountOnlineSession() (total int64, err error) { func CountOnlineSession() (total int64, err error) {
err = config.DB.Where("status = ?", Connected).Find(&Session{}).Count(&total).Error err = global.DB.Where("status = ?", Connected).Find(&Session{}).Count(&total).Error
return return
} }
@ -155,7 +155,7 @@ func CountSessionByDay(day int) (results []D, err error) {
for i := range protocols { for i := range protocols {
var result []D var result []D
err = config.DB.Raw(sql, day, protocols[i], day).Scan(&result).Error err = global.DB.Raw(sql, day, protocols[i], day).Scan(&result).Error
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -1,7 +1,7 @@
package model package model
import ( import (
"next-terminal/pkg/config" "next-terminal/pkg/global"
"next-terminal/pkg/utils" "next-terminal/pkg/utils"
"reflect" "reflect"
) )
@ -25,7 +25,7 @@ func (r *User) IsEmpty() bool {
} }
func FindAllUser() (o []User) { func FindAllUser() (o []User) {
if config.DB.Find(&o).Error != nil { if global.DB.Find(&o).Error != nil {
return nil return nil
} }
return return
@ -33,7 +33,7 @@ func FindAllUser() (o []User) {
func FindPageUser(pageIndex, pageSize int, username, nickname string) (o []User, total int64, err error) { func FindPageUser(pageIndex, pageSize int, username, nickname string) (o []User, total int64, err error) {
db := config.DB db := global.DB
if len(username) > 0 { if len(username) > 0 {
db = db.Where("username like ?", "%"+username+"%") db = db.Where("username like ?", "%"+username+"%")
} }
@ -50,30 +50,30 @@ func FindPageUser(pageIndex, pageSize int, username, nickname string) (o []User,
} }
func CreateNewUser(o *User) (err error) { func CreateNewUser(o *User) (err error) {
err = config.DB.Create(o).Error err = global.DB.Create(o).Error
return return
} }
func FindUserById(id string) (o User, err error) { func FindUserById(id string) (o User, err error) {
err = config.DB.Where("id = ?", id).First(&o).Error err = global.DB.Where("id = ?", id).First(&o).Error
return return
} }
func FindUserByUsername(username string) (o User, err error) { func FindUserByUsername(username string) (o User, err error) {
err = config.DB.Where("username = ?", username).First(&o).Error err = global.DB.Where("username = ?", username).First(&o).Error
return return
} }
func UpdateUserById(o *User, id string) { func UpdateUserById(o *User, id string) {
o.ID = id o.ID = id
config.DB.Updates(o) global.DB.Updates(o)
} }
func DeleteUserById(id string) { func DeleteUserById(id string) {
config.DB.Where("id = ?", id).Delete(&User{}) global.DB.Where("id = ?", id).Delete(&User{})
} }
func CountUser() (total int64, err error) { func CountUser() (total int64, err error) {
err = config.DB.Find(&User{}).Count(&total).Error err = global.DB.Find(&User{}).Count(&total).Error
return return
} }

View File

@ -6,6 +6,7 @@ import (
"github.com/gofrs/uuid" "github.com/gofrs/uuid"
"golang.org/x/crypto/bcrypt" "golang.org/x/crypto/bcrypt"
"net" "net"
"os"
"strconv" "strconv"
"time" "time"
) )
@ -79,3 +80,29 @@ func Tcping(ip string, port int) bool {
defer conn.Close() defer conn.Close()
return true return true
} }
// 判断所给路径文件/文件夹是否存在
func Exists(path string) bool {
_, err := os.Stat(path) //os.Stat获取文件信息
if err != nil {
if os.IsExist(err) {
return true
}
return false
}
return true
}
// 判断所给路径是否为文件夹
func IsDir(path string) bool {
s, err := os.Stat(path)
if err != nil {
return false
}
return s.IsDir()
}
// 判断所给路径是否为文件
func IsFile(path string) bool {
return !IsDir(path)
}

8
supervisord.conf Normal file
View File

@ -0,0 +1,8 @@
[supervisord]
nodaemon=true
[program:guacd]
command=/usr/local/guacamole/sbin/guacd -b 0.0.0.0 -L info -f
[program:next-terminal]
; command=/usr/local/nt/nt --mysql.hostname $MYSQL_HOSTNAME --mysql.port $MYSQL_PORT --mysql.username $MYSQL_USERNAME --mysql.password $MYSQL_PASSWORD --mysql.database $MYSQL_DATABASE --server.addr 0.0.0.0:$SERVER_PORT
command=/usr/local/nt/nt --mysql.hostname %(ENV_MYSQL_HOSTNAME)s --mysql.port %(ENV_MYSQL_PORT)s --mysql.username %(ENV_MYSQL_USERNAME)s --mysql.password %(ENV_MYSQL_PASSWORD)s --mysql.database %(ENV_MYSQL_DATABASE)s --server.addr 0.0.0.0:%(ENV_SERVER_PORT)s

View File

@ -226,7 +226,7 @@ class App extends Component {
<Route path="/setting" component={Setting}/> <Route path="/setting" component={Setting}/>
<Footer style={{textAlign: 'center'}}> <Footer style={{textAlign: 'center'}}>
Next Terminal ©2020 Created by 杜世翔 Next Terminal ©2020 dushixiang Version:0.0.1
</Footer> </Footer>
</Layout> </Layout>

View File

@ -18,7 +18,7 @@ const handleError = (error) => {
return; return;
} }
if (error.response !== undefined) { if (error.response !== undefined) {
message.error(error.response.data.message); // message.error(error.response.data.message);
} }
}; };

View File

@ -3,7 +3,6 @@ import Guacamole from 'guacamole-common-js';
import {message, Modal} from 'antd' import {message, Modal} from 'antd'
import qs from "qs"; import qs from "qs";
import {prefix, wsServer} from "../../common/constants"; import {prefix, wsServer} from "../../common/constants";
import {LoadingOutlined} from '@ant-design/icons';
import {getToken} from "../../utils/utils"; import {getToken} from "../../utils/utils";
import './Access.css' import './Access.css'
@ -14,8 +13,6 @@ const STATE_CONNECTED = 3;
const STATE_DISCONNECTING = 4; const STATE_DISCONNECTING = 4;
const STATE_DISCONNECTED = 5; const STATE_DISCONNECTED = 5;
const antIcon = <LoadingOutlined/>;
class Access extends Component { class Access extends Component {
formRef = React.createRef() formRef = React.createRef()

View File

@ -1,5 +1,5 @@
import React, {Component} from 'react'; import React, {Component} from 'react';
import {Card, Col, Layout, PageHeader, Radio, Row, Statistic, Typography} from "antd"; import {Card, Col, PageHeader, Radio, Row, Statistic} from "antd";
import {DesktopOutlined, IdcardOutlined, LinkOutlined, UserOutlined} from '@ant-design/icons'; import {DesktopOutlined, IdcardOutlined, LinkOutlined, UserOutlined} from '@ant-design/icons';
import {itemRender} from '../../utils/utils' import {itemRender} from '../../utils/utils'
import request from "../../common/request"; import request from "../../common/request";
@ -7,9 +7,6 @@ import './Dashboard.css'
import {Link} from "react-router-dom"; import {Link} from "react-router-dom";
import {Area} from '@ant-design/charts'; import {Area} from '@ant-design/charts';
const {Content} = Layout;
const {Title, Paragraph} = Typography;
const routes = [ const routes = [
{ {

View File

@ -258,14 +258,6 @@ class OfflineSession extends Component {
return `${record.username}@${record.ip}:${record.port}`; return `${record.username}@${record.ip}:${record.port}`;
} }
}, {
title: '屏幕大小',
dataIndex: 'screen',
key: 'screen',
render: (text, record) => {
return `${record.width}x${record.height}`;
}
}, { }, {
title: '连接协议', title: '连接协议',
dataIndex: 'protocol', dataIndex: 'protocol',
@ -385,7 +377,7 @@ class OfflineSession extends Component {
/> />
<Select <Select
style={{width: 200}} style={{width: 150}}
showSearch showSearch
value={this.state.queryParams.userId} value={this.state.queryParams.userId}
placeholder='用户昵称' placeholder='用户昵称'
@ -397,7 +389,7 @@ class OfflineSession extends Component {
</Select> </Select>
<Select <Select
style={{width: 200}} style={{width: 150}}
showSearch showSearch
value={this.state.queryParams.assetId} value={this.state.queryParams.assetId}
placeholder='资产名称' placeholder='资产名称'

View File

@ -255,14 +255,6 @@ class OnlineSession extends Component {
return `${record.username}@${record.ip}:${record.port}`; return `${record.username}@${record.ip}:${record.port}`;
} }
}, {
title: '屏幕大小',
dataIndex: 'screen',
key: 'screen',
render: (text, record) => {
return `${record.width}x${record.height}`;
}
}, { }, {
title: '连接协议', title: '连接协议',
dataIndex: 'protocol', dataIndex: 'protocol',
@ -378,7 +370,7 @@ class OnlineSession extends Component {
/> />
<Select <Select
style={{width: 200}} style={{width: 150}}
showSearch showSearch
value={this.state.queryParams.userId} value={this.state.queryParams.userId}
placeholder='用户昵称' placeholder='用户昵称'
@ -390,7 +382,7 @@ class OnlineSession extends Component {
</Select> </Select>
<Select <Select
style={{width: 200}} style={{width: 150}}
showSearch showSearch
value={this.state.queryParams.assetId} value={this.state.queryParams.assetId}
placeholder='资产名称' placeholder='资产名称'

View File

@ -1,5 +1,6 @@
import React, {Component} from 'react'; import React, {Component} from 'react';
import Guacamole from "guacamole-common-js"; import Guacamole from "guacamole-common-js";
import {prefix, server} from "../../common/constants";
class Playback extends Component { class Playback extends Component {
@ -13,7 +14,7 @@ class Playback extends Component {
} }
initPlayer(sessionId) { initPlayer(sessionId) {
var RECORDING_URL = '/sessions/' + sessionId + '/recording'; var RECORDING_URL = `${server + prefix}/sessions/${sessionId}/recording`;
var player = document.getElementById('player'); var player = document.getElementById('player');
var display = document.getElementById('display'); var display = document.getElementById('display');

View File

@ -1,7 +1,6 @@
import React, {Component} from 'react'; import React, {Component} from 'react';
import {Layout, PageHeader} from "antd"; import {Button, Form, Input, Layout, PageHeader} from "antd";
import {itemRender} from '../../utils/utils' import {itemRender} from '../../utils/utils'
import {Form, Input, Button, Checkbox} from "antd";
import request from "../../common/request"; import request from "../../common/request";
import {message} from "antd/es"; import {message} from "antd/es";
@ -110,7 +109,8 @@ class Info extends Component {
}, },
]} ]}
> >
<Input type='password' placeholder="新的密码" onChange={(value) => this.onNewPasswordChange(value)}/> <Input type='password' placeholder="新的密码"
onChange={(value) => this.onNewPasswordChange(value)}/>
</Form.Item> </Form.Item>
<Form.Item <Form.Item
@ -126,7 +126,8 @@ class Info extends Component {
validateStatus={this.state.validateStatus} validateStatus={this.state.validateStatus}
help={this.state.errorMsg || ''} help={this.state.errorMsg || ''}
> >
<Input type='password' placeholder="请和上面输入新的密码保持一致" onChange={(value) => this.onNewPassword2Change(value)}/> <Input type='password' placeholder="请和上面输入新的密码保持一致"
onChange={(value) => this.onNewPassword2Change(value)}/>
</Form.Item> </Form.Item>
<Form.Item {...formTailLayout}> <Form.Item {...formTailLayout}>

View File

@ -1,5 +1,5 @@
import React from 'react'; import React from 'react';
import {Form, Input, Modal, Radio} from "antd/lib/index"; import {Form, Input, Modal} from "antd/lib/index";
const UserModal = ({title, visible, handleOk, handleCancel, confirmLoading, model}) => { const UserModal = ({title, visible, handleOk, handleCancel, confirmLoading, model}) => {

Binary file not shown.