Compare commits

15 Commits

Author SHA1 Message Date
6840a25901 change udp->tcp 2023-01-11 15:51:33 +02:00
af24e54ce1 return the udp-telnet to tcp-telent with bar 2023-01-11 15:43:04 +02:00
0cd699b2d3 cancel timezone error 2023-01-05 09:46:33 +02:00
a2a0d85e5d add TZ to Dockerfile 2023-01-05 08:03:38 +02:00
8f39f4e907 telnet tcp->udp, https->http 2023-01-04 22:46:11 +02:00
Ni Rui
b01b552834 Upgrade backend dependencies 2022-11-10 14:01:02 +08:00
Ni Rui
e81f5f4238 Upgrade front-end dependencies 2022-11-10 14:00:39 +08:00
Ni Rui
7486d335c4 Add example file for docker-compose 2022-09-24 10:28:51 +08:00
Ni Rui
ed2e2dacac Upgrade backend dependencies 2022-09-24 10:27:57 +08:00
Ni Rui
3d5d14137a Upgrade front-end dependencies + add Hack font 2022-09-24 10:27:19 +08:00
Ni Rui
f44a71c9b5 Font: Add Hack Font back so we have consistent and expectable font rendering 2022-09-24 10:25:05 +08:00
Ni Rui
981be0c5d2 Dockerfile: fixed try.sh for better retrying 2022-09-24 10:23:09 +08:00
Ni Rui
5ab64e931b Upgrade backend dependencies 2022-09-20 16:57:59 +08:00
Ni Rui
56fd8ee768 Upgrade frontend dependencies 2022-09-20 16:57:39 +08:00
Ni Rui
bc80b52c84 Get ready to upgrade to xterm.js once the new version is stabilized 2022-09-20 16:38:58 +08:00
16 changed files with 1921 additions and 2138 deletions

View File

