安装 Shadowsocks
- 下载安装:从官方 npm 官网下载 Shadowsocks,并安装到本地,确保你有足够的网络连接,Shadowsocks 已经通过 CDN 下载。
npm install
- 本地安装:如果需要安装到本地,可以使用 Node.js 的本地版本,安装时可以使用以下命令:
npm install --save-dev
端点配置
Shadowsocks 通过配置端点来实现跨进程的通信,端点必须在同一个网络路径上。
端点注册
- 服务器端点:在你的服务器上注册 Shadowsocks 端点。
npm run register-sphere
- 客户端端点:在客户端(如 Node.js 或其他 Web 应用)注册端点。
npm run register-sphere --client
端点路径
Shadowsocks 会自动生成一个路径,/shadowsocks,在端点注册时,确保路径是正确的,并且允许共享。
本地配置
Shadowsocks 通常需要在服务器上配置本地配置文件 shadowsocks.config.js,这是一个全局配置文件,允许多个客户端共享相同的配置。
本地配置示例
module.exports = {
defaultProtocol: 'http',
defaultPort: 88,
defaultPath: '/shadowsocks',
defaultProtocolName: 'http',
defaultPortName: '88',
defaultEnabled: true,
protocolOptions: {
defaultProtocol: {
defaultPort: 88,
defaultProtocol: 'http',
}
},
networkOptions: {
defaultPort: 88,
networkPath: '/shadowsocks',
},
configurationOptions: {
defaultProtocol: {
defaultPort: 88,
defaultProtocol: 'http',
},
},
defaultEnabled: true,
protocolOptions: {
defaultProtocol: {
defaultPort: 88,
defaultProtocol: 'http',
},
},
networkOptions: {
defaultPort: 88,
networkPath: '/shadowsocks',
},
configurationOptions: {
defaultProtocol: {
defaultPort: 88,
defaultProtocol: 'http',
},
},
defaultEnabled: true,
protocolOptions: {
defaultProtocol: {
defaultPort: 88,
defaultProtocol: 'http',
},
},
networkOptions: {
defaultPort: 88,
networkPath: '/shadowsocks',
},
configurationOptions: {
defaultProtocol: {
defaultPort: 88,
defaultProtocol: 'http',
},
},
defaultEnabled: true,
protocolOptions: {
defaultProtocol: {
defaultPort: 88,
defaultProtocol: 'http',
},
},
networkOptions: {
defaultPort: 88,
networkPath: '/shadowsocks',
},
configurationOptions: {
defaultProtocol: {
defaultPort: 88,
defaultProtocol: 'http',
},
},
}
// 本地配置文件 path
module.exports = {
config: {
shadowsocks: {
// 配置选项
protocol: {
defaultPort: 88,
defaultProtocol: 'http',
},
networkOptions: {
defaultPort: 88,
networkPath: '/shadowsocks',
},
configurationOptions: {
defaultProtocol: {
defaultPort: 88,
defaultProtocol: 'http',
},
},
defaultEnabled: true,
},
},
}
服务器配置
Shadowsocks 通常需要在服务器上配置客户端端点,对于移动应用,还需要配置移动协议。
服务器配置
npm run register-sphere
服务器配置示例
module.exports = {
defaultProtocol: 'http',
defaultPort: 88,
defaultPath: '/shadowsocks',
defaultProtocolName: 'http',
defaultPortName: '88',
defaultEnabled: true,
protocolOptions: {
defaultProtocol: {
defaultPort: 88,
defaultProtocol: 'http',
}
},
networkOptions: {
defaultPort: 88,
networkPath: '/shadowsocks',
},
configurationOptions: {
defaultProtocol: {
defaultPort: 88,
defaultProtocol: 'http',
},
},
defaultEnabled: true,
protocolOptions: {
defaultProtocol: {
defaultPort: 88,
defaultProtocol: 'http',
},
},
networkOptions: {
defaultPort: 88,
networkPath: '/shadowsocks',
},
configurationOptions: {
defaultProtocol: {
defaultPort: 88,
defaultProtocol: 'http',
},
},
defaultEnabled: true,
protocolOptions: {
defaultProtocol: {
defaultPort: 88,
defaultProtocol: 'http',
},
},
networkOptions: {
defaultPort: 88,
networkPath: '/shadowsocks',
},
configurationOptions: {
defaultProtocol: {
defaultPort: 88,
defaultProtocol: 'http',
},
},
defaultEnabled: true,
protocolOptions: {
defaultProtocol: {
defaultPort: 88,
defaultProtocol: 'http',
},
},
networkOptions: {
defaultPort: 88,
networkPath: '/shadowsocks',
},
configurationOptions: {
defaultProtocol: {
defaultPort: 88,
defaultProtocol: 'http',
},
},
}
端点运行方式
Shadowsocks 提供不同的客户端运行方式,如 client 和 web,默认为 client。
端点运行方式示例
npm run register-sphere --client
配置输出
Shadowsocks 会生成一个配置文件 shadowsocks.config.js,允许客户端共享配置。
端点的运行方式
Shadowsocks 提供以下客户端运行方式:
client: 本地端点,用于跨进程通信。web: 本地端点,用于 Web 应用。web-snovscap: 本地端点,用于 Web 应用和SNV 环境。web-snovscap-client: 本地端点,用于 Web 应用和SNV 环境的客户端。







京公网安备11000000000001号
京ICP备11000001号