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); 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) { version(linux) {
listener = new Socket(AddressFamily.UNIX, SocketType.STREAM); listener = new Socket(AddressFamily.UNIX, SocketType.STREAM);
string filename = "\0" ~ host["abstract:".length .. $]; 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)); listener.bind(new UnixAddress(filename));
tcp = false; tcp = false;
} else { } else {

22
http2.d
View File

@ -36,6 +36,11 @@ version(arsd_http_winhttp_implementation) {
pragma(lib, "winhttp") pragma(lib, "winhttp")
import core.sys.windows.winhttp; import core.sys.windows.winhttp;
// FIXME: alter the dub package file too // 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; private string unixSocketPath = null;
/// Indicates it should be accessed through a unix socket instead of regular tcp /// Indicates it should be accessed through a unix socket instead of regular tcp. Returns new version without modifying this object.
void viaUnixSocket(string path) { Uri viaUnixSocket(string path) const {
unixSocketPath = path; 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) version(linux)
void viaAbstractSocket(string path) { Uri viaAbstractSocket(string path) const {
unixSocketPath = "\0" ~ path; Uri copy = this;
copy.unixSocketPath = "\0" ~ path;
return copy;
} }
private void reparse(string uri) { private void reparse(string uri) {
@ -860,6 +869,7 @@ class HttpRequest {
socket = new Socket(family(unixSocketPath), SocketType.STREAM); socket = new Socket(family(unixSocketPath), SocketType.STREAM);
if(unixSocketPath) { if(unixSocketPath) {
import std.stdio; writeln(cast(ubyte[]) unixSocketPath);
socket.connect(new UnixAddress(unixSocketPath)); socket.connect(new UnixAddress(unixSocketPath));
} else { } else {
// FIXME: i should prolly do ipv6 if available too. // FIXME: i should prolly do ipv6 if available too.

View File

@ -1977,7 +1977,7 @@ class SimpleWindow : CapableOfHandlingNativeEvent, CapableOfBeingDrawnUpon {
XChangeProperty( XChangeProperty(
display, display,
impl.window, impl.window,
GetAtom!"_NET_WM_ICON"(display), GetAtom!("_NET_WM_ICON", true)(display),
GetAtom!"CARDINAL"(display), GetAtom!"CARDINAL"(display),
32 /* bits */, 32 /* bits */,
0 /*PropModeReplace*/, 0 /*PropModeReplace*/,
@ -9367,6 +9367,14 @@ version(X11) {
if(!xshmQueryCompleted) { if(!xshmQueryCompleted) {
int i1, i2, i3; int i1, i2, i3;
xshmQueryCompleted = true; 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; _xshmAvailable = XQueryExtension(XDisplayConnection.get(), "MIT-SHM", &i1, &i2, &i3) != 0;
} }
return _xshmAvailable; return _xshmAvailable;
@ -14294,6 +14302,7 @@ void demandAttention(Window window, bool needs = true) {
/// X-specific /// X-specific
TrueColorImage getWindowNetWmIcon(Window window) { TrueColorImage getWindowNetWmIcon(Window window) {
try {
auto display = XDisplayConnection.get; auto display = XDisplayConnection.get;
auto data = getX11PropertyData (window, GetAtom!"_NET_WM_ICON"(display), XA_CARDINAL); auto data = getX11PropertyData (window, GetAtom!"_NET_WM_ICON"(display), XA_CARDINAL);
@ -14336,9 +14345,12 @@ TrueColorImage getWindowNetWmIcon(Window window) {
} }
return null; return null;
} catch(Exception e) {
return null;
}
} }
} } /* UsingSimpledisplayX11 */
void loadBinNameToWindowClassName () { void loadBinNameToWindowClassName () {

View File

@ -63,7 +63,7 @@
module arsd.terminal; module arsd.terminal;
// FIXME: needs to support VT output on Windows too in certain situations // 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) $(H3 Get Line)