Skip to content

Commit

Permalink
Update release:
Browse files Browse the repository at this point in the history
- Add Systemd user unit files
- Security improvement to system units
- Update the default config.json according to the manual
  • Loading branch information
demarcush committed Jun 24, 2024
1 parent 8a2d3fb commit 2be82aa
Show file tree
Hide file tree
Showing 7 changed files with 149 additions and 43 deletions.
28 changes: 17 additions & 11 deletions release/config/config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{
"log": {
"level": "info"
},
"dns": {
"servers": [
{
Expand All @@ -11,29 +8,38 @@
},
"inbounds": [
{
"type": "shadowsocks",
"listen": "::",
"listen_port": 8080,
"sniff": true,
"network": "tcp",
"method": "2022-blake3-aes-128-gcm",
"password": "8JCsPssfgS8tiRwiMlhARg=="
"multiplex": {
"enabled": true
},
"network": "tcp",
"password": "8JCsPssfgS8tiRwiMlhARg==",
"sniff": true,
"tcp_fast_open": true,
"tcp_multi_path": true,
"type": "shadowsocks",
"udp_fragment": true
}
],
"log": {
"level": "info"
},
"outbounds": [
{
"type": "direct"
},
{
"type": "dns",
"tag": "dns-out"
"tag": "dns-out",
"type": "dns"
}
],
"route": {
"rules": [
{
"protocol": "dns",
"outbound": "dns-out"
"outbound": "dns-out",
"protocol": "dns"
}
]
}
Expand Down
16 changes: 0 additions & 16 deletions release/config/sing-box.service

This file was deleted.

16 changes: 0 additions & 16 deletions release/config/[email protected]

This file was deleted.

37 changes: 37 additions & 0 deletions release/config/system/sing-box.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[Unit]
Description=sing-box service
Documentation=https://sing-box.sagernet.org
After=network.target nss-lookup.target network-online.target

[Service]
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_SYS_PTRACE CAP_DAC_READ_SEARCH
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_SYS_PTRACE CAP_DAC_READ_SEARCH
ConfigurationDirectory=sing-box
DynamicUser=true
ExecReload=/bin/kill -HUP $MAINPID
ExecStart=/usr/bin/sing-box -D ${STATE_DIRECTORY} -C ${CONFIGURATION_DIRECTORY} run
LimitNOFILE=infinity
LockPersonality=true
MemoryDenyWriteExecute=true
NoNewPrivileges=true
PrivateTmp=true
ProcSubset=pid
ProtectClock=true
ProtectControlGroups=true
ProtectHome=true
ProtectHostname=true
ProtectKernelLogs=true
ProtectKernelModules=true
ProtectKernelTunables=true
ProtectProc=noaccess
ProtectSystem=full
Restart=on-failure
RestartSec=10s
RestrictNamespaces=true
RestrictRealtime=true
StateDirectory=sing-box
SystemCallArchitectures=native
SystemCallFilter=@system-service

[Install]
WantedBy=multi-user.target
38 changes: 38 additions & 0 deletions release/config/system/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[Unit]
Description=sing-box service (%i)
Documentation=https://sing-box.sagernet.org
After=network.target nss-lookup.target network-online.target

[Service]
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_SYS_PTRACE CAP_DAC_READ_SEARCH
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_SYS_PTRACE CAP_DAC_READ_SEARCH
ConfigurationDirectory=sing-box
DynamicUser=true
ExecReload=/bin/kill -HUP $MAINPID
ExecStart=/usr/bin/sing-box -D ${STATE_DIRECTORY} -c ${CONFIGURATION_DIRECTORY}/%i.json run
LimitNOFILE=infinity
LockPersonality=true
MemoryDenyWriteExecute=true
NoNewPrivileges=true
PrivateTmp=true
ProcSubset=pid
ProtectClock=true
ProtectControlGroups=true
ProtectHome=true
ProtectHostname=true
ProtectKernelLogs=true
ProtectKernelModules=true
ProtectKernelTunables=true
ProtectProc=noaccess
ProtectSystem=full
Restart=on-failure
RestartSec=10s
RestrictNamespaces=true
RestrictRealtime=true
StateDirectory=sing-box-%i
SystemCallArchitectures=native
SystemCallFilter=@system-service

[Install]
WantedBy=multi-user.target
DefaultInstance=sing-box.service
28 changes: 28 additions & 0 deletions release/config/user/sing-box.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[Unit]
Description=sing-box user service
Documentation=https://sing-box.sagernet.org
After=basic.target

[Service]
ConfigurationDirectory=sing-box
ExecReload=/bin/kill -HUP $MAINPID
ExecStart=/usr/bin/sing-box -D ${STATE_DIRECTORY} -C ${CONFIGURATION_DIRECTORY} run
LimitNOFILE=infinity
LockPersonality=true
MemoryDenyWriteExecute=true
NoNewPrivileges=true
PrivateDevices=true
PrivateTmp=true
PrivateUsers=true
ProcSubset=pid
ProtectProc=noaccess
Restart=on-failure
RestartSec=10s
RestrictNamespaces=true
RestrictRealtime=true
StateDirectory=sing-box
SystemCallArchitectures=native
SystemCallFilter=@system-service

[Install]
WantedBy=default.target
29 changes: 29 additions & 0 deletions release/config/user/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[Unit]
Description=sing-box user service (%i)
Documentation=https://sing-box.sagernet.org
After=basic.target

[Service]
ConfigurationDirectory=sing-box
ExecReload=/bin/kill -HUP $MAINPID
ExecStart=/usr/bin/sing-box -D ${STATE_DIRECTORY} -c ${CONFIGURATION_DIRECTORY}/%i.json run
LimitNOFILE=infinity
LockPersonality=true
MemoryDenyWriteExecute=true
NoNewPrivileges=true
PrivateDevices=true
PrivateTmp=true
PrivateUsers=true
ProcSubset=pid
ProtectProc=noaccess
Restart=on-failure
RestartSec=10s
RestrictNamespaces=true
RestrictRealtime=true
StateDirectory=sing-box-%i
SystemCallArchitectures=native
SystemCallFilter=@system-service

[Install]
WantedBy=default.target
DefaultInstance=sing-box.service

0 comments on commit 2be82aa

Please sign in to comment.