Changeset 74
- Timestamp:
- 07/01/09 16:22:13 (4 years ago)
- Location:
- trunk/luci/libs/lucittpd
- Files:
-
- 4 modified
-
hostfiles/usr/lib/lucittpd/plugins/httpd.lua (modified) (1 diff)
-
luasrc/ttpd/server.lua (modified) (1 diff)
-
root/usr/lib/lucittpd/plugins/httpd.lua (modified) (1 diff)
-
src/main.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/luci/libs/lucittpd/hostfiles/usr/lib/lucittpd/plugins/httpd.lua
r4 r74 30 30 local chunk, err = webuci_sendfile(...) 31 31 return chunk or (err and error(err, 0)) 32 end 32 end, 33 34 _REMOTE_ADDR = webuci_REMOTE_ADDR, 35 _SERVER_ADDR = webuci_SERVER_ADDR 33 36 }) 34 37 end -
trunk/luci/libs/lucittpd/luasrc/ttpd/server.lua
r4 r74 323 323 end 324 324 325 -- set remote_addr and server_addr 326 message.env.REMOTE_ADDR = self._REMOTE_ADDR 327 message.env.SERVER_ADDR = self._SERVER_ADDR 328 325 329 -- keep-alive 326 330 if message.http_version == 1.1 then -
trunk/luci/libs/lucittpd/root/usr/lib/lucittpd/plugins/httpd.lua
r4 r74 31 31 local chunk, err = webuci_sendfile(...) 32 32 return chunk or (err and error(err, 0)) 33 end 33 end, 34 35 _REMOTE_ADDR = webuci_REMOTE_ADDR, 36 _SERVER_ADDR = webuci_SERVER_ADDR 34 37 }) 35 38 end -
trunk/luci/libs/lucittpd/src/main.c
r4 r74 212 212 } 213 213 214 static void run_luci(int sockfd) 215 { 214 static void run_luci(int sockfd, char *remote_addr, char *server_addr) 215 { 216 lua_pushstring(ctx.L, remote_addr); 217 lua_setfield(ctx.L, LUA_GLOBALSINDEX, "webuci_REMOTE_ADDR"); 218 219 lua_pushstring(ctx.L, server_addr); 220 lua_setfield(ctx.L, LUA_GLOBALSINDEX, "webuci_SERVER_ADDR"); 221 216 222 lua_pushinteger(ctx.L, sockfd); 217 223 lua_pushcclosure(ctx.L, webuci_read, 1); … … 245 251 { 246 252 int sockfd, new_fd; 247 struct sockaddr_storage their_addr;248 253 socklen_t sin_size; 249 254 int yes = 1; 250 struct sockaddr_in myaddr; 255 struct sockaddr_in myaddr, local_addr, their_addr; 256 char local_ip[INET6_ADDRSTRLEN+1], remote_ip[INET6_ADDRSTRLEN+1]; 251 257 252 258 log_start(1); … … 308 314 continue; 309 315 } 316 memset(remote_ip, 0, sizeof remote_ip); 317 inet_ntop(their_addr.sin_family, (void*)&their_addr.sin_addr, 318 remote_ip, sizeof remote_ip); 319 320 /* local address */ 321 memset(local_ip, 0, sizeof local_ip); 322 sin_size = sizeof local_addr; 323 getsockname(new_fd, (struct sockaddr*)&local_addr, &sin_size); 324 inet_ntop(local_addr.sin_family, (void*)&local_addr.sin_addr, 325 local_ip, sizeof local_ip); 326 310 327 311 328 /*inet_ntop(their_addr.ss_family, … … 321 338 setsockopt(new_fd, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof(timeout)); 322 339 323 run_luci(new_fd );340 run_luci(new_fd, remote_ip, local_ip); 324 341 cleanup_luci(); 325 342 close(new_fd);
