XrayRConfig.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. namespace App\Http\Controllers\Api\Client;
  3. use App\Http\Controllers\Controller;
  4. use File;
  5. use Illuminate\Http\Request;
  6. use Symfony\Component\Yaml\Yaml;
  7. use function Matrix\diagonal;
  8. class XrayRConfig extends Controller
  9. {
  10. public function GetConfig(Request $request){
  11. $level = $request->input("level");
  12. $host = $request->input("host");
  13. $id = $request->input("id");
  14. $ptype = $request->input("ptype");
  15. $key = $request->input("key");
  16. $type = $request->input("type");
  17. $yaml = <<<EOD
  18. Log:
  19. Level: none # Log level: none, error, warning, info, debug
  20. AccessPath: # /etc/XrayR/access.Log
  21. ErrorPath: # /etc/XrayR/error.log
  22. DnsConfigPath: # /etc/XrayR/dns.json # Path to dns config, check https://xtls.github.io/config/base/dns/ for help
  23. RouteConfigPath: # /etc/XrayR/route.json # Path to route config, check https://xtls.github.io/config/base/route/ for help
  24. OutboundConfigPath: # /etc/XrayR/custom_outbound.json # Path to custom outbound config, check https://xtls.github.io/config/base/outbound/ for help
  25. ConnetionConfig:
  26. Handshake: 4 # Handshake time limit, Second
  27. ConnIdle: 30 # Connection idle time limit, Second
  28. UplinkOnly: 2 # Time limit when the connection downstream is closed, Second
  29. DownlinkOnly: 4 # Time limit when the connection is closed after the uplink is closed, Second
  30. BufferSize: 64 # The internal cache size of each connection, kB
  31. Nodes:
  32. -
  33. PanelType: "$ptype" # Panel type: SSpanel, V2board, PMpanel, , Proxypanel
  34. ApiConfig:
  35. ApiHost: "$host"
  36. ApiKey: "$key"
  37. NodeID: $id
  38. NodeType: $type # Node type: V2ray, Shadowsocks, Trojan, Shadowsocks-Plugin
  39. Timeout: 30 # Timeout for the api request
  40. EnableVless: false # Enable Vless for V2ray Type
  41. EnableXTLS: false # Enable XTLS for V2ray and Trojan
  42. SpeedLimit: 0 # Mbps, Local settings will replace remote settings, 0 means disable
  43. DeviceLimit: 0 # Local settings will replace remote settings, 0 means disable
  44. RuleListPath: # ./rulelist Path to local rulelist file
  45. ControllerConfig:
  46. ListenIP: 0.0.0.0 # IP address you want to listen
  47. SendIP: 0.0.0.0 # IP address you want to send pacakage
  48. UpdatePeriodic: 60 # Time to update the nodeinfo, how many sec.
  49. EnableDNS: false # Use custom DNS config, Please ensure that you set the dns.json well
  50. DNSType: AsIs # AsIs, UseIP, UseIPv4, UseIPv6, DNS strategy
  51. EnableProxyProtocol: false # Only works for WebSocket and TCP
  52. EnableFallback: false # Only support for Trojan and Vless
  53. FallBackConfigs: # Support multiple fallbacks
  54. -
  55. SNI: # TLS SNI(Server Name Indication), Empty for any
  56. Path: # HTTP PATH, Empty for any
  57. Dest: 80 # Required, Destination of fallback, check https://xtls.github.io/config/fallback/ for details.
  58. ProxyProtocolVer: 0 # Send PROXY protocol version, 0 for dsable
  59. CertConfig:
  60. CertMode: dns # Option about how to get certificate: none, file, http, dns. Choose "none" will forcedly disable the tls config.
  61. CertDomain: "node1.test.com" # Domain to cert
  62. CertFile: ./cert/node1.test.com.cert # Provided if the CertMode is file
  63. KeyFile: ./cert/node1.test.com.key
  64. Provider: alidns # DNS cert provider, Get the full support list here: https://go-acme.github.io/lego/dns/
  65. Email: test@me.com
  66. DNSEnv: # DNS ENV option used by DNS provider
  67. ALICLOUD_ACCESS_KEY: aaa
  68. ALICLOUD_SECRET_KEY: bbb
  69. EOD;
  70. // $defaultConfig = base_path().'/resources/rules/config.yml';
  71. // //$config = [];
  72. // if (File::exists($defaultConfig)) {
  73. // $config = yaml_parse_file($defaultConfig);
  74. // }
  75. //https://api.ruanjian.buzz/api/client/v1/getConfig?level=debug&ptype=Proxypanel&host=http://apitx.naiyout.buzz&key=p47fTOcWKOvKuZBP&id=22&type=Shadowsocks
  76. //var_dump(urlencode("http://apitx.naiyout.buzz"));
  77. // $config["Log"]["Level"] = $request->input("level");
  78. // $config["Nodes"][0]["PanelType"] = $ptype;
  79. // $config["Nodes"][0]["ApiConfig"]["ApiHost"] = $host;
  80. // $config["Nodes"][0]["ApiConfig"]["ApiKey"] = $key;
  81. // $config["Nodes"][0]["ApiConfig"]["NodeID"] = (int)$id;
  82. // $config["Nodes"][0]["ApiConfig"]["NodeType"] = $type;
  83. echo $yaml;
  84. die();
  85. return Yaml::dump($config,6,4,0);
  86. }
  87. }