mirror of
https://github.com/bytedream/docker4ssh.git
synced 2025-05-12 13:45:10 +02:00
Compare commits
No commits in common. "main" and "v0.1.1" have entirely different histories.
15
.github/dependabot.yml
vendored
15
.github/dependabot.yml
vendored
@ -1,15 +0,0 @@
|
||||
# To get started with Dependabot version updates, you'll need to specify which
|
||||
# package ecosystems to update and where the package manifests are located.
|
||||
# Please see the documentation for all configuration options:
|
||||
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
||||
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "cargo"
|
||||
directory: "container"
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
- package-ecosystem: "gomod"
|
||||
directory: "/server"
|
||||
schedule:
|
||||
interval: "weekly"
|
4
Makefile
4
Makefile
@ -1,4 +1,4 @@
|
||||
VERSION=0.1.2
|
||||
VERSION=0.1.0
|
||||
|
||||
BUILDDIR = .
|
||||
_BUILDDIR = $(shell realpath $(BUILDDIR))/
|
||||
@ -67,8 +67,6 @@ install:
|
||||
install -Dm644 $(_BUILDDIR)profile/* -t $(DESTDIR)/etc/docker4ssh/profile/
|
||||
install -Dm644 $(_BUILDDIR)LICENSE $(DESTDIR)/etc/docker4ssh/LICENSE
|
||||
|
||||
touch $(DESTDIR)/etc/docker4ssh/docker4ssh.log && chmod 777 $(DESTDIR)/etc/docker4ssh/docker4ssh.log
|
||||
|
||||
uninstall:
|
||||
rm -rf $(DESTDIR)/etc/docker4ssh/
|
||||
rm -f $(DESTDIR)$(PREFIX)/bin/docker4ssh
|
||||
|
@ -51,7 +51,7 @@ For every install method your OS **must** be linux and docker has to be installe
|
||||
|
||||
Replace the `RELEASE` value in the following oneliner with the latest release [version](https://github.com/ByteDream/docker4ssh/releases/latest).
|
||||
```shell
|
||||
$ RELEASE=<latest version>; curl -L https://github.com/ByteDream/docker4ssh/releases/download/v$RELEASE/docker4ssh-$RELEASE.tar.gz | tar -xvzf - -C /
|
||||
$ RELEASE=<latest version> curl -L https://github.com/ByteDream/docker4ssh/releases/download/v$RELEASE/docker4ssh-$RELEASE.tar.gz | tar -xvzf - -C /
|
||||
- Building from source
|
||||
|
||||
Before start installing, make sure you have to following things ready:
|
||||
@ -104,4 +104,4 @@ For further information, visit the [wiki](https://github.com/ByteDream/docker4ss
|
||||
|
||||
## ⚖ License
|
||||
|
||||
This project is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0) - see the [LICENSE](LICENSE) file for more details.
|
||||
This project is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0) - see the [LICENSE](LICENSE) file for more details.
|
173
container/Cargo.lock
generated
173
container/Cargo.lock
generated
@ -2,6 +2,21 @@
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "addr2line"
|
||||
version = "0.17.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b"
|
||||
dependencies = [
|
||||
"gimli",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "adler"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
|
||||
|
||||
[[package]]
|
||||
name = "ansi_term"
|
||||
version = "0.11.0"
|
||||
@ -11,12 +26,6 @@ dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.66"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "216261ddc8289130e551ddcd5ce8a064710c0d064a4d2895c67151c92b5443f6"
|
||||
|
||||
[[package]]
|
||||
name = "atty"
|
||||
version = "0.2.14"
|
||||
@ -28,12 +37,39 @@ dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
|
||||
|
||||
[[package]]
|
||||
name = "backtrace"
|
||||
version = "0.3.63"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "321629d8ba6513061f26707241fa9bc89524ff1cd7a915a97ef0c62c666ce1b6"
|
||||
dependencies = [
|
||||
"addr2line",
|
||||
"cc",
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"miniz_oxide",
|
||||
"object",
|
||||
"rustc-demangle",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.72"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
@ -59,7 +95,7 @@ dependencies = [
|
||||
name = "docker4ssh"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"failure",
|
||||
"log",
|
||||
"serde",
|
||||
"serde_json",
|
||||
@ -67,6 +103,34 @@ dependencies = [
|
||||
"structopt",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "failure"
|
||||
version = "0.1.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d32e9bd16cc02eae7db7ef620b392808b89f6a5e16bb3497d159c6b92a0f4f86"
|
||||
dependencies = [
|
||||
"backtrace",
|
||||
"failure_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "failure_derive"
|
||||
version = "0.1.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"synstructure",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gimli"
|
||||
version = "0.26.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4"
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.3.3"
|
||||
@ -87,9 +151,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.2"
|
||||
version = "0.4.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "112c678d4050afce233f4f2852bb2eb519230b3cf12f33585275537d7e41578d"
|
||||
checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4"
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
@ -105,13 +169,38 @@ checksum = "fbe5e23404da5b4f555ef85ebed98fb4083e55a00c317800bc2a50ede9f3d219"
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.17"
|
||||
version = "0.4.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e"
|
||||
checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a"
|
||||
|
||||
[[package]]
|
||||
name = "miniz_oxide"
|
||||
version = "0.4.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b"
|
||||
dependencies = [
|
||||
"adler",
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "object"
|
||||
version = "0.27.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "67ac1d3f9a1d3616fd9a60c8d74296f22406a238b6a72f5cc1e6f314df4ffbf9"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-error"
|
||||
version = "1.0.4"
|
||||
@ -138,11 +227,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.39"
|
||||
version = "1.0.32"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c54b25569025b7fc9651de43004ae593a75ad88543b17178aa5e1b9c4f15f56f"
|
||||
checksum = "ba508cc11742c0dc5c1659771673afbab7a0efab23aa17e854cbab0837ed0b43"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
"unicode-xid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -154,6 +243,12 @@ dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc-demangle"
|
||||
version = "0.1.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342"
|
||||
|
||||
[[package]]
|
||||
name = "ryu"
|
||||
version = "1.0.5"
|
||||
@ -162,18 +257,18 @@ checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.147"
|
||||
version = "1.0.130"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d193d69bae983fc11a79df82342761dfbf28a99fc8d203dca4c3c1b590948965"
|
||||
checksum = "f12d06de37cf59146fbdecab66aa99f9fe4f78722e3607577a5375d66bd0c913"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.147"
|
||||
version = "1.0.130"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4f1d362ca8fc9c3e3a7484440752472d68a6caa98f1ab81d99b5dfe517cec852"
|
||||
checksum = "d7bc1a1ab1961464eae040d96713baa5a724a8152c1222492465b54322ec508b"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@ -182,9 +277,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.87"
|
||||
version = "1.0.69"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6ce777b7b150d76b9cf60d28b55f5847135a003f7d7350c6be7a773508ce7d45"
|
||||
checksum = "e466864e431129c7e0d3476b92f20458e5879919a0596c6472738d9fa2d342f8"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"ryu",
|
||||
@ -193,9 +288,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "serde_repr"
|
||||
version = "0.1.9"
|
||||
version = "0.1.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fe39d9fbb0ebf5eb2c7cb7e2a47e4f462fad1379f1166b8ae49ad9eae89a7ca"
|
||||
checksum = "98d0516900518c29efa217c298fa1f4e6c6ffc85ae29fd7f4ee48f176e1a9ed5"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@ -210,9 +305,9 @@ checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
|
||||
|
||||
[[package]]
|
||||
name = "structopt"
|
||||
version = "0.3.26"
|
||||
version = "0.3.25"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0c6b5c64445ba8094a6ab0c3cd2ad323e07171012d9c98b0b15651daf1787a10"
|
||||
checksum = "40b9788f4202aa75c240ecc9c15c65185e6a39ccdeb0fd5d008b98825464c87c"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"lazy_static",
|
||||
@ -234,13 +329,25 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.95"
|
||||
version = "1.0.81"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fbaf6116ab8924f39d52792136fb74fd60a80194cf1b1c6ffa6453eef1c3f942"
|
||||
checksum = "f2afee18b8beb5a596ecb4a2dce128c719b4ba399d34126b9e4396e3f9860966"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
"unicode-xid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "synstructure"
|
||||
version = "0.12.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"unicode-xid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -252,12 +359,6 @@ dependencies = [
|
||||
"unicode-width",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d22af068fba1eb5edcb4aea19d382b2a3deb4c8f9d475c589b6ada9e0fd493ee"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-segmentation"
|
||||
version = "1.8.0"
|
||||
@ -270,6 +371,12 @@ version = "0.1.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-xid"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
|
||||
|
||||
[[package]]
|
||||
name = "vec_map"
|
||||
version = "0.8.2"
|
||||
|
@ -12,7 +12,7 @@ name = "configure"
|
||||
path = "src/configure/main.rs"
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0"
|
||||
failure = "0.1"
|
||||
log = "0.4"
|
||||
structopt = "0.3"
|
||||
serde = { version = "1.0", features = ["derive"]}
|
||||
|
@ -1,13 +1,17 @@
|
||||
use std::process::Command;
|
||||
use std::fmt::{Debug, format};
|
||||
use std::net::TcpStream;
|
||||
use std::os::unix::process::ExitStatusExt;
|
||||
use std::process::{Command, ExitStatus};
|
||||
use std::time::SystemTime;
|
||||
use anyhow::Result;
|
||||
use log::{info, warn};
|
||||
use structopt::StructOpt;
|
||||
use structopt::clap::AppSettings;
|
||||
use crate::configure::cli::parser;
|
||||
use crate::shared::api::api::API;
|
||||
use crate::shared::api::request;
|
||||
use crate::shared::api::request::{ConfigGetResponse, ConfigNetworkMode, ConfigRunLevel};
|
||||
use crate::shared::api::request::{ConfigGetResponse, ConfigNetworkMode, ConfigPostRequest, ConfigRunLevel};
|
||||
|
||||
type Result<T> = std::result::Result<T, failure::Error>;
|
||||
|
||||
trait Execute {
|
||||
fn execute(self, api: &mut API) -> Result<()>;
|
||||
@ -20,6 +24,9 @@ trait Execute {
|
||||
settings = &[AppSettings::ArgRequiredElseHelp]
|
||||
)]
|
||||
struct Opts {
|
||||
#[structopt(short, long, global = true, help = "Verbose output")]
|
||||
verbose: bool,
|
||||
|
||||
#[structopt(subcommand)]
|
||||
commands: Option<Root>
|
||||
}
|
||||
@ -252,7 +259,7 @@ enum Root {
|
||||
pub fn cli(route: String) {
|
||||
if let Some(subcommand) = Opts::from_args().commands {
|
||||
let mut result: Result<()> = Ok(());
|
||||
let mut api = API::new(route);
|
||||
let mut api = API::new(route, String::new());
|
||||
match subcommand {
|
||||
Root::Auth(auth) => {
|
||||
if let Some(subsubcommand) = auth.commands {
|
||||
|
@ -1,3 +1,5 @@
|
||||
use std::f32::consts::E;
|
||||
use std::fmt::format;
|
||||
use crate::shared::api::request::{ConfigNetworkMode, ConfigRunLevel};
|
||||
|
||||
pub fn parse_network_mode(src: &str) -> Result<ConfigNetworkMode, String> {
|
||||
|
@ -1,13 +1,13 @@
|
||||
use std::fs;
|
||||
use std::net::TcpStream;
|
||||
use std::os::unix::net::UnixStream;
|
||||
use std::process::exit;
|
||||
use log::{LevelFilter, error};
|
||||
use log::{LevelFilter, trace, warn, info, error};
|
||||
use docker4ssh::configure::cli;
|
||||
use docker4ssh::shared::logging::init_logger;
|
||||
|
||||
fn main() {
|
||||
if init_logger(LevelFilter::Debug).is_err() {
|
||||
println!("Failed to initialize logger");
|
||||
}
|
||||
init_logger(LevelFilter::Debug);
|
||||
|
||||
match fs::read_to_string("/etc/docker4ssh") {
|
||||
Ok(route) => cli(route),
|
||||
|
@ -1,24 +1,28 @@
|
||||
use std::collections::HashMap;
|
||||
use std::io::{Read, Write};
|
||||
use std::net::TcpStream;
|
||||
use anyhow::{anyhow, bail, Result};
|
||||
use log::Level::Error;
|
||||
use serde::Deserialize;
|
||||
|
||||
pub type Result<T> = std::result::Result<T, failure::Error>;
|
||||
|
||||
pub struct API {
|
||||
route: String,
|
||||
host: String,
|
||||
}
|
||||
|
||||
impl API {
|
||||
pub const fn new(route: String) -> Self {
|
||||
pub const fn new(route: String, host: String) -> Self {
|
||||
API {
|
||||
route,
|
||||
host,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_connection(&mut self) -> Result<TcpStream> {
|
||||
match TcpStream::connect(&self.route) {
|
||||
Ok(stream) => Ok(stream),
|
||||
Err(e) => bail!("Failed to connect to {}: {}", self.route, e.to_string())
|
||||
Err(e) => Err(failure::format_err!("Failed to connect to {}: {}", self.route, e.to_string()))
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,7 +31,7 @@ impl API {
|
||||
|
||||
connection.write_all(request.as_string().as_bytes())?;
|
||||
let mut buf: String = String::new();
|
||||
connection.read_to_string(&mut buf)?;
|
||||
connection.read_to_string(&mut buf).map_err(|e| failure::err_msg(e.to_string()))?;
|
||||
Ok(APIResult::new(request, buf))
|
||||
}
|
||||
|
||||
@ -35,7 +39,7 @@ impl API {
|
||||
let result = self.request(request)?;
|
||||
if result.result_code >= 400 {
|
||||
let err: APIError = result.body()?;
|
||||
bail!("Error {}: {}", result.result_code, err.message)
|
||||
Err(failure::err_msg(format!("Error {}: {}", result.result_code, err.message)))
|
||||
} else {
|
||||
Ok(result)
|
||||
}
|
||||
@ -79,15 +83,15 @@ impl APIResult {
|
||||
}
|
||||
|
||||
pub fn body<'a, T: Deserialize<'a>>(&'a self) -> Result<T> {
|
||||
let result = serde_json::from_str(&self.result_body).map_err(|e| {
|
||||
let result: T = serde_json::from_str(&self.result_body).map_err(|e| {
|
||||
// checks if the error has a body and if so, return it
|
||||
if self.has_body() {
|
||||
let error: APIError = serde_json::from_str(&self.result_body).unwrap_or_else(|_| {
|
||||
let error: APIError = serde_json::from_str(&self.result_body).unwrap_or_else(|ee| {
|
||||
APIError{message: format!("could not deserialize response: {}", e.to_string())}
|
||||
});
|
||||
anyhow!("Failed to call '{}': {}", self.request_path, error.message)
|
||||
failure::format_err!("Failed to call '{}': {}", self.request_path, error.message)
|
||||
} else {
|
||||
anyhow!("Failed to call '{}': {}", self.request_path, e.to_string())
|
||||
failure::format_err!("Failed to call '{}': {}", self.request_path, e.to_string())
|
||||
}
|
||||
})?;
|
||||
Ok(result)
|
||||
|
@ -1,9 +1,9 @@
|
||||
use std::fmt::{Display, Formatter};
|
||||
use anyhow::Result;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::de::Unexpected::Str;
|
||||
use serde_repr::{Deserialize_repr, Serialize_repr};
|
||||
|
||||
use crate::shared::api::api::{API, Method, Request};
|
||||
use crate::shared::api::api::{API, Method, Request, Result};
|
||||
use crate::shared::api::api::Method::POST;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
|
@ -1,9 +1,9 @@
|
||||
use log::{Metadata, Record};
|
||||
use log::{info, Metadata, Record};
|
||||
|
||||
pub struct Logger;
|
||||
|
||||
impl log::Log for Logger {
|
||||
fn enabled(&self, _metadata: &Metadata) -> bool {
|
||||
fn enabled(&self, metadata: &Metadata) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
@ -13,5 +13,7 @@ impl log::Log for Logger {
|
||||
}
|
||||
}
|
||||
|
||||
fn flush(&self) {}
|
||||
fn flush(&self) {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,8 @@ pub mod logger;
|
||||
|
||||
pub use logger::Logger;
|
||||
|
||||
static LOGGER: Logger = Logger;
|
||||
|
||||
pub fn init_logger(level: LevelFilter) -> Result<(), SetLoggerError> {
|
||||
log::set_logger(&Logger).map(|()| log::set_max_level(level))
|
||||
}
|
||||
|
@ -1,22 +1,47 @@
|
||||
FROM alpine:latest as build
|
||||
FROM golang:1.17 as server
|
||||
|
||||
WORKDIR /docker4ssh
|
||||
|
||||
RUN apk add git go make openssh rustup sqlite
|
||||
COPY ["../", "."]
|
||||
|
||||
RUN rustup-init -y && \
|
||||
ln -s $HOME/.cargo/bin/cargo /usr/bin/cargo
|
||||
RUN apt update && \
|
||||
apt install make sqlite3 && \
|
||||
apt clean && \
|
||||
apt autoremove && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN git clone https://github.com/ByteDream/docker4ssh .
|
||||
RUN make BUILDDIR=build/ build-server
|
||||
|
||||
|
||||
FROM rust:1.56 as client
|
||||
|
||||
WORKDIR /docker4ssh
|
||||
|
||||
COPY ../ .
|
||||
|
||||
RUN apt update && \
|
||||
apt install make \
|
||||
|
||||
RUN make BUILDDIR=build/ build-client
|
||||
|
||||
|
||||
FROM alpine:lastest as extra
|
||||
|
||||
WORKDIR /docker4ssh
|
||||
|
||||
COPY ../ .
|
||||
|
||||
RUN apk add make
|
||||
|
||||
RUN make BUILDDIR=build/ build-extra
|
||||
|
||||
RUN mkdir build/ && \
|
||||
make BUILDDIR=build/ build && \
|
||||
rm -rf build/release/ build/x86_64-unknown-linux-musl/
|
||||
|
||||
FROM alpine:latest
|
||||
|
||||
WORKDIR /docker4ssh
|
||||
|
||||
COPY --from=build /docker4ssh/build/ ./
|
||||
COPY --from=server /docker4ssh/build/* .
|
||||
COPY --from=client /docker4ssh/build/docker4ssh .
|
||||
COPY --from=extra /docker4ssh/build/* .
|
||||
|
||||
ENTRYPOINT ./docker4ssh start
|
||||
ENTRYPOINT docker4ssh
|
||||
|
@ -1,13 +1,11 @@
|
||||
version: '3.7'
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
docker4ssh:
|
||||
build: https://raw.githubusercontent.com/ByteDream/docker4ssh/main/examples/Dockerfile
|
||||
build: .
|
||||
ports:
|
||||
- "2222:2222"
|
||||
- "8642:8642"
|
||||
volumes:
|
||||
- type: bind
|
||||
source: /var/run/docker.sock
|
||||
target: /var/run/docker.sock
|
||||
- "./docker4ssh.log.log:/docker4ssh/docker4ssh.log"
|
||||
restart: unless-stopped
|
||||
container_name: docker4ssh
|
||||
|
@ -3,22 +3,25 @@ module docker4ssh
|
||||
go 1.17
|
||||
|
||||
require (
|
||||
github.com/BurntSushi/toml v1.2.1
|
||||
github.com/docker/docker v20.10.21+incompatible
|
||||
github.com/docker/go-units v0.5.0
|
||||
github.com/mattn/go-sqlite3 v2.0.3+incompatible
|
||||
github.com/BurntSushi/toml v0.4.1
|
||||
github.com/docker/docker v20.10.11+incompatible
|
||||
github.com/docker/go-units v0.4.0
|
||||
github.com/mattn/go-sqlite3 v1.14.9
|
||||
github.com/morikuni/aec v1.0.0
|
||||
github.com/spf13/cobra v1.6.1
|
||||
go.uber.org/zap v1.23.0
|
||||
golang.org/x/crypto v0.0.0-20220517005047-85d78b3ac167
|
||||
github.com/spf13/cobra v1.0.0
|
||||
go.uber.org/zap v1.19.1
|
||||
golang.org/x/crypto v0.0.0-20211202192323-5770296d904e
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/Microsoft/go-winio v0.5.2 // indirect
|
||||
github.com/docker/distribution v2.8.1+incompatible // indirect
|
||||
github.com/Microsoft/go-winio v0.4.17 // indirect
|
||||
github.com/containerd/containerd v1.5.8 // indirect
|
||||
github.com/docker/distribution v2.7.1+incompatible // indirect
|
||||
github.com/docker/go-connections v0.4.0 // indirect
|
||||
github.com/gogo/protobuf v1.3.2 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.0.1 // indirect
|
||||
github.com/golang/protobuf v1.5.0 // indirect
|
||||
github.com/gorilla/mux v1.8.0 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.0.0 // indirect
|
||||
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect
|
||||
github.com/opencontainers/go-digest v1.0.0 // indirect
|
||||
github.com/opencontainers/image-spec v1.0.2 // indirect
|
||||
@ -29,6 +32,10 @@ require (
|
||||
go.uber.org/multierr v1.6.0 // indirect
|
||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 // indirect
|
||||
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22 // indirect
|
||||
golang.org/x/time v0.0.0-20220411224347-583f2d630306 // indirect
|
||||
gotest.tools/v3 v3.2.0 // indirect
|
||||
golang.org/x/time v0.0.0-20211116232009-f0f3c7e86c11 // indirect
|
||||
google.golang.org/genproto v0.0.0-20201110150050-8816d57aaa9a // indirect
|
||||
google.golang.org/grpc v1.42.0 // indirect
|
||||
google.golang.org/protobuf v1.27.1 // indirect
|
||||
)
|
||||
|
||||
replace golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 => github.com/ByteDream/term v0.0.0-20211025115508-891a970291e6
|
||||
|
943
server/go.sum
943
server/go.sum
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user