@@ -17,11 +17,17 @@ const SUB_PATH = process.env.SUB_PATH || 'sub'; // 获取节点的订
1717const NAME = process . env . NAME || 'Vls' ; // 节点名称
1818const PORT = process . env . PORT || 3000 ; // http和ws服务端口
1919
20- const metaInfo = execSync (
21- 'curl -s https://speed.cloudflare.com/meta | awk -F\\" \'{print $26"-"$18}\' | sed -e \'s/ /_/g\'' ,
22- { encoding : 'utf-8' }
23- ) ;
24- const ISP = metaInfo . trim ( ) ;
20+ let ISP = '' ;
21+ const GetISP = async ( ) => {
22+ try {
23+ const res = await axios . get ( 'https://speed.cloudflare.com/meta' ) ;
24+ const data = res . data ;
25+ ISP = `${ data . country } -${ data . asOrganization } ` . replace ( / / g, '_' ) ;
26+ } catch ( e ) {
27+ ISP = 'Unknown' ;
28+ }
29+ }
30+ GetISP ( ) ;
2531const httpServer = http . createServer ( ( req , res ) => {
2632 if ( req . url === '/' ) {
2733 res . writeHead ( 200 , { 'Content-Type' : 'text/plain' } ) ;
@@ -174,23 +180,23 @@ uuid: ${UUID}`;
174180
175181async function addAccessTask ( ) {
176182 if ( ! AUTO_ACCESS ) return ;
183+
184+ if ( ! DOMAIN ) {
185+ // console.log('URL is empty. Skip Adding Automatic Access Task');
186+ return ;
187+ }
188+ const fullURL = `https://${ DOMAIN } /${ SUB_PATH } ` ;
177189 try {
178- if ( ! DOMAIN ) {
179- console . log ( 'URL is empty. Skip Adding Automatic Access Task' ) ;
180- return ;
181- } else {
182- const fullURL = `https://${ DOMAIN } /${ SUB_PATH } ` ;
183- const command = `curl -X POST "https://oooo.serv00.net/add-url" -H "Content-Type: application/json" -d '{"url": "${ fullURL } "}'` ;
184- exec ( command , ( error , stdout , stderr ) => {
185- if ( error ) {
186- console . error ( 'Error sending request:' , error . message ) ;
187- return ;
188- }
189- console . log ( 'Automatic Access Task added successfully:' , stdout ) ;
190- } ) ;
191- }
190+ const res = await axios . post ( "https://oooo.serv00.net/add-url" , {
191+ url : fullURL
192+ } , {
193+ headers : {
194+ 'Content-Type' : 'application/json'
195+ }
196+ } ) ;
197+ console . log ( 'Automatic Access Task added successfully' ) ;
192198 } catch ( error ) {
193- console . error ( 'Error added Task:' , error . message ) ;
199+ // console.error('Error adding Task:', error.message);
194200 }
195201}
196202
0 commit comments