Skip to content

Commit 9c73f4a

Browse files
committed
lib name dns2socks_core
1 parent a23fe67 commit 9c73f4a

File tree

10 files changed

+22
-16
lines changed

10 files changed

+22
-16
lines changed

.github/workflows/publish-exe.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,17 @@ jobs:
6767
cbindgen --config cbindgen.toml -o target/dns2socks.h
6868
if [[ "${{ matrix.host_os }}" == "windows-latest" ]]; then
6969
powershell -Command "(Get-Item README.md).LastWriteTime = Get-Date"
70-
powershell Compress-Archive -Path target/${{ matrix.target }}/release/dns2socks.exe, README.md, target/dns2socks.h, target/${{ matrix.target }}/release/dns2socks.dll -DestinationPath mypubdir4/dns2socks-${{ matrix.target }}.zip
70+
powershell Compress-Archive -Path target/${{ matrix.target }}/release/dns2socks.exe, README.md, target/dns2socks.h, target/${{ matrix.target }}/release/dns2socks_core.dll -DestinationPath mypubdir4/dns2socks-${{ matrix.target }}.zip
7171
elif [[ "${{ matrix.host_os }}" == "macos-latest" ]]; then
72-
zip -j mypubdir4/dns2socks-${{ matrix.target }}.zip target/${{ matrix.target }}/release/dns2socks README.md target/dns2socks.h target/${{ matrix.target }}/release/libdns2socks.dylib
72+
zip -j mypubdir4/dns2socks-${{ matrix.target }}.zip target/${{ matrix.target }}/release/dns2socks README.md target/dns2socks.h target/${{ matrix.target }}/release/libdns2socks_core.dylib
7373
if [[ "${{ matrix.target }}" == "x86_64-apple-darwin" ]]; then
7474
./build-aarch64-apple-ios.sh
7575
zip -r mypubdir4/dns2socks-aarch64-apple-ios-xcframework.zip ./dns2socks.xcframework/
7676
./build-apple.sh
7777
zip -r mypubdir4/dns2socks-apple-xcframework.zip ./dns2socks.xcframework/
7878
fi
7979
elif [[ "${{ matrix.host_os }}" == "ubuntu-latest" ]]; then
80-
zip -j mypubdir4/dns2socks-${{ matrix.target }}.zip target/${{ matrix.target }}/release/dns2socks README.md target/dns2socks.h target/${{ matrix.target }}/release/libdns2socks.so
80+
zip -j mypubdir4/dns2socks-${{ matrix.target }}.zip target/${{ matrix.target }}/release/dns2socks README.md target/dns2socks.h target/${{ matrix.target }}/release/libdns2socks_core.so
8181
fi
8282
8383
- name: Publish

.github/workflows/rust.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ env:
88

99
jobs:
1010
build_n_test:
11+
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
1112
strategy:
1213
matrix:
1314
os: [ubuntu-latest, macos-latest, windows-latest]
@@ -29,6 +30,7 @@ jobs:
2930
run: cargo build --verbose --tests --all-features
3031

3132
build_android:
33+
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
3234
strategy:
3335
fail-fast: false
3436
runs-on: ubuntu-latest

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ description = "Convert DNS requests to SOCKS5 proxy."
99
readme = "README.md"
1010

1111
[lib]
12+
name = "dns2socks_core"
1213
crate-type = ["staticlib", "cdylib", "rlib"]
1314

1415
[dependencies]

build-aarch64-apple-ios-debug.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ EOF
2222
echo "Creating XCFramework"
2323
rm -rf ./dns2socks.xcframework
2424
xcodebuild -create-xcframework \
25-
-library ./target/aarch64-apple-ios/debug/libdns2socks.a -headers ./target/include/ \
25+
-library ./target/aarch64-apple-ios/debug/libdns2socks_core.a -headers ./target/include/ \
2626
-output ./dns2socks.xcframework

build-aarch64-apple-ios.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ EOF
2222
echo "Creating XCFramework"
2323
rm -rf ./dns2socks.xcframework
2424
xcodebuild -create-xcframework \
25-
-library ./target/aarch64-apple-ios/release/libdns2socks.a -headers ./target/include/ \
25+
-library ./target/aarch64-apple-ios/release/libdns2socks_core.a -headers ./target/include/ \
2626
-output ./dns2socks.xcframework

