tested unix socket stuff, workaround phobos bug

This commit is contained in:
Adam D. Ruppe 2020-01-28 22:35:54 -05:00
parent 216b1bdcfb
commit fcc8aed896
4 changed files with 68 additions and 41 deletions

7
cgi.d
View File

@ -1590,7 +1590,11 @@ class Cgi {
sendAll(ir.source, d);
}
this(ir, ir.source.remoteAddress().toString(), 80 /* FIXME */, 0, false, &rdo, null, closeConnection);
auto ira = ir.source.remoteAddress();
// that check for UnixAddress is to work around a Phobos bug
// see: https://github.com/dlang/phobos/pull/7383
this(ir, cast(UnixAddress) ira ? "unix:" : ira.toString(), 80 /* FIXME */, 0, false, &rdo, null, closeConnection);
}
/**
@ -4219,6 +4223,7 @@ class ListeningConnectionManager {
version(linux) {
listener = new Socket(AddressFamily.UNIX, SocketType.STREAM);
string filename = "\0" ~ host["abstract:".length .. $];
import std.stdio; stderr.writeln("Listening to abstract unix domain socket: ", host["abstract:".length .. $]);
listener.bind(new UnixAddress(filename));
tcp = false;
} else {

22
http2.d
View File

@ -36,6 +36,11 @@ version(arsd_http_winhttp_implementation) {
pragma(lib, "winhttp")
import core.sys.windows.winhttp;
// FIXME: alter the dub package file too
// https://docs.microsoft.com/en-us/windows/win32/api/winhttp/nf-winhttp-winhttpreaddata
// https://docs.microsoft.com/en-us/windows/win32/api/winhttp/nf-winhttp-winhttpsendrequest
// https://docs.microsoft.com/en-us/windows/win32/api/winhttp/nf-winhttp-winhttpopenrequest
// https://docs.microsoft.com/en-us/windows/win32/api/winhttp/nf-winhttp-winhttpconnect
}
@ -357,15 +362,19 @@ struct Uri {
}
private string unixSocketPath = null;
/// Indicates it should be accessed through a unix socket instead of regular tcp
void viaUnixSocket(string path) {
unixSocketPath = path;
/// Indicates it should be accessed through a unix socket instead of regular tcp. Returns new version without modifying this object.
Uri viaUnixSocket(string path) const {
Uri copy = this;
copy.unixSocketPath = path;
return copy;
}
/// Goes through a unix socket in the abstract namespace (linux only)
/// Goes through a unix socket in the abstract namespace (linux only). Returns new version without modifying this object.
version(linux)
void viaAbstractSocket(string path) {
unixSocketPath = "\0" ~ path;
Uri viaAbstractSocket(string path) const {
Uri copy = this;
copy.unixSocketPath = "\0" ~ path;
return copy;
}
private void reparse(string uri) {
@ -860,6 +869,7 @@ class HttpRequest {
socket = new Socket(family(unixSocketPath), SocketType.STREAM);
if(unixSocketPath) {
import std.stdio; writeln(cast(ubyte[]) unixSocketPath);
socket.connect(new UnixAddress(unixSocketPath));
} else {
// FIXME: i should prolly do ipv6 if available too.

View File

@ -1977,7 +1977,7 @@ class SimpleWindow : CapableOfHandlingNativeEvent, CapableOfBeingDrawnUpon {
XChangeProperty(
display,
impl.window,
GetAtom!"_NET_WM_ICON"(display),
GetAtom!("_NET_WM_ICON", true)(display),
GetAtom!"CARDINAL"(display),
32 /* bits */,
0 /*PropModeReplace*/,
@ -9367,6 +9367,14 @@ version(X11) {
if(!xshmQueryCompleted) {
int i1, i2, i3;
xshmQueryCompleted = true;
auto str = XDisplayConnection.get().display_name;
// only if we are actually on the same machine does this
// have any hope, and the query extension only asks if
// the server can in theory, not in practice.
if(str is null || str[0] != ':')
_xshmAvailable = false;
else
_xshmAvailable = XQueryExtension(XDisplayConnection.get(), "MIT-SHM", &i1, &i2, &i3) != 0;
}
return _xshmAvailable;
@ -14294,6 +14302,7 @@ void demandAttention(Window window, bool needs = true) {
/// X-specific
TrueColorImage getWindowNetWmIcon(Window window) {
try {
auto display = XDisplayConnection.get;
auto data = getX11PropertyData (window, GetAtom!"_NET_WM_ICON"(display), XA_CARDINAL);
@ -14336,9 +14345,12 @@ TrueColorImage getWindowNetWmIcon(Window window) {
}
return null;
} catch(Exception e) {
return null;
}
}
}
} /* UsingSimpledisplayX11 */
void loadBinNameToWindowClassName () {

View File

@ -63,7 +63,7 @@
module arsd.terminal;
// FIXME: needs to support VT output on Windows too in certain situations
// FIXME: paste on Windows and alt+NNNN codes in getline function
// detect VT on windows by trying to set the flag. if this succeeds, ask it for caps. if this replies with my code we good to do extended output.
/++
$(H3 Get Line)