mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-05-05 03:23:49 +08:00
fix unexpected ReadPassword behavior in linux(#794)
(cherry picked from commit a361366916013e7c47ee7a70910b1295ac18d3b5)
This commit is contained in:
parent
f1a480c01d
commit
127d636b8a
18
main.go
18
main.go
@ -8,9 +8,6 @@ import (
|
|||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/Mrs4s/go-cqhttp/global/terminal"
|
|
||||||
rotatelogs "github.com/lestrrat-go/file-rotatelogs"
|
|
||||||
easy "github.com/t-tomalak/logrus-easy-formatter"
|
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -25,18 +22,21 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/Mrs4s/go-cqhttp/server"
|
"github.com/Mrs4s/MiraiGo/binary"
|
||||||
|
"github.com/Mrs4s/MiraiGo/client"
|
||||||
"github.com/guonaihong/gout"
|
"github.com/guonaihong/gout"
|
||||||
|
jsoniter "github.com/json-iterator/go"
|
||||||
|
rotatelogs "github.com/lestrrat-go/file-rotatelogs"
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
easy "github.com/t-tomalak/logrus-easy-formatter"
|
||||||
"github.com/tidwall/gjson"
|
"github.com/tidwall/gjson"
|
||||||
"golang.org/x/crypto/pbkdf2"
|
"golang.org/x/crypto/pbkdf2"
|
||||||
"golang.org/x/term"
|
"golang.org/x/term"
|
||||||
|
|
||||||
"github.com/Mrs4s/MiraiGo/binary"
|
|
||||||
"github.com/Mrs4s/MiraiGo/client"
|
|
||||||
"github.com/Mrs4s/go-cqhttp/coolq"
|
"github.com/Mrs4s/go-cqhttp/coolq"
|
||||||
"github.com/Mrs4s/go-cqhttp/global"
|
"github.com/Mrs4s/go-cqhttp/global"
|
||||||
jsoniter "github.com/json-iterator/go"
|
"github.com/Mrs4s/go-cqhttp/global/terminal"
|
||||||
log "github.com/sirupsen/logrus"
|
"github.com/Mrs4s/go-cqhttp/server"
|
||||||
)
|
)
|
||||||
|
|
||||||
var json = jsoniter.ConfigCompatibleWithStandardLibrary
|
var json = jsoniter.ConfigCompatibleWithStandardLibrary
|
||||||
@ -187,6 +187,7 @@ func main() {
|
|||||||
if len(byteKey) == 0 {
|
if len(byteKey) == 0 {
|
||||||
log.Infof("密码加密已启用, 请输入Key对密码进行解密以继续: (Enter 提交)")
|
log.Infof("密码加密已启用, 请输入Key对密码进行解密以继续: (Enter 提交)")
|
||||||
cancel := make(chan struct{}, 1)
|
cancel := make(chan struct{}, 1)
|
||||||
|
state, _ := term.GetState(int(os.Stdin.Fd()))
|
||||||
go func() {
|
go func() {
|
||||||
select {
|
select {
|
||||||
case <-cancel:
|
case <-cancel:
|
||||||
@ -194,6 +195,7 @@ func main() {
|
|||||||
case <-time.After(time.Second * 45):
|
case <-time.After(time.Second * 45):
|
||||||
log.Infof("解密key输入超时")
|
log.Infof("解密key输入超时")
|
||||||
time.Sleep(3 * time.Second)
|
time.Sleep(3 * time.Second)
|
||||||
|
_ = term.Restore(int(os.Stdin.Fd()), state)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user