├── .travis.yml ├── Formula └── v2ray-core.rb ├── LICENSE ├── README.md └── checker.sh /.travis.yml: -------------------------------------------------------------------------------- 1 | language: generic 2 | 3 | dist: xenial 4 | 5 | os: linux 6 | 7 | notifications: 8 | email: false 9 | 10 | before_install: 11 | - git config --global user.name "$USERNAME" 12 | - git config --global user.email "$EMAIL" 13 | 14 | script: 15 | - chmod +x checker.sh 16 | - ./checker.sh 17 | -------------------------------------------------------------------------------- /Formula/v2ray-core.rb: -------------------------------------------------------------------------------- 1 | class V2rayCore < Formula 2 | desc "Platform for building proxies to bypass network restrictions" 3 | homepage "https://www.v2fly.org/" 4 | url "https://github.com/v2fly/v2ray-core/releases/download/v4.39.2/v2ray-macos-64.zip" 5 | version "4.39.2" 6 | sha256 "8a3c936d84d662f98ab83c34d5674046439e7abe22d6ce9a62e0253b466b90f7" 7 | license all_of: ["MIT", "CC-BY-SA-4.0"] 8 | 9 | def install 10 | bin.install "v2ray" 11 | bin.install "v2ctl" 12 | 13 | pkgetc.install "config.json" 14 | 15 | pkgshare.install "geoip.dat" 16 | pkgshare.install "geosite.dat" 17 | end 18 | 19 | plist_options manual: "v2ray -config=#{HOMEBREW_PREFIX}/etc/v2ray/config.json" 20 | 21 | def plist; <<~EOS 22 | 23 | 24 | 25 | 26 | KeepAlive 27 | 28 | RunAtLoad 29 | 30 | Label 31 | #{plist_name} 32 | ProgramArguments 33 | 34 | #{bin}/v2ray 35 | -config 36 | #{etc}/v2ray/config.json 37 | 38 | 39 | 40 | EOS 41 | end 42 | 43 | test do 44 | (testpath/"config.json").write <<~EOS 45 | { 46 | "log": { 47 | "access": "#{testpath}/log" 48 | }, 49 | "outbounds": [ 50 | { 51 | "protocol": "freedom", 52 | "tag": "direct" 53 | } 54 | ], 55 | "routing": { 56 | "rules": [ 57 | { 58 | "ip": [ 59 | "geoip:private" 60 | ], 61 | "outboundTag": "direct", 62 | "type": "field" 63 | } 64 | ] 65 | } 66 | } 67 | EOS 68 | output = shell_output "#{bin}/v2ray -c #{testpath}/config.json -test" 69 | 70 | assert_match "Configuration OK", output 71 | assert_predicate testpath/"log", :exist? 72 | end 73 | 74 | def caveats 75 | <<~EOS 76 | v2ray-core has entered homebrew-core (https://github.com/Homebrew/homebrew-core). 77 | We suggest installing v2ray-core with `brew install v2ray`. 78 | However, you can continue using this formula. 79 | EOS 80 | end 81 | end 82 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 V2Fly Community 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### homebrew v2ray [![Build Status](https://travis-ci.org/v2ray/homebrew-v2ray.svg?branch=master)](https://travis-ci.org/v2ray/homebrew-v2ray) 2 | 3 | 4 | The homebrew tap for v2ray-core. 5 | 6 | > **NOTE:** v2ray-core has entered [homebrew-core](https://github.com/Homebrew/homebrew-core). 7 | > 8 | > We suggest installing v2ray-core with `brew install v2ray`. 9 | > 10 | > However, you can continue using this tap. 11 | 12 | ------ 13 | 14 | 15 | ### Install v2ray-core 16 | 17 | 18 | step 1: Add official tap 19 | 20 | ```bash 21 | brew tap v2ray/v2ray 22 | ``` 23 | 24 | step 2: Install v2ray-core: 25 | 26 | ```bash 27 | brew install v2ray-core 28 | ``` 29 | 30 | ### Update v2ray-core 31 | 32 | step 1: update tap 33 | 34 | ```bash 35 | brew update 36 | ``` 37 | 38 | step 2: update v2ray-core 39 | 40 | ```bash 41 | brew upgrade v2ray-core 42 | ``` 43 | 44 | ------ 45 | 46 | ### Uninstall v2ray-core 47 | 48 | step 1: uninstall core 49 | 50 | ```bash 51 | brew uninstall v2ray-core 52 | ``` 53 | 54 | step 2: untap official formula 55 | 56 | ```bash 57 | brew untap v2ray/v2ray 58 | ``` 59 | 60 | ------ 61 | 62 | ### Usage 63 | 64 | once you installed, you can run command via `v2ray` to run v2ray-core. 65 | 66 | The defualt config file location is:`/usr/local/etc/v2ray/config.json` 67 | 68 | step 1: edit the default config: 69 | 70 | ```bash 71 | vim /usr/local/etc/v2ray/config.json 72 | ``` 73 | 74 | step 2: run v2ray-core without starting at login. 75 | 76 | ```bash 77 | brew services run v2ray-core 78 | ``` 79 | 80 | or run v2ray-core and register it to launch at login via: 81 | 82 | ```bash 83 | brew services start v2ray-core 84 | ``` 85 | -------------------------------------------------------------------------------- /checker.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | log(){ 4 | echo '' 5 | echo '-------------------------------------' 6 | echo "$*" 7 | echo '-------------------------------------' 8 | echo '' 9 | } 10 | 11 | loop_parser(){ 12 | while true 13 | do 14 | result=$(curl -s -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/v2fly/v2ray-core/releases/latest | grep "$1" | cut -d '"' -f 4) 15 | if [ -n "$result" ]; then 16 | echo "$result" 17 | break 18 | fi 19 | done 20 | } 21 | 22 | log 'parser v2ray download url' 23 | 24 | DOWNLOAD_URL=$( loop_parser 'browser_download_url.*macos-64.zip"$' ) 25 | 26 | if [ -z "$DOWNLOAD_URL" ]; then 27 | 28 | log 'parser download url error, skip update.' 29 | exit 0 30 | 31 | fi 32 | 33 | log "download url: $DOWNLOAD_URL start downloading..." 34 | 35 | curl -s -L "$DOWNLOAD_URL" > v2ray-macos-64.zip || { log 'file download failed!' ; exit 1; } 36 | 37 | if [ ! -e v2ray-macos-64.zip ]; then 38 | log "file download failed!" 39 | exit 1 40 | fi 41 | 42 | V_HASH256=$(sha256sum v2ray-macos-64.zip |cut -d ' ' -f 1) 43 | 44 | log "file hash: $V_HASH256 parser v2ray-core version..." 45 | 46 | V_VERSION=$( loop_parser "tag_name" ) 47 | V_VERSION="${V_VERSION:1}" 48 | 49 | if [ -z "$V_VERSION" ]; then 50 | 51 | log 'parser file version error, skip update.' 52 | exit 0 53 | 54 | fi 55 | 56 | 57 | log "file version: $V_VERSION start clone..." 58 | 59 | git clone https://github.com/v2ray/homebrew-v2ray.git 60 | 61 | log "update config...." 62 | 63 | sed -i "s#^\s*url.*# url \"$DOWNLOAD_URL\"#g" homebrew-v2ray/Formula/v2ray-core.rb 64 | sed -i "s#^\s*sha256.*# sha256 \"$V_HASH256\"#g" homebrew-v2ray/Formula/v2ray-core.rb 65 | sed -i "s#^\s*version.*# version \"$V_VERSION\"#g" homebrew-v2ray/Formula/v2ray-core.rb 66 | 67 | log "update config done. start update repo..." 68 | 69 | cd homebrew-v2ray || exit 70 | git commit -am "travis automated update version $V_VERSION" 71 | git push --quiet "https://${GH_TOKEN}@${GH_REF}" master:master 72 | 73 | log "update repo done." 74 | --------------------------------------------------------------------------------