build-apple.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,20 @@ EOF
3636
echo "lipo..."
3737
echo "Simulator"
3838
lipo -create \
39-
target/aarch64-apple-ios-sim/release/libdns2socks.a \
40-
target/x86_64-apple-ios/release/libdns2socks.a \
39+
target/aarch64-apple-ios-sim/release/libdns2socks_core.a \
40+
target/x86_64-apple-ios/release/libdns2socks_core.a \
4141
-output ./target/libdns2socks-ios-sim.a
4242

4343
echo "MacOS"
4444
lipo -create \
45-
target/aarch64-apple-darwin/release/libdns2socks.a \
46-
target/x86_64-apple-darwin/release/libdns2socks.a \
45+
target/aarch64-apple-darwin/release/libdns2socks_core.a \
46+
target/x86_64-apple-darwin/release/libdns2socks_core.a \
4747
-output ./target/libdns2socks-macos.a
4848

4949
echo "Creating XCFramework"
5050
rm -rf ./dns2socks.xcframework
5151
xcodebuild -create-xcframework \
52-
-library ./target/aarch64-apple-ios/release/libdns2socks.a -headers ./target/include/ \
52+
-library ./target/aarch64-apple-ios/release/libdns2socks_core.a -headers ./target/include/ \
5353
-library ./target/libdns2socks-ios-sim.a -headers ./target/include/ \
5454
-library ./target/libdns2socks-macos.a -headers ./target/include/ \
5555
-output ./dns2socks.xcframework

cbindgen.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ include = [
66
"dns2socks_start",
77
"dns2socks_stop",
88
"dns2socks_set_log_callback",
9+
]
10+
exclude = [
911
"Java_com_github_shadowsocks_bg_Dns2socks_start",
10-
"Java_com_github_shadowsocks_bg_Dns2socks_stop",
12+
"Java_com_github_shadowsocks_bg_Dns2socks_stop",
1113
]
12-
exclude = []
1314

1415
[export.rename]
1516
"ArgVerbosity" = "Dns2socksVerbosity"

src/android.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![cfg(target_os = "android")]
22

3-
use crate::{ArgProxy, ArgVerbosity, Config, main_entry};
3+
use crate::{ArgProxy, ArgVerbosity, Config, LIB_NAME, main_entry};
44
use jni::{
55
JNIEnv,
66
objects::{JClass, JString},
@@ -33,7 +33,7 @@ pub unsafe extern "C" fn Java_com_github_shadowsocks_bg_Dns2socks_start(
3333
timeout: jint,
3434
) -> jint {
3535
let verbosity: ArgVerbosity = verbosity.try_into().unwrap_or_default();
36-
let filter_str = &format!("off,dns2socks={verbosity}");
36+
let filter_str = &format!("off,{LIB_NAME}={verbosity}");
3737
let filter = android_logger::FilterBuilder::new().parse(filter_str).build();
3838
android_logger::init_once(
3939
android_logger::Config::default()

src/bin/dns2socks.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
use dns2socks::{Config, main_entry};
1+
use dns2socks_core::{Config, LIB_NAME, main_entry};
22

33
#[tokio::main]
44
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
55
let config = Config::parse_args();
66

77
dotenvy::dotenv().ok();
88

9-
let default = format!("{}={:?}", module_path!(), config.verbosity);
9+
let default = format!("{}={:?},{LIB_NAME}={:?}", module_path!(), config.verbosity, config.verbosity);
1010
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or(default)).init();
1111

1212
let shutdown_token = tokio_util::sync::CancellationToken::new();

src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ pub use api::{dns2socks_start, dns2socks_stop};
2121
pub use config::{ArgProxy, ArgVerbosity, Config, ProxyType};
2222
pub use dump_logger::dns2socks_set_log_callback;
2323

24+
pub const LIB_NAME: &str = "dns2socks_core";
25+
2426
const MAX_BUFFER_SIZE: usize = 4096;
2527

2628
pub async fn main_entry(config: Config, shutdown_token: tokio_util::sync::CancellationToken) -> Result<()> {

0 commit comments

Comments
 (0)