Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
f7c8f5b3
Commit
f7c8f5b3
authored
May 15, 2014
by
Hans Leidekker
Committed by
Alexandre Julliard
May 15, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jsproxy: Implement InternetGetProxyInfo.
parent
8545a971
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
748 additions
and
1 deletion
+748
-1
Makefile.in
dlls/jsproxy/Makefile.in
+3
-0
jsproxy.spec
dlls/jsproxy/jsproxy.spec
+1
-1
main.c
dlls/jsproxy/main.c
+480
-0
pac.js
dlls/jsproxy/pac.js
+244
-0
rsrc.rc
dlls/jsproxy/rsrc.rc
+20
-0
No files found.
dlls/jsproxy/Makefile.in
View file @
f7c8f5b3
MODULE
=
jsproxy.dll
MODULE
=
jsproxy.dll
IMPORTS
=
uuid oleaut32 ole32
IMPORTLIB
=
jsproxy
IMPORTLIB
=
jsproxy
C_SRCS
=
\
C_SRCS
=
\
main.c
main.c
RC_SRCS
=
rsrc.rc
dlls/jsproxy/jsproxy.spec
View file @
f7c8f5b3
...
@@ -2,4 +2,4 @@
...
@@ -2,4 +2,4 @@
@ stub InternetInitializeExAutoProxyDll
@ stub InternetInitializeExAutoProxyDll
@ stdcall InternetDeInitializeAutoProxyDll(str long)
@ stdcall InternetDeInitializeAutoProxyDll(str long)
@ stub InternetDeInitializeExAutoProxyDll
@ stub InternetDeInitializeExAutoProxyDll
@ st
ub InternetGetProxyInfo
@ st
dcall InternetGetProxyInfo(str long str long ptr ptr)
dlls/jsproxy/main.c
View file @
f7c8f5b3
...
@@ -20,12 +20,38 @@
...
@@ -20,12 +20,38 @@
#include "wine/port.h"
#include "wine/port.h"
#include <stdarg.h>
#include <stdarg.h>
#include <sys/types.h>
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#ifdef HAVE_NETDB_H
# include <netdb.h>
#endif
#if defined(__MINGW32__) || defined (_MSC_VER)
# include <ws2tcpip.h>
#else
# define closesocket close
# define ioctlsocket ioctl
#endif
#include "windef.h"
#include "windef.h"
#include "winbase.h"
#include "winbase.h"
#ifndef __MINGW32__
#define USE_WS_PREFIX
#endif
#include "winsock2.h"
#include "ws2ipdef.h"
#include "winnls.h"
#include "winnls.h"
#include "wininet.h"
#include "wininet.h"
#define COBJMACROS
#include "ole2.h"
#include "dispex.h"
#include "activscp.h"
#include "wine/debug.h"
#include "wine/debug.h"
#include "wine/unicode.h"
static
HINSTANCE
instance
;
static
HINSTANCE
instance
;
...
@@ -40,6 +66,9 @@ static CRITICAL_SECTION_DEBUG critsect_debug =
...
@@ -40,6 +66,9 @@ static CRITICAL_SECTION_DEBUG critsect_debug =
};
};
static
CRITICAL_SECTION
cs_jsproxy
=
{
&
critsect_debug
,
-
1
,
0
,
0
,
0
,
0
};
static
CRITICAL_SECTION
cs_jsproxy
=
{
&
critsect_debug
,
-
1
,
0
,
0
,
0
,
0
};
static
const
WCHAR
global_funcsW
[]
=
{
'g'
,
'l'
,
'o'
,
'b'
,
'a'
,
'l'
,
'_'
,
'f'
,
'u'
,
'n'
,
'c'
,
's'
,
0
};
static
const
WCHAR
dns_resolveW
[]
=
{
'd'
,
'n'
,
's'
,
'_'
,
'r'
,
'e'
,
's'
,
'o'
,
'l'
,
'v'
,
'e'
,
0
};
/******************************************************************
/******************************************************************
* DllMain (jsproxy.@)
* DllMain (jsproxy.@)
*/
*/
...
@@ -80,6 +109,17 @@ static inline WCHAR *strdupAW( const char *src, DWORD len )
...
@@ -80,6 +109,17 @@ static inline WCHAR *strdupAW( const char *src, DWORD len )
return
dst
;
return
dst
;
}
}
static
inline
char
*
strdupWA
(
const
WCHAR
*
src
)
{
char
*
dst
=
NULL
;
if
(
src
)
{
int
len
=
WideCharToMultiByte
(
CP_ACP
,
0
,
src
,
-
1
,
NULL
,
0
,
NULL
,
NULL
);
if
((
dst
=
heap_alloc
(
len
)))
WideCharToMultiByte
(
CP_ACP
,
0
,
src
,
-
1
,
dst
,
len
,
NULL
,
NULL
);
}
return
dst
;
}
static
struct
pac_script
static
struct
pac_script
{
{
WCHAR
*
text
;
WCHAR
*
text
;
...
@@ -155,3 +195,443 @@ BOOL WINAPI JSPROXY_InternetInitializeAutoProxyDll( DWORD version, LPSTR tmpfile
...
@@ -155,3 +195,443 @@ BOOL WINAPI JSPROXY_InternetInitializeAutoProxyDll( DWORD version, LPSTR tmpfile
LeaveCriticalSection
(
&
cs_jsproxy
);
LeaveCriticalSection
(
&
cs_jsproxy
);
return
ret
;
return
ret
;
}
}
static
HRESULT
WINAPI
dispex_QueryInterface
(
IDispatchEx
*
iface
,
REFIID
riid
,
void
**
ppv
)
{
*
ppv
=
NULL
;
if
(
IsEqualGUID
(
riid
,
&
IID_IUnknown
)
||
IsEqualGUID
(
riid
,
&
IID_IDispatch
)
||
IsEqualGUID
(
riid
,
&
IID_IDispatchEx
))
*
ppv
=
iface
;
else
return
E_NOINTERFACE
;
return
S_OK
;
}
static
ULONG
WINAPI
dispex_AddRef
(
IDispatchEx
*
iface
)
{
return
2
;
}
static
ULONG
WINAPI
dispex_Release
(
IDispatchEx
*
iface
)
{
return
1
;
}
static
HRESULT
WINAPI
dispex_GetTypeInfoCount
(
IDispatchEx
*
iface
,
UINT
*
info
)
{
return
E_NOTIMPL
;
}
static
HRESULT
WINAPI
dispex_GetTypeInfo
(
IDispatchEx
*
iface
,
UINT
info
,
LCID
lcid
,
ITypeInfo
**
type_info
)
{
return
E_NOTIMPL
;
}
static
HRESULT
WINAPI
dispex_GetIDsOfNames
(
IDispatchEx
*
iface
,
REFIID
riid
,
LPOLESTR
*
names
,
UINT
count
,
LCID
lcid
,
DISPID
*
id
)
{
return
E_NOTIMPL
;
}
static
HRESULT
WINAPI
dispex_Invoke
(
IDispatchEx
*
iface
,
DISPID
member
,
REFIID
riid
,
LCID
lcid
,
WORD
flags
,
DISPPARAMS
*
params
,
VARIANT
*
result
,
EXCEPINFO
*
excep
,
UINT
*
err
)
{
return
E_NOTIMPL
;
}
static
HRESULT
WINAPI
dispex_DeleteMemberByName
(
IDispatchEx
*
iface
,
BSTR
name
,
DWORD
flags
)
{
return
E_NOTIMPL
;
}
static
HRESULT
WINAPI
dispex_DeleteMemberByDispID
(
IDispatchEx
*
iface
,
DISPID
id
)
{
return
E_NOTIMPL
;
}
static
HRESULT
WINAPI
dispex_GetMemberProperties
(
IDispatchEx
*
iface
,
DISPID
id
,
DWORD
flags_fetch
,
DWORD
*
flags
)
{
return
E_NOTIMPL
;
}
static
HRESULT
WINAPI
dispex_GetMemberName
(
IDispatchEx
*
iface
,
DISPID
id
,
BSTR
*
name
)
{
return
E_NOTIMPL
;
}
static
HRESULT
WINAPI
dispex_GetNextDispID
(
IDispatchEx
*
iface
,
DWORD
flags
,
DISPID
id
,
DISPID
*
next
)
{
return
E_NOTIMPL
;
}
static
HRESULT
WINAPI
dispex_GetNameSpaceParent
(
IDispatchEx
*
iface
,
IUnknown
**
unk
)
{
return
E_NOTIMPL
;
}
#define DISPID_GLOBAL_DNSRESOLVE 0x1000
static
HRESULT
WINAPI
dispex_GetDispID
(
IDispatchEx
*
iface
,
BSTR
name
,
DWORD
flags
,
DISPID
*
id
)
{
if
(
!
strcmpW
(
name
,
dns_resolveW
))
{
*
id
=
DISPID_GLOBAL_DNSRESOLVE
;
return
S_OK
;
}
return
DISP_E_UNKNOWNNAME
;
}
static
char
*
get_computer_name
(
COMPUTER_NAME_FORMAT
format
)
{
char
*
ret
;
DWORD
size
=
0
;
GetComputerNameExA
(
format
,
NULL
,
&
size
);
if
(
GetLastError
()
!=
ERROR_MORE_DATA
)
return
NULL
;
if
(
!
(
ret
=
heap_alloc
(
size
)))
return
NULL
;
if
(
!
GetComputerNameExA
(
format
,
ret
,
&
size
))
{
heap_free
(
ret
);
return
NULL
;
}
return
ret
;
}
static
void
printf_addr
(
const
WCHAR
*
fmt
,
WCHAR
*
buf
,
struct
sockaddr_in
*
addr
)
{
sprintfW
(
buf
,
fmt
,
(
unsigned
int
)(
ntohl
(
addr
->
sin_addr
.
s_addr
)
>>
24
&
0xff
),
(
unsigned
int
)(
ntohl
(
addr
->
sin_addr
.
s_addr
)
>>
16
&
0xff
),
(
unsigned
int
)(
ntohl
(
addr
->
sin_addr
.
s_addr
)
>>
8
&
0xff
),
(
unsigned
int
)(
ntohl
(
addr
->
sin_addr
.
s_addr
)
&
0xff
)
);
}
static
HRESULT
dns_resolve
(
const
WCHAR
*
hostname
,
VARIANT
*
result
)
{
#ifdef HAVE_GETADDRINFO
static
const
WCHAR
fmtW
[]
=
{
'%'
,
'u'
,
'.'
,
'%'
,
'u'
,
'.'
,
'%'
,
'u'
,
'.'
,
'%'
,
'u'
,
0
};
WCHAR
addr
[
16
];
struct
addrinfo
*
ai
,
*
elem
;
char
*
hostnameA
;
int
res
;
if
(
hostname
[
0
])
hostnameA
=
strdupWA
(
hostname
);
else
hostnameA
=
get_computer_name
(
ComputerNamePhysicalDnsFullyQualified
);
if
(
!
hostnameA
)
return
E_OUTOFMEMORY
;
res
=
getaddrinfo
(
hostnameA
,
NULL
,
NULL
,
&
ai
);
heap_free
(
hostnameA
);
if
(
res
)
return
S_FALSE
;
elem
=
ai
;
while
(
elem
&&
elem
->
ai_family
!=
AF_INET
)
elem
=
elem
->
ai_next
;
if
(
!
elem
)
{
freeaddrinfo
(
ai
);
return
S_FALSE
;
}
printf_addr
(
fmtW
,
addr
,
(
struct
sockaddr_in
*
)
elem
->
ai_addr
);
freeaddrinfo
(
ai
);
V_VT
(
result
)
=
VT_BSTR
;
V_BSTR
(
result
)
=
SysAllocString
(
addr
);
return
S_OK
;
#else
FIXME
(
"getaddrinfo not found at build time
\n
"
);
return
S_FALSE
;
#endif
}
static
HRESULT
WINAPI
dispex_InvokeEx
(
IDispatchEx
*
iface
,
DISPID
id
,
LCID
lcid
,
WORD
flags
,
DISPPARAMS
*
params
,
VARIANT
*
result
,
EXCEPINFO
*
exep
,
IServiceProvider
*
caller
)
{
if
(
id
==
DISPID_GLOBAL_DNSRESOLVE
)
{
if
(
params
->
cArgs
!=
1
)
return
DISP_E_BADPARAMCOUNT
;
if
(
V_VT
(
&
params
->
rgvarg
[
0
])
!=
VT_BSTR
)
return
DISP_E_BADVARTYPE
;
return
dns_resolve
(
V_BSTR
(
&
params
->
rgvarg
[
0
]),
result
);
}
return
DISP_E_MEMBERNOTFOUND
;
}
static
const
IDispatchExVtbl
dispex_vtbl
=
{
dispex_QueryInterface
,
dispex_AddRef
,
dispex_Release
,
dispex_GetTypeInfoCount
,
dispex_GetTypeInfo
,
dispex_GetIDsOfNames
,
dispex_Invoke
,
dispex_GetDispID
,
dispex_InvokeEx
,
dispex_DeleteMemberByName
,
dispex_DeleteMemberByDispID
,
dispex_GetMemberProperties
,
dispex_GetMemberName
,
dispex_GetNextDispID
,
dispex_GetNameSpaceParent
};
static
IDispatchEx
global_dispex
=
{
&
dispex_vtbl
};
static
HRESULT
WINAPI
site_QueryInterface
(
IActiveScriptSite
*
iface
,
REFIID
riid
,
void
**
ppv
)
{
*
ppv
=
NULL
;
if
(
IsEqualGUID
(
&
IID_IUnknown
,
riid
))
*
ppv
=
iface
;
else
if
(
IsEqualGUID
(
&
IID_IActiveScriptSite
,
riid
))
*
ppv
=
iface
;
else
return
E_NOINTERFACE
;
IUnknown_AddRef
(
(
IUnknown
*
)
*
ppv
);
return
S_OK
;
}
static
ULONG
WINAPI
site_AddRef
(
IActiveScriptSite
*
iface
)
{
return
2
;
}
static
ULONG
WINAPI
site_Release
(
IActiveScriptSite
*
iface
)
{
return
1
;
}
static
HRESULT
WINAPI
site_GetLCID
(
IActiveScriptSite
*
iface
,
LCID
*
lcid
)
{
return
E_NOTIMPL
;
}
static
HRESULT
WINAPI
site_GetItemInfo
(
IActiveScriptSite
*
iface
,
LPCOLESTR
name
,
DWORD
mask
,
IUnknown
**
item
,
ITypeInfo
**
type_info
)
{
if
(
!
strcmpW
(
name
,
global_funcsW
)
&&
mask
==
SCRIPTINFO_IUNKNOWN
)
{
*
item
=
(
IUnknown
*
)
&
global_dispex
;
return
S_OK
;
}
return
E_NOTIMPL
;
}
static
HRESULT
WINAPI
site_GetDocVersionString
(
IActiveScriptSite
*
iface
,
BSTR
*
version
)
{
return
E_NOTIMPL
;
}
static
HRESULT
WINAPI
site_OnScriptTerminate
(
IActiveScriptSite
*
iface
,
const
VARIANT
*
result
,
const
EXCEPINFO
*
info
)
{
return
E_NOTIMPL
;
}
static
HRESULT
WINAPI
site_OnStateChange
(
IActiveScriptSite
*
iface
,
SCRIPTSTATE
state
)
{
return
E_NOTIMPL
;
}
static
HRESULT
WINAPI
site_OnScriptError
(
IActiveScriptSite
*
iface
,
IActiveScriptError
*
error
)
{
return
E_NOTIMPL
;
}
static
HRESULT
WINAPI
site_OnEnterScript
(
IActiveScriptSite
*
iface
)
{
return
E_NOTIMPL
;
}
static
HRESULT
WINAPI
site_OnLeaveScript
(
IActiveScriptSite
*
iface
)
{
return
E_NOTIMPL
;
}
static
const
IActiveScriptSiteVtbl
site_vtbl
=
{
site_QueryInterface
,
site_AddRef
,
site_Release
,
site_GetLCID
,
site_GetItemInfo
,
site_GetDocVersionString
,
site_OnScriptTerminate
,
site_OnStateChange
,
site_OnScriptError
,
site_OnEnterScript
,
site_OnLeaveScript
};
static
IActiveScriptSite
script_site
=
{
&
site_vtbl
};
static
BSTR
include_pac_utils
(
const
WCHAR
*
script
)
{
static
const
WCHAR
pacjsW
[]
=
{
'p'
,
'a'
,
'c'
,
'.'
,
'j'
,
's'
,
0
};
HMODULE
hmod
=
GetModuleHandleA
(
"jsproxy.dll"
);
HRSRC
rsrc
;
DWORD
size
;
const
char
*
data
;
BSTR
ret
;
int
len
;
if
(
!
(
rsrc
=
FindResourceW
(
hmod
,
pacjsW
,
(
LPCWSTR
)
40
)))
return
NULL
;
size
=
SizeofResource
(
hmod
,
rsrc
);
data
=
LoadResource
(
hmod
,
rsrc
);
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
data
,
size
,
NULL
,
0
);
if
(
!
(
ret
=
SysAllocStringLen
(
NULL
,
len
+
strlenW
(
script
)
+
1
)))
return
NULL
;
MultiByteToWideChar
(
CP_ACP
,
0
,
data
,
size
,
ret
,
len
);
strcpyW
(
ret
+
len
,
script
);
return
ret
;
}
#ifdef _WIN64
#define IActiveScriptParse_Release IActiveScriptParse64_Release
#define IActiveScriptParse_InitNew IActiveScriptParse64_InitNew
#define IActiveScriptParse_ParseScriptText IActiveScriptParse64_ParseScriptText
#else
#define IActiveScriptParse_Release IActiveScriptParse32_Release
#define IActiveScriptParse_InitNew IActiveScriptParse32_InitNew
#define IActiveScriptParse_ParseScriptText IActiveScriptParse32_ParseScriptText
#endif
static
BOOL
run_script
(
const
WCHAR
*
script
,
const
WCHAR
*
url
,
const
WCHAR
*
hostname
,
char
**
result_str
,
DWORD
*
result_len
)
{
static
const
WCHAR
jscriptW
[]
=
{
'J'
,
'S'
,
'c'
,
'r'
,
'i'
,
'p'
,
't'
,
0
};
static
const
WCHAR
findproxyW
[]
=
{
'F'
,
'i'
,
'n'
,
'd'
,
'P'
,
'r'
,
'o'
,
'x'
,
'y'
,
'F'
,
'o'
,
'r'
,
'U'
,
'R'
,
'L'
,
0
};
IActiveScriptParse
*
parser
=
NULL
;
IActiveScript
*
engine
=
NULL
;
IDispatch
*
dispatch
=
NULL
;
BOOL
ret
=
FALSE
;
CLSID
clsid
;
DISPID
dispid
;
BSTR
func
=
NULL
,
full_script
=
NULL
;
VARIANT
args
[
2
],
retval
;
DISPPARAMS
params
;
HRESULT
hr
,
init
;
init
=
CoInitialize
(
NULL
);
hr
=
CLSIDFromProgID
(
jscriptW
,
&
clsid
);
if
(
hr
!=
S_OK
)
goto
done
;
hr
=
CoCreateInstance
(
&
clsid
,
NULL
,
CLSCTX_INPROC_SERVER
|
CLSCTX_INPROC_HANDLER
,
&
IID_IActiveScript
,
(
void
**
)
&
engine
);
if
(
hr
!=
S_OK
)
goto
done
;
hr
=
IActiveScript_QueryInterface
(
engine
,
&
IID_IActiveScriptParse
,
(
void
**
)
&
parser
);
if
(
hr
!=
S_OK
)
goto
done
;
hr
=
IActiveScriptParse_InitNew
(
parser
);
if
(
hr
!=
S_OK
)
goto
done
;
hr
=
IActiveScript_SetScriptSite
(
engine
,
&
script_site
);
if
(
hr
!=
S_OK
)
goto
done
;
hr
=
IActiveScript_AddNamedItem
(
engine
,
global_funcsW
,
SCRIPTITEM_GLOBALMEMBERS
);
if
(
hr
!=
S_OK
)
goto
done
;
if
(
!
(
full_script
=
include_pac_utils
(
script
)))
goto
done
;
hr
=
IActiveScriptParse_ParseScriptText
(
parser
,
full_script
,
NULL
,
NULL
,
NULL
,
0
,
0
,
0
,
NULL
,
NULL
);
if
(
hr
!=
S_OK
)
goto
done
;
hr
=
IActiveScript_SetScriptState
(
engine
,
SCRIPTSTATE_STARTED
);
if
(
hr
!=
S_OK
)
goto
done
;
hr
=
IActiveScript_GetScriptDispatch
(
engine
,
NULL
,
&
dispatch
);
if
(
hr
!=
S_OK
)
goto
done
;
if
(
!
(
func
=
SysAllocString
(
findproxyW
)))
goto
done
;
hr
=
IDispatch_GetIDsOfNames
(
dispatch
,
&
IID_NULL
,
&
func
,
1
,
LOCALE_SYSTEM_DEFAULT
,
&
dispid
);
if
(
hr
!=
S_OK
)
goto
done
;
V_VT
(
&
args
[
0
]
)
=
VT_BSTR
;
V_BSTR
(
&
args
[
0
]
)
=
SysAllocString
(
hostname
);
V_VT
(
&
args
[
1
]
)
=
VT_BSTR
;
V_BSTR
(
&
args
[
1
]
)
=
SysAllocString
(
url
);
params
.
rgvarg
=
args
;
params
.
rgdispidNamedArgs
=
NULL
;
params
.
cArgs
=
2
;
params
.
cNamedArgs
=
0
;
hr
=
IDispatch_Invoke
(
dispatch
,
dispid
,
&
IID_NULL
,
LOCALE_SYSTEM_DEFAULT
,
DISPATCH_METHOD
,
&
params
,
&
retval
,
NULL
,
NULL
);
VariantClear
(
&
args
[
0
]
);
VariantClear
(
&
args
[
1
]
);
if
(
hr
!=
S_OK
)
{
WARN
(
"script failed 0x%08x
\n
"
,
hr
);
goto
done
;
}
if
((
*
result_str
=
strdupWA
(
V_BSTR
(
&
retval
)
)))
{
TRACE
(
"result: %s
\n
"
,
debugstr_a
(
*
result_str
)
);
*
result_len
=
strlen
(
*
result_str
)
+
1
;
ret
=
TRUE
;
}
VariantClear
(
&
retval
);
done:
SysFreeString
(
full_script
);
SysFreeString
(
func
);
if
(
dispatch
)
IDispatch_Release
(
dispatch
);
if
(
parser
)
IActiveScriptParse_Release
(
parser
);
if
(
engine
)
IActiveScript_Release
(
engine
);
if
(
SUCCEEDED
(
init
))
CoUninitialize
();
return
ret
;
}
/******************************************************************
* InternetGetProxyInfo (jsproxy.@)
*/
BOOL
WINAPI
InternetGetProxyInfo
(
LPCSTR
url
,
DWORD
len_url
,
LPCSTR
hostname
,
DWORD
len_hostname
,
LPSTR
*
proxy
,
LPDWORD
len_proxy
)
{
WCHAR
*
urlW
=
NULL
,
*
hostnameW
=
NULL
;
BOOL
ret
=
FALSE
;
TRACE
(
"%s, %u, %s, %u, %p, %p
\n
"
,
url
,
len_url
,
hostname
,
len_hostname
,
proxy
,
len_proxy
);
EnterCriticalSection
(
&
cs_jsproxy
);
if
(
!
global_script
->
text
)
goto
done
;
if
(
!
(
urlW
=
strdupAW
(
url
,
len_url
)))
goto
done
;
if
(
hostname
&&
!
(
hostnameW
=
strdupAW
(
hostname
,
len_hostname
)))
goto
done
;
TRACE
(
"%s
\n
"
,
debugstr_w
(
global_script
->
text
)
);
ret
=
run_script
(
global_script
->
text
,
urlW
,
hostnameW
,
proxy
,
len_proxy
);
done:
heap_free
(
hostnameW
);
heap_free
(
urlW
);
LeaveCriticalSection
(
&
cs_jsproxy
);
return
ret
;
}
dlls/jsproxy/pac.js
0 → 100644
View file @
f7c8f5b3
/*
* Copyright 2011 Hans Leidekker for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
* Based on nsProxyAutoConfig.js from mozilla.org.
*/
function
myIpAddress
()
{
try
{
return
dns_resolve
(
''
);
}
catch
(
e
)
{
return
'127.0.0.1'
;
}
}
function
dnsResolve
(
host
)
{
try
{
return
dns_resolve
(
host
);
}
catch
(
e
)
{
return
null
;
}
}
function
dnsDomainIs
(
host
,
domain
)
{
return
(
host
.
length
>=
domain
.
length
&&
host
.
substring
(
host
.
length
-
domain
.
length
)
==
domain
);
}
function
dnsDomainLevels
(
host
)
{
return
host
.
split
(
'.'
).
length
-
1
;
}
function
convert_addr
(
ipchars
)
{
var
bytes
=
ipchars
.
split
(
'.'
);
var
result
=
((
bytes
[
0
]
&
0xff
)
<<
24
)
|
((
bytes
[
1
]
&
0xff
)
<<
16
)
|
((
bytes
[
2
]
&
0xff
)
<<
8
)
|
(
bytes
[
3
]
&
0xff
);
return
result
;
}
function
isInNet
(
ipaddr
,
pattern
,
maskstr
)
{
var
test
=
/^
(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})
$/
.
exec
(
ipaddr
);
if
(
test
==
null
)
{
ipaddr
=
dnsResolve
(
ipaddr
);
if
(
ipaddr
==
null
)
return
false
;
}
else
if
(
test
[
1
]
>
255
||
test
[
2
]
>
255
||
test
[
3
]
>
255
||
test
[
4
]
>
255
)
{
return
false
;
// not an IP address
}
var
host
=
convert_addr
(
ipaddr
);
var
pat
=
convert_addr
(
pattern
);
var
mask
=
convert_addr
(
maskstr
);
return
((
host
&
mask
)
==
(
pat
&
mask
));
}
function
isPlainHostName
(
host
)
{
return
(
host
.
search
(
'
\\
.'
)
==
-
1
);
}
function
isResolvable
(
host
)
{
var
ip
=
dnsResolve
(
host
);
return
(
ip
!=
null
);
}
function
localHostOrDomainIs
(
host
,
hostdom
)
{
return
(
host
==
hostdom
)
||
(
hostdom
.
lastIndexOf
(
host
+
'.'
,
0
)
==
0
);
}
function
shExpMatch
(
url
,
pattern
)
{
pattern
=
pattern
.
replace
(
/
\.
/g
,
'
\\
.'
);
pattern
=
pattern
.
replace
(
/
\*
/g
,
'.*'
);
pattern
=
pattern
.
replace
(
/
\?
/g
,
'.'
);
var
newRe
=
new
RegExp
(
'^'
+
pattern
+
'$'
);
return
newRe
.
test
(
url
);
}
var
wdays
=
{
SUN
:
0
,
MON
:
1
,
TUE
:
2
,
WED
:
3
,
THU
:
4
,
FRI
:
5
,
SAT
:
6
};
var
months
=
{
JAN
:
0
,
FEB
:
1
,
MAR
:
2
,
APR
:
3
,
MAY
:
4
,
JUN
:
5
,
JUL
:
6
,
AUG
:
7
,
SEP
:
8
,
OCT
:
9
,
NOV
:
10
,
DEC
:
11
};
function
weekdayRange
()
{
function
getDay
(
weekday
)
{
if
(
weekday
in
wdays
)
{
return
wdays
[
weekday
];
}
return
-
1
;
}
var
date
=
new
Date
();
var
argc
=
arguments
.
length
;
var
wday
;
if
(
argc
<
1
)
return
false
;
if
(
arguments
[
argc
-
1
]
==
'GMT'
)
{
argc
--
;
wday
=
date
.
getUTCDay
();
}
else
{
wday
=
date
.
getDay
();
}
var
wd1
=
getDay
(
arguments
[
0
]);
var
wd2
=
(
argc
==
2
)
?
getDay
(
arguments
[
1
])
:
wd1
;
return
(
wd1
==
-
1
||
wd2
==
-
1
)
?
false
:
(
wd1
<=
wday
&&
wday
<=
wd2
);
}
function
dateRange
()
{
function
getMonth
(
name
)
{
if
(
name
in
months
)
{
return
months
[
name
];
}
return
-
1
;
}
var
date
=
new
Date
();
var
argc
=
arguments
.
length
;
if
(
argc
<
1
)
{
return
false
;
}
var
isGMT
=
(
arguments
[
argc
-
1
]
==
'GMT'
);
if
(
isGMT
)
{
argc
--
;
}
// function will work even without explicit handling of this case
if
(
argc
==
1
)
{
var
tmp
=
parseInt
(
arguments
[
0
]);
if
(
isNaN
(
tmp
))
{
return
((
isGMT
?
date
.
getUTCMonth
()
:
date
.
getMonth
())
==
getMonth
(
arguments
[
0
]));
}
else
if
(
tmp
<
32
)
{
return
((
isGMT
?
date
.
getUTCDate
()
:
date
.
getDate
())
==
tmp
);
}
else
{
return
((
isGMT
?
date
.
getUTCFullYear
()
:
date
.
getFullYear
())
==
tmp
);
}
}
var
year
=
date
.
getFullYear
();
var
date1
,
date2
;
date1
=
new
Date
(
year
,
0
,
1
,
0
,
0
,
0
);
date2
=
new
Date
(
year
,
11
,
31
,
23
,
59
,
59
);
var
adjustMonth
=
false
;
for
(
var
i
=
0
;
i
<
(
argc
>>
1
);
i
++
)
{
var
tmp
=
parseInt
(
arguments
[
i
]);
if
(
isNaN
(
tmp
))
{
var
mon
=
getMonth
(
arguments
[
i
]);
date1
.
setMonth
(
mon
);
}
else
if
(
tmp
<
32
)
{
adjustMonth
=
(
argc
<=
2
);
date1
.
setDate
(
tmp
);
}
else
{
date1
.
setFullYear
(
tmp
);
}
}
for
(
var
i
=
(
argc
>>
1
);
i
<
argc
;
i
++
)
{
var
tmp
=
parseInt
(
arguments
[
i
]);
if
(
isNaN
(
tmp
))
{
var
mon
=
getMonth
(
arguments
[
i
]);
date2
.
setMonth
(
mon
);
}
else
if
(
tmp
<
32
)
{
date2
.
setDate
(
tmp
);
}
else
{
date2
.
setFullYear
(
tmp
);
}
}
if
(
adjustMonth
)
{
date1
.
setMonth
(
date
.
getMonth
());
date2
.
setMonth
(
date
.
getMonth
());
}
if
(
isGMT
)
{
var
tmp
=
date
;
tmp
.
setFullYear
(
date
.
getUTCFullYear
());
tmp
.
setMonth
(
date
.
getUTCMonth
());
tmp
.
setDate
(
date
.
getUTCDate
());
tmp
.
setHours
(
date
.
getUTCHours
());
tmp
.
setMinutes
(
date
.
getUTCMinutes
());
tmp
.
setSeconds
(
date
.
getUTCSeconds
());
date
=
tmp
;
}
return
((
date1
<=
date
)
&&
(
date
<=
date2
));
}
function
timeRange
()
{
var
argc
=
arguments
.
length
;
var
date
=
new
Date
();
var
isGMT
=
false
;
if
(
argc
<
1
)
{
return
false
;
}
if
(
arguments
[
argc
-
1
]
==
'GMT'
)
{
isGMT
=
true
;
argc
--
;
}
var
hour
=
isGMT
?
date
.
getUTCHours
()
:
date
.
getHours
();
var
date1
,
date2
;
date1
=
new
Date
();
date2
=
new
Date
();
if
(
argc
==
1
)
{
return
(
hour
==
arguments
[
0
]);
}
else
if
(
argc
==
2
)
{
return
((
arguments
[
0
]
<=
hour
)
&&
(
hour
<=
arguments
[
1
]));
}
else
{
switch
(
argc
)
{
case
6
:
date1
.
setSeconds
(
arguments
[
2
]);
date2
.
setSeconds
(
arguments
[
5
]);
case
4
:
var
middle
=
argc
>>
1
;
date1
.
setHours
(
arguments
[
0
]);
date1
.
setMinutes
(
arguments
[
1
]);
date2
.
setHours
(
arguments
[
middle
]);
date2
.
setMinutes
(
arguments
[
middle
+
1
]);
if
(
middle
==
2
)
{
date2
.
setSeconds
(
59
);
}
break
;
default
:
throw
'timeRange: bad number of arguments'
}
}
if
(
isGMT
)
{
date
.
setFullYear
(
date
.
getUTCFullYear
());
date
.
setMonth
(
date
.
getUTCMonth
());
date
.
setDate
(
date
.
getUTCDate
());
date
.
setHours
(
date
.
getUTCHours
());
date
.
setMinutes
(
date
.
getUTCMinutes
());
date
.
setSeconds
(
date
.
getUTCSeconds
());
}
return
((
date1
<=
date
)
&&
(
date
<=
date2
));
}
dlls/jsproxy/rsrc.rc
0 → 100644
View file @
f7c8f5b3
/*
* Copyright 2014 Hans Leidekker for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
/* @makedep: pac.js */
pac.js 40 "pac.js"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment