-
Notifications
You must be signed in to change notification settings - Fork 672
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
21 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,30 @@ | ||
/* eslint-disable no-case-declarations */ | ||
import { Base64 } from 'js-base64'; | ||
import URI_Producer from './uri'; | ||
import $ from '@/core/app'; | ||
|
||
const URI = URI_Producer(); | ||
|
||
export default function V2Ray_Producer() { | ||
const type = 'ALL'; | ||
const produce = (proxies) => | ||
Base64.encode(proxies.map((proxy) => URI.produce(proxy)).join('\n')); | ||
const produce = (proxies) => { | ||
let result = []; | ||
proxies.map((proxy) => { | ||
try { | ||
result.push(URI.produce(proxy)); | ||
} catch (err) { | ||
$.error( | ||
`Cannot produce proxy: ${JSON.stringify( | ||
proxy, | ||
null, | ||
2, | ||
)}\nReason: ${err}`, | ||
); | ||
} | ||
}); | ||
|
||
return Base64.encode(result.join('\n')); | ||
}; | ||
|
||
return { type, produce }; | ||
} |