@@ -95,7 +95,7 @@ static int ngx_stream_lua_socket_receiveuntil_iterator(lua_State *L);
95
95
static ngx_int_t ngx_stream_lua_socket_compile_pattern (u_char * data , size_t len ,
96
96
ngx_stream_lua_socket_compiled_pattern_t * cp , ngx_log_t * log );
97
97
static int ngx_stream_lua_socket_cleanup_compiled_pattern (lua_State * L );
98
- static int ngx_stream_lua_req_socket (lua_State * L );
98
+ static int ngx_stream_lua_tcp_req_socket (lua_State * L );
99
99
static void ngx_stream_lua_req_socket_rev_handler (ngx_stream_session_t * s ,
100
100
ngx_stream_lua_ctx_t * ctx );
101
101
static int ngx_stream_lua_socket_tcp_getreusedtimes (lua_State * L );
@@ -193,7 +193,7 @@ enum {
193
193
static char ngx_stream_lua_req_socket_metatable_key ;
194
194
#endif
195
195
static char ngx_stream_lua_raw_req_socket_metatable_key ;
196
- static char ngx_stream_lua_tcp_socket_metatable_key ;
196
+ static char ngx_stream_lua_socket_tcp_metatable_key ;
197
197
static char ngx_stream_lua_upstream_udata_metatable_key ;
198
198
static char ngx_stream_lua_downstream_udata_metatable_key ;
199
199
static char ngx_stream_lua_pool_udata_metatable_key ;
@@ -276,8 +276,16 @@ ngx_stream_lua_inject_socket_tcp_api(ngx_log_t *log, lua_State *L)
276
276
/* }}} */
277
277
278
278
/* {{{tcp object metatable */
279
+ <<<<<<< HEAD
279
280
lua_pushlightuserdata (L , & ngx_stream_lua_tcp_socket_metatable_key );
280
281
lua_createtable (L , 0 /* narr */ , 11 /* nrec */ );
282
+ = == == ==
283
+ lua_pushlightuserdata (L , & ngx_stream_lua_skcoet_tcp_metatable_key );
284
+ lua_createtable (L , 0 /* narr */ , 12 /* nrec */ );
285
+
286
+ lua_pushcfunction (L , ngx_stream_lua_socket_tcp_bind );
287
+ lua_setfield (L , -2 , "bind" );
288
+ >>>>>>> 75 a9f4b ... udp downstream api - work in progress
281
289
282
290
lua_pushcfunction (L , ngx_stream_lua_socket_tcp_connect );
283
291
lua_setfield (L , -2 , "connect" );
@@ -364,14 +372,6 @@ ngx_stream_lua_inject_socket_tcp_api(ngx_log_t *log, lua_State *L)
364
372
}
365
373
366
374
367
- void
368
- ngx_stream_lua_inject_req_socket_api (lua_State * L )
369
- {
370
- lua_pushcfunction (L , ngx_stream_lua_req_socket );
371
- lua_setfield (L , -2 , "socket" );
372
- }
373
-
374
-
375
375
static int
376
376
ngx_stream_lua_socket_tcp (lua_State * L )
377
377
{
@@ -396,8 +396,13 @@ ngx_stream_lua_socket_tcp(lua_State *L)
396
396
ngx_stream_lua_check_context (L , ctx , NGX_STREAM_LUA_CONTEXT_CONTENT
397
397
| NGX_STREAM_LUA_CONTEXT_TIMER );
398
398
399
+ <<<<<<< HEAD
399
400
lua_createtable (L , 3 /* narr */ , 1 /* nrec */ );
400
401
lua_pushlightuserdata (L , & ngx_stream_lua_tcp_socket_metatable_key );
402
+ = == == ==
403
+ lua_createtable (L , 4 /* narr */ , 1 /* nrec */ );
404
+ lua_pushlightuserdata (L , & ngx_stream_lua_socket_tcp_metatable_key );
405
+ >>>>>>> 75 a9f4b ... udp downstream api - work in progress
401
406
lua_rawget (L , LUA_REGISTRYINDEX );
402
407
lua_setmetatable (L , -2 );
403
408
@@ -3918,14 +3923,22 @@ ngx_stream_lua_socket_cleanup_compiled_pattern(lua_State *L)
3918
3923
}
3919
3924
3920
3925
3926
+ void
3927
+ ngx_stream_lua_inject_tcp_req_socket_api (lua_State * L )
3928
+ {
3929
+ lua_pushcfunction (L , ngx_stream_lua_tcp_req_socket );
3930
+ lua_setfield (L , -2 , "socket" );
3931
+ }
3932
+
3933
+
3921
3934
static int
3922
- ngx_stream_lua_req_socket (lua_State * L )
3935
+ ngx_stream_lua_tcp_req_socket (lua_State * L )
3923
3936
{
3924
3937
int n , raw ;
3938
+ ngx_stream_session_t * s ;
3925
3939
ngx_peer_connection_t * pc ;
3926
3940
ngx_stream_lua_srv_conf_t * lscf ;
3927
3941
ngx_connection_t * c ;
3928
- ngx_stream_session_t * s ;
3929
3942
ngx_stream_lua_ctx_t * ctx ;
3930
3943
ngx_stream_lua_co_ctx_t * coctx ;
3931
3944
ngx_stream_lua_cleanup_t * cln ;
@@ -3956,6 +3969,11 @@ ngx_stream_lua_req_socket(lua_State *L)
3956
3969
3957
3970
c = s -> connection ;
3958
3971
3972
+ if (c -> type != SOCK_STREAM ) {
3973
+ return luaL_error (L , "socket api does not match connection transport" ,
3974
+ lua_gettop (L ));
3975
+ }
3976
+
3959
3977
#if !defined(nginx_version ) || nginx_version < 1003013
3960
3978
lua_pushnil (L );
3961
3979
lua_pushliteral (L , "nginx version too old" );
0 commit comments