23 lines
385 B
D
23 lines
385 B
D
module comp.ssh;
|
|
|
|
import std.process : environment;
|
|
import std.socket : Socket;
|
|
|
|
string ssh() {
|
|
string ssh = environment.get("SSH_TTY");
|
|
string username = environment.get("USER");
|
|
username = username ? username : "";
|
|
|
|
if (!ssh) {
|
|
return "";
|
|
}
|
|
|
|
auto s = new Socket();
|
|
scope (exit)
|
|
s.close();
|
|
|
|
string hostname = s.hostName;
|
|
|
|
return username ~ "@" ~ hostname;
|
|
}
|