Commit f928a595 authored by Liang-Heng Chen's avatar Liang-Heng Chen
Browse files

Bug 1288308 - Part 0: add Named Pipe type on Windows platform; r=bagder

MozReview-Commit-ID: It2l5BJuHiS
parent 780e21d6
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -301,6 +301,7 @@ LOCAL_INCLUDES += [
    '/docshell/base',
    '/dom/base',
    '/netwerk/protocol/http',
    '/netwerk/socket',
    '/security/pkix/include'
]

+3 −12
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
#include "nsIPrefService.h"
#include "nsIPrefBranch.h"
#include "nsThreadUtils.h"
#include "nsSOCKSIOLayer.h"
#include "nsString.h"
#include "nsNetUtil.h"
#include "nsNetCID.h"
@@ -387,16 +388,6 @@ proxy_GetBoolPref(nsIPrefBranch *aPrefBranch,
        aResult = temp;
}

static inline bool
IsHostDomainSocket(const nsACString& aHost)
{
#ifdef XP_UNIX
    return Substring(aHost, 0, 5) == "file:";
#else
    return false;
#endif // XP_UNIX
}

//----------------------------------------------------------------------------

static const int32_t PROXYCONFIG_DIRECT4X = 3;
@@ -1862,7 +1853,7 @@ nsProtocolProxyService::Resolve_Internal(nsIChannel *channel,

    if ((flags & RESOLVE_PREFER_SOCKS_PROXY) &&
        !mSOCKSProxyTarget.IsEmpty() &&
        (IsHostDomainSocket(mSOCKSProxyTarget) || mSOCKSProxyPort > 0)) {
        (IsHostLocalTarget(mSOCKSProxyTarget) || mSOCKSProxyPort > 0)) {
      host = &mSOCKSProxyTarget;
      if (mSOCKSProxyVersion == 4)
          type = kProxyType_SOCKS4;
@@ -1900,7 +1891,7 @@ nsProtocolProxyService::Resolve_Internal(nsIChannel *channel,
        port = mFTPProxyPort;
    }
    else if (!mSOCKSProxyTarget.IsEmpty() &&
        (IsHostDomainSocket(mSOCKSProxyTarget) || mSOCKSProxyPort > 0)) {
        (IsHostLocalTarget(mSOCKSProxyTarget) || mSOCKSProxyPort > 0)) {
        host = &mSOCKSProxyTarget;
        if (mSOCKSProxyVersion == 4)
            type = kProxyType_SOCKS4;
+2 −1
Original line number Diff line number Diff line
@@ -382,7 +382,8 @@ protected:
    nsCString                    mHTTPSProxyHost;
    int32_t                      mHTTPSProxyPort;

    // mSOCKSProxyTarget could be a host or a domain socket path.
    // mSOCKSProxyTarget could be a host, a domain socket path,
    // or a named-pipe name.
    nsCString                    mSOCKSProxyTarget;
    int32_t                      mSOCKSProxyPort;
    int32_t                      mSOCKSProxyVersion;
+5 −0
Original line number Diff line number Diff line
@@ -92,6 +92,11 @@ void NetAddrToPRNetAddr(const NetAddr *addr, PRNetAddr *prAddr)
    prAddr->local.family = PR_AF_LOCAL;
    memcpy(prAddr->local.path, addr->local.path, sizeof(addr->local.path));
  }
#elif defined(XP_WIN)
  else if (addr->raw.family == AF_LOCAL) {
    prAddr->local.family = PR_AF_LOCAL;
    memcpy(prAddr->local.path, addr->local.path, sizeof(addr->local.path));
  }
#endif
}

+7 −2
Original line number Diff line number Diff line
@@ -22,6 +22,10 @@
#include "winsock2.h"
#endif

#ifndef AF_LOCAL
#define AF_LOCAL 1  // used for named pipe
#endif

#define IPv6ADDR_IS_LOOPBACK(a) \
  (((a)->u32[0] == 0)     &&    \
   ((a)->u32[1] == 0)     &&    \
@@ -103,8 +107,9 @@ union NetAddr {
    IPv6Addr ip;                    /* the actual 128 bits of address */
    uint32_t scope_id;              /* set of interfaces for a scope */
  } inet6;
#if defined(XP_UNIX)
  struct {                          /* Unix domain socket address */
#if defined(XP_UNIX) || defined(XP_WIN)
  struct {                          /* Unix domain socket or
                                       Windows Named Pipes address */
    uint16_t family;                /* address family (AF_UNIX) */
    char path[104];                 /* null-terminated pathname */
  } local;
Loading