Rizin
unix-like reverse engineering framework and cli tools
rtr_http.c File Reference

Go to the source code of this file.

Functions

static int rz_core_rtr_http_run (RzCore *core, int launch, int browse, const char *path)
 
RZ_API int rz_core_rtr_http (RzCore *core, int launch, int browse, const char *path)
 

Function Documentation

◆ rz_core_rtr_http()

RZ_API int rz_core_rtr_http ( RzCore core,
int  launch,
int  browse,
const char *  path 
)

Definition at line 491 of file rtr_http.c.

491  {
492  int ret = 0;
493  if (launch == '-') {
494  return 0;
495  }
496  if (core->http_up) {
497  eprintf("http server is already running\n");
498  return 1;
499  }
500  if (launch == '&') {
501  while (*path == '&') {
502  path++;
503  }
504  return rz_core_cmdf(core, "& Rh%s", path);
505  }
506  do {
507  ret = rz_core_rtr_http_run(core, launch, browse, path);
508  } while (ret == -2);
509  return ret;
510 }
RZ_API int rz_core_cmdf(RzCore *core, const char *fmt,...)
Definition: cmd.c:5413
static static fork const void static count static fd const char const char static newpath const char static path const char path
Definition: sflib.h:35
#define eprintf(x, y...)
Definition: rlcc.c:7
static int rz_core_rtr_http_run(RzCore *core, int launch, int browse, const char *path)
Definition: rtr_http.c:6
int http_up
Definition: rz_core.h:355

References eprintf, rz_core_t::http_up, path, rz_core_cmdf(), and rz_core_rtr_http_run().

Referenced by rz_equal_h_handler_old(), and rz_equal_H_handler_old().

◆ rz_core_rtr_http_run()

static int rz_core_rtr_http_run ( RzCore core,
int  launch,
int  browse,
const char *  path 
)
static

Definition at line 6 of file rtr_http.c.

6  {
7  RzConfig *newcfg = NULL, *origcfg = NULL;
8  char headers[128] = RZ_EMPTY;
10  char buf[32];
11  int ret = 0;
12  RzSocket *s;
14  char *dir;
15  int iport;
16  const char *host = rz_config_get(core->config, "http.bind");
17  const char *index = rz_config_get(core->config, "http.index");
18  const char *root = rz_config_get(core->config, "http.root");
19  const char *homeroot = rz_config_get(core->config, "http.homeroot");
20  const char *port = rz_config_get(core->config, "http.port");
21  const char *allow = rz_config_get(core->config, "http.allow");
22  const char *httpauthfile = rz_config_get(core->config, "http.authfile");
23  char *pfile = NULL;
24 
25  if (!rz_file_is_directory(root)) {
26  if (!rz_file_is_directory(homeroot)) {
27  eprintf("Cannot find http.root or http.homeroot\n");
28  }
29  }
30  if (!path) {
31  return false;
32  }
33  char *arg = strchr(path, ' ');
34  if (arg) {
35  path = arg + 1;
36  }
37  if (path && atoi(path)) {
38  port = path;
39  rz_config_set(core->config, "http.port", port);
40  path = NULL;
41  }
42 
43  if (!strcmp(port, "0")) {
44  rz_num_irand();
45  iport = 1024 + rz_num_rand(45256);
46  snprintf(buf, sizeof(buf), "%d", iport);
47  port = buf;
48  }
49  s = rz_socket_new(false);
50  {
51  if (host && *host) {
52  if (!strcmp(host, "::1")) {
53  s->local = true;
54  } else if (!strcmp(host, "localhost")) {
55  s->local = true;
56  } else if (!strcmp(host, "127.0.0.1")) {
57  s->local = true;
58  } else if (!strcmp(host, "local")) {
59  s->local = true;
60  rz_config_set(core->config, "http.bind", "localhost");
61  } else if (host[0] == '0' || !strcmp(host, "public")) {
62  // public
63  host = "127.0.0.1";
64  rz_config_set(core->config, "http.bind", "0.0.0.0");
65  s->local = false;
66  } else {
67  s->local = true;
68  }
69  } else {
70  s->local = true;
71  }
72  memset(&so, 0, sizeof(so));
73  }
74  if (!rz_socket_listen(s, port, NULL)) {
76  eprintf("Cannot listen on http.port\n");
77  return 1;
78  }
79 
80  if (browse == 'H') {
81  const char *browser = rz_config_get(core->config, "http.browser");
82  rz_sys_cmdf("%s http://%s:%d/%s &",
83  browser, host, atoi(port), path ? path : "");
84  }
85 
86  so.httpauth = rz_config_get_i(core->config, "http.auth");
87 
88  if (so.httpauth) {
89  if (!httpauthfile) {
91  eprintf("No user list set for HTTP Authentication\n");
92  return 1;
93  }
94 
95  pfile = rz_file_slurp(httpauthfile, NULL);
96 
97  if (pfile) {
98  so.authtokens = rz_str_split_list(pfile, "\n", 0);
99  } else {
100  rz_socket_free(s);
101  eprintf("Empty list of HTTP users\n");
102  return 1;
103  }
104 
105  so.timeout = rz_config_get_i(core->config, "http.timeout");
106  so.accept_timeout = 1;
107  }
108 
109  origcfg = core->config;
110  newcfg = rz_config_clone(core->config);
111  core->config = newcfg;
112 
113  rz_config_set(core->config, "asm.cmt.right", "false");
114 #if 0
115  // WHY
116  rz_config_set (core->config, "scr.html", "true");
117 #endif
118  rz_config_set_i(core->config, "scr.color", COLOR_MODE_DISABLED);
119  rz_config_set(core->config, "asm.bytes", "false");
120  rz_config_set(core->config, "scr.interactive", "false");
121  eprintf("Starting http server...\n");
122  eprintf("open http://%s:%d/\n", host, atoi(port));
123  eprintf("rizin -C http://%s:%d/cmd/\n", host, atoi(port));
124  core->http_up = true;
125 
126  ut64 newoff, origoff = core->offset;
127  int newblksz, origblksz = core->blocksize;
128  ut8 *newblk, *origblk = core->block;
129 
130  newblk = malloc(core->blocksize);
131  if (!newblk) {
132  rz_socket_free(s);
134  free(pfile);
135  return 1;
136  }
137  memcpy(newblk, core->block, core->blocksize);
138 
139  core->block = newblk;
140  // TODO: handle mutex lock/unlock here
141  rz_cons_break_push((RzConsBreak)rz_core_rtr_http_stop, core);
142  while (!rz_cons_is_breaked()) {
143  /* restore environment */
144  core->config = origcfg;
145  rz_config_set(origcfg, "scr.html", rz_config_get(origcfg, "scr.html"));
146  rz_config_set_i(origcfg, "scr.color", rz_config_get_i(origcfg, "scr.color"));
147  rz_config_set(origcfg, "scr.interactive", rz_config_get(origcfg, "scr.interactive"));
148  core->http_up = 0; // DAT IS NOT TRUE AT ALL.. but its the way to enable visual
149 
150  newoff = core->offset;
151  newblk = core->block;
152  newblksz = core->blocksize;
153 
154  core->offset = origoff;
155  core->block = origblk;
156  core->blocksize = origblksz;
157 
158  // backup and restore offset and blocksize
159 
160  /* this is blocking */
161  activateDieTime(core);
162 
163  void *bed = rz_cons_sleep_begin();
164  rs = rz_socket_http_accept(s, &so);
165  rz_cons_sleep_end(bed);
166 
167  origoff = core->offset;
168  origblk = core->block;
169  origblksz = core->blocksize;
170  core->offset = newoff;
171  core->block = newblk;
172  core->blocksize = newblksz;
173  /* set environment */
174  // backup and restore offset and blocksize
175  core->http_up = 1;
176  core->config = newcfg;
177  rz_config_set(newcfg, "scr.html", rz_config_get(newcfg, "scr.html"));
178  rz_config_set_i(newcfg, "scr.color", rz_config_get_i(newcfg, "scr.color"));
179  rz_config_set(newcfg, "scr.interactive", rz_config_get(newcfg, "scr.interactive"));
180 
181  if (!rs) {
182  bed = rz_cons_sleep_begin();
183  rz_sys_usleep(100);
184  rz_cons_sleep_end(bed);
185  continue;
186  }
187  if (allow && *allow) {
188  bool accepted = false;
189  const char *allows_host;
190  char *p, *peer = rz_socket_to_string(rs->s);
191  char *allows = strdup(allow);
192  // eprintf ("Firewall (%s)\n", allows);
193  int i, count = rz_str_split(allows, ',');
194  p = strchr(peer, ':');
195  if (p) {
196  *p = 0;
197  }
198  for (i = 0; i < count; i++) {
199  allows_host = rz_str_word_get0(allows, i);
200  // eprintf ("--- (%s) (%s)\n", host, peer);
201  if (!strcmp(allows_host, peer)) {
202  accepted = true;
203  break;
204  }
205  }
206  free(peer);
207  free(allows);
208  if (!accepted) {
210  continue;
211  }
212  }
213  if (!rs->method || !rs->path) {
214  http_logf(core, "Invalid http headers received from client\n");
216  continue;
217  }
218  dir = NULL;
219 
220  if (!rs->auth) {
221  rz_socket_http_response(rs, 401, "", 0, NULL);
222  }
223 
224  if (rz_config_get_i(core->config, "http.verbose")) {
225  char *peer = rz_socket_to_string(rs->s);
226  http_logf(core, "[HTTP] %s %s\n", peer, rs->path);
227  free(peer);
228  }
229  if (rz_config_get_i(core->config, "http.dirlist")) {
230  if (rz_file_is_directory(rs->path)) {
231  dir = strdup(rs->path);
232  }
233  }
234  if (rz_config_get_i(core->config, "http.cors")) {
235  strcpy(headers, "Access-Control-Allow-Origin: *\n"
236  "Access-Control-Allow-Headers: Origin, "
237  "X-Requested-With, Content-Type, Accept\n");
238  }
239  if (!strcmp(rs->method, "OPTIONS")) {
240  rz_socket_http_response(rs, 200, "", 0, headers);
241  } else if (!strcmp(rs->method, "GET")) {
242  if (!strncmp(rs->path, "/up/", 4)) {
243  if (rz_config_get_i(core->config, "http.upget")) {
244  const char *uproot = rz_config_get(core->config, "http.uproot");
245  if (!rs->path[3] || (rs->path[3] == '/' && !rs->path[4])) {
246  char *ptr = rtr_dir_files(uproot);
247  rz_socket_http_response(rs, 200, ptr, 0, headers);
248  free(ptr);
249  } else {
250  char *path = rz_file_root(uproot, rs->path + 4);
251  if (rz_file_exists(path)) {
252  size_t sz = 0;
253  char *f = rz_file_slurp(path, &sz);
254  if (f) {
255  rz_socket_http_response(rs, 200, f, (int)sz, headers);
256  free(f);
257  } else {
258  rz_socket_http_response(rs, 403, "Permission denied", 0, headers);
259  http_logf(core, "http: Cannot open '%s'\n", path);
260  }
261  } else {
262  if (dir) {
263  char *resp = rtr_dir_files(dir);
264  rz_socket_http_response(rs, 404, resp, 0, headers);
265  free(resp);
266  } else {
267  http_logf(core, "File '%s' not found\n", path);
268  rz_socket_http_response(rs, 404, "File not found\n", 0, headers);
269  }
270  }
271  free(path);
272  }
273  } else {
274  rz_socket_http_response(rs, 403, "", 0, NULL);
275  }
276  } else if (!strncmp(rs->path, "/cmd/", 5)) {
277  const bool colon = rz_config_get_i(core->config, "http.colon");
278  if (colon && rs->path[5] != ':') {
279  rz_socket_http_response(rs, 403, "Permission denied", 0, headers);
280  } else {
281  char *cmd = rs->path + 5;
282  const char *httpcmd = rz_config_get(core->config, "http.uri");
283  const char *httpref = rz_config_get(core->config, "http.referer");
284  const bool httpref_enabled = (httpref && *httpref);
285  char *refstr = NULL;
286  if (httpref_enabled) {
287  if (strstr(httpref, "http")) {
288  refstr = strdup(httpref);
289  } else {
290  refstr = rz_str_newf("http://localhost:%d/", atoi(port));
291  }
292  }
293 
294  while (*cmd == '/') {
295  cmd++;
296  }
297  if (httpref_enabled && (!rs->referer || (refstr && !strstr(rs->referer, refstr)))) {
298  rz_socket_http_response(rs, 503, "", 0, headers);
299  } else {
300  if (httpcmd && *httpcmd) {
301  int len; // do remote http query and proxy response
302  char *res, *bar = rz_str_newf("%s/%s", httpcmd, cmd);
303  bed = rz_cons_sleep_begin();
304  res = rz_socket_http_get(bar, NULL, &len);
305  rz_cons_sleep_end(bed);
306  if (res) {
307  res[len] = 0;
308  rz_cons_println(res);
309  }
310  free(bar);
311  } else {
312  char *out, *cmd = rs->path + 5;
314  rz_config_set(core->config, "scr.interactive", "false");
315 
316  if ((!strcmp(cmd, "Rh*") ||
317  !strcmp(cmd, "Rh--"))) {
318  out = NULL;
319  } else if (*cmd == ':') {
320  /* commands in /cmd/: starting with : do not show any output */
321  rz_core_cmd0(core, cmd + 1);
322  out = NULL;
323  } else {
324  out = rz_core_cmd_str_pipe(core, cmd);
325  }
326 
327  if (out) {
328  char *res = rz_str_uri_encode(out);
329  char *newheaders = rz_str_newf(
330  "Content-Type: text/plain\n%s", headers);
331  rz_socket_http_response(rs, 200, out, 0, newheaders);
332  free(out);
333  free(newheaders);
334  free(res);
335  } else {
336  rz_socket_http_response(rs, 200, "", 0, headers);
337  }
338 
339  if (!strcmp(cmd, "Rh*")) {
340  /* do stuff */
342  free(dir);
343  free(refstr);
344  ret = -2;
345  goto the_end;
346  } else if (!strcmp(cmd, "Rh--")) {
348  free(dir);
349  free(refstr);
350  ret = 0;
351  goto the_end;
352  }
353  }
354  }
355  free(refstr);
356  }
357  } else {
358  const char *root = rz_config_get(core->config, "http.root");
359  const char *homeroot = rz_config_get(core->config, "http.homeroot");
360  char *path = NULL;
361  if (!strcmp(rs->path, "/")) {
362  free(rs->path);
363  if (*index == '/') {
364  rs->path = strdup(index);
365  path = strdup(index);
366  } else {
367  rs->path = rz_str_newf("/%s", index);
368  path = rz_file_root(root, rs->path);
369  }
370  } else if (homeroot && *homeroot) {
371  char *homepath = rz_file_abspath(homeroot);
372  path = rz_file_root(homepath, rs->path);
373  free(homepath);
375  free(path);
376  path = rz_file_root(root, rs->path);
377  }
378  } else {
379  if (*index == '/') {
380  path = strdup(index);
381  } else {
382  }
383  }
384  // FD IS OK HERE
385  if (rs->path[strlen(rs->path) - 1] == '/') {
386  path = (*index == '/') ? strdup(index) : rz_str_append(path, index);
387  } else {
388  // snprintf (path, sizeof (path), "%s/%s", root, rs->path);
389  if (rz_file_is_directory(path)) {
390  char *res = rz_str_newf("Location: %s/\n%s", rs->path, headers);
391  rz_socket_http_response(rs, 302, NULL, 0, res);
393  free(path);
394  free(res);
395  RZ_FREE(dir);
396  continue;
397  }
398  }
399  if (rz_file_exists(path)) {
400  size_t sz = 0;
401  char *f = rz_file_slurp(path, &sz);
402  if (f) {
403  const char *ct = NULL;
404  if (strstr(path, ".js")) {
405  ct = "Content-Type: application/javascript\n";
406  }
407  if (strstr(path, ".css")) {
408  ct = "Content-Type: text/css\n";
409  }
410  if (strstr(path, ".html")) {
411  ct = "Content-Type: text/html\n";
412  }
413  char *hdr = rz_str_newf("%s%s", ct, headers);
414  rz_socket_http_response(rs, 200, f, (int)sz, hdr);
415  free(hdr);
416  free(f);
417  } else {
418  rz_socket_http_response(rs, 403, "Permission denied", 0, headers);
419  http_logf(core, "http: Cannot open '%s'\n", path);
420  }
421  } else {
422  if (dir) {
423  char *resp = rtr_dir_files(dir);
424  http_logf(core, "Dirlisting %s\n", dir);
425  rz_socket_http_response(rs, 404, resp, 0, headers);
426  free(resp);
427  } else {
428  http_logf(core, "File '%s' not found\n", path);
429  rz_socket_http_response(rs, 404, "File not found\n", 0, headers);
430  }
431  }
432  free(path);
433  }
434  } else if (!strcmp(rs->method, "POST")) {
435  ut8 *ret;
436  int retlen;
437  char buf[128];
438  if (rz_config_get_i(core->config, "http.upload")) {
439  ret = rz_socket_http_handle_upload(rs->data, rs->data_length, &retlen);
440  if (ret) {
441  ut64 size = rz_config_get_i(core->config, "http.maxsize");
442  if (size && retlen > size) {
443  rz_socket_http_response(rs, 403, "403 File too big\n", 0, headers);
444  } else {
445  char *filename = rz_file_root(
446  rz_config_get(core->config, "http.uproot"),
447  rs->path + 4);
448  http_logf(core, "UPLOADED '%s'\n", filename);
449  rz_file_dump(filename, ret, retlen, 0);
450  free(filename);
451  snprintf(buf, sizeof(buf),
452  "<html><body><h2>uploaded %d byte(s). Thanks</h2>\n", retlen);
453  rz_socket_http_response(rs, 200, buf, 0, headers);
454  }
455  free(ret);
456  }
457  } else {
458  rz_socket_http_response(rs, 403, "403 Forbidden\n", 0, headers);
459  }
460  } else {
461  rz_socket_http_response(rs, 404, "Invalid protocol", 0, headers);
462  }
464  free(dir);
465  }
466 the_end : {
467  int timeout = rz_config_get_i(core->config, "http.timeout");
468  const char *host = rz_config_get(core->config, "http.bind");
469  const char *port = rz_config_get(core->config, "http.port");
470  const char *cors = rz_config_get(core->config, "http.cors");
471  const char *allow = rz_config_get(core->config, "http.allow");
472  core->config = origcfg;
473  rz_config_set_i(core->config, "http.timeout", timeout);
474  rz_config_set(core->config, "http.bind", host);
475  rz_config_set(core->config, "http.port", port);
476  rz_config_set(core->config, "http.cors", cors);
477  rz_config_set(core->config, "http.allow", allow);
478 }
480  core->http_up = false;
481  free(pfile);
482  rz_socket_free(s);
483  rz_config_free(newcfg);
484  /* refresh settings - run callbacks */
485  rz_config_set(origcfg, "scr.html", rz_config_get(origcfg, "scr.html"));
486  rz_config_set_i(origcfg, "scr.color", rz_config_get_i(origcfg, "scr.color"));
487  rz_config_set(origcfg, "scr.interactive", rz_config_get(origcfg, "scr.interactive"));
488  return ret;
489 }
size_t len
Definition: 6502dis.c:15
#define rs()
lzma_index ** i
Definition: index.h:629
static bool the_end(void *p)
Definition: asm_ppc_cs.c:12
const lzma_allocator const uint8_t size_t uint8_t * out
Definition: block.h:528
RZ_API char * rz_core_cmd_str_pipe(RzCore *core, const char *cmd)
Definition: cmd.c:5438
RZ_API int rz_core_cmd0(RzCore *core, const char *cmd)
Definition: cmd.c:5428
RZ_API ut64 rz_config_get_i(RzConfig *cfg, RZ_NONNULL const char *name)
Definition: config.c:119
RZ_API RzConfigNode * rz_config_set(RzConfig *cfg, RZ_NONNULL const char *name, const char *value)
Definition: config.c:267
RZ_API RzConfig * rz_config_clone(RzConfig *cfg)
Definition: config.c:507
RZ_API RzConfigNode * rz_config_set_i(RzConfig *cfg, RZ_NONNULL const char *name, const ut64 i)
Definition: config.c:419
RZ_API RZ_BORROW const char * rz_config_get(RzConfig *cfg, RZ_NONNULL const char *name)
Definition: config.c:75
RZ_API void rz_config_free(RzConfig *cfg)
Definition: config.c:523
RZ_API void * rz_cons_sleep_begin(void)
Definition: cons.c:443
RZ_API void rz_cons_break_pop(void)
Definition: cons.c:361
RZ_API void rz_cons_break_push(RzConsBreak cb, void *user)
Definition: cons.c:357
RZ_API bool rz_cons_is_breaked(void)
Definition: cons.c:373
RZ_API void rz_cons_println(const char *str)
Definition: cons.c:233
RZ_API void rz_cons_sleep_end(void *user)
Definition: cons.c:450
#define NULL
Definition: cris-opc.c:27
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void count
Definition: sflib.h:98
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags cmd
Definition: sflib.h:79
int root
Definition: enough.c:226
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
voidpf void uLong size
Definition: ioapi.h:138
const char * filename
Definition: ioapi.h:137
voidpf void * buf
Definition: ioapi.h:138
snprintf
Definition: kernel.h:364
uint8_t ut8
Definition: lh5801.h:11
return memset(p, 0, total)
void * p
Definition: libc.cpp:67
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
RZ_API void rz_list_free(RZ_NONNULL RzList *list)
Empties the list and frees the list pointer.
Definition: list.c:137
void * malloc(size_t size)
Definition: malloc.c:123
return strdup("=SP r13\n" "=LR r14\n" "=PC r15\n" "=A0 r0\n" "=A1 r1\n" "=A2 r2\n" "=A3 r3\n" "=ZF zf\n" "=SF nf\n" "=OF vf\n" "=CF cf\n" "=SN or0\n" "gpr lr .32 56 0\n" "gpr pc .32 60 0\n" "gpr cpsr .32 64 0 ____tfiae_________________qvczn\n" "gpr or0 .32 68 0\n" "gpr tf .1 64.5 0 thumb\n" "gpr ef .1 64.9 0 endian\n" "gpr jf .1 64.24 0 java\n" "gpr qf .1 64.27 0 sticky_overflow\n" "gpr vf .1 64.28 0 overflow\n" "gpr cf .1 64.29 0 carry\n" "gpr zf .1 64.30 0 zero\n" "gpr nf .1 64.31 0 negative\n" "gpr itc .4 64.10 0 if_then_count\n" "gpr gef .4 64.16 0 great_or_equal\n" "gpr r0 .32 0 0\n" "gpr r1 .32 4 0\n" "gpr r2 .32 8 0\n" "gpr r3 .32 12 0\n" "gpr r4 .32 16 0\n" "gpr r5 .32 20 0\n" "gpr r6 .32 24 0\n" "gpr r7 .32 28 0\n" "gpr r8 .32 32 0\n" "gpr r9 .32 36 0\n" "gpr r10 .32 40 0\n" "gpr r11 .32 44 0\n" "gpr r12 .32 48 0\n" "gpr r13 .32 52 0\n" "gpr r14 .32 56 0\n" "gpr r15 .32 60 0\n" "gpr r16 .32 64 0\n" "gpr r17 .32 68 0\n")
RZ_API int rz_core_rtr_http_stop(RzCore *u)
Definition: rtr.c:110
static void http_logf(RzCore *core, const char *fmt,...)
Definition: rtr.c:61
static char * rtr_dir_files(const char *path)
Definition: rtr.c:131
static RzSocket * s
Definition: rtr.c:28
static void activateDieTime(RzCore *core)
Definition: rtr.c:156
@ COLOR_MODE_DISABLED
Definition: rz_cons.h:442
RZ_API bool rz_file_is_directory(const char *str)
Definition: file.c:167
RZ_API bool rz_file_exists(const char *str)
Definition: file.c:192
RZ_API char * rz_file_abspath(const char *file)
Definition: file.c:267
RZ_API RZ_OWN char * rz_file_slurp(const char *str, RZ_NULLABLE size_t *usz)
Definition: file.c:454
RZ_API char * rz_file_root(const char *root, const char *path)
Definition: file.c:775
RZ_API bool rz_file_dump(const char *file, const ut8 *buf, int len, bool append)
Definition: file.c:838
RZ_API int rz_num_rand(int max)
Definition: unum.c:47
RZ_API void rz_num_irand(void)
Definition: unum.c:43
RZ_API RzSocketHTTPRequest * rz_socket_http_accept(RzSocket *s, RzSocketHTTPOptions *so)
RZ_API void rz_socket_http_response(RzSocketHTTPRequest *rs, int code, const char *out, int x, const char *headers)
RZ_API bool rz_socket_listen(RzSocket *s, const char *port, const char *certfile)
Definition: socket.c:474
RZ_API ut8 * rz_socket_http_handle_upload(const ut8 *str, int len, int *olen)
RZ_API char * rz_socket_to_string(RzSocket *s)
Definition: socket.c:699
RZ_API char * rz_socket_http_get(const char *url, int *code, int *rlen)
Definition: socket_http.c:287
RZ_API RzSocket * rz_socket_new(bool is_ssl)
Definition: socket.c:179
RZ_API int rz_socket_free(RzSocket *s)
Definition: socket.c:453
RZ_API void rz_socket_http_close(RzSocketHTTPRequest *rs)
RZ_API char * rz_str_uri_encode(const char *buf)
Definition: str.c:2860
RZ_API char * rz_str_newf(const char *fmt,...) RZ_PRINTF_CHECK(1
RZ_API char * rz_str_append(char *ptr, const char *string)
Definition: str.c:1063
RZ_API RzList * rz_str_split_list(char *str, const char *c, int n)
Split the string str according to the substring c and returns a RzList with the result.
Definition: str.c:3429
RZ_API const char * rz_str_word_get0(const char *str, int idx)
Definition: str.c:598
RZ_API void rz_str_uri_decode(char *buf)
Definition: str.c:2845
RZ_API size_t rz_str_split(char *str, char ch)
Split string str in place by using ch as a delimiter.
Definition: str.c:406
RZ_API int rz_sys_cmdf(const char *fmt,...) RZ_PRINTF_CHECK(1
RZ_API int rz_sys_usleep(int usecs)
Sleep for usecs microseconds.
Definition: sys.c:317
#define RZ_FREE(x)
Definition: rz_types.h:369
#define RZ_EMPTY
Definition: rz_types_base.h:68
#define f(i)
Definition: sha256.c:46
ut64 offset
Definition: rz_core.h:301
ut8 * block
Definition: rz_core.h:305
ut32 blocksize
Definition: rz_core.h:303
RzConfig * config
Definition: rz_core.h:300
uv_timer_t timeout
Definition: main.c:9
ut64(WINAPI *w32_GetEnabledXStateFeatures)()

References rz_socket_http_options::accept_timeout, activateDieTime(), rz_socket_http_options::authtokens, rz_core_t::block, rz_core_t::blocksize, cmd, COLOR_MODE_DISABLED, rz_core_t::config, count, eprintf, f, free(), http_logf(), rz_core_t::http_up, rz_socket_http_options::httpauth, i, len, rz_socket_t::local, malloc(), memcpy(), memset(), NULL, rz_core_t::offset, out, p, path, root, rs, rtr_dir_files(), rz_config_clone(), rz_config_free(), rz_config_get(), rz_config_get_i(), rz_config_set(), rz_config_set_i(), rz_cons_break_pop(), rz_cons_break_push(), rz_cons_is_breaked(), rz_cons_println(), rz_cons_sleep_begin(), rz_cons_sleep_end(), rz_core_cmd0(), rz_core_cmd_str_pipe(), rz_core_rtr_http_stop(), RZ_EMPTY, rz_file_abspath(), rz_file_dump(), rz_file_exists(), rz_file_is_directory(), rz_file_root(), rz_file_slurp(), RZ_FREE, rz_list_free(), rz_num_irand(), rz_num_rand(), rz_socket_free(), rz_socket_http_accept(), rz_socket_http_close(), rz_socket_http_get(), rz_socket_http_handle_upload(), rz_socket_http_response(), rz_socket_listen(), rz_socket_new(), rz_socket_to_string(), rz_str_append(), rz_str_newf(), rz_str_split(), rz_str_split_list(), rz_str_uri_decode(), rz_str_uri_encode(), rz_str_word_get0(), rz_sys_cmdf(), rz_sys_usleep(), s, snprintf, strdup(), the_end(), rz_socket_http_options::timeout, timeout, and ut64().

Referenced by rz_core_rtr_http().