Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/cargo/state-0.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ibigbug authored Sep 21, 2023
2 parents 4eb82c3 + 26c226b commit 7ec5d01
Show file tree
Hide file tree
Showing 8 changed files with 493 additions and 47 deletions.
39 changes: 24 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ jobs:
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
- name: Output Release URL File
run: echo "${{ steps.create_release.outputs.upload_url }}" > release_url.txt
run: echo "${{ steps.create_release.outputs.id }}" > release_id.txt
- name: Save Release URL File for publish
uses: actions/upload-artifact@v3
with:
name: release_url
path: release_url.txt
name: release_id
path: release_id.txt

publish:
if: contains(github.ref, 'tags/v')
Expand All @@ -60,35 +60,44 @@ jobs:
os: [ubuntu-22.04, macos-13]
include:
- os: ubuntu-22.04
platform: linux-amd64
targets: >
x86_64-unknown-linux-gnu
aarch64-unknown-linux-gnu
- os: macos-13
platform: darwin-amd64
targets: >
aarch64-apple-darwin
x86_64-apple-darwin
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: actions/setup-go@v4
with:
go-version: '1.20'
- name: Load Release URL File from release job
uses: actions/download-artifact@v3
with:
path: release_url
name: release_url
path: release_id
name: release_id
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- uses: Swatinem/rust-cache@v2
- name: Build
run: CARGO_BAZEL_ISOLATED=0 CARGO_BAZEL_REPIN=true bazel build --strip=always //clash/...
run: sh ./scripts/build.sh "${{ matrix.targets }}"
- name: Get Release Upload URL
id: get_release_info
run: |
value=`cat release_url/release_url.txt`
echo "upload_url=$value" >> $GITHUB_OUTPUT
value=`cat release_id/release_id.txt`
echo "upload_id=$value" >> $GITHUB_OUTPUT
env:
TAG_REF_NAME: ${{ github.ref }}
REPOSITORY_NAME: ${{ github.repository }}
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1.0.2
uses: dwenegar/upload-release-assets@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.get_release_info.outputs.upload_url }}
asset_path: ./bazel-bin/clash/clash
asset_name: clash-${{ matrix.platform }}
asset_content_type: application/octet-stream
release_id: ${{ steps.get_release_info.outputs.id }}
assets_path: target/artifacts
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Options:

## 🔗 Links

- [Documentation(Coming Soon)]()
- [Documentation](https://watfaq.gitbook.io/clashrs-user-manual/)
- [Config Reference](https://watfaq.github.io/clash-rs/)
- [Roadmap](https://github.com/Watfaq/clash-rs/issues/59)

Expand Down
11 changes: 5 additions & 6 deletions clash_lib/src/app/dispatcher/dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,11 @@ impl Dispatcher {
RunMode::Direct => (PROXY_DIRECT, None),
};

let handler = self
.outbound_manager
.read()
.await
.get_outbound(outbound_name)
.expect(format!("unknown rule: {}", outbound_name).as_str()); // should never happen
let mgr = self.outbound_manager.read().await;
let handler = mgr.get_outbound(outbound_name).unwrap_or_else(|| {
debug!("unknown rule: {}, fallback to direct", outbound_name);
mgr.get_outbound(PROXY_DIRECT).unwrap()
});

match handler
.connect_stream(&sess, self.resolver.clone())
Expand Down
228 changes: 227 additions & 1 deletion clash_lib/src/config/def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,233 @@ impl Display for LogLevel {
#[serde(rename_all = "kebab-case", default)]
/// Example
/// ```yaml
/// port: 7890
/// ---
/// port: 8888
/// socks-port: 8889
/// mixed-port: 8899
/// tun:
/// enable: false
/// device-id: "dev://utun1989"
/// dns:
/// enable: true
/// listen: 127.0.0.1:53553
/// # udp: 127.0.0.1:53553
/// # tcp: 127.0.0.1:53553
/// # dot: 127.0.0.1:53554
/// # doh: 127.0.0.1:53555
/// # ipv6: false # when the false, response to AAAA questions will be empty
/// # These nameservers are used to resolve the DNS nameserver hostnames below.
/// # Specify IP addresses only
/// default-nameserver:
/// - 114.114.114.114
/// - 8.8.8.8
/// enhanced-mode: fake-ip
/// fake-ip-range: 198.18.0.2/16 # Fake IP addresses pool CIDR
/// # use-hosts: true # lookup hosts and return IP record
/// # Hostnames in this list will not be resolved with fake IPs
/// # i.e. questions to these domain names will always be answered with their
/// # real IP addresses
/// # fake-ip-filter:
/// # - '*.lan'
/// # - localhost.ptlogin2.qq.com
/// # Supports UDP, TCP, DoT, DoH. You can specify the port to connect to.
/// # All DNS questions are sent directly to the nameserver, without proxies
/// # involved. Clash answers the DNS question with the first result gathered.
/// nameserver:
/// - 114.114.114.114 # default value
/// - 1.1.1.1 # default value
/// - tls://1.1.1.1:853 # DNS over TLS
/// - https://1.1.1.1/dns-query # DNS over HTTPS
/// # - dhcp://en0 # dns from dhcp
/// allow-lan: true
/// mode: rule
/// log-level: debug
/// external-controller: 127.0.0.1:9090
/// external-ui: "public"
/// # secret: "clash-rs"
/// experimental:
/// ignore-resolve-fail: true
/// profile:
/// store-selected: true
/// store-fake-ip: false
/// proxy-groups:
/// - name: "relay"
/// type: relay
/// proxies:
/// - "plain-vmess"
/// - "ws-vmess"
/// - "auto"
/// - "fallback-auto"
/// - "load-balance"
/// - "select"
/// - DIRECT
/// - name: "relay-one"
/// type: relay
/// use:
/// - "file-provider"
/// - name: "auto"
/// type: url-test
/// use:
/// - "file-provider"
/// proxies:
/// - DIRECT
/// url: "http://www.gstatic.com/generate_204"
/// interval: 300
/// - name: "fallback-auto"
/// type: fallback
/// use:
/// - "file-provider"
/// proxies:
/// - DIRECT
/// url: "http://www.gstatic.com/generate_204"
/// interval: 300
/// - name: "load-balance"
/// type: load-balance
/// use:
/// - "file-provider"
/// proxies:
/// - DIRECT
/// strategy: round-robin
/// url: "http://www.gstatic.com/generate_204"
/// interval: 300
/// - name: select
/// type: select
/// use:
/// - "file-provider"
/// - name: test 🌏
/// type: select
/// use:
/// - "file-provider"
/// proxies:
/// - DIRECT
/// proxies:
/// - name: plain-vmess
/// type: vmess
/// server: 10.0.0.13
/// port: 16823
/// uuid: b831381d-6324-4d53-ad4f-8cda48b30811
/// alterId: 0
/// cipher: auto
/// udp: true
/// skip-cert-verify: true
/// - name: ws-vmess
/// type: vmess
/// server: 10.0.0.13
/// port: 16824
/// uuid: b831381d-6324-4d53-ad4f-8cda48b30811
/// alterId: 0
/// cipher: auto
/// udp: true
/// skip-cert-verify: true
/// network: ws
/// ws-opts:
/// path: /api/v3/download.getFile
/// headers:
/// Host: www.amazon.com
/// - name: tls-vmess
/// type: vmess
/// server: 10.0.0.13
/// port: 8443
/// uuid: 23ad6b10-8d1a-40f7-8ad0-e3e35cd38297
/// alterId: 0
/// cipher: auto
/// udp: true
/// skip-cert-verify: true
/// tls: true
/// - name: h2-vmess
/// type: vmess
/// server: 10.0.0.13
/// port: 8444
/// uuid: b831381d-6324-4d53-ad4f-8cda48b30811
/// alterId: 0
/// cipher: auto
/// udp: true
/// skip-cert-verify: true
/// tls: true
/// network: h2
/// h2-opts:
/// path: /ray
/// - name: vmess-altid
/// type: vmess
/// server: tw-1.ac.laowanxiang.com
/// port: 153
/// uuid: 46dd0dd3-2cc0-3f55-907c-d94e54877687
/// alterId: 64
/// cipher: auto
/// udp: true
/// network: ws
/// ws-opts:
/// path: /api/v3/download.getFile
/// headers:
/// Host: 5607b9d187e655736f563fee87d7283994721.laowanxiang.com
/// - name: "ss-simple"
/// type: ss
/// server: 10.0.0.13
/// port: 8388
/// cipher: aes-256-gcm
/// password: "password"
/// udp: true
/// - name: "trojan"
/// type: trojan
/// server: 10.0.0.13
/// port: 9443
/// password: password1
/// udp: true
/// # sni: example.com # aka server name
/// alpn:
/// - h2
/// - http/1.1
/// skip-cert-verify: true
/// proxy-providers:
/// file-provider:
/// type: file
/// path: ./ss.yaml
/// interval: 300
/// health-check:
/// enable: true
/// url: http://www.gstatic.com/generate_204
/// interval: 300
/// rule-providers:
/// file-provider:
/// type: file
/// path: ./rule-set.yaml
/// interval: 300
/// behavior: domain
/// rules:
/// - DOMAIN,ipinfo.io,relay
/// - RULE-SET,file-provider,trojan
/// - GEOIP,CN,relay
/// - DOMAIN-SUFFIX,facebook.com,REJECT
/// - DOMAIN-KEYWORD,google,select
/// - DOMAIN,google.com,select
/// - SRC-IP-CIDR,192.168.1.1/24,DIRECT
/// - GEOIP,CN,DIRECT
/// - DST-PORT,53,trojan
/// - SRC-PORT,7777,DIRECT
/// - MATCH, DIRECT
/// ...
/// ```
pub struct Config {
/// The HTTP proxy port
Expand Down
6 changes: 3 additions & 3 deletions clash_lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,12 @@ async fn start_async(opts: Options) -> Result<(), Error> {
runners.push(r);
}

tasks.push(Box::pin(async move {
futures::future::join_all(runners).await;
runners.push(Box::pin(async move {
shutdown_rx.recv().await;
}));

tasks.push(Box::pin(async move {
shutdown_rx.recv().await;
futures::future::join_all(runners).await;
}));

tasks.push(Box::pin(async move {
Expand Down
Loading

0 comments on commit 7ec5d01

Please sign in to comment.