Skip to content

Instantly share code, notes, and snippets.

@LostInsight
Forked from zjx20/gist:1c7f4dd1392866f9d8b00dd2a05bd481
Last active May 29, 2018 05:19
Show Gist options
  • Save LostInsight/72f2c59fe18f033e6ce138f9e86aa0ed to your computer and use it in GitHub Desktop.
Save LostInsight/72f2c59fe18f033e6ce138f9e86aa0ed to your computer and use it in GitHub Desktop.
kcptun install and systemd daemon
wget https://github.com/xtaci/kcptun/releases/download/v20180316/kcptun-linux-amd64-20180316.tar.gz
tar xvf kcptun-linux-amd64-20180316.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\": \"fast3\",
\"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