Add publish CI and run fmt
This commit is contained in:
parent
fc7a3038bd
commit
754a5af794
39
.github/workflows/publish-binaries.yml
vendored
Normal file
39
.github/workflows/publish-binaries.yml
vendored
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [published]
|
||||||
|
|
||||||
|
name: Publish binaries to release
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
publish:
|
||||||
|
name: Publish for ${{ matrix.os }}
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||||
|
include:
|
||||||
|
- os: ubuntu-latest
|
||||||
|
artifact_name: fourth
|
||||||
|
asset_name: fourth-linux-amd64
|
||||||
|
- os: macos-latest
|
||||||
|
artifact_name: fourth
|
||||||
|
asset_name: fourth-macos-amd64
|
||||||
|
- os: windows-latest
|
||||||
|
artifact_name: fourth.exe
|
||||||
|
asset_name: fourth-windows-amd64.exe
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: hecrj/setup-rust-action@master
|
||||||
|
with:
|
||||||
|
rust-version: stable
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Build
|
||||||
|
run: cargo build --release --locked
|
||||||
|
- name: Publish
|
||||||
|
uses: svenstaro/upload-release-action@v1-release
|
||||||
|
with:
|
||||||
|
repo_token: ${{ secrets.PUBLISH_TOKEN }}
|
||||||
|
file: target/release/${{ matrix.artifact_name }}
|
||||||
|
asset_name: ${{ matrix.asset_name }}
|
||||||
|
tag: ${{ github.ref }}
|
@ -31,6 +31,8 @@ Or you can use Cargo to install Fourth:
|
|||||||
$ cargo install fourth
|
$ cargo install fourth
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Or you can download binary file form the Release page.
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
Fourth will read yaml format configuration file from `/etc/fourth/config.yaml`, here is an minimal viable example:
|
Fourth will read yaml format configuration file from `/etc/fourth/config.yaml`, here is an minimal viable example:
|
||||||
|
@ -33,6 +33,8 @@ $ cargo build --release
|
|||||||
$ cargo install fourth
|
$ cargo install fourth
|
||||||
```
|
```
|
||||||
|
|
||||||
|
或者您也可以直接从Release中下载二进制文件。
|
||||||
|
|
||||||
## 配置
|
## 配置
|
||||||
|
|
||||||
Fourth使用yaml格式的配置文件,默认情况下会读取`/etc/fourth/config.yaml`,如下是一个最小有效配置:
|
Fourth使用yaml格式的配置文件,默认情况下会读取`/etc/fourth/config.yaml`,如下是一个最小有效配置:
|
||||||
|
@ -192,10 +192,7 @@ fn verify_config(config: ParsedConfig) -> Result<ParsedConfig, ConfigError> {
|
|||||||
|
|
||||||
for key in &used_upstreams {
|
for key in &used_upstreams {
|
||||||
if !config.upstream.contains_key(key) {
|
if !config.upstream.contains_key(key) {
|
||||||
return Err(ConfigError::Custom(format!(
|
return Err(ConfigError::Custom(format!("Upstream {} not found", key)));
|
||||||
"Upstream {} not found",
|
|
||||||
key
|
|
||||||
)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,8 +74,7 @@ async fn process(
|
|||||||
let bytes_tx = inbound_to_inbound.await;
|
let bytes_tx = inbound_to_inbound.await;
|
||||||
debug!("Bytes read: {:?}", bytes_tx);
|
debug!("Bytes read: {:?}", bytes_tx);
|
||||||
}
|
}
|
||||||
Upstream::Custom(custom) => {
|
Upstream::Custom(custom) => match custom.protocol.as_ref() {
|
||||||
match custom.protocol.as_ref() {
|
|
||||||
"tcp" => {
|
"tcp" => {
|
||||||
let outbound = TcpStream::connect(custom.addr.clone()).await?;
|
let outbound = TcpStream::connect(custom.addr.clone()).await?;
|
||||||
|
|
||||||
@ -85,15 +84,15 @@ async fn process(
|
|||||||
let inbound_to_outbound = copy(&mut ri, &mut wo);
|
let inbound_to_outbound = copy(&mut ri, &mut wo);
|
||||||
let outbound_to_inbound = copy(&mut ro, &mut wi);
|
let outbound_to_inbound = copy(&mut ro, &mut wi);
|
||||||
|
|
||||||
let (bytes_tx, bytes_rx) = try_join(inbound_to_outbound, outbound_to_inbound).await?;
|
let (bytes_tx, bytes_rx) =
|
||||||
|
try_join(inbound_to_outbound, outbound_to_inbound).await?;
|
||||||
|
|
||||||
debug!("Bytes read: {:?} write: {:?}", bytes_tx, bytes_rx);
|
debug!("Bytes read: {:?} write: {:?}", bytes_tx, bytes_rx);
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
error!("Reached unknown protocol: {:?}", custom.protocol);
|
error!("Reached unknown protocol: {:?}", custom.protocol);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
|
||||||
};
|
};
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -93,8 +93,7 @@ async fn process(
|
|||||||
let bytes_tx = inbound_to_inbound.await;
|
let bytes_tx = inbound_to_inbound.await;
|
||||||
debug!("Bytes read: {:?}", bytes_tx);
|
debug!("Bytes read: {:?}", bytes_tx);
|
||||||
}
|
}
|
||||||
Upstream::Custom(custom) => {
|
Upstream::Custom(custom) => match custom.protocol.as_ref() {
|
||||||
match custom.protocol.as_ref() {
|
|
||||||
"tcp" => {
|
"tcp" => {
|
||||||
let outbound = TcpStream::connect(custom.addr.clone()).await?;
|
let outbound = TcpStream::connect(custom.addr.clone()).await?;
|
||||||
|
|
||||||
@ -104,15 +103,15 @@ async fn process(
|
|||||||
let inbound_to_outbound = copy(&mut ri, &mut wo);
|
let inbound_to_outbound = copy(&mut ri, &mut wo);
|
||||||
let outbound_to_inbound = copy(&mut ro, &mut wi);
|
let outbound_to_inbound = copy(&mut ro, &mut wi);
|
||||||
|
|
||||||
let (bytes_tx, bytes_rx) = try_join(inbound_to_outbound, outbound_to_inbound).await?;
|
let (bytes_tx, bytes_rx) =
|
||||||
|
try_join(inbound_to_outbound, outbound_to_inbound).await?;
|
||||||
|
|
||||||
debug!("Bytes read: {:?} write: {:?}", bytes_tx, bytes_rx);
|
debug!("Bytes read: {:?} write: {:?}", bytes_tx, bytes_rx);
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
error!("Reached unknown protocol: {:?}", custom.protocol);
|
error!("Reached unknown protocol: {:?}", custom.protocol);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
|
||||||
};
|
};
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user