PinkD / corplink-rs

使用 rust 实现的飞连客户端
GNU General Public License v2.0
230 stars 31 forks source link

missing field `protocol_version` at line 1 column 514', src/main.rs:112:21 #3

Closed XuQK closed 2 years ago

XuQK commented 2 years ago

配置文件:

{
  "company_name": "xxx",
  "username": "xxx",
  "password": "xxx",
  "platform": "feilian"
}

报错:

running corplink-rs@0.2.1
try to connect
found 1 vpn(s)
check if udp vpn 123.127.86.173:8002 is available
available
try to get wg conf from remote
2fa code generated: 509009, 15 seconds left
thread 'main' panicked at 'error decoding response body: missing field `protocol_version` at line 1 column 514', src/main.rs:112:21
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
PinkD commented 2 years ago

应该是旧版本飞连服务器没有这个字段,我给改成可选字段吧

PinkD commented 2 years ago

改好了,你用 master 重新编译一下试试?

XuQK commented 2 years ago

运行结果:

login success
try to connect
found 1 vpn(s)
check if udp vpn xxx:xxx is available
available
try to get wg conf from remote
2fa code generated: xxxxx, 7 seconds left
start wg-corplink for corplink
launch wg-corplink with env: {}
socket file /var/run/wireguard/corplink.sock not ready, sleep 1s
socket file /var/run/wireguard/corplink.sock not ready, sleep 1s
socket file /var/run/wireguard/corplink.sock not ready, sleep 1s
socket file /var/run/wireguard/corplink.sock not ready, sleep 1s
socket file /var/run/wireguard/corplink.sock not ready, sleep 1s
socket file /var/run/wireguard/corplink.sock not ready, sleep 1s
socket file /var/run/wireguard/corplink.sock not ready, sleep 1s
socket file /var/run/wireguard/corplink.sock not ready, sleep 1s
socket file /var/run/wireguard/corplink.sock not ready, sleep 1s
socket file /var/run/wireguard/corplink.sock not ready, sleep 1s
failed to config interface with uapi for corplink: No such file or directory (os error 2)

wireguard-go 应该不用重新编译吧?

PinkD commented 2 years ago

看起来是 wg-go 有点问题,你可以:

PinkD commented 2 years ago

将 wg-go 的输出接到 corplink-rs 上看下 log 的原因

注释掉这两行即可

https://github.com/PinkD/corplink-rs/blob/8dc4019bb0d6694d25b900ce8c8f2d1f0eb389ea/src/wg.rs#L65-L66

XuQK commented 2 years ago

注释掉后:

running corplink-rs@0.2.1
┌──────────────────────────────────────────────────────┐
│                                                      │
│   Running wireguard-go is not required because this  │
│   kernel has first class support for WireGuard. For  │
│   information on installing the kernel module,       │
│   please visit:                                      │
│         https://www.wireguard.com/install/           │
│                                                      │
└──────────────────────────────────────────────────────┘
Usage: wg-corplink [-f/--foreground] INTERFACE-NAME
company name is xxxx server is xxxxx3
not login yet, try to login
found set-cookie in header, saving cookie
try to login with password
found set-cookie in header, saving cookie
got 2fa token: xxxxx
login success
try to connect
found 1 vpn(s)
check if udp vpn xxxxx is available
available
try to get wg conf from remote
2fa code generated: xxxxx, 21 seconds left
start wg-corplink for corplink
launch wg-corplink with env: {}
socket file /var/run/wireguard/corplink.sock not ready, sleep 1s
socket file /var/run/wireguard/corplink.sock not ready, sleep 1s
socket file /var/run/wireguard/corplink.sock not ready, sleep 1s
socket file /var/run/wireguard/corplink.sock not ready, sleep 1s
socket file /var/run/wireguard/corplink.sock not ready, sleep 1s
socket file /var/run/wireguard/corplink.sock not ready, sleep 1s
socket file /var/run/wireguard/corplink.sock not ready, sleep 1s
socket file /var/run/wireguard/corplink.sock not ready, sleep 1s
socket file /var/run/wireguard/corplink.sock not ready, sleep 1s
socket file /var/run/wireguard/corplink.sock not ready, sleep 1s
failed to config interface with uapi for corplink: No such file or directory (os error 2)

我对这套东西是一窍不通 ~

PinkD commented 2 years ago

看起来像是进程没起起来。是用的 root 权限执行吗?

XuQK commented 2 years ago

之前没有,刚用 sudo 看起来像是成功了,但是访问不了我们内网。

start wg-corplink for corplink
launch wg-corplink with env: {}
socket file /var/run/wireguard/corplink.sock not ready, sleep 1s
send config to uapi
keep alive
keep alive
keep alive
keep alive
keep alive
last handshake is at 2022-07-25 01:11:57 +08:00, elapsed time 60.465466s
keep alive
PinkD commented 2 years ago

ip route 看下 dev corplink 的项,有没有你们的内网,如果没有,那可以考虑手动加一下,命令是:

# add route 10.0.0.0/8 
ip route add 10.0.0.0/8 dev corplink
# or use short command
ip r a 10.0.0.0/8 dev corplink
PinkD commented 2 years ago

btw ,从 log 来看,有 last handshake ,说明是连上了的,大概率是路由问题

XuQK commented 2 years ago

我们内网 ip 是指连接的时候终端输出中的check if udp vpn xxx.xxx.xxx.xxx:xxxx is available这句中的这个ip吗?

ip route的输出中确实没有这个ip,然后我尝试了下添加:

sudo ip route add xxx.xxx.xxx.xxx/8 dev corplink

报错:Error: Invalid prefix for given prefix length.

sudo ip route add xxx.xxx.xxx.xxx dev corplink

这个运行完后,ip route查看已经添加成功了,但是仍然访问不了内网。

PinkD commented 2 years ago

内网 ip 是指你要访问的服务器的 ip (段),上面的 10.0.0.0/8 是举例,具体的内网 ip 段需要你自己想办法获取,但是根据我自己使用的经验,飞连是会提供内网 ip 段的,所以我才叫你使用 ip route 来检查

不能将 vpn 的 ip 添加到路由里,因为 vpn 是基于这个 ip 来连接的,添加进去会导致 vpn 断开

XuQK commented 2 years ago

我用飞连连了我们内网,ping了我想访问的服务器域名,拿到了 ip,加进去了,还是访问不了对应的网址。。我也无法确定我拿到的 ip 对不对。今天问我们网管,得知飞连有 linux 客户端,已经成功连接了,所以,打扰了~~