|
112 | 112 | console.log('检测到用户地区:', userLocation); |
113 | 113 | return userLocation; |
114 | 114 | } catch (error) { |
115 | | - console.warn('IP地址检测失败,使用默认设置:', error); |
| 115 | + console.warn('IP地址检测失败,使用默认设置(gitee):', error); |
| 116 | + userLocation = 'DEFAULT'; // 标记为默认状态 |
116 | 117 | return null; |
117 | 118 | } |
118 | 119 | } |
119 | 120 |
|
120 | 121 | // 生成安装脚本 |
121 | | - function generateInstallScript(secret, isChinaUser = false) { |
| 122 | + function generateInstallScript(secret) { |
122 | 123 | const host = '{{.Conf.GRPCHost}}'; |
123 | 124 | const port = '{{if .Conf.ProxyGRPCPort}}{{.Conf.ProxyGRPCPort}}{{else}}{{.Conf.GRPCPort}}{{end}}'; |
124 | 125 | const tls = '{{if .Conf.TLS}} --tls{{end}}'; |
|
127 | 128 | return '{{tr "NoDomainAlert"}}'; |
128 | 129 | } |
129 | 130 |
|
130 | | - const baseUrl = isChinaUser ? |
131 | | - 'https://gitee.com/ten/ServerStatus/raw/master' : |
132 | | - 'https://raw.githubusercontent.com/xos/serverstatus/master'; |
| 131 | + // 默认使用gitee,只有明确检测到非中国大陆IP才使用github |
| 132 | + let baseUrl = 'https://gitee.com/ten/ServerStatus/raw/master'; // 默认gitee |
| 133 | + |
| 134 | + // 只有明确检测到非中国大陆IP才使用github |
| 135 | + if (userLocation && userLocation !== 'CN' && userLocation !== 'DEFAULT') { |
| 136 | + baseUrl = 'https://raw.githubusercontent.com/xos/serverstatus/master'; |
| 137 | + } |
133 | 138 |
|
134 | 139 | return `curl -L ${baseUrl}/script/server-status.sh -o server-status.sh && chmod +x server-status.sh && sudo ./server-status.sh install_agent ${host} ${port} ${secret}${tls}`; |
135 | 140 | } |
|
147 | 152 | await detectUserLocation(); |
148 | 153 | } |
149 | 154 |
|
150 | | - // 判断是否为中国用户 |
151 | | - const isChinaUser = userLocation === 'CN'; |
152 | | - const script = generateInstallScript(secret, isChinaUser); |
| 155 | + const script = generateInstallScript(secret); |
153 | 156 |
|
154 | 157 | // 复制到剪贴板 |
155 | 158 | try { |
|
0 commit comments