mirror of https://github.com/adamdruppe/arsd.git
tested unix socket stuff, workaround phobos bug
This commit is contained in:
parent
216b1bdcfb
commit
fcc8aed896
7
cgi.d
7
cgi.d
|
@ -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
22
http2.d
|
@ -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.
|
||||
|
|
|
@ -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,7 +9367,15 @@ version(X11) {
|
|||
if(!xshmQueryCompleted) {
|
||||
int i1, i2, i3;
|
||||
xshmQueryCompleted = true;
|
||||
_xshmAvailable = XQueryExtension(XDisplayConnection.get(), "MIT-SHM", &i1, &i2, &i3) != 0;
|
||||
|
||||
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,51 +14302,55 @@ void demandAttention(Window window, bool needs = true) {
|
|||
|
||||
/// X-specific
|
||||
TrueColorImage getWindowNetWmIcon(Window window) {
|
||||
auto display = XDisplayConnection.get;
|
||||
try {
|
||||
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);
|
||||
|
||||
if (data.length > arch_ulong.sizeof * 2) {
|
||||
auto meta = cast(arch_ulong[]) (data[0 .. arch_ulong.sizeof * 2]);
|
||||
// these are an array of rgba images that we have to convert into pixmaps ourself
|
||||
if (data.length > arch_ulong.sizeof * 2) {
|
||||
auto meta = cast(arch_ulong[]) (data[0 .. arch_ulong.sizeof * 2]);
|
||||
// these are an array of rgba images that we have to convert into pixmaps ourself
|
||||
|
||||
int width = cast(int) meta[0];
|
||||
int height = cast(int) meta[1];
|
||||
int width = cast(int) meta[0];
|
||||
int height = cast(int) meta[1];
|
||||
|
||||
auto bytes = cast(ubyte[]) (data[arch_ulong.sizeof * 2 .. $]);
|
||||
auto bytes = cast(ubyte[]) (data[arch_ulong.sizeof * 2 .. $]);
|
||||
|
||||
static if(arch_ulong.sizeof == 4) {
|
||||
bytes = bytes[0 .. width * height * 4];
|
||||
alias imageData = bytes;
|
||||
} else static if(arch_ulong.sizeof == 8) {
|
||||
bytes = bytes[0 .. width * height * 8];
|
||||
auto imageData = new ubyte[](4 * width * height);
|
||||
} else static assert(0);
|
||||
static if(arch_ulong.sizeof == 4) {
|
||||
bytes = bytes[0 .. width * height * 4];
|
||||
alias imageData = bytes;
|
||||
} else static if(arch_ulong.sizeof == 8) {
|
||||
bytes = bytes[0 .. width * height * 8];
|
||||
auto imageData = new ubyte[](4 * width * height);
|
||||
} else static assert(0);
|
||||
|
||||
|
||||
|
||||
// this returns ARGB. Remember it is little-endian so
|
||||
// we have BGRA
|
||||
// our thing uses RGBA, which in little endian, is ABGR
|
||||
for(int idx = 0, idx2 = 0; idx < bytes.length; idx += arch_ulong.sizeof, idx2 += 4) {
|
||||
auto r = bytes[idx + 2];
|
||||
auto g = bytes[idx + 1];
|
||||
auto b = bytes[idx + 0];
|
||||
auto a = bytes[idx + 3];
|
||||
// this returns ARGB. Remember it is little-endian so
|
||||
// we have BGRA
|
||||
// our thing uses RGBA, which in little endian, is ABGR
|
||||
for(int idx = 0, idx2 = 0; idx < bytes.length; idx += arch_ulong.sizeof, idx2 += 4) {
|
||||
auto r = bytes[idx + 2];
|
||||
auto g = bytes[idx + 1];
|
||||
auto b = bytes[idx + 0];
|
||||
auto a = bytes[idx + 3];
|
||||
|
||||
imageData[idx2 + 0] = r;
|
||||
imageData[idx2 + 1] = g;
|
||||
imageData[idx2 + 2] = b;
|
||||
imageData[idx2 + 3] = a;
|
||||
imageData[idx2 + 0] = r;
|
||||
imageData[idx2 + 1] = g;
|
||||
imageData[idx2 + 2] = b;
|
||||
imageData[idx2 + 3] = a;
|
||||
}
|
||||
|
||||
return new TrueColorImage(width, height, imageData);
|
||||
}
|
||||
|
||||
return new TrueColorImage(width, height, imageData);
|
||||
return null;
|
||||
} catch(Exception e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
} /* UsingSimpledisplayX11 */
|
||||
|
||||
|
||||
void loadBinNameToWindowClassName () {
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue