initial commit

This commit is contained in:
pyrschtjag committed 2026-10-02 21:34:01 +04:00
commit 13eace9ce9
219 files changed
+6918

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
[Unit]
Description=Xray-core Service
Documentation=https://github.com/xtls/xray-core
After=network.target network-online.target nftables.service
Wants=network-online.target
[Service]
Type=simple
User=xray-core
Group=xray-core
WorkingDirectory=/opt/xray-core
ExecStart=/opt/xray-core/xray run -config /etc/xray-core/config.json
Restart=on-failure
RestartSec=3s
LimitNOFILE=65535
AmbientCapabilities=CAP_NET_BIND_SERVICE CAP_NET_ADMIN
CapabilityBoundingSet=CAP_NET_BIND_SERVICE CAP_NET_ADMIN
NoNewPrivileges=true
[Install]
WantedBy=multi-user.target
+13
View File
@@ -0,0 +1,13 @@
---
- name: check xray-core config
ansible.builtin.command: su -s /bin/sh xray-core -c "/opt/xray-core/xray run -test -c /etc/xray-core/config.json"
changed_when: false
listen: restart xray-core
- name: restart xray-core systemd service unit
ansible.builtin.systemd_service:
name: xray-core
state: restarted
enabled: true
daemon_reload: true
listen: restart xray-core
+100
View File
@@ -0,0 +1,100 @@
---
- name: create xray-core group
ansible.builtin.group:
name: xray-core
system: true
state: present
- name: create xray-core user
ansible.builtin.user:
name: xray-core
group: xray-core
system: true
shell: /usr/sbin/nologin
home: /var/lib/xray-core
create_home: false
state: present
- name: install unzip
ansible.builtin.package:
name: unzip
state: present
- name: get latest xray-core release info
ansible.builtin.uri:
url: https://api.github.com/repos/XTLS/Xray-core/releases/latest
return_content: true
register: xray_release
run_once: true
check_mode: false
- name: set current xray-core version
ansible.builtin.set_fact:
xray_version: "{{ xray_release.json.tag_name | regex_replace('^v', '') }}"
xray_asset_url: "{{ xray_release.json.assets | selectattr('name', 'equalto', 'Xray-linux-64.zip') | map(attribute='browser_download_url') | first }}"
- name: check xray-core installed version
ansible.builtin.shell: >
/opt/xray-core/xray version 2>/dev/null | grep -oP 'Xray \K[0-9.]+' | head -n 1
register: xray_current_version
changed_when: false
failed_when: false
- name: display xray-core version info
ansible.builtin.debug:
msg: "latest version: {{ xray_version }}, installed version: {{ xray_current_version.stdout | default('not installed', true) }}"
- name: ensure xray-core directory exists
ansible.builtin.file:
path: /opt/xray-core
state: directory
owner: root
group: root
mode: "0755"
- name: update xray-core
ansible.builtin.unarchive:
src: "{{ xray_asset_url }}"
dest: /opt/xray-core
remote_src: true
owner: root
group: root
when: xray_version != xray_current_version.stdout
notify: restart xray-core
- name: make xray-core binary executable
ansible.builtin.file:
path: /opt/xray-core/xray
mode: "0755"
- name: deploy xray-core systemd service unit
ansible.builtin.copy:
src: xray-core.service
dest: /etc/systemd/system/xray-core.service
mode: "0644"
notify: restart xray-core
- name: ensure xray-core log directory exists
ansible.builtin.file:
path: /var/log/xray-core
state: directory
owner: xray-core
group: xray-core
mode: "0755"
- name: ensure xray-core config directory exists
ansible.builtin.file:
path: /etc/xray-core
owner: root
group: root
state: directory
mode: "0755"
- name: render xray-core dynamic config
ansible.builtin.template:
src: "{{ inventory_hostname }}/config.json.j2"
dest: "/etc/xray-core/config.json"
owner: root
group: xray-core
mode: "0644"
notify: restart xray-core
@@ -0,0 +1,78 @@
{
"log": {
"access": "/var/log/xray-core/access.log",
"error": "/var/log/xray-core/error.log",
"loglevel": "warning",
"dnsLog": false,
"maskAddress": ""
},
"dns": {
"queryStrategy": "UseIPv4",
"servers": [
"1.1.1.1",
"1.0.0.1"
]
},
"inbounds": [
{
"listen": "/dev/shm/xrxh.socket,0666",
"protocol": "vless",
"settings": {
"clients": [
{% for user in xray_users %}
{
"email": "{{ user.email }}",
"flow": "xtls-rprx-vision",
"id": "{{ user.id }}"
}{{ "," if not loop.last else "" }}
{% endfor %}
],
"decryption": "{{ xray_decryption }}"
},
"streamSettings": {
"network": "xhttp",
"security": "none",
"xhttpSettings": {
"mode": "stream-one",
"path": "{{ xray_xhttp_path }}"
}
},
"sniffing": {
"enabled": false
}
}
],
"outbounds": [
{
"tag": "direct",
"protocol": "freedom",
"settings": {
"domainStrategy": "UseIPv4"
}
},
{
"tag": "blocked",
"protocol": "blackhole",
"settings": {
"response": {
"type": "none"
}
}
}
],
"routing": {
"domainStrategy": "IPIfNonMatch",
"rules": [
{
"type": "field",
"protocol": "bittorrent",
"outboundTag": "blocked"
},
{
"type": "field",
"ip": "geoip:ru",
"outboundTag": "blocked"
}
]
}
}
@@ -0,0 +1,78 @@
{
"log": {
"access": "/var/log/xray-core/access.log",
"error": "/var/log/xray-core/error.log",
"loglevel": "warning",
"dnsLog": false,
"maskAddress": ""
},
"dns": {
"queryStrategy": "UseIPv4",
"servers": [
"1.1.1.1",
"1.0.0.1"
]
},
"inbounds": [
{
"listen": "/dev/shm/xrxh.socket,0666",
"protocol": "vless",
"settings": {
"clients": [
{% for user in xray_users %}
{
"email": "{{ user.email }}",
"flow": "xtls-rprx-vision",
"id": "{{ user.id }}"
}{{ "," if not loop.last else "" }}
{% endfor %}
],
"decryption": "{{ xray_decryption }}"
},
"streamSettings": {
"network": "xhttp",
"security": "none",
"xhttpSettings": {
"mode": "stream-one",
"path": "{{ xray_xhttp_path }}"
}
},
"sniffing": {
"enabled": false
}
}
],
"outbounds": [
{
"tag": "direct",
"protocol": "freedom",
"settings": {
"domainStrategy": "UseIPv4"
}
},
{
"tag": "blocked",
"protocol": "blackhole",
"settings": {
"response": {
"type": "none"
}
}
}
],
"routing": {
"domainStrategy": "IPIfNonMatch",
"rules": [
{
"type": "field",
"protocol": "bittorrent",
"outboundTag": "blocked"
},
{
"type": "field",
"ip": "geoip:ru",
"outboundTag": "blocked"
}
]
}
}
@@ -0,0 +1,183 @@
{
"log": {
"access": "/var/log/xray-core/access.log",
"error": "/var/log/xray-core/error.log",
"loglevel": "warning",
"dnsLog": false,
"maskAddress": ""
},
"dns": {
"tag": "dns-in",
"servers": ["localhost"],
"queryStrategy": "UseIPv4"
},
"inbounds": [
{
"tag": "tproxy-in",
"listen": "0.0.0.0",
"port": 61219,
"protocol": "dokodemo-door",
"settings": {
"followRedirect": true,
"network": "tcp,udp"
},
"streamSettings": {
"sockopt": {
"tproxy": "tproxy"
}
},
"sniffing": {
"enabled": false
}
},
{
"tag": "socks-in",
"listen": "127.0.0.1",
"port": 1080,
"protocol": "socks",
"settings": {
"auth": "password",
"accounts": [
{
"user": "embargo",
"pass": "moistnes12"
}
],
"udp": true
},
"sniffing": {
"enabled": false
}
},
{
"tag": "http-in",
"listen": "0.0.0.0",
"port": 8080,
"protocol": "http",
"settings": {
"allowTransparent": false
},
"sniffing": {
"enabled": false
}
}
],
"outbounds": [
{% for item in xray_outbounds %}
{
"tag": "vless-{{ item.tag }}",
"protocol": "vless",
"settings": {
"vnext": [
{
"address": "{{ item.address }}",
"port": 443,
"users": [
{
"id": "{{ item.xray_id }}",
"flow": "xtls-rprx-vision",
"encryption": "{{ item.xray_encryption }}"
}
]
}
],
"domainStrategy": "UseIPv4"
},
"streamSettings": {
"network": "xhttp",
"xhttpSettings": {
"path": "{{ item.xray_xhttp_path }}",
"mode": "stream-one"
},
"security": "tls",
"tlsSettings": {
"alpn": [
"h2",
"h3"
],
"fingerprint": "firefox"
}
}
},
{% endfor %}
{
"tag": "direct",
"protocol": "freedom",
"settings": {
"domainStrategy": "UseIPv4"
}
},
{
"tag": "blocked",
"protocol": "blackhole",
"settings": {
"response": {
"type": "none"
}
}
}
],
"policy": {
"levels": {
"0": {
"handshake": 4,
"connIdle": 300,
"uplinkOnly": 2,
"downlinkOnly": 5,
"statsUserUplink": false,
"statsUserDownlink": false,
"statsUserOnline": false,
"bufferSize": 512
}
},
"system": {
"statsInboundUplink": false,
"statsInboundDownlink": false,
"statsOutboundUplink": false,
"statsOutboundDownlink": false
}
},
"observatory": {
"subjectSelector": ["vless-"],
"probeUrl": "https://www.google.com/generate_204",
"probeInterval": "30s",
"enableConcurrency": true
},
"routing": {
"domainStrategy": "IPIfNonMatch",
{% if xray_outbounds | length > 1 %}
"balancers": [
{
"tag": "balancer-vless",
"selector": ["vless-"],
"strategy": {
"type": "leastLoad",
"settings": {
"costs": [
{% for item in xray_outbounds %}
{ "match": "vless-{{ item.tag }}", "value": {{ item.value }}}{{ "," if not loop.last else "" }}
{% endfor %}
]
}
}
}
],
{% endif %}
"rules": [
{
"type": "field",
"protocol": ["bittorrent"],
"outboundTag": "direct"
},
{
"type": "field",
"inboundTag": [
"tproxy-in",
"socks-in",
"http-ip"
],
"balancerTag": "{{ 'balancer-vless' if xray_outbounds | length > 1 else 'vless-' ~ xray_outbounds[0].tag }}"
}
]
}
}
@@ -0,0 +1,78 @@
{
"log": {
"access": "/var/log/xray-core/access.log",
"error": "/var/log/xray-core/error.log",
"loglevel": "warning",
"dnsLog": false,
"maskAddress": ""
},
"dns": {
"queryStrategy": "UseIPv4",
"servers": [
"1.1.1.1",
"1.0.0.1"
]
},
"inbounds": [
{
"listen": "/dev/shm/xrxh.socket,0666",
"protocol": "vless",
"settings": {
"clients": [
{% for user in xray_users %}
{
"email": "{{ user.email }}",
"flow": "xtls-rprx-vision",
"id": "{{ user.id }}"
}{{ "," if not loop.last else "" }}
{% endfor %}
],
"decryption": "{{ xray_decryption }}"
},
"streamSettings": {
"network": "xhttp",
"security": "none",
"xhttpSettings": {
"mode": "stream-one",
"path": "{{ xray_xhttp_path }}"
}
},
"sniffing": {
"enabled": false
}
}
],
"outbounds": [
{
"tag": "direct",
"protocol": "freedom",
"settings": {
"domainStrategy": "UseIPv4"
}
},
{
"tag": "blocked",
"protocol": "blackhole",
"settings": {
"response": {
"type": "none"
}
}
}
],
"routing": {
"domainStrategy": "IPIfNonMatch",
"rules": [
{
"type": "field",
"protocol": "bittorrent",
"outboundTag": "blocked"
},
{
"type": "field",
"ip": "geoip:ru",
"outboundTag": "blocked"
}
]
}
}