feat: add default paths and rename dfdaemon to client (#8)

Signed-off-by: Gaius <gaius.qi@gmail.com>
This commit is contained in:
Gaius 2023-04-12 18:43:20 +08:00 committed by GitHub
parent 89c6be8285
commit 93b616004a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 360 additions and 50 deletions

View File

@ -1,8 +1,7 @@
--- ---
name: Bug Report name: Bug Report
about: Report a bug for dfdaemon about: Report a bug for client
labels: bug labels: bug
--- ---
### Bug report: ### Bug report:
@ -19,7 +18,7 @@ labels: bug
### Environment: ### Environment:
- Dfdaemon version: - Client version:
- OS: - OS:
- Kernel (e.g. `uname -a`): - Kernel (e.g. `uname -a`):
- Others: - Others:

View File

@ -1,5 +1,4 @@
--- ---
name: Custom issue template name: Custom issue template
about: Custom issue template for dfdaemon about: Custom issue template for client
--- ---

View File

@ -1,6 +1,6 @@
--- ---
name: Feature Request name: Feature Request
about: Request a new feature for dfdameon about: Request a new feature for client
labels: enhancement labels: enhancement
--- ---

View File

@ -18,8 +18,6 @@ jobs:
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v3 uses: actions/checkout@v3
with:
submodules: recursive
- name: Install stable toolchain - name: Install stable toolchain
uses: actions-rs/toolchain@v1 uses: actions-rs/toolchain@v1

View File

@ -14,8 +14,6 @@ jobs:
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v3 uses: actions/checkout@v3
with:
submodules: recursive
- name: Install stable toolchain - name: Install stable toolchain
uses: actions-rs/toolchain@v1 uses: actions-rs/toolchain@v1

2
.gitignore vendored
View File

@ -4,7 +4,7 @@
*.dll *.dll
*.so *.so
*.dylib *.dylib
bin/ /bin/
# Test binary, built with `go test -c` # Test binary, built with `go test -c`
*.test *.test

View File

@ -1,6 +1,6 @@
# Contributing to Dfdaemon # Contributing to Dragonfly Client
It is warmly welcomed if you have the interest to hack on dfdaemon. It is warmly welcomed if you have the interest to hack on client.
First, we encourage this kind of willingness very much. First, we encourage this kind of willingness very much.
And here is a list of contributing guide for you. And here is a list of contributing guide for you.
@ -15,19 +15,19 @@ And here is a list of contributing guide for you.
Security issues are always treated seriously. Security issues are always treated seriously.
As our usual principle, we discourage anyone to spread security issues. As our usual principle, we discourage anyone to spread security issues.
If you find a security issue of dfdaemon, please do not discuss it in If you find a security issue of client, please do not discuss it in
public and even do not open a public issue. public and even do not open a public issue.
Instead, we encourage you to send us a private email to Instead, we encourage you to send us a private email to
[dragonfly-developers@googlegroups.com](mailto:dragonfly-developers@googlegroups.com) to report this. [dragonfly-developers@googlegroups.com](mailto:dragonfly-developers@googlegroups.com) to report this.
## Reporting general issues ## Reporting general issues
To be honest, we regard every user of dfdaemon as a very kind contributor. To be honest, we regard every user of client as a very kind contributor.
After experiencing dfdaemon, you may have some feedback for the project. After experiencing client, you may have some feedback for the project.
Then feel free to open an issue via Then feel free to open an issue via
[NEW ISSUE](https://github.com/dragonflyoss/dfdaemon/issues/new). [NEW ISSUE](https://github.com/dragonflyoss/client/issues/new).
Since we collaborate project dfdaemon in a distributed way, Since we collaborate project client in a distributed way,
we appreciate **WELL-WRITTEN**, **DETAILED**, **EXPLICIT** issue reports. we appreciate **WELL-WRITTEN**, **DETAILED**, **EXPLICIT** issue reports.
To make the communication more efficient, we wish everyone could To make the communication more efficient, we wish everyone could
search if your issue is an existing one in the searching list. search if your issue is an existing one in the searching list.
@ -60,8 +60,8 @@ network locations, private business data and so on.
## Code and doc contribution ## Code and doc contribution
Every action to make project dfdaemon better is encouraged. Every action to make project client better is encouraged.
On GitHub, every improvement for dfdaemon could be On GitHub, every improvement for client could be
via a PR (short for pull request). via a PR (short for pull request).
- If you find a typo, try to fix it! - If you find a typo, try to fix it!
@ -94,27 +94,27 @@ To put forward a PR, we assume you have registered
a GitHub ID. Then you could finish a GitHub ID. Then you could finish
the preparation in the following steps: the preparation in the following steps:
1. **FORK** dfdaemon to your repository. 1. **FORK** client to your repository.
To make this work, you just need to click the button Fork To make this work, you just need to click the button Fork
in right-left of [dragonflyoss/dfdaemon](https://github.com/dragonflyoss/dfdaemon) in right-left of [dragonflyoss/client](https://github.com/dragonflyoss/client)
main page. Then you will end up with your repository in main page. Then you will end up with your repository in
`https://github.com/<your-username>/dfdaemon`, `https://github.com/<your-username>/client`,
in which `your-username` is your GitHub username. in which `your-username` is your GitHub username.
1. **CLONE** your own repository to develop locally. 1. **CLONE** your own repository to develop locally.
Use `git clone https://github.com/<your-username>/dfdaemon.git` Use `git clone https://github.com/<your-username>/client.git`
to clone repository to your local machine. to clone repository to your local machine.
Then you can create new branches to finish the change you wish to make. Then you can create new branches to finish the change you wish to make.
1. **Set Remote** upstream to be 1. **Set Remote** upstream to be
`https://github.com/dragonflyoss/dfdaemon.git` `https://github.com/dragonflyoss/client.git`
using the following two commands: using the following two commands:
```bash ```bash
git remote add upstream https://github.com/dragonflyoss/dfdaemon.git git remote add upstream https://github.com/dragonflyoss/client.git
git remote set-url --push upstream no-pushing git remote set-url --push upstream no-pushing
``` ```
@ -122,9 +122,9 @@ With this remote setting, you can check your git remote configuration like this:
```bash ```bash
$ git remote -v $ git remote -v
origin https://github.com/<your-username>/dfdaemon.git (fetch) origin https://github.com/<your-username>/client.git (fetch)
origin https://github.com/<your-username>/dfdaemon.git (push) origin https://github.com/<your-username>/client.git (push)
upstream https://github.com/dragonflyoss/dfdaemon.git (fetch) upstream https://github.com/dragonflyoss/client.git (fetch)
upstream no-pushing (push) upstream no-pushing (push)
``` ```
@ -135,7 +135,7 @@ Adding this, we can easily synchronize local branches with upstream branches.
Update local working directory: Update local working directory:
```bash ```bash
cd dfdaemon cd client
git fetch upstream git fetch upstream
git checkout main git checkout main
git rebase upstream/main git rebase upstream/main
@ -152,13 +152,13 @@ Make any change on the `new-branch` then build and test your codes.
### Branch Definition ### Branch Definition
Right now we assume every contribution via pull Right now we assume every contribution via pull
request is for [branch main](https://github.com/dragonflyoss/dfdaemon/tree/main) request is for [branch main](https://github.com/dragonflyoss/client/tree/main)
in dfdaemon. Before contributing, in client. Before contributing,
be aware of branch definition would help a lot. be aware of branch definition would help a lot.
As a contributor, keep in mind again that every As a contributor, keep in mind again that every
contribution via pull request is for branch main. contribution via pull request is for branch main.
While in project dfdaemon, there are several other branches, While in project client, there are several other branches,
we generally call them rc branches, release branches and backport branches. we generally call them rc branches, release branches and backport branches.
Before officially releasing a version, Before officially releasing a version,
@ -176,7 +176,7 @@ MAJOR.MINOR.PATCH of [SemVer](http://semver.org/).
### Commit Rules ### Commit Rules
Actually in dfdaemon, we take two rules seriously when committing: Actually in client, we take two rules seriously when committing:
- [Commit Message](#commit-message) - [Commit Message](#commit-message)
- [Commit Content](#commit-content) - [Commit Content](#commit-content)
@ -223,7 +223,7 @@ we do take more emphasis on code review.
### PR Description ### PR Description
PR is the only way to make change to dfdaemon project files. PR is the only way to make change to client project files.
To help reviewers better get your purpose, To help reviewers better get your purpose,
PR description could not be too detailed. PR description could not be too detailed.
We encourage contributors to follow the We encourage contributors to follow the
@ -231,8 +231,8 @@ We encourage contributors to follow the
## Engage to help anything ## Engage to help anything
We choose GitHub as the primary place for dfdaemon to We choose GitHub as the primary place for client to
collaborate. So the latest updates of dfdaemon are always here. collaborate. So the latest updates of client are always here.
Although contributions via PR is an explicit way to help, Although contributions via PR is an explicit way to help,
we still call for any other ways. we still call for any other ways.
@ -240,9 +240,9 @@ we still call for any other ways.
- Help solve other users' problems. - Help solve other users' problems.
- Help review others' PR design. - Help review others' PR design.
- Help review others' codes in PR. - Help review others' codes in PR.
- Discuss about dfdaemon to make things clearer. - Discuss about client to make things clearer.
- Advocate dfdaemon technology beyond GitHub. - Advocate client technology beyond GitHub.
- Write blogs on dfdaemon and so on. - Write blogs on client and so on.
In a word, **ANY HELP IS CONTRIBUTION.** In a word, **ANY HELP IS CONTRIBUTION.**
@ -251,5 +251,5 @@ In a word, **ANY HELP IS CONTRIBUTION.**
You can do it in either of two ways: You can do it in either of two ways:
- Submit a PR in the - Submit a PR in the
[dragonflyoss/dfdaemon](https://github.com/dragonflyoss/dfdaemon) repo. [dragonflyoss/client](https://github.com/dragonflyoss/client) repo.
- Contact with the community's [maintainers](MAINTAINERS.md) offline. - Contact with the community's [maintainers](MAINTAINERS.md) offline.

View File

@ -1,13 +1,27 @@
[package] [package]
name = "dfdaemon" name = "client"
version = "1.0.0" version = "1.0.0"
authors = ["The Dragonfly Developers"] authors = ["The Dragonfly Developers"]
homepage = "https://d7y.io/" homepage = "https://d7y.io/"
repository = "https://github.com/dragonflyoss/dfdaemon.git" repository = "https://github.com/dragonflyoss/client.git"
description = "Dragonfly client written in Rust" description = "Dragonfly client written in Rust"
keywords = ["dragonfly", "d7y", "dfdaemon", "dfget","p2p", "container", "docker-image"] keywords = ["dragonfly", "d7y", "client", "dfdaemon", "dfget", "dfstore", "p2p", "container", "docker-image"]
license = "Apache-2.0" license = "Apache-2.0"
readme = "README.md" readme = "README.md"
edition = "2021" edition = "2021"
[[bin]]
name = "dfdaemon"
path = "src/bin/dfdaemon/main.rs"
[[bin]]
name = "dfget"
path = "src/bin/dfget/main.rs"
[[bin]]
name = "dfstore"
path = "src/bin/dfstore/main.rs"
[dependencies] [dependencies]
clap = { version = "4.1.13", features = [ "derive" ] }
home = "0.5.4"

View File

@ -1,9 +1,9 @@
# Dfdaemon # Dragonfly Client
[![GitHub release](https://img.shields.io/github/release/dragonflyoss/dfdaemon.svg)](https://github.com/dragonflyoss/dfdaemon/releases) [![GitHub release](https://img.shields.io/github/release/dragonflyoss/client.svg)](https://github.com/dragonflyoss/client/releases)
[![CI](https://github.com/dragonflyoss/dfdaemon/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/dragonflyoss/dfdaemon/actions/workflows/ci.yml) [![CI](https://github.com/dragonflyoss/client/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/dragonflyoss/client/actions/workflows/ci.yml)
[![Coverage](https://codecov.io/gh/dragonflyoss/dfdaemon/branch/main/graph/badge.svg)](https://codecov.io/gh/dragonflyoss/dfdameon) [![Coverage](https://codecov.io/gh/dragonflyoss/client/branch/main/graph/badge.svg)](https://codecov.io/gh/dragonflyoss/dfdameon)
[![Open Source Helpers](https://www.codetriage.com/dragonflyoss/dfdaemon/badges/users.svg)](https://www.codetriage.com/dragonflyoss/dfdaemon) [![Open Source Helpers](https://www.codetriage.com/dragonflyoss/client/badges/users.svg)](https://www.codetriage.com/dragonflyoss/client)
[![Discussions](https://img.shields.io/badge/discussions-on%20github-blue?style=flat-square)](https://github.com/dragonflyoss/Dragonfly2/discussions) [![Discussions](https://img.shields.io/badge/discussions-on%20github-blue?style=flat-square)](https://github.com/dragonflyoss/Dragonfly2/discussions)
[![Twitter](https://img.shields.io/twitter/url?style=social&url=https%3A%2F%2Ftwitter.com%2Fdragonfly_oss)](https://twitter.com/dragonfly_oss) [![Twitter](https://img.shields.io/twitter/url?style=social&url=https%3A%2F%2Ftwitter.com%2Fdragonfly_oss)](https://twitter.com/dragonfly_oss)
[![LICENSE](https://img.shields.io/github/license/dragonflyoss/Dragonfly2.svg?style=flat-square)](https://github.com/dragonflyoss/Dragonfly2/blob/main/LICENSE) [![LICENSE](https://img.shields.io/github/license/dragonflyoss/Dragonfly2.svg?style=flat-square)](https://github.com/dragonflyoss/Dragonfly2/blob/main/LICENSE)

17
src/bin/dfdaemon/main.rs Normal file
View File

@ -0,0 +1,17 @@
/*
* Copyright 2023 The Dragonfly Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
fn main() {}

43
src/bin/dfget/main.rs Normal file
View File

@ -0,0 +1,43 @@
/*
* Copyright 2023 The Dragonfly Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
use clap::Parser;
use std::path::PathBuf;
#[derive(Debug, Parser)]
#[command(
name = "dfget",
author,
version,
about = "Dragonfly client written in Rust",
long_about = "A download client based on P2P technology in Dragonfly that can download resources of different protocols."
)]
struct Args {
#[arg(
short = 'o',
long = "output",
help = "Specify the output path of downloading file."
)]
output: PathBuf,
#[arg(short = 'c', long = "config", help = "Specify config file to use.")]
config: PathBuf,
}
fn main() {
let args = Args::parse();
print!("{:?}", args.output)
}

17
src/bin/dfstore/main.rs Normal file
View File

@ -0,0 +1,17 @@
/*
* Copyright 2023 The Dragonfly Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
fn main() {}

53
src/config/dfdaemon.rs Normal file
View File

@ -0,0 +1,53 @@
/*
* Copyright 2023 The Dragonfly Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
use crate::config::*;
use std::path::PathBuf;
// default_dfdaemon_config_path is the default config path for dfdaemon.
pub fn default_dfdaemon_config_path() -> PathBuf {
default_config_dir().join("dfdaemon.yaml")
}
// default_dfdaemon_log_dir is the default log directory for dfdaemon.
pub fn default_dfdaemon_log_dir() -> PathBuf {
default_log_dir().join("dfdaemon")
}
// default_dfdaemon_task_dir is the default tasks directory for dfdaemon.
pub fn default_dfdaemon_tasks_dir() -> PathBuf {
default_data_dir().join("dfdaemon").join("tasks")
}
// default_dfdaemon_plugin_dir is the default plugin directory for dfdaemon.
pub fn default_dfdaemon_plugin_dir() -> PathBuf {
default_plugin_dir().join("dfdaemon")
}
// default_dfdaemon_cache_dir is the default cache directory for dfdaemon.
pub fn default_dfdaemon_cache_dir() -> PathBuf {
default_cache_dir().join("dfdaemon")
}
// default_dfdaemon_unix_socket_path is the default unix socket path for dfdaemon GRPC service.
pub fn default_dfdaemon_unix_socket_path() -> PathBuf {
default_root_dir().join("dfdaemon.sock")
}
// default_dfdaemon_lock_path is the default file lock path for dfdaemon service.
pub fn default_dfdaemon_lock_path() -> PathBuf {
default_lock_dir().join("dfdaemon.lock")
}

28
src/config/dfget.rs Normal file
View File

@ -0,0 +1,28 @@
/*
* Copyright 2023 The Dragonfly Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
use crate::config::*;
use std::path::PathBuf;
// default_dfget_config_path is the default config path for dfget.
pub fn default_dfget_config_path() -> PathBuf {
default_config_dir().join("dfget.yaml")
}
// default_dfget_log_dir is the default log directory for dfget.
pub fn default_dfget_log_dir() -> PathBuf {
default_log_dir().join("dfget")
}

28
src/config/dfstore.rs Normal file
View File

@ -0,0 +1,28 @@
/*
* Copyright 2023 The Dragonfly Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
use crate::config::*;
use std::path::PathBuf;
// default_dfstore_config_path is the default config path for dfstore.
pub fn default_dfstore_config_path() -> PathBuf {
default_config_dir().join("dfstore.yaml")
}
// default_dfstore_log_dir is the default log directory for dfstore.
pub fn default_dfstore_log_dir() -> PathBuf {
default_log_dir().join("dfstore")
}

84
src/config/mod.rs Normal file
View File

@ -0,0 +1,84 @@
/*
* Copyright 2023 The Dragonfly Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
use std::path::PathBuf;
pub mod dfdaemon;
pub mod dfget;
pub mod dfstore;
// default_root_dir is the default root directory for client.
pub fn default_root_dir() -> PathBuf {
#[cfg(target_os = "linux")]
return PathBuf::from("/var/run/dragonfly/");
#[cfg(target_os = "macos")]
return home::home_dir().unwrap().join(".dragonfly");
}
// default_lock_dir is the default lock directory for client.
pub fn default_lock_dir() -> PathBuf {
#[cfg(target_os = "linux")]
return PathBuf::from("/var/lock/dragonfly/");
#[cfg(target_os = "macos")]
return home::home_dir().unwrap().join(".dragonfly");
}
// default_config_dir is the default config directory for client.
pub fn default_config_dir() -> PathBuf {
#[cfg(target_os = "linux")]
return PathBuf::from("/etc/dragonfly/");
#[cfg(target_os = "macos")]
return home::home_dir().unwrap().join(".dragonfly").join("config");
}
// default_log_dir is the default log directory for client.
pub fn default_log_dir() -> PathBuf {
#[cfg(target_os = "linux")]
return PathBuf::from("/var/log/dragonfly/");
#[cfg(target_os = "macos")]
return home::home_dir().unwrap().join(".dragonfly").join("logs");
}
// default_data_dir is the default data directory for client.
pub fn default_data_dir() -> PathBuf {
#[cfg(target_os = "linux")]
return PathBuf::from("/var/lib/dragonfly/");
#[cfg(target_os = "macos")]
return home::home_dir().unwrap().join(".dragonfly").join("data");
}
// default_plugin_dir is the default plugin directory for client.
pub fn default_plugin_dir() -> PathBuf {
#[cfg(target_os = "linux")]
return PathBuf::from("/var/lib/dragonfly/plugins/");
#[cfg(target_os = "macos")]
return home::home_dir().unwrap().join(".dragonfly").join("plugins");
}
// default_cache_dir is the default cache directory for client.
pub fn default_cache_dir() -> PathBuf {
#[cfg(target_os = "linux")]
return PathBuf::from("/var/cache/dragonfly/");
#[cfg(target_os = "macos")]
return home::home_dir().unwrap().join(".dragonfly").join("cache");
}

15
src/daemon/mod.rs Normal file
View File

@ -0,0 +1,15 @@
/*
* Copyright 2023 The Dragonfly Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

18
src/lib.rs Normal file
View File

@ -0,0 +1,18 @@
/*
* Copyright 2023 The Dragonfly Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
pub mod config;
pub mod daemon;

View File

@ -1 +0,0 @@
fn main() {}