Kaynağa Gözat

Duktape: Add integer connection properties

bel 9 yıl önce
ebeveyn
işleme
f3fe12c519
1 değiştirilmiş dosya ile 6 ekleme ve 0 silme
  1. 6 0
      src/mod_duktape.inl

+ 6 - 0
src/mod_duktape.inl

@@ -155,6 +155,12 @@ mg_exec_duktape_script(struct mg_connection *conn, const char *path)
 	duk_push_string(ctx, conn->request_info.remote_addr);
 	duk_push_string(ctx, conn->request_info.remote_addr);
 	duk_put_prop_string(ctx, -2, "remote_addr");
 	duk_put_prop_string(ctx, -2, "remote_addr");
 
 
+	duk_push_int(ctx, conn->request_info.remote_port);
+	duk_put_prop_string(ctx, -2, "remote_port");
+
+	duk_push_int(ctx, ntohs(conn->client.lsa.sin.sin_port));
+	duk_put_prop_string(ctx, -2, "server_port");
+
 	duk_put_prop_string(ctx, -2, "conn"); /* call the table "conn" */
 	duk_put_prop_string(ctx, -2, "conn"); /* call the table "conn" */
 
 
 	duk_push_global_stash(ctx);
 	duk_push_global_stash(ctx);