add view traffic

pull/149/head
BOYPT 6 years ago committed by cutelua
parent 62fe59a1b4
commit 31e69f78c3
  1. 42
      config/server/dynamic/http.json
  2. 42
      config/server/dynamic/kcp.json
  3. 42
      config/server/dynamic/quic.json
  4. 42
      config/server/dynamic/tcp.json
  5. 42
      config/server/dynamic/ws.json
  6. 42
      config/server/h2.json
  7. 42
      config/server/http.json
  8. 1
      config/server/include/socks.json
  9. 1
      config/server/include/ss.json
  10. 42
      config/server/kcp.json
  11. 42
      config/server/quic.json
  12. 42
      config/server/tcp.json
  13. 42
      config/server/ws.json
  14. 33
      src/v2ray-traffic.sh

@ -1,4 +1,29 @@
{ {
"stats": {},
"api": {
"tag": "api",
"services": [
"HandlerService",
"LoggerService",
"StatsService"
]
},
"policy": {
"levels": {
"0": {
"statsUserUplink": true,
"statsUserDownlink": true
},
"1": {
"statsUserUplink": true,
"statsUserDownlink": true
}
},
"system": {
"statsInboundUplink": true,
"statsInboundDownlink": true
}
},
"log": { "log": {
"access": "/var/log/v2ray/access.log", "access": "/var/log/v2ray/access.log",
"error": "/var/log/v2ray/error.log", "error": "/var/log/v2ray/error.log",
@ -6,6 +31,16 @@
}, },
"inbounds": [ "inbounds": [
{ {
"listen": "127.0.0.1",
"port": 10086,
"protocol": "dokodemo-door",
"settings": {
"address": "127.0.0.1"
},
"tag": "api"
},
{
"tag": "vmess-in",
"port": 2333, "port": 2333,
"protocol": "vmess", "protocol": "vmess",
"settings": { "settings": {
@ -129,6 +164,13 @@
"routing": { "routing": {
"domainStrategy": "IPOnDemand", "domainStrategy": "IPOnDemand",
"rules": [ "rules": [
{
"inboundTag": [
"api"
],
"outboundTag": "api",
"type": "field"
},
{ {
"type": "field", "type": "field",
"ip": [ "ip": [

@ -1,4 +1,29 @@
{ {
"stats": {},
"api": {
"tag": "api",
"services": [
"HandlerService",
"LoggerService",
"StatsService"
]
},
"policy": {
"levels": {
"0": {
"statsUserUplink": true,
"statsUserDownlink": true
},
"1": {
"statsUserUplink": true,
"statsUserDownlink": true
}
},
"system": {
"statsInboundUplink": true,
"statsInboundDownlink": true
}
},
"log": { "log": {
"access": "/var/log/v2ray/access.log", "access": "/var/log/v2ray/access.log",
"error": "/var/log/v2ray/error.log", "error": "/var/log/v2ray/error.log",
@ -6,6 +31,16 @@
}, },
"inbounds": [ "inbounds": [
{ {
"listen": "127.0.0.1",
"port": 10086,
"protocol": "dokodemo-door",
"settings": {
"address": "127.0.0.1"
},
"tag": "api"
},
{
"tag": "vmess-in",
"port": 2333, "port": 2333,
"protocol": "vmess", "protocol": "vmess",
"settings": { "settings": {
@ -101,6 +136,13 @@
"routing": { "routing": {
"domainStrategy": "IPOnDemand", "domainStrategy": "IPOnDemand",
"rules": [ "rules": [
{
"inboundTag": [
"api"
],
"outboundTag": "api",
"type": "field"
},
{ {
"type": "field", "type": "field",
"ip": [ "ip": [

@ -1,4 +1,29 @@
{ {
"stats": {},
"api": {
"tag": "api",
"services": [
"HandlerService",
"LoggerService",
"StatsService"
]
},
"policy": {
"levels": {
"0": {
"statsUserUplink": true,
"statsUserDownlink": true
},
"1": {
"statsUserUplink": true,
"statsUserDownlink": true
}
},
"system": {
"statsInboundUplink": true,
"statsInboundDownlink": true
}
},
"log": { "log": {
"access": "/var/log/v2ray/access.log", "access": "/var/log/v2ray/access.log",
"error": "/var/log/v2ray/error.log", "error": "/var/log/v2ray/error.log",
@ -6,6 +31,16 @@
}, },
"inbounds": [ "inbounds": [
{ {
"listen": "127.0.0.1",
"port": 10086,
"protocol": "dokodemo-door",
"settings": {
"address": "127.0.0.1"
},
"tag": "api"
},
{
"tag": "vmess-in",
"port": 2333, "port": 2333,
"protocol": "vmess", "protocol": "vmess",
"settings": { "settings": {
@ -105,6 +140,13 @@
"routing": { "routing": {
"domainStrategy": "IPOnDemand", "domainStrategy": "IPOnDemand",
"rules": [ "rules": [
{
"inboundTag": [
"api"
],
"outboundTag": "api",
"type": "field"
},
{ {
"type": "field", "type": "field",
"ip": [ "ip": [

@ -1,4 +1,29 @@
{ {
"stats": {},
"api": {
"tag": "api",
"services": [
"HandlerService",
"LoggerService",
"StatsService"
]
},
"policy": {
"levels": {
"0": {
"statsUserUplink": true,
"statsUserDownlink": true
},
"1": {
"statsUserUplink": true,
"statsUserDownlink": true
}
},
"system": {
"statsInboundUplink": true,
"statsInboundDownlink": true
}
},
"log": { "log": {
"access": "/var/log/v2ray/access.log", "access": "/var/log/v2ray/access.log",
"error": "/var/log/v2ray/error.log", "error": "/var/log/v2ray/error.log",
@ -6,6 +31,16 @@
}, },
"inbounds": [ "inbounds": [
{ {
"listen": "127.0.0.1",
"port": 10086,
"protocol": "dokodemo-door",
"settings": {
"address": "127.0.0.1"
},
"tag": "api"
},
{
"tag": "vmess-in",
"port": 2333, "port": 2333,
"protocol": "vmess", "protocol": "vmess",
"settings": { "settings": {
@ -88,6 +123,13 @@
"routing": { "routing": {
"domainStrategy": "IPOnDemand", "domainStrategy": "IPOnDemand",
"rules": [ "rules": [
{
"inboundTag": [
"api"
],
"outboundTag": "api",
"type": "field"
},
{ {
"type": "field", "type": "field",
"ip": [ "ip": [

@ -1,4 +1,29 @@
{ {
"stats": {},
"api": {
"tag": "api",
"services": [
"HandlerService",
"LoggerService",
"StatsService"
]
},
"policy": {
"levels": {
"0": {
"statsUserUplink": true,
"statsUserDownlink": true
},
"1": {
"statsUserUplink": true,
"statsUserDownlink": true
}
},
"system": {
"statsInboundUplink": true,
"statsInboundDownlink": true
}
},
"log": { "log": {
"access": "/var/log/v2ray/access.log", "access": "/var/log/v2ray/access.log",
"error": "/var/log/v2ray/error.log", "error": "/var/log/v2ray/error.log",
@ -6,6 +31,16 @@
}, },
"inbounds": [ "inbounds": [
{ {
"listen": "127.0.0.1",
"port": 10086,
"protocol": "dokodemo-door",
"settings": {
"address": "127.0.0.1"
},
"tag": "api"
},
{
"tag": "vmess-in",
"port": 2333, "port": 2333,
"protocol": "vmess", "protocol": "vmess",
"settings": { "settings": {
@ -91,6 +126,13 @@
"routing": { "routing": {
"domainStrategy": "IPOnDemand", "domainStrategy": "IPOnDemand",
"rules": [ "rules": [
{
"inboundTag": [
"api"
],
"outboundTag": "api",
"type": "field"
},
{ {
"type": "field", "type": "field",
"ip": [ "ip": [

@ -1,4 +1,29 @@
{ {
"stats": {},
"api": {
"tag": "api",
"services": [
"HandlerService",
"LoggerService",
"StatsService"
]
},
"policy": {
"levels": {
"0": {
"statsUserUplink": true,
"statsUserDownlink": true
},
"1": {
"statsUserUplink": true,
"statsUserDownlink": true
}
},
"system": {
"statsInboundUplink": true,
"statsInboundDownlink": true
}
},
"log": { "log": {
"access": "/var/log/v2ray/access.log", "access": "/var/log/v2ray/access.log",
"error": "/var/log/v2ray/error.log", "error": "/var/log/v2ray/error.log",
@ -6,6 +31,16 @@
}, },
"inbounds": [ "inbounds": [
{ {
"listen": "127.0.0.1",
"port": 10086,
"protocol": "dokodemo-door",
"settings": {
"address": "127.0.0.1"
},
"tag": "api"
},
{
"tag": "vmess-in",
"port": 2333, "port": 2333,
"protocol": "vmess", "protocol": "vmess",
"settings": { "settings": {
@ -84,6 +119,13 @@
"routing": { "routing": {
"domainStrategy": "IPOnDemand", "domainStrategy": "IPOnDemand",
"rules": [ "rules": [
{
"inboundTag": [
"api"
],
"outboundTag": "api",
"type": "field"
},
{ {
"type": "field", "type": "field",
"ip": [ "ip": [

@ -1,4 +1,29 @@
{ {
"stats": {},
"api": {
"tag": "api",
"services": [
"HandlerService",
"LoggerService",
"StatsService"
]
},
"policy": {
"levels": {
"0": {
"statsUserUplink": true,
"statsUserDownlink": true
},
"1": {
"statsUserUplink": true,
"statsUserDownlink": true
}
},
"system": {
"statsInboundUplink": true,
"statsInboundDownlink": true
}
},
"log": { "log": {
"access": "/var/log/v2ray/access.log", "access": "/var/log/v2ray/access.log",
"error": "/var/log/v2ray/error.log", "error": "/var/log/v2ray/error.log",
@ -6,6 +31,16 @@
}, },
"inbounds": [ "inbounds": [
{ {
"listen": "127.0.0.1",
"port": 10086,
"protocol": "dokodemo-door",
"settings": {
"address": "127.0.0.1"
},
"tag": "api"
},
{
"tag": "vmess-in",
"port": 2333, "port": 2333,
"protocol": "vmess", "protocol": "vmess",
"settings": { "settings": {
@ -102,6 +137,13 @@
"routing": { "routing": {
"domainStrategy": "IPOnDemand", "domainStrategy": "IPOnDemand",
"rules": [ "rules": [
{
"inboundTag": [
"api"
],
"outboundTag": "api",
"type": "field"
},
{ {
"type": "field", "type": "field",
"ip": [ "ip": [

@ -1,4 +1,5 @@
{ {
"tag": "socks-in",
"protocol": "socks", "protocol": "socks",
"port": 6666, "port": 6666,
"settings": { "settings": {

@ -1,4 +1,5 @@
{ {
"tag": "ss-in",
"protocol": "shadowsocks", "protocol": "shadowsocks",
"port": 6666, "port": 6666,
"settings": { "settings": {

@ -1,4 +1,29 @@
{ {
"stats": {},
"api": {
"tag": "api",
"services": [
"HandlerService",
"LoggerService",
"StatsService"
]
},
"policy": {
"levels": {
"0": {
"statsUserUplink": true,
"statsUserDownlink": true
},
"1": {
"statsUserUplink": true,
"statsUserDownlink": true
}
},
"system": {
"statsInboundUplink": true,
"statsInboundDownlink": true
}
},
"log": { "log": {
"access": "/var/log/v2ray/access.log", "access": "/var/log/v2ray/access.log",
"error": "/var/log/v2ray/error.log", "error": "/var/log/v2ray/error.log",
@ -6,6 +31,16 @@
}, },
"inbounds": [ "inbounds": [
{ {
"listen": "127.0.0.1",
"port": 10086,
"protocol": "dokodemo-door",
"settings": {
"address": "127.0.0.1"
},
"tag": "api"
},
{
"tag": "vmess-in",
"port": 2333, "port": 2333,
"protocol": "vmess", "protocol": "vmess",
"settings": { "settings": {
@ -74,6 +109,13 @@
"routing": { "routing": {
"domainStrategy": "IPOnDemand", "domainStrategy": "IPOnDemand",
"rules": [ "rules": [
{
"inboundTag": [
"api"
],
"outboundTag": "api",
"type": "field"
},
{ {
"type": "field", "type": "field",
"ip": [ "ip": [

@ -1,4 +1,29 @@
{ {
"stats": {},
"api": {
"tag": "api",
"services": [
"HandlerService",
"LoggerService",
"StatsService"
]
},
"policy": {
"levels": {
"0": {
"statsUserUplink": true,
"statsUserDownlink": true
},
"1": {
"statsUserUplink": true,
"statsUserDownlink": true
}
},
"system": {
"statsInboundUplink": true,
"statsInboundDownlink": true
}
},
"log": { "log": {
"access": "/var/log/v2ray/access.log", "access": "/var/log/v2ray/access.log",
"error": "/var/log/v2ray/error.log", "error": "/var/log/v2ray/error.log",
@ -6,6 +31,16 @@
}, },
"inbounds": [ "inbounds": [
{ {
"listen": "127.0.0.1",
"port": 10086,
"protocol": "dokodemo-door",
"settings": {
"address": "127.0.0.1"
},
"tag": "api"
},
{
"tag": "vmess-in",
"port": 2333, "port": 2333,
"protocol": "vmess", "protocol": "vmess",
"settings": { "settings": {
@ -76,6 +111,13 @@
"routing": { "routing": {
"domainStrategy": "IPOnDemand", "domainStrategy": "IPOnDemand",
"rules": [ "rules": [
{
"inboundTag": [
"api"
],
"outboundTag": "api",
"type": "field"
},
{ {
"type": "field", "type": "field",
"ip": [ "ip": [

@ -1,4 +1,29 @@
{ {
"stats": {},
"api": {
"tag": "api",
"services": [
"HandlerService",
"LoggerService",
"StatsService"
]
},
"policy": {
"levels": {
"0": {
"statsUserUplink": true,
"statsUserDownlink": true
},
"1": {
"statsUserUplink": true,
"statsUserDownlink": true
}
},
"system": {
"statsInboundUplink": true,
"statsInboundDownlink": true
}
},
"log": { "log": {
"access": "/var/log/v2ray/access.log", "access": "/var/log/v2ray/access.log",
"error": "/var/log/v2ray/error.log", "error": "/var/log/v2ray/error.log",
@ -6,6 +31,16 @@
}, },
"inbounds": [ "inbounds": [
{ {
"listen": "127.0.0.1",
"port": 10086,
"protocol": "dokodemo-door",
"settings": {
"address": "127.0.0.1"
},
"tag": "api"
},
{
"tag": "vmess-in",
"port": 2333, "port": 2333,
"protocol": "vmess", "protocol": "vmess",
"settings": { "settings": {
@ -69,6 +104,13 @@
"routing": { "routing": {
"domainStrategy": "IPOnDemand", "domainStrategy": "IPOnDemand",
"rules": [ "rules": [
{
"inboundTag": [
"api"
],
"outboundTag": "api",
"type": "field"
},
{ {
"type": "field", "type": "field",
"ip": [ "ip": [

@ -1,4 +1,29 @@
{ {
"stats": {},
"api": {
"tag": "api",
"services": [
"HandlerService",
"LoggerService",
"StatsService"
]
},
"policy": {
"levels": {
"0": {
"statsUserUplink": true,
"statsUserDownlink": true
},
"1": {
"statsUserUplink": true,
"statsUserDownlink": true
}
},
"system": {
"statsInboundUplink": true,
"statsInboundDownlink": true
}
},
"log": { "log": {
"access": "/var/log/v2ray/access.log", "access": "/var/log/v2ray/access.log",
"error": "/var/log/v2ray/error.log", "error": "/var/log/v2ray/error.log",
@ -6,6 +31,16 @@
}, },
"inbounds": [ "inbounds": [
{ {
"listen": "127.0.0.1",
"port": 10086,
"protocol": "dokodemo-door",
"settings": {
"address": "127.0.0.1"
},
"tag": "api"
},
{
"tag": "vmess-in",
"port": 2333, "port": 2333,
"protocol": "vmess", "protocol": "vmess",
"settings": { "settings": {
@ -69,6 +104,13 @@
"routing": { "routing": {
"domainStrategy": "IPOnDemand", "domainStrategy": "IPOnDemand",
"rules": [ "rules": [
{
"inboundTag": [
"api"
],
"outboundTag": "api",
"type": "field"
},
{ {
"type": "field", "type": "field",
"ip": [ "ip": [

@ -0,0 +1,33 @@
_V2CTL=/usr/bin/v2ray/v2ctl
_APISERVER=127.0.0.1:10086
v2_inbound() {
local inbound=$1
local direct=$2
$_V2CTL api --server=$_APISERVER StatsService.GetStats "name: \"inbound>>>${inbound}>>>traffic>>>${direct}\"" \
| awk '{
if (match($1, /name:/)){ f=1; gsub(/"$/, "", $2); split($2, p, ">>>"); print p[2]":"p[4] }
else if (match($1, /value:/)){ f=0; print $2}
else if (match($0, /^>$/) && f == 1) print "0"
else {}
}' \
| sed '$!N;s/\n/ /; s/link//' \
| numfmt --field=2 --suffix=B --to=iec \
| sort \
| column -t
}
v2_query_all () {
$_V2CTL api --server=$_APISERVER StatsService.QueryStats '' \
| awk '{
if (match($1, /name:/)){ f=1; gsub(/"$/, "", $2); split($2, p, ">>>"); print p[2]":"p[4] }
else if (match($1, /value:/)){ f=0; print $2}
else if (match($0, /^>$/) && f == 1) print "0"
else {}
}' \
| sed '$!N;s/\n/ /; s/link//' \
| numfmt --field=2 --suffix=B --to=iec \
| sort \
| column -t
}
Loading…
Cancel
Save