@@ -4,7 +4,14 @@ newoption({
4
4
value = " path to garrysmod_common directory"
5
5
})
6
6
7
+ newoption ({
8
+ trigger = " whitelist" ,
9
+ description = " Enables wrapping of getaddrinfo and a whitelist file to filter valid addresses and ports" ,
10
+ value = " 0 or 1"
11
+ })
12
+
7
13
local gmcommon = _OPTIONS .gmcommon or os.getenv (" GARRYSMOD_COMMON" )
14
+ local whitelist = _OPTIONS .whitelist == " 1"
8
15
if gmcommon == nil then
9
16
error (" you didn't provide a path to your garrysmod_common (https://github.com/danielga/garrysmod_common) directory" )
10
17
end
@@ -16,6 +23,7 @@ local LUASOCKET_FOLDER = "../luasocket/src"
16
23
CreateWorkspace ({name = " socket.core" })
17
24
CreateProject ({serverside = true , manual_files = true })
18
25
files (" ../source/socket.cpp" )
26
+ if whitelist then files (" ../source/whitelist.cpp" ) end
19
27
IncludeLuaShared ()
20
28
links (" socket" )
21
29
@@ -24,6 +32,7 @@ CreateWorkspace({name = "socket.core"})
24
32
25
33
CreateProject ({serverside = false , manual_files = true })
26
34
files (" ../source/socket.cpp" )
35
+ if whitelist then files (" ../source/whitelist.cpp" ) end
27
36
IncludeLuaShared ()
28
37
links (" socket" )
29
38
@@ -52,19 +61,24 @@ CreateWorkspace({name = "socket.core"})
52
61
IncludeLuaShared ()
53
62
54
63
filter (" system:windows" )
55
- defines ( {
64
+ local windowsdefines = {
56
65
" LUASOCKET_API=__declspec(dllexport)" ,
57
- " MIME_API=__declspec(dllexport)"
58
- })
66
+ " MIME_API=__declspec(dllexport)" ,
67
+ " getaddrinfo=__wrap_getaddrinfo"
68
+ }
69
+ if whitelist then windowsdefines [# windowsdefines + 1 ] = " getaddrinfo=__wrap_getaddrinfo" end
70
+ defines (windowsdefines )
59
71
files (LUASOCKET_FOLDER .. " /wsocket.c" )
60
72
links (" ws2_32" )
61
73
62
74
filter (" system:not windows" )
63
- defines ( {
75
+ local unixdefines = {
64
76
" LUASOCKET_API=''" ,
65
77
" UNIX_API=''" ,
66
78
" MIME_API=''"
67
- })
79
+ }
80
+ if whitelist then unixdefines [# unixdefines + 1 ] = " getaddrinfo=__wrap_getaddrinfo" end
81
+ defines (unixdefines )
68
82
files (LUASOCKET_FOLDER .. " /usocket.c" )
69
83
70
84
CreateWorkspace ({name = " mime.core" })
0 commit comments