-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.rs
More file actions
60 lines (48 loc) · 1.95 KB
/
main.rs
File metadata and controls
60 lines (48 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
use indoc::indoc;
use std::env;
use std::process::Command;
fn main() {
match env::var("GIT_DIR") {
Ok(_git_dir) => {
let args: Vec<String> = env::args().collect();
let url = &args[2];
let protocol = url.splitn(2, ':').collect::<Vec<&str>>()[0];
let remote_helper = "remote-".to_owned() + protocol;
Command::new("git")
.arg("-c")
.arg("remote.origin.proxy=socks5h://127.0.0.1:9050")
.arg(&remote_helper)
.args(args.iter().skip(1))
.spawn()
.unwrap_or_else(|_| {
panic!("Error proxying to {}", &remote_helper)
});
}
Err(_e) => {
eprintln!(
"{}",
indoc!(
"
Hi there, thanks for checking out git-remote-tor!
This is a program that is called _by git_ when you use commands
that interact with remotes over the network.
So when you call it directly like this, it does nothing (except
print this message.)
To use it, add a `tor::` prefix (without the backticks) to the
remote's url. Here are some examples:
$ git clone tor::http://3lytcgmoe2j75c6t.onion/ logit
OR
$ git remote add agentofuser tor::https://github.com/agentofuser/logit
After the remote is defined, the `tor::` is saved to `.git/config`,
so you don't need to think about it again. You can use `git pull`,
`git fetch`, etc. as you normally would.
Don't forget to have a tor daemon running !
If you find a bug or need help please let me know. More docs
and contact info are at https://agentofuser.com/git-remote-tor/.
"
)
);
std::process::exit(1)
}
}
}