Last active
February 2, 2024 19:07
-
-
Save zjx20/1c7f4dd1392866f9d8b00dd2a05bd481 to your computer and use it in GitHub Desktop.
kcptun install and systemd daemon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wget https://github.com/xtaci/kcptun/releases/download/v20170525/kcptun-linux-amd64-20170525.tar.gz | |
tar xvf kcptun-linux-amd64-20170525.tar.gz | |
sudo mv server_linux_amd64 /usr/local/bin/kcptun_server | |
sudo mv client_linux_amd64 /usr/local/bin/kcptun_client | |
sudo mkdir -p /etc/kcptun | |
sudo bash -c "cat <<EOT > /etc/kcptun/server_conf.json | |
{ | |
\"listen\": \":4321\", | |
\"target\": \"127.0.0.1:8421\", | |
\"mode\": \"fast2\", | |
\"dscp\": 46, | |
\"crypt\": \"salsa20\", | |
\"key\": \"THE PASSWORD\" | |
} | |
EOT" | |
sudo bash -c "cat <<EOT > /etc/systemd/system/kcptun_server.service | |
[Unit] | |
Description=Kcptun server | |
Requires=network.target | |
After=network-online.target | |
[Service] | |
Type=simple | |
User=nobody | |
RemainAfterExit=yes | |
ExecStart=/usr/local/bin/kcptun_server -c /etc/kcptun/server_conf.json | |
ExecReload=/usr/bin/kill -HUP $MAINPID | |
RestartSec=1min | |
Restart=on-failure | |
[Install] | |
WantedBy=multi-user.target | |
EOT" | |
sudo systemctl enable kcptun_server | |
sudo systemctl start kcptun_server | |
sudo bash -c "cat <<EOT > /etc/kcptun/client_conf.json | |
{ | |
\"localaddr\": \":38421\", | |
\"remoteaddr\": \"<server_ip>:4321\", | |
\"mode\": \"fast2\", | |
\"dscp\": 46, | |
\"crypt\": \"salsa20\", | |
\"key\": \"THE PASSWORD\" | |
} | |
EOT" | |
sudo bash -c "cat <<EOT > /etc/systemd/system/kcptun_client.service | |
[Unit] | |
Description=Kcptun client | |
Requires=network.target | |
After=network-online.target | |
[Service] | |
Type=simple | |
User=nobody | |
RemainAfterExit=yes | |
ExecStart=/usr/local/bin/kcptun_client -c /etc/kcptun/client_conf.json | |
ExecReload=/usr/bin/kill -HUP $MAINPID | |
RestartSec=1min | |
Restart=on-failure | |
[Install] | |
WantedBy=multi-user.target | |
EOT" | |
sudo systemctl enable kcptun_client | |
sudo systemctl start kcptun_client | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment