lwch / natpass

🔥居家办公,远程开发神器
https://lwch.gitbook.io/natpass/
MIT License
4.22k stars 480 forks source link

三端启动报错 #35

Closed bugstark closed 2 years ago

bugstark commented 2 years ago

hi. 我在测试中遇到一些问题,所有配置文件仅修改了端口和服务器IP,local 可以跑起来看到设备列表,但是无法vnc 和shell, 有如下错误信息。 ser:

 + (/root/go/pkg/mod/github.com/lwch/logging@v0.0.0-20220322084100-ec48185d95ab/log.go:30) github.com/lwch/logging.Error
  + (/build/code/server/handler/handler.go:64) github.com/lwch/natpass/code/server/handler.(*Handler).Handle
2022/07/11 11:46:59 [ERROR]invalid handshake from 
  + (/root/go/pkg/mod/github.com/lwch/logging@v0.0.0-20220322084100-ec48185d95ab/log.go:30) github.com/lwch/logging.Error
  + (/build/code/server/handler/handler.go:64) github.com/lwch/natpass/code/server/handler.(*Handler).Handle
panic: runtime error: index out of range [0] with length 0

goroutine 56 [running]:
github.com/lwch/logging.(*rotateSizeLogger).rotate(0xc000190000)
    /root/go/pkg/mod/github.com/lwch/logging@v0.0.0-20220322084100-ec48185d95ab/rotate_size.go:99 +0x951
github.com/lwch/logging.(*Logger).Error(0xb9d900, {0x88a118, 0x27}, {0xc0001010e0, 0x3, 0x3})
    /root/go/pkg/mod/github.com/lwch/logging@v0.0.0-20220322084100-ec48185d95ab/log.go:90 +0x9b
github.com/lwch/logging.Error(...)
    /root/go/pkg/mod/github.com/lwch/logging@v0.0.0-20220322084100-ec48185d95ab/log.go:30
github.com/lwch/natpass/code/server/handler.(*Handler).Handle(0xc0001940c0, {0x929ec0?, 0xc00000e248?})
    /build/code/server/handler/handler.go:67 +0xdc
created by main.run
    /build/code/server/main.go:141 +0x165

cli local:

  + (/root/go/pkg/mod/github.com/lwch/logging@v0.0.0-20220322084100-ec48185d95ab/log.go:30) github.com/lwch/logging.Error
  + (/build/code/client/conn/conn.go:114) github.com/lwch/natpass/code/client/conn.(*Conn).loopRead
2022/07/11 11:46:59 [INFO]x.x.x.x:8976 connected
2022/07/11 11:46:59 [ERROR]read message: EOF
  + (/root/go/pkg/mod/github.com/lwch/logging@v0.0.0-20220322084100-ec48185d95ab/log.go:30) github.com/lwch/logging.Error
  + (/build/code/client/conn/conn.go:114) github.com/lwch/natpass/code/client/conn.(*Conn).loopRead

cli remote(win 10)

panic: runtime error: index out of range [0] with length 0

goroutine 35 [running]:
github.com/lwch/logging.(*rotateSizeLogger).rotate(0xc000094000)
        /root/go/pkg/mod/github.com/lwch/logging@v0.0.0-20220322084100-ec48185d95ab/rotate_size.go:99 +0x951
github.com/lwch/logging.(*Logger).Error(0x14268c0, {0x15169df, 0xe}, {0xc000210170, 0x1, 0x1})
        /root/go/pkg/mod/github.com/lwch/logging@v0.0.0-20220322084100-ec48185d95ab/log.go:90 +0x9b
github.com/lwch/logging.Error(...)
        /root/go/pkg/mod/github.com/lwch/logging@v0.0.0-20220322084100-ec48185d95ab/log.go:30
github.com/lwch/natpass/code/network.(*Conn).loopWrite(0xc000222040)
        /build/code/network/network.go:127 +0x248
created by github.com/lwch/natpass/code/network.NewConn
        /build/code/network/network.go:42 +0x137
lwch commented 2 years ago

你好,看错误信息表现为两个问题

  1. 服务器端和客户端中的common.yaml里的secret配置不一致导致握手失败
  2. common.yaml中的log相关配置被设置为0导致日志无法被滚动生成
bugstark commented 2 years ago

哦哦,不好意思,看到#include common.yaml 是注释状态,私以为可以无需配置 解除注释,并修改格式后变为 include: common.yaml 重启3端后。连接被控端报错:

2022/07/11 12:26:54 [INFO]add link a975db41d3f34cec
panic: runtime error: index out of range [0] with length 0

goroutine 34 [running]:
github.com/lwch/logging.(*rotateSizeLogger).rotate(0x1400009e000)
    /root/go/pkg/mod/github.com/lwch/logging@v0.0.0-20220322084100-ec48185d95ab/rotate_size.go:99 +0x7f8
github.com/lwch/logging.(*Logger).Error(0x101c6de60, {0x10125ca7c, 0xe}, {0x14000068160, 0x1, 0x1})
    /root/go/pkg/mod/github.com/lwch/logging@v0.0.0-20220322084100-ec48185d95ab/log.go:90 +0x7c
github.com/lwch/logging.Error(...)
    /root/go/pkg/mod/github.com/lwch/logging@v0.0.0-20220322084100-ec48185d95ab/log.go:30
github.com/lwch/natpass/code/network.(*Conn).loopWrite(0x140000ac040)
    /build/code/network/network.go:127 +0x1cc
created by github.com/lwch/natpass/code/network.NewConn
    /build/code/network/network.go:42 +0x148
lwch commented 2 years ago

可以检查一下common.yaml中的log.size和log.rotate配置这两个目前不支持设置为0哦

bugstark commented 2 years ago

common都是保持的原有设置,未曾修改

common

secret: 0123456789  # 预共享密钥,否则握手失败
link:
  read_timeout:  1s # 读取数据包超时时间
  write_timeout: 1s # 发送数据包超时时间
log:
  dir: ./logs # 路径,相对于可执行文件所在目录的相对路径
  size: 50M   # 单个文件大小
  rotate: 7   # 保留数量

local

id: local              # 客户端ID
server: XXXXXX:9876 # 服务器地址
ssl: false             # 是否使用tls加密连接
dashboard: # web面板
  enabled: true   # 是否开放dashboard
  listen: 0.0.0.0 # 监听地址
  port: 8080      # 监听端口号
include: common.yaml
rules: # rule列表
  #include rule.d/*.yaml

remote

id: remote             # 客户端ID
server: xxxxx:9876 # 服务器地址
ssl: false             # 是否使用tls加密连接
dashboard: # web面板
  enabled: false # 是否开放dashboard
include: common.yaml
rules: # rule列表

server

listen: 9876 # 监听端口号
include: common.yaml
#tls:
#  key: /dir/to/tls/key/file # tls密钥
#  crt: /dir/to/tls/crt/file # tls证书
lwch commented 2 years ago

include前面有个井号哦

bugstark commented 2 years ago

可以了,我还以为 #include是被注释了