PinkD / corplink-rs

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

fix: kill old wg process when starting corplink-rs #15

Closed LionheartLann closed 1 year ago

LionheartLann commented 1 year ago

Desc

fix a timeout issue caused by old wg process on MacOS

ref: https://github.com/PinkD/corplink-rs/issues/14

Test on MacOS

before starting corplink-rs, the old wg PID is 38944

ps aux | grep corplink                                                                                                                       
root             38944   0.6  0.1 409215312   8896 s000  S     5:44PM   0:00.11 wg-corplink -f utun5
lannister        39070   0.0  0.0 408495824   1072 s003  R+    5:45PM   0:00.00 grep corplink

after starting corplink-rs, the old process was killed, the new wg PID is 39128

ps aux | grep corplink                                                                                                                       
lannister        39223   0.0  0.0 407962000    176 s003  R+    5:45PM   0:00.00 grep corplink
root             39128   0.0  0.0 409213616   7408 s000  S+    5:45PM   0:00.06 wg-corplink -f utun5
root             39087   0.0  0.1 409008336   9344 s000  S+    5:45PM   0:00.03 /Users/lannister/pragmatic/corplink-rs/target/release/corplink-rs config/config.json
root             39086   0.0  0.0 408649072   6720 s000  S+    5:45PM   0:00.02 /usr/bin/sudo /Users/lannister/pragmatic/corplink-rs/target/release/corplink-rs config/config.json
lannister        39083   0.0  0.0 408554688   3968 s000  S+    5:45PM   0:00.01 /Users/lannister/pragmatic/corplink-rs/target/release/corplink-rs config/config.json

Test on Ubuntu

before starting:

lannister@ubuntu:/Users/lannister/corplink/corplink-rs$ ps aux | grep corplink
root         346  0.0  0.0 712368  3712 ?        Sl   18:08   0:00 wg-corplink -f corplink
lannist+     416  0.0  0.0   3056  1280 pts/1    S+   18:09   0:00 grep --color=auto corplink

after starting, killed old wg process:

lannister@ubuntu:/Users/lannister/corplink/corplink-rs$ ps aux | grep corplink
lannist+     417  0.0  0.0 689852  5120 pts/2    Sl+  18:09   0:00 /Users/lannister/corplink/corplink-rs/target/release/corplink-rs ../config.json
root         428  0.0  0.0   8436  3840 pts/2    S+   18:09   0:00 /usr/bin/sudo /Users/lannister/corplink/corplink-rs/target/release/corplink-rs ../config.json
root         429  0.0  0.0   8436  1548 pts/4    Ss   18:09   0:00 /usr/bin/sudo /Users/lannister/corplink/corplink-rs/target/release/corplink-rs ../config.json
root         430  0.4  0.1 758936 11392 pts/4    Sl+  18:09   0:00 /Users/lannister/corplink/corplink-rs/target/release/corplink-rs ../config.json
root         447  0.2  0.0 712624  4480 pts/4    Sl+  18:09   0:00 wg-corplink -f corplink
lannist+     461  0.0  0.0   3056  1280 pts/1    S+   18:09   0:00 grep --color=auto corplink

@PinkD pls review