@@ -18,7 +18,8 @@ Major dependencies includes:
- [iconv-lite](https://github.com/ashtuchkin/iconv-lite), Licensed under MIT license
- [buffer](https://github.com/feross/buffer), Licensed under MIT license
- [fontfaceobserver](https://github.com/bramstein/fontfaceobserver), [View license](https://github.com/bramstein/fontfaceobserver/blob/master/LICENSE)
- [Nerd Font](https://www.nerdfonts.com/), packaged by [@azurity/pure-nerd-font](http://github.com/azurity/pure-nerd-font)
- [Hack Font](https://github.com/source-foundry/Hack), [View license](https://github.com/source-foundry/Hack/blob/master/LICENSE.md)
- [Nerd Fonts](https://www.nerdfonts.com/), packaged by [@azurity/pure-nerd-font](http://github.com/azurity/pure-nerd-font)
includes icons from following fonts:
- [Powerline Extra Symbols](https://github.com/ryanoasis/powerline-extra-symbols), Licensed under MIT license
- [Font Awesome](https://github.com/FortAwesome/Font-Awesome), [View license](https://github.com/FortAwesome/Font-Awesome/blob/6.x/LICENSE.txt)

View File

@@ -2,7 +2,7 @@
FROM ubuntu:devel AS base
RUN set -ex && \
cd / && \
echo '#!/bin/sh' > /try.sh && echo 'res=0; for i in $(seq 0 36); do $@; res=$?; [ $res -eq 0 ] && exit $res || sleep 10; done; exit $res' >> /try.sh && chmod +x /try.sh && \
echo '#!/bin/sh' > /try.sh && echo 'res=1; for i in $(seq 0 36); do $@; res=$?; [ $res -eq 0 ] && exit $res || sleep 10; done; exit $res' >> /try.sh && chmod +x /try.sh && \
echo '#!/bin/sh' > /child.sh && echo 'cpid=""; ret=0; i=0; for c in "$@"; do ( (((((eval "$c"; echo $? >&3) | sed "s/^/|-($i) /" >&4) 2>&1 | sed "s/^/|-($i)!/" >&2) 3>&1) | (read xs; exit $xs)) 4>&1) & ppid=$!; cpid="$cpid $ppid"; echo "+ Child $i (PID $ppid): $c ..."; i=$((i+1)); done; for c in $cpid; do wait $c; cret=$?; [ $cret -eq 0 ] && continue; echo "* Child PID $c has failed." >&2; ret=$cret; done; exit $ret' >> /child.sh && chmod +x /child.sh && \
export PATH=$PATH:/ && \
export DEBIAN_FRONTEND=noninteractive && \
@@ -68,6 +68,7 @@ ENV SSHWIFTY_HOSTNAME= \
SSHWIFTY_ONLYALLOWPRESETREMOTES=
COPY --from=builder /sshwifty /
COPY . /sshwifty-src
RUN apk add --no-cache tzdata
RUN set -ex && \
adduser -D sshwifty && \
chmod +x /sshwifty && \

View File

@@ -254,45 +254,45 @@ func (s socket) Get(
// DO NOT rely on this if you want to secured communitcation, in
// that case, you need to use HTTPS.
//
readNonce := [socketGCMStandardNonceSize]byte{}
_, nonceReadErr := io.ReadFull(&wsReader, readNonce[:])
// readNonce := [socketGCMStandardNonceSize]byte{}
// _, nonceReadErr := io.ReadFull(&wsReader, readNonce[:])
if nonceReadErr != nil {
return NewError(http.StatusBadRequest, fmt.Sprintf(
"Unable to read initial client nonce: %s", nonceReadErr.Error()))
}
// if nonceReadErr != nil {
// return NewError(http.StatusBadRequest, fmt.Sprintf(
// "Unable to read initial client nonce: %s", nonceReadErr.Error()))
// }
writeNonce := [socketGCMStandardNonceSize]byte{}
nonceReadErr = s.generateNonce(writeNonce[:])
// writeNonce := [socketGCMStandardNonceSize]byte{}
// nonceReadErr = s.generateNonce(writeNonce[:])
if nonceReadErr != nil {
return NewError(http.StatusBadRequest, fmt.Sprintf(
"Unable to generate initial server nonce: %s",
nonceReadErr.Error()))
}
// if nonceReadErr != nil {
// return NewError(http.StatusBadRequest, fmt.Sprintf(
// "Unable to generate initial server nonce: %s",
// nonceReadErr.Error()))
// }
_, nonceSendErr := wsWriter.Write(writeNonce[:])
// _, nonceSendErr := wsWriter.Write(writeNonce[:])
if nonceSendErr != nil {
return NewError(http.StatusBadRequest, fmt.Sprintf(
"Unable to send server nonce to client: %s", nonceSendErr.Error()))
}
// if nonceSendErr != nil {
// return NewError(http.StatusBadRequest, fmt.Sprintf(
// "Unable to send server nonce to client: %s", nonceSendErr.Error()))
// }
cipherKey := s.buildCipherKey(r)
// cipherKey := s.buildCipherKey(r)
readCipher, writeCipher, cipherCreationErr := s.createCipher(cipherKey[:])
// readCipher, writeCipher, cipherCreationErr := s.createCipher(cipherKey[:])
if cipherCreationErr != nil {
return NewError(http.StatusInternalServerError, fmt.Sprintf(
"Unable to create cipher: %s", cipherCreationErr.Error()))
}
// if cipherCreationErr != nil {
// return NewError(http.StatusInternalServerError, fmt.Sprintf(
// "Unable to create cipher: %s", cipherCreationErr.Error()))
// }
// Start service
const cipherReadBufSize = 4096
cipherReadBuf := [cipherReadBufSize]byte{}
cipherWriteBuf := [cipherReadBufSize]byte{}
maxWriteLen := int(cipherReadBufSize) - (writeCipher.Overhead() + 2)
maxWriteLen := int(cipherReadBufSize) // - (writeCipher.Overhead() + 2)
senderLock := sync.Mutex{}
cmdExec, cmdExecErr := s.commander.New(
@@ -301,7 +301,7 @@ func (s socket) Get(
DialTimeout: s.commonCfg.DecideDialTimeout(s.serverCfg.ReadTimeout),
},
rw.NewFetchReader(func() ([]byte, error) {
defer s.increaseNonce(readNonce[:])
// defer s.increaseNonce(readNonce[:])
// Size is unencrypted
_, rErr := io.ReadFull(&wsReader, cipherReadBuf[:2])
@@ -326,8 +326,10 @@ func (s socket) Get(
return nil, rErr
}
return readCipher.Open(
cipherReadBuf[:0], readNonce[:], rData, nil)
copy(cipherReadBuf[2:], rData)
return cipherReadBuf[2 : 2+packageSize], nil
// return readCipher.Open(
// cipherReadBuf[:0], readNonce[:], rData, nil)
}
_, rErr = io.ReadFull(&wsReader, cipherReadBuf[:packageSize])
@@ -336,11 +338,12 @@ func (s socket) Get(
return nil, rErr
}
return readCipher.Open(
cipherReadBuf[:0],
readNonce[:],
cipherReadBuf[:packageSize],
nil)
return cipherReadBuf[:packageSize], nil
// return readCipher.Open(
// cipherReadBuf[:0],
// readNonce[:],
// cipherReadBuf[:packageSize],
// nil)
}),
socketPackageWriter{
w: wsWriter,
@@ -354,15 +357,18 @@ func (s socket) Get(
readLen = maxWriteLen
}
encrypted := writeCipher.Seal(
cipherWriteBuf[2:2],
writeNonce[:],
b[start:start+readLen],
nil)
// encrypted := writeCipher.Seal(
// cipherWriteBuf[2:2],
// writeNonce[:],
// b[start:start+readLen],
// nil)
s.increaseNonce(writeNonce[:])
// s.increaseNonce(writeNonce[:])
encryptedSize := uint16(len(encrypted))
copy(cipherWriteBuf[2+start:2+start+readLen], b[start:start+readLen])
// encryptedSize := uint16(len(cipherWriteBuf[2:]))
encryptedSize := readLen
if encryptedSize <= 0 {
return ErrSocketInvalidDataPackage

View File

@@ -0,0 +1,21 @@
version: "3.9"
services:
sshwifty:
image: sshwifty:dev
container_name: sshwifty
user: "nobody:nobody"
build: ./
restart: always
# environment:
# - SSHWIFTY_SHAREDKEY=WEB_ACCESS_PASSWORD
ports:
- "127.0.0.1:8182:8182/tcp"
stdin_open: true
tty: true
# deploy:
# replicas: 3
# resources:
# limits:
# cpus: '0.3'
# memory: 600M

6
go.mod
View File

@@ -21,7 +21,7 @@ go 1.13
require (
github.com/gorilla/websocket v1.5.0
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90
golang.org/x/net v0.0.0-20220909164309-bea034e7d591
golang.org/x/sys v0.0.0-20220909162455-aba9fc2a8ff2 // indirect
golang.org/x/crypto v0.2.0
golang.org/x/net v0.2.0
golang.org/x/sys v0.2.0 // indirect
)

34
go.sum
View File

@@ -2,6 +2,9 @@ github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0U
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20220210151621-f4118a5b28e2 h1:XdAboW3BNMv9ocSCOk/u1MFioZGzCNkiJZ19v9Oe3Ig=
golang.org/x/crypto v0.0.0-20220210151621-f4118a5b28e2/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 h1:kUhD7nTDoI3fVd9G4ORWrbV5NY0liEs/Jg2pv5f+bBA=
@@ -16,6 +19,15 @@ golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJ
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 h1:Y/gsMcFOcR+6S6f3YeMKl5g+dZMEWqcz5Czj/GWYbkM=
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20220919173607-35f4265a4bc0 h1:a5Yg6ylndHHYJqIPrdq0AhvR6KTvDTAvgBtaidhEevY=
golang.org/x/crypto v0.0.0-20220919173607-35f4265a4bc0/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20220924013350-4ba4fb4dd9e7 h1:WJywXQVIb56P2kAvXeMGTIgQ1ZHQxR60+F9dLsodECc=
golang.org/x/crypto v0.0.0-20220924013350-4ba4fb4dd9e7/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.2.0 h1:BRXPfhNivWL5Yq0BGQ39a2sW6t44aODpfxkWjYdzewE=
golang.org/x/crypto v0.2.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd h1:O7DYs+zxREGLKzKoMQrtrEacpb0ZVXA5rIwylE2Xchk=
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
@@ -27,10 +39,20 @@ golang.org/x/net v0.0.0-20220617184016-355a448f1bc9 h1:Yqz/iviulwKwAREEeUd3nbBFn
golang.org/x/net v0.0.0-20220617184016-355a448f1bc9/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.0.0-20220708220712-1185a9018129 h1:vucSRfWwTsoXro7P+3Cjlr6flUMtzCwzlvkxEQtHHB0=
golang.org/x/net v0.0.0-20220708220712-1185a9018129/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.0.0-20220811182439-13a9a731de15 h1:cik0bxZUSJVDyaHf1hZPSDsU8SZHGQZQMeueXCE7yBQ=
golang.org/x/net v0.0.0-20220811182439-13a9a731de15/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
golang.org/x/net v0.0.0-20220909164309-bea034e7d591 h1:D0B/7al0LLrVC8aWF4+oxpv/m8bc7ViFfVS8/gXGdqI=
golang.org/x/net v0.0.0-20220909164309-bea034e7d591/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
golang.org/x/net v0.0.0-20220919232410-f2f64ebce3c1 h1:TWZxd/th7FbRSMret2MVQdlI8uT49QEtwZdvJrxjEHU=
golang.org/x/net v0.0.0-20220919232410-f2f64ebce3c1/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
golang.org/x/net v0.0.0-20220923203811-8be639271d50 h1:vKyz8L3zkd+xrMeIaBsQ/MNVPVFSffdaU3ZyYlBGFnI=
golang.org/x/net v0.0.0-20220923203811-8be639271d50/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
golang.org/x/net v0.2.0 h1:sZfSu1wtKLGlWI4ZZayP0ck9Y73K1ynO6gqzTdBVdPU=
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
@@ -46,13 +68,25 @@ golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c h1:aFV+BgZ4svzjfabn8ERpuB4JI
golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab h1:2QkjZIsXupsJbJIdSjjUOgWK3aEtzyuh2mPt3l/CkeU=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220909162455-aba9fc2a8ff2 h1:wM1k/lXfpc5HdkJJyW9GELpd8ERGdnh8sMGL6Gzq3Ho=
golang.org/x/sys v0.0.0-20220909162455-aba9fc2a8ff2/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220919091848-fb04ddd9f9c8 h1:h+EGohizhe9XlX18rfpa8k8RAc5XyaeamM+0VHRd4lc=
golang.org/x/sys v0.0.0-20220919091848-fb04ddd9f9c8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A=
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

3657
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -5,30 +5,31 @@
"main": "",
"devDependencies": {
"@azurity/pure-nerd-font": "1.0.0",
"@babel/core": "^7.19.0",
"@babel/eslint-parser": "^7.18.9",
"@babel/plugin-transform-runtime": "^7.18.10",
"@babel/preset-env": "^7.19.0",
"@babel/core": "^7.20.2",
"@babel/eslint-parser": "^7.19.1",
"@babel/plugin-transform-runtime": "^7.19.6",
"@babel/preset-env": "^7.20.2",
"@babel/register": "^7.18.9",
"@babel/runtime": "^7.19.0",
"babel-loader": "^8.2.5",
"@babel/runtime": "^7.20.1",
"babel-loader": "^9.1.0",
"buffer": "^6.0.3",
"clean-webpack-plugin": "^4.0.0",
"copy-webpack-plugin": "^11.0.0",
"css-loader": "^6.7.1",
"css-minimizer-webpack-plugin": "^4.1.0",
"css-minimizer-webpack-plugin": "^4.2.2",
"cwebp-bin": "^8.0.0",
"eslint": "^8.23.1",
"eslint": "^8.27.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-vue": "^9.4.0",
"eslint-plugin-vue": "^9.7.0",
"eslint-webpack-plugin": "^3.2.0",
"favicons": "^7.0.0",
"favicons": "^7.0.2",
"fontfaceobserver": "^2.3.0",
"html-loader": "^4.1.0",
"hack-font": "^3.3.0",
"html-loader": "^4.2.0",
"html-webpack-plugin": "^5.5.0",
"iconv-lite": "^0.6.3",
"image-minimizer-webpack-plugin": "^3.4.0",
"image-minimizer-webpack-plugin": "^3.8.0",
"imagemin": "^8.0.1",
"imagemin-gifsicle": "^7.0.0",
"imagemin-mozjpeg": "^10.0.0",
@@ -36,7 +37,7 @@
"imagemin-svgo": "^10.0.1",
"imagemin-webp": "^7.0.0",
"mini-css-extract-plugin": "^2.6.1",
"mocha": "^10.0.0",
"mocha": "^10.1.0",
"normalize.css": "^8.0.1",
"prettier": "^2.7.1",
"roboto-fontface": "^0.10.0",
@@ -45,12 +46,12 @@
"vue": "^2.6.14",
"vue-loader": "^15.9.8",
"vue-template-compiler": "^2.6.14",
"webpack": "^5.74.0",
"webpack": "^5.75.0",
"webpack-cli": "^4.10.0",
"webpack-favicons": "^1.3.8",
"xterm": "^4.19.0",
"xterm-addon-fit": "^0.5.0",
"xterm-addon-web-links": "^0.6.0"
"xterm": "^5.0.0",
"xterm-addon-fit": "^0.6.0",
"xterm-addon-web-links": "^0.7.0"
},
"scripts": {
"dev": "NODE_ENV=development webpack --mode=development --config=webpack.config.js --watch",

View File

@@ -1,6 +1,6 @@
{
"HostName": "",
"SharedKey": "WEB_ACCESS_PASSWORD",
"SharedKey": "",
"DialTimeout": 5,
"Socks5": "",
"Socks5User": "",

View File

@@ -286,16 +286,16 @@ function startApp(rootEl) {
clientTime = new Date().getTime(),
timeDiff = Math.abs(serverTime - clientTime);
if (timeDiff > maxTimeDiff) {
this.loadErr =
"The time difference between this client " +
"and the backend server is beyond operational limit.\r\n\r\n" +
"Please try reload the page, and if the problem persisted, " +
"consider to adjust your local time so both the client and " +
"the server are running at same date time";
// if (timeDiff > maxTimeDiff) {
// this.loadErr =
// "The time difference between this client " +
// "and the backend server is beyond operational limit.\r\n\r\n" +
// "Please try reload the page, and if the problem persisted, " +
// "consider to adjust your local time so both the client and " +
// "the server are running at same date time";
return;
}
// return;
// }
}
let self = this;

View File

@@ -20,7 +20,7 @@
<template>
<div id="home">
<header id="home-header">
<h1 id="home-hd-title">Sshwifty</h1>
<h1 id="home-hd-title">Vala Terminal</h1>
<a id="home-hd-delay" href="javascript:;" @click="showDelayWindow">
<span
@@ -32,7 +32,6 @@
socket.message
}}</span>
</a>
<a
id="home-hd-plus"
class="icon icon-plus1"
@@ -75,6 +74,8 @@
servers without downloading any additional software.
</p>
<h1>Eli Cohen</h1>
<p>
To get started, click the
<span

View File

@@ -2,14 +2,14 @@ import * as history from "./history.js";
import { ECHO_FAILED } from "./socket.js";
export function build(ctx) {
const connectionStatusNotConnected = "Sshwifty is ready to connect";
const connectionStatusNotConnected = "Vala Terminal is ready to connect";
const connectionStatusConnecting =
"Connecting to Sshwifty backend server. It should only take " +
"Connecting to Vala Terminal backend server. It should only take " +
"less than a second, or two";
const connectionStatusDisconnected =
"Sshwifty is disconnected from it's backend server";
"Vala Terminal is disconnected from it's backend server";
const connectionStatusConnected =
"Sshwifty is connected to it's backend server, user interface operational";
"Vala Terminal is connected to it's backend server, user interface operational";
const connectionStatusUnmeasurable =
"Unable to measure connection delay. The connection maybe very " +
"busy or already lost";

View File

@@ -20,7 +20,7 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Sshwifty Web SSH Client</title>
<title>Vala Terminal</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body>
@@ -28,7 +28,7 @@
<div id="landing-message">
<div id="landing-message-logo"></div>
<h1 id="landing-message-title">Loading Sshwifty</h1>
<h1 id="landing-message-title">Loading Vala Terminal</h1>
<div id="landing-message-info">
<p>
@@ -45,9 +45,6 @@
Copyright &copy; 2019-2022 Ni Rui &lt;ranqus@gmail.com&gt;
</p>
<p class="copy">
<a href="https://github.com/nirui/sshwifty" target="blank">
Source code
</a>
<a href="/sshwifty/assets/DEPENDENCIES.md" target="blank">
Third-party

View File

@@ -36,10 +36,10 @@ class Dial {
* decrypt socket traffic
*
*/
constructor(address, timeout, privateKey) {
constructor(address, timeout) {
this.address = address;
this.timeout = timeout;
this.privateKey = privateKey;
// this.privateKey = privateKey;
this.keepAliveTicker = null;
}
@@ -205,17 +205,17 @@ class Dial {
10 // max 10 buffered requests
);
let senderNonce = crypt.generateNonce();
sd.send(senderNonce);
// let senderNonce = crypt.generateNonce();
// sd.send(senderNonce);
let receiverNonce = await reader.readN(rd, crypt.GCMNonceSize);
// let receiverNonce = await reader.readN(rd, crypt.GCMNonceSize);
let key = await this.buildKey();
// let key = await this.buildKey();
sdDataConvert = async (rawData) => {
let encoded = await crypt.encryptGCM(key, senderNonce, rawData);
let encoded = rawData; // await crypt.encryptGCM(key, senderNonce, rawData);
crypt.increaseNonce(senderNonce);
// crypt.increaseNonce(senderNonce);
let dataToSend = new Uint8Array(encoded.byteLength + 2);
@@ -236,13 +236,13 @@ class Dial {
dSize <<= 8;
dSize |= dSizeBytes[1];
let decoded = await crypt.decryptGCM(
key,
receiverNonce,
await reader.readN(rd, dSize)
);
// let decoded = await crypt.decryptGCM(
// key,
// receiverNonce,
let decoded = await reader.readN(rd, dSize);
// );
crypt.increaseNonce(receiverNonce);
// crypt.increaseNonce(receiverNonce);
r.feed(
new reader.Buffer(new Uint8Array(decoded), () => {}),
@@ -276,7 +276,7 @@ export class Socket {
* @param {number} echoInterval Echo interval
*/
constructor(address, privateKey, timeout, echoInterval) {
this.dial = new Dial(address, timeout, privateKey);
this.dial = new Dial(address, timeout);
this.echoInterval = echoInterval;
this.streamHandler = null;
}

View File

@@ -19,19 +19,20 @@
@charset "utf-8";
@import "~hack-font/build/web/hack.css";
@import "~@azurity/pure-nerd-font/pure-nerd-font.css";
#connector-resource-preload-control-console {
font-family: PureNerdFont;
font-family: PureNerdFont, Hack;
}
#connector-resource-preload-control-console::after {
content: " ";
font-family: PureNerdFont;
font-family: PureNerdFont, Hack;
font-weight: bold;
}
#connector-resource-preload-control-console::before {
content: " ";
font-family: PureNerdFont;
font-family: PureNerdFont, Hack;
font-style: italic;
}

View File

@@ -21,7 +21,7 @@
<div class="screen-console">
<div
class="console-console"
:style="'font-family: ' + typeface + ', inherit'"
:style="'font-family: ' + typefaces + ', inherit'"
>
<h2 style="display: none">Console</h2>
@@ -117,15 +117,15 @@ import { consoleScreenKeys } from "./screen_console_keys.js";
import "./screen_console.css";
import "xterm/css/xterm.css";
const termTypeFace = "PureNerdFont";
const termFallbackTypeFace = "monospace";
const termTypeFaces = "PureNerdFont, Hack";
const termFallbackTypeFace = "\"Cascadia Code\" , monospace";
const termTypeFaceLoadTimeout = 3000;
const termTypeFaceLoadError =
'Remote font "' +
termTypeFace +
'" is unavailable, using "' +
'Remote font ' +
termTypeFaces +
' is unavailable, using ' +
termFallbackTypeFace +
'" instead until the remote font is loaded';
' instead until the remote font is loaded';
const termDefaultFontSize = 16;
const termMinFontSize = 8;
const termMaxFontSize = 36;
@@ -138,10 +138,11 @@ class Term {
this.closed = false;
this.fontSize = termDefaultFontSize;
this.term = new Terminal({
allowProposedApi: true,
allowTransparency: false,
cursorBlink: true,
cursorStyle: "block",
fontFamily: termTypeFace + ", " + termFallbackTypeFace,
fontFamily: termTypeFaces + ", " + termFallbackTypeFace,
fontSize: this.fontSize,
logLevel: process.env.NODE_ENV === "development" ? "info" : "off",
theme: {
@@ -154,7 +155,6 @@ class Term {
if (this.closed) {
return;
}
this.control.send(data);
});
@@ -162,7 +162,6 @@ class Term {
if (this.closed) {
return;
}
this.control.sendBinary(data);
});
@@ -170,28 +169,23 @@ class Term {
if (this.closed) {
return;
}
if (!this.control.echo()) {
return;
}
const printable =
!ev.domEvent.altKey &&
!ev.domEvent.altGraphKey &&
!ev.domEvent.ctrlKey &&
!ev.domEvent.metaKey;
switch (ev.domEvent.key) {
case "Enter":
ev.domEvent.preventDefault();
this.writeStr("\r\n");
break;
case "Backspace":
ev.domEvent.preventDefault();
this.writeStr("\b \b");
break;
default:
if (printable) {
ev.domEvent.preventDefault();
@@ -200,49 +194,6 @@ class Term {
}
});
// It seems Xtermjs now handles copy paste by itself, following code is no
// longer useful
// this.term.attachCustomKeyEventHandler(async (ev) => {
// if (this.closed) {
// return true;
// }
// if (
// ev.type == "keyup" &&
// ((ev.key.toLowerCase() === "v" && ev.shiftKey && ev.ctrlKey) ||
// (ev.key === "Insert" && ev.shiftKey))
// ) {
// try {
// let text = await window.navigator.clipboard.readText();
// this.writeEchoStr(text);
// } catch (e) {
// alert(
// "Unable to paste: " +
// e +
// ". Please try again without using the Control+Shift+V / " +
// "Shift+Insert hot key"
// );
// }
// return false;
// }
// if (
// ev.type == "keyup" &&
// ((ev.key.toLowerCase() === "c" && ev.shiftKey && ev.ctrlKey) ||
// (ev.key === "Insert" && ev.ctrlKey))
// ) {
// try {
// window.navigator.clipboard.writeText(this.term.getSelection());
// } catch (e) {
// alert("Unable to copy: " + e);
// }
// return false;
// }
// return true;
// });
let resizeDelay = null,
oldRows = 0,
oldCols = 0;
@@ -251,30 +202,23 @@ class Term {
if (this.closed) {
return;
}
if (dim.cols === oldCols && dim.rows === oldRows) {
return;
}
oldRows = dim.rows;
oldCols = dim.cols;
if (resizeDelay !== null) {
clearTimeout(resizeDelay);
resizeDelay = null;
}
resizeDelay = setTimeout(() => {
resizeDelay = null;
if (!isNumber(dim.cols) || !isNumber(dim.rows)) {
return;
}
if (!dim.cols || !dim.rows) {
return;
}
this.control.resize({
rows: dim.rows,
cols: dim.cols,
@@ -287,7 +231,6 @@ class Term {
if (this.closed) {
return;
}
this.term.open(root);
this.term.loadAddon(this.fit);
this.term.loadAddon(new WebLinksAddon());
@@ -304,7 +247,6 @@ class Term {
// }) {
// this.term.loadAddon(new WebglAddon());
// }
this.refit();
}
@@ -312,7 +254,6 @@ class Term {
if (this.closed) {
return;
}
try {
this.term.textarea.dispatchEvent(event);
} catch (e) {
@@ -324,13 +265,10 @@ class Term {
if (this.closed) {
return;
}
this.control.send(d);
if (!this.control.echo()) {
return;
}
this.writeStr(d);
}
@@ -338,7 +276,6 @@ class Term {
if (this.closed) {
return;
}
try {
this.term.write(d);
} catch (e) {
@@ -350,7 +287,6 @@ class Term {
if (this.closed) {
return;
}
try {
this.term.write(d);
} catch (e) {
@@ -362,7 +298,6 @@ class Term {
if (this.closed) {
return;
}
this.term.options.fontFamily = value;
this.refit();
}
@@ -371,11 +306,9 @@ class Term {
if (this.closed) {
return;
}
if (this.fontSize >= termMaxFontSize) {
return;
}
this.fontSize += 2;
this.term.options.fontSize = this.fontSize;
this.refit();
@@ -385,11 +318,9 @@ class Term {
if (this.closed) {
return;
}
if (this.fontSize <= termMinFontSize) {
return;
}
this.fontSize -= 2;
this.term.options.fontSize = this.fontSize;
this.refit();
@@ -399,7 +330,6 @@ class Term {
if (this.closed) {
return;
}
try {
this.term.focus();
this.refit();
@@ -412,7 +342,6 @@ class Term {
if (this.closed) {
return;
}
try {
this.term.blur();
} catch (e) {
@@ -424,7 +353,6 @@ class Term {
if (this.closed) {
return;
}
try {
this.fit.fit();
} catch (e) {
@@ -440,9 +368,7 @@ class Term {
if (this.closed) {
return;
}
this.closed = true;
try {
this.term.dispose();
} catch (e) {
@@ -490,7 +416,7 @@ export default {
return {
screenKeys: consoleScreenKeys,
term: new Term(this.control),
typeface: termTypeFace,
typefaces: termTypeFaces,
runner: null,
eventHandlers: {
keydown: null,
@@ -530,25 +456,22 @@ export default {
this.deinit();
},
methods: {
loadRemoteFont(typeface, timeout) {
return Promise.all([
new FontFaceObserver(typeface).load(null, timeout),
new FontFaceObserver(typeface, {
loadRemoteFont(typefaces, timeout) {
const tfs = typefaces.split(",");
let observers = [];
for (let v in tfs) {
observers.push(new FontFaceObserver(tfs[v].trim()).load(null, timeout))
observers.push(new FontFaceObserver(tfs[v].trim(), {
weight: "bold",
}).load(null, timeout),
]);
}).load(null, timeout))
}
return Promise.all(observers);
},
async retryLoadRemoteFont(typeface, timeout, onSuccess) {
async retryLoadRemoteFont(typefaces, timeout, onSuccess) {
const self = this;
for (;;) {
if (self.term.destroyed()) {
return;
}
try {
onSuccess(await self.loadRemoteFont(typeface, timeout));
onSuccess(await self.loadRemoteFont(typefaces, timeout));
return;
} catch (e) {
// Retry
@@ -557,41 +480,29 @@ export default {
},
async openTerm(root, callbacks) {
const self = this;
try {
await self.loadRemoteFont(termTypeFace, termTypeFaceLoadTimeout);
await self.loadRemoteFont(termTypeFaces, termTypeFaceLoadTimeout);
if (self.term.destroyed()) {
return;
}
root.innerHTML = "";
self.term.init(root);
return;
} catch (e) {
// Ignore
}
if (self.term.destroyed()) {
return;
}
root.innerHTML = "";
callbacks.warn(termTypeFaceLoadError, false);
self.term.setFont(termFallbackTypeFace);
self.term.init(root);
self.retryLoadRemoteFont(termTypeFace, termTypeFaceLoadTimeout, () => {
self.retryLoadRemoteFont(termTypeFaces, termTypeFaceLoadTimeout, () => {
if (self.term.destroyed()) {
return;
}
self.term.setFont(termTypeFace);
self.term.setFont(termTypeFaces);
callbacks.warn(termTypeFaceLoadError, true);
});
},