{"id":27910601,"url":"https://github.com/tourze/shadowsocks-config-php","last_synced_at":"2025-07-28T23:02:04.137Z","repository":{"id":291505704,"uuid":"965025420","full_name":"tourze/shadowsocks-config-php","owner":"tourze","description":null,"archived":false,"fork":false,"pushed_at":"2025-06-30T13:16:51.000Z","size":47,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-30T14:28:30.985Z","etag":null,"topics":["shadowsocks"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tourze.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-04-12T08:43:58.000Z","updated_at":"2025-06-30T13:16:54.000Z","dependencies_parsed_at":"2025-06-30T14:25:29.206Z","dependency_job_id":"04fadd08-6c00-40b4-98ae-9e86266351b9","html_url":"https://github.com/tourze/shadowsocks-config-php","commit_stats":null,"previous_names":["tourze/shadowsocks-config-php"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/tourze/shadowsocks-config-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tourze%2Fshadowsocks-config-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tourze%2Fshadowsocks-config-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tourze%2Fshadowsocks-config-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tourze%2Fshadowsocks-config-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tourze","download_url":"https://codeload.github.com/tourze/shadowsocks-config-php/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tourze%2Fshadowsocks-config-php/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267600093,"owners_count":24113712,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-28T02:00:09.689Z","response_time":68,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["shadowsocks"],"created_at":"2025-05-06T09:45:25.279Z","updated_at":"2025-07-28T23:02:04.131Z","avatar_url":"https://github.com/tourze.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Workerman Shadowsocks Config\n\n[English](README.md) | [中文](README.zh-CN.md)\n\n[![Latest Version](https://img.shields.io/packagist/v/tourze/shadowsocks-config-php.svg?style=flat-square)](https://packagist.org/packages/tourze/shadowsocks-config-php)\n[![MIT Licensed](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)\n\nThis package provides configuration classes for Shadowsocks services, supporting parsing and generating Shadowsocks\nconfigurations.\n\n## Features\n\n- Support for loading configurations from JSON files\n- Support for standard URI format (`ss://method:password@hostname:port#tag`)\n- Support for Base64 encoded URI format (`ss://BASE64-ENCODED-STRING-WITHOUT-PADDING#TAG`)\n- Support for SIP002 URI format (with plugin support)\n- Support for SIP008 online configuration delivery\n- Various configuration format conversions\n\n## Installation\n\n```bash\ncomposer require tourze/shadowsocks-config-php\n```\n\n## Usage\n\n### Creating from JSON Config\n\n```php\nuse Shadowsocks\\Config\\SIP002;\n\n// Create config from JSON file\n$sip002 = SIP002::fromJsonFile('/path/to/config.json');\n$config = $sip002-\u003egetConfig();\n\n// Example JSON config\n// {\n//    \"server\":\"my_server_ip\",\n//    \"server_port\":8388,\n//    \"local_port\":1080,\n//    \"password\":\"barfoo!\",\n//    \"method\":\"chacha20-ietf-poly1305\",\n//    \"plugin\":\"obfs-local;obfs=http\" // Optional\n// }\n```\n\n### Creating from Standard URI\n\n```php\nuse Shadowsocks\\Config\\SIP002;\n\n// Create config from standard URI\n$sip002 = SIP002::fromUri('ss://bf-cfb:test/!@#:@192.168.100.1:8888#example-server');\n$config = $sip002-\u003egetConfig();\n```\n\n### Creating from Base64 Encoded URI\n\n```php\nuse Shadowsocks\\Config\\SIP002;\n\n// Create config from Base64 URI\n$sip002 = SIP002::fromBase64Uri('ss://YmYtY2ZiOnRlc3QvIUAjOkAxOTIuMTY4LjEwMC4xOjg4ODg#example-server');\n$config = $sip002-\u003egetConfig();\n```\n\n### Using SIP002 URI Format\n\n```php\nuse Shadowsocks\\Config\\SIP002;\nuse Shadowsocks\\Config\\ClientConfig;\n\n// Create from SIP002 URI\n$sip002 = SIP002::fromUri('ss://YWVzLTI1Ni1nY206cGFzc3dvcmQ@192.168.100.1:8888/?plugin=obfs-local%3Bobfs%3Dhttp#Example');\n\n// Get the config object\n$config = $sip002-\u003egetConfig();\n\n// Get plugin information\n$plugin = $sip002-\u003egetPlugin();\n\n// Create a new SIP002 URI\n$config = new ClientConfig('192.168.100.1', 8888, 1080, 'password', 'aes-256-gcm');\n$sip002 = new SIP002($config);\n$sip002-\u003esetPlugin('v2ray-plugin;server');\n\n// Generate SIP002 URI\n$uri = $sip002-\u003etoUri();\n```\n\n### Using SIP008 Online Configuration\n\n```php\nuse Shadowsocks\\Config\\SIP008;\nuse Shadowsocks\\Config\\ServerConfig;\n\n// Create from SIP008 JSON\n$jsonContent = '{\n    \"version\": 1,\n    \"servers\": [\n        {\n            \"id\": \"27b8a625-4f4b-4428-9f0f-8a2317db7c79\",\n            \"remarks\": \"Server 1\",\n            \"server\": \"example1.com\",\n            \"server_port\": 8388,\n            \"password\": \"password1\",\n            \"method\": \"aes-256-gcm\",\n            \"plugin\": \"v2ray-plugin\",\n            \"plugin_opts\": \"server\"\n        },\n        {\n            \"id\": \"7842c068-c667-41f2-8f7d-04feece3cb67\",\n            \"remarks\": \"Server 2\",\n            \"server\": \"example2.com\",\n            \"server_port\": 8389,\n            \"password\": \"password2\",\n            \"method\": \"chacha20-ietf-poly1305\"\n        }\n    ],\n    \"bytes_used\": 274877906944,\n    \"bytes_remaining\": 824633720832\n}';\n\n$sip008 = SIP008::fromJson($jsonContent);\n\n// Or load from URL (HTTPS required)\ntry {\n    $sip008 = SIP008::fromUrl('https://example.com/config.json');\n} catch (\\InvalidArgumentException $e) {\n    // Handle error\n}\n\n// Get servers from SIP008\n$servers = $sip008-\u003egetServers();\nforeach ($servers as $server) {\n    $id = $server-\u003egetId();\n    $remarks = $server-\u003egetRemarks();\n    $config = $server-\u003etoConfig(); // Convert to Config object\n    \n    // Check for plugin\n    $plugin = $server-\u003egetPlugin();\n    $pluginOpts = $server-\u003egetPluginOpts();\n    \n    // Use the server...\n}\n\n// Get data usage information (optional)\n$bytesUsed = $sip008-\u003egetBytesUsed();\n$bytesRemaining = $sip008-\u003egetBytesRemaining();\n\n// Convert SIP008 to list of SIP002 objects\n$sip002List = $sip008-\u003etoSIP002List();\n\n// Create SIP008 from Config\n$config = new Config('example.com', 8388, 1080, 'password', 'aes-256-gcm');\n$sip008 = SIP008::fromConfig($config, 'v2ray-plugin', 'server');\n\n// Create SIP008 from SIP002\n$sip002 = new SIP002($config);\n$sip002-\u003esetPlugin('v2ray-plugin;server');\n$sip008 = SIP008::fromSIP002($sip002);\n\n// Create SIP008 from multiple SIP002 objects\n$sip002List = [\n    new SIP002($config1),\n    new SIP002($config2)\n];\n$sip008 = SIP008::fromSIP002List($sip002List);\n\n// Convert SIP008 to JSON\n$jsonString = $sip008-\u003etoJson();\n```\n\n### Direct Configuration Creation\n\n```php\nuse Shadowsocks\\Config\\ClientConfig;\nuse Shadowsocks\\Config\\SIP002;\n\n// Create a config instance directly\n$config = new ClientConfig(\n    '192.168.100.1',  // Server address\n    8888,             // Server port\n    1080,             // Local port\n    'password123',    // Password\n    'aes-256-gcm'     // Encryption method\n);\n\n// Set tag\n$config-\u003esetTag('my-server');\n\n// Wrap with SIP002 for URI generation\n$sip002 = new SIP002($config);\n```\n\n### Converting to Different Formats\n\n```php\nuse Shadowsocks\\Config\\ClientConfig;\nuse Shadowsocks\\Config\\SIP002;\n\n$config = new ClientConfig('192.168.100.1', 8888, 1080, 'password123', 'aes-256-gcm');\n$sip002 = new SIP002($config);\n\n// Convert to JSON config\n$jsonConfig = $config-\u003etoJson();\n\n// Convert to SIP002 URI (recommended)\n$sip002Uri = $sip002-\u003etoUri();\n\n// Convert to standard URI format\n$standardUri = $sip002-\u003etoStandardUri();\n\n// Convert to Base64 encoded URI format\n$base64Uri = $sip002-\u003etoBase64Uri();\n```\n\n## SIP002 Specification\n\nSIP002 defines a standard Shadowsocks URI format with plugin support:\n\n```\nSS-URI = \"ss://\" userinfo \"@\" hostname \":\" port [ \"/\" ] [ \"?\" plugin ] [ \"#\" tag ]\nuserinfo = websafe-base64-encode-utf8(method \":\" password)\n           method \":\" password\n```\n\n- User info can be Base64URL encoded or plain text (which must be percent-encoded)\n- For AEAD-2022 encryption methods, plain text user info must be used\n- Plugin parameters use URL encoding\n\n## SIP008 Specification\n\nSIP008 defines a standard JSON document format for online configuration sharing and delivery:\n\n```json\n{\n  \"version\": 1,\n  \"servers\": [\n    {\n      \"id\": \"server-uuid\",\n      \"remarks\": \"Server name\",\n      \"server\": \"example.com\",\n      \"server_port\": 8388,\n      \"password\": \"password\",\n      \"method\": \"aes-256-gcm\",\n      \"plugin\": \"plugin-name\",\n      \"plugin_opts\": \"plugin-options\"\n    }\n  ],\n  \"bytes_used\": 274877906944,\n  \"bytes_remaining\": 824633720832\n}\n```\n\n- The `version` and `servers` fields are mandatory\n- Each server must have the fields: `id`, `server`, `server_port`, `password`, and `method`\n- Optional fields include `remarks`, `plugin`, and `plugin_opts`\n- Data usage fields `bytes_used` and `bytes_remaining` are optional\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE) for more information.\n\n## References\n\n- [Shadowsocks Configuration Documentation](https://shadowsocks.org/doc/configs.html)\n- [SIP002 URI Scheme](https://shadowsocks.org/doc/sip002.html)\n- [SIP008 Online Configuration Delivery](https://shadowsocks.org/doc/sip008.html)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftourze%2Fshadowsocks-config-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftourze%2Fshadowsocks-config-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftourze%2Fshadowsocks-config-php/lists"}